@qodalis/cli-files 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4616 @@
1
+ "use strict";
2
+ var files = (() => {
3
+ // ../../../dist/core/public-api.mjs
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var require_constants = __commonJS({
30
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js"(exports$1, module2) {
31
+ var SEMVER_SPEC_VERSION = "2.0.0";
32
+ var MAX_LENGTH = 256;
33
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
34
+ 9007199254740991;
35
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
36
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
37
+ var RELEASE_TYPES = [
38
+ "major",
39
+ "premajor",
40
+ "minor",
41
+ "preminor",
42
+ "patch",
43
+ "prepatch",
44
+ "prerelease"
45
+ ];
46
+ module2.exports = {
47
+ MAX_LENGTH,
48
+ MAX_SAFE_COMPONENT_LENGTH,
49
+ MAX_SAFE_BUILD_LENGTH,
50
+ MAX_SAFE_INTEGER,
51
+ RELEASE_TYPES,
52
+ SEMVER_SPEC_VERSION,
53
+ FLAG_INCLUDE_PRERELEASE: 1,
54
+ FLAG_LOOSE: 2
55
+ };
56
+ }
57
+ });
58
+ var require_debug = __commonJS({
59
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js"(exports$1, module2) {
60
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
61
+ };
62
+ module2.exports = debug;
63
+ }
64
+ });
65
+ var require_re = __commonJS({
66
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js"(exports$1, module2) {
67
+ var {
68
+ MAX_SAFE_COMPONENT_LENGTH,
69
+ MAX_SAFE_BUILD_LENGTH,
70
+ MAX_LENGTH
71
+ } = require_constants();
72
+ var debug = require_debug();
73
+ exports$1 = module2.exports = {};
74
+ var re = exports$1.re = [];
75
+ var safeRe = exports$1.safeRe = [];
76
+ var src = exports$1.src = [];
77
+ var safeSrc = exports$1.safeSrc = [];
78
+ var t = exports$1.t = {};
79
+ var R = 0;
80
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
81
+ var safeRegexReplacements = [
82
+ ["\\s", 1],
83
+ ["\\d", MAX_LENGTH],
84
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
85
+ ];
86
+ var makeSafeRegex = (value) => {
87
+ for (const [token, max] of safeRegexReplacements) {
88
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
89
+ }
90
+ return value;
91
+ };
92
+ var createToken = (name, value, isGlobal) => {
93
+ const safe = makeSafeRegex(value);
94
+ const index = R++;
95
+ debug(name, index, value);
96
+ t[name] = index;
97
+ src[index] = value;
98
+ safeSrc[index] = safe;
99
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
100
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
101
+ };
102
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
103
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
104
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
105
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
106
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
107
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
108
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
109
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
110
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
111
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
112
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
113
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
114
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
115
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
116
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
117
+ createToken("GTLT", "((?:<|>)?=?)");
118
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
119
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
120
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
121
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
122
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
123
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
124
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
125
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
126
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
127
+ createToken("COERCERTL", src[t.COERCE], true);
128
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
129
+ createToken("LONETILDE", "(?:~>?)");
130
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
131
+ exports$1.tildeTrimReplace = "$1~";
132
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
133
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
134
+ createToken("LONECARET", "(?:\\^)");
135
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
136
+ exports$1.caretTrimReplace = "$1^";
137
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
138
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
139
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
140
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
141
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
142
+ exports$1.comparatorTrimReplace = "$1$2$3";
143
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
144
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
145
+ createToken("STAR", "(<|>)?=?\\s*\\*");
146
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
147
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
148
+ }
149
+ });
150
+ var require_parse_options = __commonJS({
151
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js"(exports$1, module2) {
152
+ var looseOption = Object.freeze({ loose: true });
153
+ var emptyOpts = Object.freeze({});
154
+ var parseOptions = (options) => {
155
+ if (!options) {
156
+ return emptyOpts;
157
+ }
158
+ if (typeof options !== "object") {
159
+ return looseOption;
160
+ }
161
+ return options;
162
+ };
163
+ module2.exports = parseOptions;
164
+ }
165
+ });
166
+ var require_identifiers = __commonJS({
167
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js"(exports$1, module2) {
168
+ var numeric = /^[0-9]+$/;
169
+ var compareIdentifiers = (a, b) => {
170
+ if (typeof a === "number" && typeof b === "number") {
171
+ return a === b ? 0 : a < b ? -1 : 1;
172
+ }
173
+ const anum = numeric.test(a);
174
+ const bnum = numeric.test(b);
175
+ if (anum && bnum) {
176
+ a = +a;
177
+ b = +b;
178
+ }
179
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
180
+ };
181
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
182
+ module2.exports = {
183
+ compareIdentifiers,
184
+ rcompareIdentifiers
185
+ };
186
+ }
187
+ });
188
+ var require_semver = __commonJS({
189
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js"(exports$1, module2) {
190
+ var debug = require_debug();
191
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
192
+ var { safeRe: re, t } = require_re();
193
+ var parseOptions = require_parse_options();
194
+ var { compareIdentifiers } = require_identifiers();
195
+ var SemVer = class _SemVer {
196
+ constructor(version, options) {
197
+ options = parseOptions(options);
198
+ if (version instanceof _SemVer) {
199
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
200
+ return version;
201
+ } else {
202
+ version = version.version;
203
+ }
204
+ } else if (typeof version !== "string") {
205
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
206
+ }
207
+ if (version.length > MAX_LENGTH) {
208
+ throw new TypeError(
209
+ `version is longer than ${MAX_LENGTH} characters`
210
+ );
211
+ }
212
+ debug("SemVer", version, options);
213
+ this.options = options;
214
+ this.loose = !!options.loose;
215
+ this.includePrerelease = !!options.includePrerelease;
216
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
217
+ if (!m) {
218
+ throw new TypeError(`Invalid Version: ${version}`);
219
+ }
220
+ this.raw = version;
221
+ this.major = +m[1];
222
+ this.minor = +m[2];
223
+ this.patch = +m[3];
224
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
225
+ throw new TypeError("Invalid major version");
226
+ }
227
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
228
+ throw new TypeError("Invalid minor version");
229
+ }
230
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
231
+ throw new TypeError("Invalid patch version");
232
+ }
233
+ if (!m[4]) {
234
+ this.prerelease = [];
235
+ } else {
236
+ this.prerelease = m[4].split(".").map((id) => {
237
+ if (/^[0-9]+$/.test(id)) {
238
+ const num = +id;
239
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
240
+ return num;
241
+ }
242
+ }
243
+ return id;
244
+ });
245
+ }
246
+ this.build = m[5] ? m[5].split(".") : [];
247
+ this.format();
248
+ }
249
+ format() {
250
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
251
+ if (this.prerelease.length) {
252
+ this.version += `-${this.prerelease.join(".")}`;
253
+ }
254
+ return this.version;
255
+ }
256
+ toString() {
257
+ return this.version;
258
+ }
259
+ compare(other) {
260
+ debug("SemVer.compare", this.version, this.options, other);
261
+ if (!(other instanceof _SemVer)) {
262
+ if (typeof other === "string" && other === this.version) {
263
+ return 0;
264
+ }
265
+ other = new _SemVer(other, this.options);
266
+ }
267
+ if (other.version === this.version) {
268
+ return 0;
269
+ }
270
+ return this.compareMain(other) || this.comparePre(other);
271
+ }
272
+ compareMain(other) {
273
+ if (!(other instanceof _SemVer)) {
274
+ other = new _SemVer(other, this.options);
275
+ }
276
+ if (this.major < other.major) {
277
+ return -1;
278
+ }
279
+ if (this.major > other.major) {
280
+ return 1;
281
+ }
282
+ if (this.minor < other.minor) {
283
+ return -1;
284
+ }
285
+ if (this.minor > other.minor) {
286
+ return 1;
287
+ }
288
+ if (this.patch < other.patch) {
289
+ return -1;
290
+ }
291
+ if (this.patch > other.patch) {
292
+ return 1;
293
+ }
294
+ return 0;
295
+ }
296
+ comparePre(other) {
297
+ if (!(other instanceof _SemVer)) {
298
+ other = new _SemVer(other, this.options);
299
+ }
300
+ if (this.prerelease.length && !other.prerelease.length) {
301
+ return -1;
302
+ } else if (!this.prerelease.length && other.prerelease.length) {
303
+ return 1;
304
+ } else if (!this.prerelease.length && !other.prerelease.length) {
305
+ return 0;
306
+ }
307
+ let i = 0;
308
+ do {
309
+ const a = this.prerelease[i];
310
+ const b = other.prerelease[i];
311
+ debug("prerelease compare", i, a, b);
312
+ if (a === void 0 && b === void 0) {
313
+ return 0;
314
+ } else if (b === void 0) {
315
+ return 1;
316
+ } else if (a === void 0) {
317
+ return -1;
318
+ } else if (a === b) {
319
+ continue;
320
+ } else {
321
+ return compareIdentifiers(a, b);
322
+ }
323
+ } while (++i);
324
+ }
325
+ compareBuild(other) {
326
+ if (!(other instanceof _SemVer)) {
327
+ other = new _SemVer(other, this.options);
328
+ }
329
+ let i = 0;
330
+ do {
331
+ const a = this.build[i];
332
+ const b = other.build[i];
333
+ debug("build compare", i, a, b);
334
+ if (a === void 0 && b === void 0) {
335
+ return 0;
336
+ } else if (b === void 0) {
337
+ return 1;
338
+ } else if (a === void 0) {
339
+ return -1;
340
+ } else if (a === b) {
341
+ continue;
342
+ } else {
343
+ return compareIdentifiers(a, b);
344
+ }
345
+ } while (++i);
346
+ }
347
+ // preminor will bump the version up to the next minor release, and immediately
348
+ // down to pre-release. premajor and prepatch work the same way.
349
+ inc(release, identifier, identifierBase) {
350
+ if (release.startsWith("pre")) {
351
+ if (!identifier && identifierBase === false) {
352
+ throw new Error("invalid increment argument: identifier is empty");
353
+ }
354
+ if (identifier) {
355
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
356
+ if (!match || match[1] !== identifier) {
357
+ throw new Error(`invalid identifier: ${identifier}`);
358
+ }
359
+ }
360
+ }
361
+ switch (release) {
362
+ case "premajor":
363
+ this.prerelease.length = 0;
364
+ this.patch = 0;
365
+ this.minor = 0;
366
+ this.major++;
367
+ this.inc("pre", identifier, identifierBase);
368
+ break;
369
+ case "preminor":
370
+ this.prerelease.length = 0;
371
+ this.patch = 0;
372
+ this.minor++;
373
+ this.inc("pre", identifier, identifierBase);
374
+ break;
375
+ case "prepatch":
376
+ this.prerelease.length = 0;
377
+ this.inc("patch", identifier, identifierBase);
378
+ this.inc("pre", identifier, identifierBase);
379
+ break;
380
+ // If the input is a non-prerelease version, this acts the same as
381
+ // prepatch.
382
+ case "prerelease":
383
+ if (this.prerelease.length === 0) {
384
+ this.inc("patch", identifier, identifierBase);
385
+ }
386
+ this.inc("pre", identifier, identifierBase);
387
+ break;
388
+ case "release":
389
+ if (this.prerelease.length === 0) {
390
+ throw new Error(`version ${this.raw} is not a prerelease`);
391
+ }
392
+ this.prerelease.length = 0;
393
+ break;
394
+ case "major":
395
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
396
+ this.major++;
397
+ }
398
+ this.minor = 0;
399
+ this.patch = 0;
400
+ this.prerelease = [];
401
+ break;
402
+ case "minor":
403
+ if (this.patch !== 0 || this.prerelease.length === 0) {
404
+ this.minor++;
405
+ }
406
+ this.patch = 0;
407
+ this.prerelease = [];
408
+ break;
409
+ case "patch":
410
+ if (this.prerelease.length === 0) {
411
+ this.patch++;
412
+ }
413
+ this.prerelease = [];
414
+ break;
415
+ // This probably shouldn't be used publicly.
416
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
417
+ case "pre": {
418
+ const base = Number(identifierBase) ? 1 : 0;
419
+ if (this.prerelease.length === 0) {
420
+ this.prerelease = [base];
421
+ } else {
422
+ let i = this.prerelease.length;
423
+ while (--i >= 0) {
424
+ if (typeof this.prerelease[i] === "number") {
425
+ this.prerelease[i]++;
426
+ i = -2;
427
+ }
428
+ }
429
+ if (i === -1) {
430
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
431
+ throw new Error("invalid increment argument: identifier already exists");
432
+ }
433
+ this.prerelease.push(base);
434
+ }
435
+ }
436
+ if (identifier) {
437
+ let prerelease = [identifier, base];
438
+ if (identifierBase === false) {
439
+ prerelease = [identifier];
440
+ }
441
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
442
+ if (isNaN(this.prerelease[1])) {
443
+ this.prerelease = prerelease;
444
+ }
445
+ } else {
446
+ this.prerelease = prerelease;
447
+ }
448
+ }
449
+ break;
450
+ }
451
+ default:
452
+ throw new Error(`invalid increment argument: ${release}`);
453
+ }
454
+ this.raw = this.format();
455
+ if (this.build.length) {
456
+ this.raw += `+${this.build.join(".")}`;
457
+ }
458
+ return this;
459
+ }
460
+ };
461
+ module2.exports = SemVer;
462
+ }
463
+ });
464
+ var require_parse = __commonJS({
465
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js"(exports$1, module2) {
466
+ var SemVer = require_semver();
467
+ var parse = (version, options, throwErrors = false) => {
468
+ if (version instanceof SemVer) {
469
+ return version;
470
+ }
471
+ try {
472
+ return new SemVer(version, options);
473
+ } catch (er) {
474
+ if (!throwErrors) {
475
+ return null;
476
+ }
477
+ throw er;
478
+ }
479
+ };
480
+ module2.exports = parse;
481
+ }
482
+ });
483
+ var require_valid = __commonJS({
484
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js"(exports$1, module2) {
485
+ var parse = require_parse();
486
+ var valid2 = (version, options) => {
487
+ const v = parse(version, options);
488
+ return v ? v.version : null;
489
+ };
490
+ module2.exports = valid2;
491
+ }
492
+ });
493
+ var require_clean = __commonJS({
494
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js"(exports$1, module2) {
495
+ var parse = require_parse();
496
+ var clean = (version, options) => {
497
+ const s = parse(version.trim().replace(/^[=v]+/, ""), options);
498
+ return s ? s.version : null;
499
+ };
500
+ module2.exports = clean;
501
+ }
502
+ });
503
+ var require_inc = __commonJS({
504
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js"(exports$1, module2) {
505
+ var SemVer = require_semver();
506
+ var inc = (version, release, options, identifier, identifierBase) => {
507
+ if (typeof options === "string") {
508
+ identifierBase = identifier;
509
+ identifier = options;
510
+ options = void 0;
511
+ }
512
+ try {
513
+ return new SemVer(
514
+ version instanceof SemVer ? version.version : version,
515
+ options
516
+ ).inc(release, identifier, identifierBase).version;
517
+ } catch (er) {
518
+ return null;
519
+ }
520
+ };
521
+ module2.exports = inc;
522
+ }
523
+ });
524
+ var require_diff = __commonJS({
525
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js"(exports$1, module2) {
526
+ var parse = require_parse();
527
+ var diff = (version1, version2) => {
528
+ const v1 = parse(version1, null, true);
529
+ const v2 = parse(version2, null, true);
530
+ const comparison = v1.compare(v2);
531
+ if (comparison === 0) {
532
+ return null;
533
+ }
534
+ const v1Higher = comparison > 0;
535
+ const highVersion = v1Higher ? v1 : v2;
536
+ const lowVersion = v1Higher ? v2 : v1;
537
+ const highHasPre = !!highVersion.prerelease.length;
538
+ const lowHasPre = !!lowVersion.prerelease.length;
539
+ if (lowHasPre && !highHasPre) {
540
+ if (!lowVersion.patch && !lowVersion.minor) {
541
+ return "major";
542
+ }
543
+ if (lowVersion.compareMain(highVersion) === 0) {
544
+ if (lowVersion.minor && !lowVersion.patch) {
545
+ return "minor";
546
+ }
547
+ return "patch";
548
+ }
549
+ }
550
+ const prefix = highHasPre ? "pre" : "";
551
+ if (v1.major !== v2.major) {
552
+ return prefix + "major";
553
+ }
554
+ if (v1.minor !== v2.minor) {
555
+ return prefix + "minor";
556
+ }
557
+ if (v1.patch !== v2.patch) {
558
+ return prefix + "patch";
559
+ }
560
+ return "prerelease";
561
+ };
562
+ module2.exports = diff;
563
+ }
564
+ });
565
+ var require_major = __commonJS({
566
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js"(exports$1, module2) {
567
+ var SemVer = require_semver();
568
+ var major = (a, loose) => new SemVer(a, loose).major;
569
+ module2.exports = major;
570
+ }
571
+ });
572
+ var require_minor = __commonJS({
573
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js"(exports$1, module2) {
574
+ var SemVer = require_semver();
575
+ var minor = (a, loose) => new SemVer(a, loose).minor;
576
+ module2.exports = minor;
577
+ }
578
+ });
579
+ var require_patch = __commonJS({
580
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js"(exports$1, module2) {
581
+ var SemVer = require_semver();
582
+ var patch = (a, loose) => new SemVer(a, loose).patch;
583
+ module2.exports = patch;
584
+ }
585
+ });
586
+ var require_prerelease = __commonJS({
587
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js"(exports$1, module2) {
588
+ var parse = require_parse();
589
+ var prerelease = (version, options) => {
590
+ const parsed = parse(version, options);
591
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
592
+ };
593
+ module2.exports = prerelease;
594
+ }
595
+ });
596
+ var require_compare = __commonJS({
597
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js"(exports$1, module2) {
598
+ var SemVer = require_semver();
599
+ var compare2 = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
600
+ module2.exports = compare2;
601
+ }
602
+ });
603
+ var require_rcompare = __commonJS({
604
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js"(exports$1, module2) {
605
+ var compare2 = require_compare();
606
+ var rcompare = (a, b, loose) => compare2(b, a, loose);
607
+ module2.exports = rcompare;
608
+ }
609
+ });
610
+ var require_compare_loose = __commonJS({
611
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js"(exports$1, module2) {
612
+ var compare2 = require_compare();
613
+ var compareLoose = (a, b) => compare2(a, b, true);
614
+ module2.exports = compareLoose;
615
+ }
616
+ });
617
+ var require_compare_build = __commonJS({
618
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js"(exports$1, module2) {
619
+ var SemVer = require_semver();
620
+ var compareBuild = (a, b, loose) => {
621
+ const versionA = new SemVer(a, loose);
622
+ const versionB = new SemVer(b, loose);
623
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
624
+ };
625
+ module2.exports = compareBuild;
626
+ }
627
+ });
628
+ var require_sort = __commonJS({
629
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js"(exports$1, module2) {
630
+ var compareBuild = require_compare_build();
631
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
632
+ module2.exports = sort;
633
+ }
634
+ });
635
+ var require_rsort = __commonJS({
636
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js"(exports$1, module2) {
637
+ var compareBuild = require_compare_build();
638
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
639
+ module2.exports = rsort;
640
+ }
641
+ });
642
+ var require_gt = __commonJS({
643
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js"(exports$1, module2) {
644
+ var compare2 = require_compare();
645
+ var gt = (a, b, loose) => compare2(a, b, loose) > 0;
646
+ module2.exports = gt;
647
+ }
648
+ });
649
+ var require_lt = __commonJS({
650
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js"(exports$1, module2) {
651
+ var compare2 = require_compare();
652
+ var lt = (a, b, loose) => compare2(a, b, loose) < 0;
653
+ module2.exports = lt;
654
+ }
655
+ });
656
+ var require_eq = __commonJS({
657
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js"(exports$1, module2) {
658
+ var compare2 = require_compare();
659
+ var eq = (a, b, loose) => compare2(a, b, loose) === 0;
660
+ module2.exports = eq;
661
+ }
662
+ });
663
+ var require_neq = __commonJS({
664
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js"(exports$1, module2) {
665
+ var compare2 = require_compare();
666
+ var neq = (a, b, loose) => compare2(a, b, loose) !== 0;
667
+ module2.exports = neq;
668
+ }
669
+ });
670
+ var require_gte = __commonJS({
671
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js"(exports$1, module2) {
672
+ var compare2 = require_compare();
673
+ var gte2 = (a, b, loose) => compare2(a, b, loose) >= 0;
674
+ module2.exports = gte2;
675
+ }
676
+ });
677
+ var require_lte = __commonJS({
678
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js"(exports$1, module2) {
679
+ var compare2 = require_compare();
680
+ var lte = (a, b, loose) => compare2(a, b, loose) <= 0;
681
+ module2.exports = lte;
682
+ }
683
+ });
684
+ var require_cmp = __commonJS({
685
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js"(exports$1, module2) {
686
+ var eq = require_eq();
687
+ var neq = require_neq();
688
+ var gt = require_gt();
689
+ var gte2 = require_gte();
690
+ var lt = require_lt();
691
+ var lte = require_lte();
692
+ var cmp = (a, op, b, loose) => {
693
+ switch (op) {
694
+ case "===":
695
+ if (typeof a === "object") {
696
+ a = a.version;
697
+ }
698
+ if (typeof b === "object") {
699
+ b = b.version;
700
+ }
701
+ return a === b;
702
+ case "!==":
703
+ if (typeof a === "object") {
704
+ a = a.version;
705
+ }
706
+ if (typeof b === "object") {
707
+ b = b.version;
708
+ }
709
+ return a !== b;
710
+ case "":
711
+ case "=":
712
+ case "==":
713
+ return eq(a, b, loose);
714
+ case "!=":
715
+ return neq(a, b, loose);
716
+ case ">":
717
+ return gt(a, b, loose);
718
+ case ">=":
719
+ return gte2(a, b, loose);
720
+ case "<":
721
+ return lt(a, b, loose);
722
+ case "<=":
723
+ return lte(a, b, loose);
724
+ default:
725
+ throw new TypeError(`Invalid operator: ${op}`);
726
+ }
727
+ };
728
+ module2.exports = cmp;
729
+ }
730
+ });
731
+ var require_coerce = __commonJS({
732
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js"(exports$1, module2) {
733
+ var SemVer = require_semver();
734
+ var parse = require_parse();
735
+ var { safeRe: re, t } = require_re();
736
+ var coerce2 = (version, options) => {
737
+ if (version instanceof SemVer) {
738
+ return version;
739
+ }
740
+ if (typeof version === "number") {
741
+ version = String(version);
742
+ }
743
+ if (typeof version !== "string") {
744
+ return null;
745
+ }
746
+ options = options || {};
747
+ let match = null;
748
+ if (!options.rtl) {
749
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
750
+ } else {
751
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
752
+ let next;
753
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
754
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
755
+ match = next;
756
+ }
757
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
758
+ }
759
+ coerceRtlRegex.lastIndex = -1;
760
+ }
761
+ if (match === null) {
762
+ return null;
763
+ }
764
+ const major = match[2];
765
+ const minor = match[3] || "0";
766
+ const patch = match[4] || "0";
767
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
768
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
769
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
770
+ };
771
+ module2.exports = coerce2;
772
+ }
773
+ });
774
+ var require_lrucache = __commonJS({
775
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js"(exports$1, module2) {
776
+ var LRUCache = class {
777
+ constructor() {
778
+ this.max = 1e3;
779
+ this.map = /* @__PURE__ */ new Map();
780
+ }
781
+ get(key) {
782
+ const value = this.map.get(key);
783
+ if (value === void 0) {
784
+ return void 0;
785
+ } else {
786
+ this.map.delete(key);
787
+ this.map.set(key, value);
788
+ return value;
789
+ }
790
+ }
791
+ delete(key) {
792
+ return this.map.delete(key);
793
+ }
794
+ set(key, value) {
795
+ const deleted = this.delete(key);
796
+ if (!deleted && value !== void 0) {
797
+ if (this.map.size >= this.max) {
798
+ const firstKey = this.map.keys().next().value;
799
+ this.delete(firstKey);
800
+ }
801
+ this.map.set(key, value);
802
+ }
803
+ return this;
804
+ }
805
+ };
806
+ module2.exports = LRUCache;
807
+ }
808
+ });
809
+ var require_range = __commonJS({
810
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js"(exports$1, module2) {
811
+ var SPACE_CHARACTERS = /\s+/g;
812
+ var Range = class _Range {
813
+ constructor(range, options) {
814
+ options = parseOptions(options);
815
+ if (range instanceof _Range) {
816
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
817
+ return range;
818
+ } else {
819
+ return new _Range(range.raw, options);
820
+ }
821
+ }
822
+ if (range instanceof Comparator) {
823
+ this.raw = range.value;
824
+ this.set = [[range]];
825
+ this.formatted = void 0;
826
+ return this;
827
+ }
828
+ this.options = options;
829
+ this.loose = !!options.loose;
830
+ this.includePrerelease = !!options.includePrerelease;
831
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
832
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
833
+ if (!this.set.length) {
834
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
835
+ }
836
+ if (this.set.length > 1) {
837
+ const first = this.set[0];
838
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
839
+ if (this.set.length === 0) {
840
+ this.set = [first];
841
+ } else if (this.set.length > 1) {
842
+ for (const c of this.set) {
843
+ if (c.length === 1 && isAny(c[0])) {
844
+ this.set = [c];
845
+ break;
846
+ }
847
+ }
848
+ }
849
+ }
850
+ this.formatted = void 0;
851
+ }
852
+ get range() {
853
+ if (this.formatted === void 0) {
854
+ this.formatted = "";
855
+ for (let i = 0; i < this.set.length; i++) {
856
+ if (i > 0) {
857
+ this.formatted += "||";
858
+ }
859
+ const comps = this.set[i];
860
+ for (let k = 0; k < comps.length; k++) {
861
+ if (k > 0) {
862
+ this.formatted += " ";
863
+ }
864
+ this.formatted += comps[k].toString().trim();
865
+ }
866
+ }
867
+ }
868
+ return this.formatted;
869
+ }
870
+ format() {
871
+ return this.range;
872
+ }
873
+ toString() {
874
+ return this.range;
875
+ }
876
+ parseRange(range) {
877
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
878
+ const memoKey = memoOpts + ":" + range;
879
+ const cached = cache.get(memoKey);
880
+ if (cached) {
881
+ return cached;
882
+ }
883
+ const loose = this.options.loose;
884
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
885
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
886
+ debug("hyphen replace", range);
887
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
888
+ debug("comparator trim", range);
889
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
890
+ debug("tilde trim", range);
891
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
892
+ debug("caret trim", range);
893
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
894
+ if (loose) {
895
+ rangeList = rangeList.filter((comp) => {
896
+ debug("loose invalid filter", comp, this.options);
897
+ return !!comp.match(re[t.COMPARATORLOOSE]);
898
+ });
899
+ }
900
+ debug("range list", rangeList);
901
+ const rangeMap = /* @__PURE__ */ new Map();
902
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
903
+ for (const comp of comparators) {
904
+ if (isNullSet(comp)) {
905
+ return [comp];
906
+ }
907
+ rangeMap.set(comp.value, comp);
908
+ }
909
+ if (rangeMap.size > 1 && rangeMap.has("")) {
910
+ rangeMap.delete("");
911
+ }
912
+ const result = [...rangeMap.values()];
913
+ cache.set(memoKey, result);
914
+ return result;
915
+ }
916
+ intersects(range, options) {
917
+ if (!(range instanceof _Range)) {
918
+ throw new TypeError("a Range is required");
919
+ }
920
+ return this.set.some((thisComparators) => {
921
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
922
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
923
+ return rangeComparators.every((rangeComparator) => {
924
+ return thisComparator.intersects(rangeComparator, options);
925
+ });
926
+ });
927
+ });
928
+ });
929
+ }
930
+ // if ANY of the sets match ALL of its comparators, then pass
931
+ test(version) {
932
+ if (!version) {
933
+ return false;
934
+ }
935
+ if (typeof version === "string") {
936
+ try {
937
+ version = new SemVer(version, this.options);
938
+ } catch (er) {
939
+ return false;
940
+ }
941
+ }
942
+ for (let i = 0; i < this.set.length; i++) {
943
+ if (testSet(this.set[i], version, this.options)) {
944
+ return true;
945
+ }
946
+ }
947
+ return false;
948
+ }
949
+ };
950
+ module2.exports = Range;
951
+ var LRU = require_lrucache();
952
+ var cache = new LRU();
953
+ var parseOptions = require_parse_options();
954
+ var Comparator = require_comparator();
955
+ var debug = require_debug();
956
+ var SemVer = require_semver();
957
+ var {
958
+ safeRe: re,
959
+ t,
960
+ comparatorTrimReplace,
961
+ tildeTrimReplace,
962
+ caretTrimReplace
963
+ } = require_re();
964
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
965
+ var isNullSet = (c) => c.value === "<0.0.0-0";
966
+ var isAny = (c) => c.value === "";
967
+ var isSatisfiable = (comparators, options) => {
968
+ let result = true;
969
+ const remainingComparators = comparators.slice();
970
+ let testComparator = remainingComparators.pop();
971
+ while (result && remainingComparators.length) {
972
+ result = remainingComparators.every((otherComparator) => {
973
+ return testComparator.intersects(otherComparator, options);
974
+ });
975
+ testComparator = remainingComparators.pop();
976
+ }
977
+ return result;
978
+ };
979
+ var parseComparator = (comp, options) => {
980
+ comp = comp.replace(re[t.BUILD], "");
981
+ debug("comp", comp, options);
982
+ comp = replaceCarets(comp, options);
983
+ debug("caret", comp);
984
+ comp = replaceTildes(comp, options);
985
+ debug("tildes", comp);
986
+ comp = replaceXRanges(comp, options);
987
+ debug("xrange", comp);
988
+ comp = replaceStars(comp, options);
989
+ debug("stars", comp);
990
+ return comp;
991
+ };
992
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
993
+ var replaceTildes = (comp, options) => {
994
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
995
+ };
996
+ var replaceTilde = (comp, options) => {
997
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
998
+ return comp.replace(r, (_, M, m, p, pr) => {
999
+ debug("tilde", comp, _, M, m, p, pr);
1000
+ let ret;
1001
+ if (isX(M)) {
1002
+ ret = "";
1003
+ } else if (isX(m)) {
1004
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1005
+ } else if (isX(p)) {
1006
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1007
+ } else if (pr) {
1008
+ debug("replaceTilde pr", pr);
1009
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1010
+ } else {
1011
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1012
+ }
1013
+ debug("tilde return", ret);
1014
+ return ret;
1015
+ });
1016
+ };
1017
+ var replaceCarets = (comp, options) => {
1018
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
1019
+ };
1020
+ var replaceCaret = (comp, options) => {
1021
+ debug("caret", comp, options);
1022
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1023
+ const z = options.includePrerelease ? "-0" : "";
1024
+ return comp.replace(r, (_, M, m, p, pr) => {
1025
+ debug("caret", comp, _, M, m, p, pr);
1026
+ let ret;
1027
+ if (isX(M)) {
1028
+ ret = "";
1029
+ } else if (isX(m)) {
1030
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1031
+ } else if (isX(p)) {
1032
+ if (M === "0") {
1033
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1034
+ } else {
1035
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1036
+ }
1037
+ } else if (pr) {
1038
+ debug("replaceCaret pr", pr);
1039
+ if (M === "0") {
1040
+ if (m === "0") {
1041
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1042
+ } else {
1043
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1044
+ }
1045
+ } else {
1046
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1047
+ }
1048
+ } else {
1049
+ debug("no pr");
1050
+ if (M === "0") {
1051
+ if (m === "0") {
1052
+ ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
1053
+ } else {
1054
+ ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
1055
+ }
1056
+ } else {
1057
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1058
+ }
1059
+ }
1060
+ debug("caret return", ret);
1061
+ return ret;
1062
+ });
1063
+ };
1064
+ var replaceXRanges = (comp, options) => {
1065
+ debug("replaceXRanges", comp, options);
1066
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1067
+ };
1068
+ var replaceXRange = (comp, options) => {
1069
+ comp = comp.trim();
1070
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1071
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1072
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1073
+ const xM = isX(M);
1074
+ const xm = xM || isX(m);
1075
+ const xp = xm || isX(p);
1076
+ const anyX = xp;
1077
+ if (gtlt === "=" && anyX) {
1078
+ gtlt = "";
1079
+ }
1080
+ pr = options.includePrerelease ? "-0" : "";
1081
+ if (xM) {
1082
+ if (gtlt === ">" || gtlt === "<") {
1083
+ ret = "<0.0.0-0";
1084
+ } else {
1085
+ ret = "*";
1086
+ }
1087
+ } else if (gtlt && anyX) {
1088
+ if (xm) {
1089
+ m = 0;
1090
+ }
1091
+ p = 0;
1092
+ if (gtlt === ">") {
1093
+ gtlt = ">=";
1094
+ if (xm) {
1095
+ M = +M + 1;
1096
+ m = 0;
1097
+ p = 0;
1098
+ } else {
1099
+ m = +m + 1;
1100
+ p = 0;
1101
+ }
1102
+ } else if (gtlt === "<=") {
1103
+ gtlt = "<";
1104
+ if (xm) {
1105
+ M = +M + 1;
1106
+ } else {
1107
+ m = +m + 1;
1108
+ }
1109
+ }
1110
+ if (gtlt === "<") {
1111
+ pr = "-0";
1112
+ }
1113
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1114
+ } else if (xm) {
1115
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1116
+ } else if (xp) {
1117
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1118
+ }
1119
+ debug("xRange return", ret);
1120
+ return ret;
1121
+ });
1122
+ };
1123
+ var replaceStars = (comp, options) => {
1124
+ debug("replaceStars", comp, options);
1125
+ return comp.trim().replace(re[t.STAR], "");
1126
+ };
1127
+ var replaceGTE0 = (comp, options) => {
1128
+ debug("replaceGTE0", comp, options);
1129
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1130
+ };
1131
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1132
+ if (isX(fM)) {
1133
+ from = "";
1134
+ } else if (isX(fm)) {
1135
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1136
+ } else if (isX(fp)) {
1137
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1138
+ } else if (fpr) {
1139
+ from = `>=${from}`;
1140
+ } else {
1141
+ from = `>=${from}${incPr ? "-0" : ""}`;
1142
+ }
1143
+ if (isX(tM)) {
1144
+ to = "";
1145
+ } else if (isX(tm)) {
1146
+ to = `<${+tM + 1}.0.0-0`;
1147
+ } else if (isX(tp)) {
1148
+ to = `<${tM}.${+tm + 1}.0-0`;
1149
+ } else if (tpr) {
1150
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1151
+ } else if (incPr) {
1152
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1153
+ } else {
1154
+ to = `<=${to}`;
1155
+ }
1156
+ return `${from} ${to}`.trim();
1157
+ };
1158
+ var testSet = (set, version, options) => {
1159
+ for (let i = 0; i < set.length; i++) {
1160
+ if (!set[i].test(version)) {
1161
+ return false;
1162
+ }
1163
+ }
1164
+ if (version.prerelease.length && !options.includePrerelease) {
1165
+ for (let i = 0; i < set.length; i++) {
1166
+ debug(set[i].semver);
1167
+ if (set[i].semver === Comparator.ANY) {
1168
+ continue;
1169
+ }
1170
+ if (set[i].semver.prerelease.length > 0) {
1171
+ const allowed = set[i].semver;
1172
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1173
+ return true;
1174
+ }
1175
+ }
1176
+ }
1177
+ return false;
1178
+ }
1179
+ return true;
1180
+ };
1181
+ }
1182
+ });
1183
+ var require_comparator = __commonJS({
1184
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js"(exports$1, module2) {
1185
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
1186
+ var Comparator = class _Comparator {
1187
+ static get ANY() {
1188
+ return ANY;
1189
+ }
1190
+ constructor(comp, options) {
1191
+ options = parseOptions(options);
1192
+ if (comp instanceof _Comparator) {
1193
+ if (comp.loose === !!options.loose) {
1194
+ return comp;
1195
+ } else {
1196
+ comp = comp.value;
1197
+ }
1198
+ }
1199
+ comp = comp.trim().split(/\s+/).join(" ");
1200
+ debug("comparator", comp, options);
1201
+ this.options = options;
1202
+ this.loose = !!options.loose;
1203
+ this.parse(comp);
1204
+ if (this.semver === ANY) {
1205
+ this.value = "";
1206
+ } else {
1207
+ this.value = this.operator + this.semver.version;
1208
+ }
1209
+ debug("comp", this);
1210
+ }
1211
+ parse(comp) {
1212
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1213
+ const m = comp.match(r);
1214
+ if (!m) {
1215
+ throw new TypeError(`Invalid comparator: ${comp}`);
1216
+ }
1217
+ this.operator = m[1] !== void 0 ? m[1] : "";
1218
+ if (this.operator === "=") {
1219
+ this.operator = "";
1220
+ }
1221
+ if (!m[2]) {
1222
+ this.semver = ANY;
1223
+ } else {
1224
+ this.semver = new SemVer(m[2], this.options.loose);
1225
+ }
1226
+ }
1227
+ toString() {
1228
+ return this.value;
1229
+ }
1230
+ test(version) {
1231
+ debug("Comparator.test", version, this.options.loose);
1232
+ if (this.semver === ANY || version === ANY) {
1233
+ return true;
1234
+ }
1235
+ if (typeof version === "string") {
1236
+ try {
1237
+ version = new SemVer(version, this.options);
1238
+ } catch (er) {
1239
+ return false;
1240
+ }
1241
+ }
1242
+ return cmp(version, this.operator, this.semver, this.options);
1243
+ }
1244
+ intersects(comp, options) {
1245
+ if (!(comp instanceof _Comparator)) {
1246
+ throw new TypeError("a Comparator is required");
1247
+ }
1248
+ if (this.operator === "") {
1249
+ if (this.value === "") {
1250
+ return true;
1251
+ }
1252
+ return new Range(comp.value, options).test(this.value);
1253
+ } else if (comp.operator === "") {
1254
+ if (comp.value === "") {
1255
+ return true;
1256
+ }
1257
+ return new Range(this.value, options).test(comp.semver);
1258
+ }
1259
+ options = parseOptions(options);
1260
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
1261
+ return false;
1262
+ }
1263
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
1264
+ return false;
1265
+ }
1266
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
1267
+ return true;
1268
+ }
1269
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
1270
+ return true;
1271
+ }
1272
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
1273
+ return true;
1274
+ }
1275
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
1276
+ return true;
1277
+ }
1278
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
1279
+ return true;
1280
+ }
1281
+ return false;
1282
+ }
1283
+ };
1284
+ module2.exports = Comparator;
1285
+ var parseOptions = require_parse_options();
1286
+ var { safeRe: re, t } = require_re();
1287
+ var cmp = require_cmp();
1288
+ var debug = require_debug();
1289
+ var SemVer = require_semver();
1290
+ var Range = require_range();
1291
+ }
1292
+ });
1293
+ var require_satisfies = __commonJS({
1294
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js"(exports$1, module2) {
1295
+ var Range = require_range();
1296
+ var satisfies2 = (version, range, options) => {
1297
+ try {
1298
+ range = new Range(range, options);
1299
+ } catch (er) {
1300
+ return false;
1301
+ }
1302
+ return range.test(version);
1303
+ };
1304
+ module2.exports = satisfies2;
1305
+ }
1306
+ });
1307
+ var require_to_comparators = __commonJS({
1308
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js"(exports$1, module2) {
1309
+ var Range = require_range();
1310
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1311
+ module2.exports = toComparators;
1312
+ }
1313
+ });
1314
+ var require_max_satisfying = __commonJS({
1315
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js"(exports$1, module2) {
1316
+ var SemVer = require_semver();
1317
+ var Range = require_range();
1318
+ var maxSatisfying = (versions, range, options) => {
1319
+ let max = null;
1320
+ let maxSV = null;
1321
+ let rangeObj = null;
1322
+ try {
1323
+ rangeObj = new Range(range, options);
1324
+ } catch (er) {
1325
+ return null;
1326
+ }
1327
+ versions.forEach((v) => {
1328
+ if (rangeObj.test(v)) {
1329
+ if (!max || maxSV.compare(v) === -1) {
1330
+ max = v;
1331
+ maxSV = new SemVer(max, options);
1332
+ }
1333
+ }
1334
+ });
1335
+ return max;
1336
+ };
1337
+ module2.exports = maxSatisfying;
1338
+ }
1339
+ });
1340
+ var require_min_satisfying = __commonJS({
1341
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js"(exports$1, module2) {
1342
+ var SemVer = require_semver();
1343
+ var Range = require_range();
1344
+ var minSatisfying = (versions, range, options) => {
1345
+ let min = null;
1346
+ let minSV = null;
1347
+ let rangeObj = null;
1348
+ try {
1349
+ rangeObj = new Range(range, options);
1350
+ } catch (er) {
1351
+ return null;
1352
+ }
1353
+ versions.forEach((v) => {
1354
+ if (rangeObj.test(v)) {
1355
+ if (!min || minSV.compare(v) === 1) {
1356
+ min = v;
1357
+ minSV = new SemVer(min, options);
1358
+ }
1359
+ }
1360
+ });
1361
+ return min;
1362
+ };
1363
+ module2.exports = minSatisfying;
1364
+ }
1365
+ });
1366
+ var require_min_version = __commonJS({
1367
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js"(exports$1, module2) {
1368
+ var SemVer = require_semver();
1369
+ var Range = require_range();
1370
+ var gt = require_gt();
1371
+ var minVersion = (range, loose) => {
1372
+ range = new Range(range, loose);
1373
+ let minver = new SemVer("0.0.0");
1374
+ if (range.test(minver)) {
1375
+ return minver;
1376
+ }
1377
+ minver = new SemVer("0.0.0-0");
1378
+ if (range.test(minver)) {
1379
+ return minver;
1380
+ }
1381
+ minver = null;
1382
+ for (let i = 0; i < range.set.length; ++i) {
1383
+ const comparators = range.set[i];
1384
+ let setMin = null;
1385
+ comparators.forEach((comparator) => {
1386
+ const compver = new SemVer(comparator.semver.version);
1387
+ switch (comparator.operator) {
1388
+ case ">":
1389
+ if (compver.prerelease.length === 0) {
1390
+ compver.patch++;
1391
+ } else {
1392
+ compver.prerelease.push(0);
1393
+ }
1394
+ compver.raw = compver.format();
1395
+ /* fallthrough */
1396
+ case "":
1397
+ case ">=":
1398
+ if (!setMin || gt(compver, setMin)) {
1399
+ setMin = compver;
1400
+ }
1401
+ break;
1402
+ case "<":
1403
+ case "<=":
1404
+ break;
1405
+ /* istanbul ignore next */
1406
+ default:
1407
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1408
+ }
1409
+ });
1410
+ if (setMin && (!minver || gt(minver, setMin))) {
1411
+ minver = setMin;
1412
+ }
1413
+ }
1414
+ if (minver && range.test(minver)) {
1415
+ return minver;
1416
+ }
1417
+ return null;
1418
+ };
1419
+ module2.exports = minVersion;
1420
+ }
1421
+ });
1422
+ var require_valid2 = __commonJS({
1423
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js"(exports$1, module2) {
1424
+ var Range = require_range();
1425
+ var validRange = (range, options) => {
1426
+ try {
1427
+ return new Range(range, options).range || "*";
1428
+ } catch (er) {
1429
+ return null;
1430
+ }
1431
+ };
1432
+ module2.exports = validRange;
1433
+ }
1434
+ });
1435
+ var require_outside = __commonJS({
1436
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js"(exports$1, module2) {
1437
+ var SemVer = require_semver();
1438
+ var Comparator = require_comparator();
1439
+ var { ANY } = Comparator;
1440
+ var Range = require_range();
1441
+ var satisfies2 = require_satisfies();
1442
+ var gt = require_gt();
1443
+ var lt = require_lt();
1444
+ var lte = require_lte();
1445
+ var gte2 = require_gte();
1446
+ var outside = (version, range, hilo, options) => {
1447
+ version = new SemVer(version, options);
1448
+ range = new Range(range, options);
1449
+ let gtfn, ltefn, ltfn, comp, ecomp;
1450
+ switch (hilo) {
1451
+ case ">":
1452
+ gtfn = gt;
1453
+ ltefn = lte;
1454
+ ltfn = lt;
1455
+ comp = ">";
1456
+ ecomp = ">=";
1457
+ break;
1458
+ case "<":
1459
+ gtfn = lt;
1460
+ ltefn = gte2;
1461
+ ltfn = gt;
1462
+ comp = "<";
1463
+ ecomp = "<=";
1464
+ break;
1465
+ default:
1466
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1467
+ }
1468
+ if (satisfies2(version, range, options)) {
1469
+ return false;
1470
+ }
1471
+ for (let i = 0; i < range.set.length; ++i) {
1472
+ const comparators = range.set[i];
1473
+ let high = null;
1474
+ let low = null;
1475
+ comparators.forEach((comparator) => {
1476
+ if (comparator.semver === ANY) {
1477
+ comparator = new Comparator(">=0.0.0");
1478
+ }
1479
+ high = high || comparator;
1480
+ low = low || comparator;
1481
+ if (gtfn(comparator.semver, high.semver, options)) {
1482
+ high = comparator;
1483
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1484
+ low = comparator;
1485
+ }
1486
+ });
1487
+ if (high.operator === comp || high.operator === ecomp) {
1488
+ return false;
1489
+ }
1490
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1491
+ return false;
1492
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1493
+ return false;
1494
+ }
1495
+ }
1496
+ return true;
1497
+ };
1498
+ module2.exports = outside;
1499
+ }
1500
+ });
1501
+ var require_gtr = __commonJS({
1502
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js"(exports$1, module2) {
1503
+ var outside = require_outside();
1504
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1505
+ module2.exports = gtr;
1506
+ }
1507
+ });
1508
+ var require_ltr = __commonJS({
1509
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js"(exports$1, module2) {
1510
+ var outside = require_outside();
1511
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1512
+ module2.exports = ltr;
1513
+ }
1514
+ });
1515
+ var require_intersects = __commonJS({
1516
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js"(exports$1, module2) {
1517
+ var Range = require_range();
1518
+ var intersects = (r1, r2, options) => {
1519
+ r1 = new Range(r1, options);
1520
+ r2 = new Range(r2, options);
1521
+ return r1.intersects(r2, options);
1522
+ };
1523
+ module2.exports = intersects;
1524
+ }
1525
+ });
1526
+ var require_simplify = __commonJS({
1527
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js"(exports$1, module2) {
1528
+ var satisfies2 = require_satisfies();
1529
+ var compare2 = require_compare();
1530
+ module2.exports = (versions, range, options) => {
1531
+ const set = [];
1532
+ let first = null;
1533
+ let prev = null;
1534
+ const v = versions.sort((a, b) => compare2(a, b, options));
1535
+ for (const version of v) {
1536
+ const included = satisfies2(version, range, options);
1537
+ if (included) {
1538
+ prev = version;
1539
+ if (!first) {
1540
+ first = version;
1541
+ }
1542
+ } else {
1543
+ if (prev) {
1544
+ set.push([first, prev]);
1545
+ }
1546
+ prev = null;
1547
+ first = null;
1548
+ }
1549
+ }
1550
+ if (first) {
1551
+ set.push([first, null]);
1552
+ }
1553
+ const ranges = [];
1554
+ for (const [min, max] of set) {
1555
+ if (min === max) {
1556
+ ranges.push(min);
1557
+ } else if (!max && min === v[0]) {
1558
+ ranges.push("*");
1559
+ } else if (!max) {
1560
+ ranges.push(`>=${min}`);
1561
+ } else if (min === v[0]) {
1562
+ ranges.push(`<=${max}`);
1563
+ } else {
1564
+ ranges.push(`${min} - ${max}`);
1565
+ }
1566
+ }
1567
+ const simplified = ranges.join(" || ");
1568
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1569
+ return simplified.length < original.length ? simplified : range;
1570
+ };
1571
+ }
1572
+ });
1573
+ var require_subset = __commonJS({
1574
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js"(exports$1, module2) {
1575
+ var Range = require_range();
1576
+ var Comparator = require_comparator();
1577
+ var { ANY } = Comparator;
1578
+ var satisfies2 = require_satisfies();
1579
+ var compare2 = require_compare();
1580
+ var subset = (sub, dom, options = {}) => {
1581
+ if (sub === dom) {
1582
+ return true;
1583
+ }
1584
+ sub = new Range(sub, options);
1585
+ dom = new Range(dom, options);
1586
+ let sawNonNull = false;
1587
+ OUTER: for (const simpleSub of sub.set) {
1588
+ for (const simpleDom of dom.set) {
1589
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1590
+ sawNonNull = sawNonNull || isSub !== null;
1591
+ if (isSub) {
1592
+ continue OUTER;
1593
+ }
1594
+ }
1595
+ if (sawNonNull) {
1596
+ return false;
1597
+ }
1598
+ }
1599
+ return true;
1600
+ };
1601
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1602
+ var minimumVersion = [new Comparator(">=0.0.0")];
1603
+ var simpleSubset = (sub, dom, options) => {
1604
+ if (sub === dom) {
1605
+ return true;
1606
+ }
1607
+ if (sub.length === 1 && sub[0].semver === ANY) {
1608
+ if (dom.length === 1 && dom[0].semver === ANY) {
1609
+ return true;
1610
+ } else if (options.includePrerelease) {
1611
+ sub = minimumVersionWithPreRelease;
1612
+ } else {
1613
+ sub = minimumVersion;
1614
+ }
1615
+ }
1616
+ if (dom.length === 1 && dom[0].semver === ANY) {
1617
+ if (options.includePrerelease) {
1618
+ return true;
1619
+ } else {
1620
+ dom = minimumVersion;
1621
+ }
1622
+ }
1623
+ const eqSet = /* @__PURE__ */ new Set();
1624
+ let gt, lt;
1625
+ for (const c of sub) {
1626
+ if (c.operator === ">" || c.operator === ">=") {
1627
+ gt = higherGT(gt, c, options);
1628
+ } else if (c.operator === "<" || c.operator === "<=") {
1629
+ lt = lowerLT(lt, c, options);
1630
+ } else {
1631
+ eqSet.add(c.semver);
1632
+ }
1633
+ }
1634
+ if (eqSet.size > 1) {
1635
+ return null;
1636
+ }
1637
+ let gtltComp;
1638
+ if (gt && lt) {
1639
+ gtltComp = compare2(gt.semver, lt.semver, options);
1640
+ if (gtltComp > 0) {
1641
+ return null;
1642
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
1643
+ return null;
1644
+ }
1645
+ }
1646
+ for (const eq of eqSet) {
1647
+ if (gt && !satisfies2(eq, String(gt), options)) {
1648
+ return null;
1649
+ }
1650
+ if (lt && !satisfies2(eq, String(lt), options)) {
1651
+ return null;
1652
+ }
1653
+ for (const c of dom) {
1654
+ if (!satisfies2(eq, String(c), options)) {
1655
+ return false;
1656
+ }
1657
+ }
1658
+ return true;
1659
+ }
1660
+ let higher, lower;
1661
+ let hasDomLT, hasDomGT;
1662
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1663
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1664
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
1665
+ needDomLTPre = false;
1666
+ }
1667
+ for (const c of dom) {
1668
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1669
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1670
+ if (gt) {
1671
+ if (needDomGTPre) {
1672
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
1673
+ needDomGTPre = false;
1674
+ }
1675
+ }
1676
+ if (c.operator === ">" || c.operator === ">=") {
1677
+ higher = higherGT(gt, c, options);
1678
+ if (higher === c && higher !== gt) {
1679
+ return false;
1680
+ }
1681
+ } else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c), options)) {
1682
+ return false;
1683
+ }
1684
+ }
1685
+ if (lt) {
1686
+ if (needDomLTPre) {
1687
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
1688
+ needDomLTPre = false;
1689
+ }
1690
+ }
1691
+ if (c.operator === "<" || c.operator === "<=") {
1692
+ lower = lowerLT(lt, c, options);
1693
+ if (lower === c && lower !== lt) {
1694
+ return false;
1695
+ }
1696
+ } else if (lt.operator === "<=" && !satisfies2(lt.semver, String(c), options)) {
1697
+ return false;
1698
+ }
1699
+ }
1700
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
1701
+ return false;
1702
+ }
1703
+ }
1704
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
1705
+ return false;
1706
+ }
1707
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
1708
+ return false;
1709
+ }
1710
+ if (needDomGTPre || needDomLTPre) {
1711
+ return false;
1712
+ }
1713
+ return true;
1714
+ };
1715
+ var higherGT = (a, b, options) => {
1716
+ if (!a) {
1717
+ return b;
1718
+ }
1719
+ const comp = compare2(a.semver, b.semver, options);
1720
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1721
+ };
1722
+ var lowerLT = (a, b, options) => {
1723
+ if (!a) {
1724
+ return b;
1725
+ }
1726
+ const comp = compare2(a.semver, b.semver, options);
1727
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1728
+ };
1729
+ module2.exports = subset;
1730
+ }
1731
+ });
1732
+ var require_semver2 = __commonJS({
1733
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports$1, module2) {
1734
+ var internalRe = require_re();
1735
+ var constants2 = require_constants();
1736
+ var SemVer = require_semver();
1737
+ var identifiers = require_identifiers();
1738
+ var parse = require_parse();
1739
+ var valid2 = require_valid();
1740
+ var clean = require_clean();
1741
+ var inc = require_inc();
1742
+ var diff = require_diff();
1743
+ var major = require_major();
1744
+ var minor = require_minor();
1745
+ var patch = require_patch();
1746
+ var prerelease = require_prerelease();
1747
+ var compare2 = require_compare();
1748
+ var rcompare = require_rcompare();
1749
+ var compareLoose = require_compare_loose();
1750
+ var compareBuild = require_compare_build();
1751
+ var sort = require_sort();
1752
+ var rsort = require_rsort();
1753
+ var gt = require_gt();
1754
+ var lt = require_lt();
1755
+ var eq = require_eq();
1756
+ var neq = require_neq();
1757
+ var gte2 = require_gte();
1758
+ var lte = require_lte();
1759
+ var cmp = require_cmp();
1760
+ var coerce2 = require_coerce();
1761
+ var Comparator = require_comparator();
1762
+ var Range = require_range();
1763
+ var satisfies2 = require_satisfies();
1764
+ var toComparators = require_to_comparators();
1765
+ var maxSatisfying = require_max_satisfying();
1766
+ var minSatisfying = require_min_satisfying();
1767
+ var minVersion = require_min_version();
1768
+ var validRange = require_valid2();
1769
+ var outside = require_outside();
1770
+ var gtr = require_gtr();
1771
+ var ltr = require_ltr();
1772
+ var intersects = require_intersects();
1773
+ var simplifyRange = require_simplify();
1774
+ var subset = require_subset();
1775
+ module2.exports = {
1776
+ parse,
1777
+ valid: valid2,
1778
+ clean,
1779
+ inc,
1780
+ diff,
1781
+ major,
1782
+ minor,
1783
+ patch,
1784
+ prerelease,
1785
+ compare: compare2,
1786
+ rcompare,
1787
+ compareLoose,
1788
+ compareBuild,
1789
+ sort,
1790
+ rsort,
1791
+ gt,
1792
+ lt,
1793
+ eq,
1794
+ neq,
1795
+ gte: gte2,
1796
+ lte,
1797
+ cmp,
1798
+ coerce: coerce2,
1799
+ Comparator,
1800
+ Range,
1801
+ satisfies: satisfies2,
1802
+ toComparators,
1803
+ maxSatisfying,
1804
+ minSatisfying,
1805
+ minVersion,
1806
+ validRange,
1807
+ outside,
1808
+ gtr,
1809
+ ltr,
1810
+ intersects,
1811
+ simplifyRange,
1812
+ subset,
1813
+ SemVer,
1814
+ re: internalRe.re,
1815
+ src: internalRe.src,
1816
+ tokens: internalRe.t,
1817
+ SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
1818
+ RELEASE_TYPES: constants2.RELEASE_TYPES,
1819
+ compareIdentifiers: identifiers.compareIdentifiers,
1820
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
1821
+ };
1822
+ }
1823
+ });
1824
+ var CliForegroundColor = /* @__PURE__ */ ((CliForegroundColor2) => {
1825
+ CliForegroundColor2["Black"] = "\x1B[30m";
1826
+ CliForegroundColor2["Red"] = "\x1B[31m";
1827
+ CliForegroundColor2["Green"] = "\x1B[32m";
1828
+ CliForegroundColor2["Yellow"] = "\x1B[33m";
1829
+ CliForegroundColor2["Blue"] = "\x1B[34m";
1830
+ CliForegroundColor2["Magenta"] = "\x1B[35m";
1831
+ CliForegroundColor2["Cyan"] = "\x1B[36m";
1832
+ CliForegroundColor2["White"] = "\x1B[37m";
1833
+ CliForegroundColor2["Reset"] = "\x1B[0m";
1834
+ return CliForegroundColor2;
1835
+ })(CliForegroundColor || {});
1836
+ var ICliCompletionProvider_TOKEN = "cli-completion-provider";
1837
+ var DefaultLibraryAuthor = {
1838
+ name: "Nicolae Lupei",
1839
+ email: "nicolae.lupei@qodalis.com"
1840
+ };
1841
+ var semver = __toESM(require_semver2());
1842
+ var ServerVersionNegotiator = class {
1843
+ static {
1844
+ this.CLIENT_SUPPORTED_VERSIONS = [2];
1845
+ }
1846
+ /**
1847
+ * Given a server's version info, pick the highest mutually compatible version.
1848
+ * Returns null if no compatible version exists.
1849
+ */
1850
+ static negotiate(serverInfo) {
1851
+ const common = this.CLIENT_SUPPORTED_VERSIONS.filter(
1852
+ (v) => serverInfo.supportedVersions.includes(v)
1853
+ );
1854
+ return common.length > 0 ? Math.max(...common) : null;
1855
+ }
1856
+ /**
1857
+ * Discover the server's supported versions and negotiate the best match.
1858
+ * Returns the negotiated API version and the base path for all subsequent calls,
1859
+ * or null if the server is unreachable or incompatible.
1860
+ */
1861
+ static async discover(baseUrl) {
1862
+ try {
1863
+ const response = await fetch(`${baseUrl}/api/cli/versions`);
1864
+ if (!response.ok) return null;
1865
+ const info = await response.json();
1866
+ const version = this.negotiate(info);
1867
+ if (version === null) return null;
1868
+ return {
1869
+ apiVersion: version,
1870
+ basePath: `${baseUrl}/api/v${version}/cli`
1871
+ };
1872
+ } catch {
1873
+ return null;
1874
+ }
1875
+ }
1876
+ };
1877
+ var bootCliModule = async (module2) => {
1878
+ if (typeof window !== "undefined" && window.__cliModuleRegistry) {
1879
+ await window.__cliModuleRegistry.register(module2);
1880
+ }
1881
+ };
1882
+ var DefaultThemes = {
1883
+ default: {
1884
+ background: "#070b14",
1885
+ foreground: "#dee2ea",
1886
+ cursor: "#818cf8",
1887
+ selectionBackground: "#334155",
1888
+ selectionForeground: "#ffffff",
1889
+ black: "#0d1117",
1890
+ red: "#f87171",
1891
+ green: "#4ade80",
1892
+ yellow: "#fbbf24",
1893
+ blue: "#818cf8",
1894
+ magenta: "#c084fc",
1895
+ cyan: "#67e8f9",
1896
+ white: "#dee2ea",
1897
+ brightBlack: "#475569",
1898
+ brightRed: "#fca5a5",
1899
+ brightGreen: "#86efac",
1900
+ brightYellow: "#fde68a",
1901
+ brightBlue: "#a5b4fc",
1902
+ brightMagenta: "#d8b4fe",
1903
+ brightCyan: "#a5f3fc",
1904
+ brightWhite: "#f1f5f9"
1905
+ },
1906
+ classic: {
1907
+ background: "#0c0c0c",
1908
+ foreground: "#cccccc",
1909
+ cursor: "#cccccc",
1910
+ selectionBackground: "#264f78",
1911
+ selectionForeground: "#ffffff",
1912
+ black: "#0c0c0c",
1913
+ red: "#c50f1f",
1914
+ green: "#13a10e",
1915
+ yellow: "#c19c00",
1916
+ blue: "#0037da",
1917
+ magenta: "#881798",
1918
+ cyan: "#3a96dd",
1919
+ white: "#cccccc",
1920
+ brightBlack: "#767676",
1921
+ brightRed: "#e74856",
1922
+ brightGreen: "#16c60c",
1923
+ brightYellow: "#f9f1a5",
1924
+ brightBlue: "#3b78ff",
1925
+ brightMagenta: "#b4009e",
1926
+ brightCyan: "#61d6d6",
1927
+ brightWhite: "#f2f2f2"
1928
+ },
1929
+ dracula: {
1930
+ background: "#282A36",
1931
+ foreground: "#F8F8F2",
1932
+ cursor: "#50FA7B",
1933
+ black: "#21222C",
1934
+ red: "#FF5555",
1935
+ green: "#50FA7B",
1936
+ yellow: "#F1FA8C",
1937
+ blue: "#BD93F9",
1938
+ magenta: "#FF79C6",
1939
+ cyan: "#8BE9FD",
1940
+ white: "#F8F8F2",
1941
+ brightBlack: "#6272A4",
1942
+ brightRed: "#FF6E6E",
1943
+ brightGreen: "#69FF94",
1944
+ brightYellow: "#FFFFA5",
1945
+ brightBlue: "#D6ACFF",
1946
+ brightMagenta: "#FF92D0",
1947
+ brightCyan: "#A4FFFF",
1948
+ brightWhite: "#FFFFFF"
1949
+ },
1950
+ monokai: {
1951
+ background: "#272822",
1952
+ foreground: "#F8F8F2",
1953
+ cursor: "#F8F8F0",
1954
+ black: "#272822",
1955
+ red: "#F92672",
1956
+ green: "#A6E22E",
1957
+ yellow: "#F4BF75",
1958
+ blue: "#66D9EF",
1959
+ magenta: "#AE81FF",
1960
+ cyan: "#A1EFE4",
1961
+ white: "#F8F8F2",
1962
+ brightBlack: "#75715E",
1963
+ brightRed: "#F92672",
1964
+ brightGreen: "#A6E22E",
1965
+ brightYellow: "#F4BF75",
1966
+ brightBlue: "#66D9EF",
1967
+ brightMagenta: "#AE81FF",
1968
+ brightCyan: "#A1EFE4",
1969
+ brightWhite: "#F9F8F5"
1970
+ },
1971
+ solarizedDark: {
1972
+ background: "#002B36",
1973
+ foreground: "#839496",
1974
+ cursor: "#93A1A1",
1975
+ black: "#073642",
1976
+ red: "#DC322F",
1977
+ green: "#859900",
1978
+ yellow: "#B58900",
1979
+ blue: "#268BD2",
1980
+ magenta: "#D33682",
1981
+ cyan: "#2AA198",
1982
+ white: "#EEE8D5",
1983
+ brightBlack: "#002B36",
1984
+ brightRed: "#CB4B16",
1985
+ brightGreen: "#586E75",
1986
+ brightYellow: "#657B83",
1987
+ brightBlue: "#839496",
1988
+ brightMagenta: "#6C71C4",
1989
+ brightCyan: "#93A1A1",
1990
+ brightWhite: "#FDF6E3"
1991
+ },
1992
+ solarizedLight: {
1993
+ background: "#FDF6E3",
1994
+ foreground: "#657B83",
1995
+ cursor: "#586E75",
1996
+ black: "#073642",
1997
+ red: "#DC322F",
1998
+ green: "#859900",
1999
+ yellow: "#B58900",
2000
+ blue: "#268BD2",
2001
+ magenta: "#D33682",
2002
+ cyan: "#2AA198",
2003
+ white: "#EEE8D5",
2004
+ brightBlack: "#002B36",
2005
+ brightRed: "#CB4B16",
2006
+ brightGreen: "#586E75",
2007
+ brightYellow: "#657B83",
2008
+ brightBlue: "#839496",
2009
+ brightMagenta: "#6C71C4",
2010
+ brightCyan: "#93A1A1",
2011
+ brightWhite: "#FDF6E3"
2012
+ },
2013
+ gruvboxDark: {
2014
+ background: "#282828",
2015
+ foreground: "#EBDBB2",
2016
+ cursor: "#EBDBB2",
2017
+ black: "#282828",
2018
+ red: "#CC241D",
2019
+ green: "#98971A",
2020
+ yellow: "#D79921",
2021
+ blue: "#458588",
2022
+ magenta: "#B16286",
2023
+ cyan: "#689D6A",
2024
+ white: "#A89984",
2025
+ brightBlack: "#928374",
2026
+ brightRed: "#FB4934",
2027
+ brightGreen: "#B8BB26",
2028
+ brightYellow: "#FABD2F",
2029
+ brightBlue: "#83A598",
2030
+ brightMagenta: "#D3869B",
2031
+ brightCyan: "#8EC07C",
2032
+ brightWhite: "#EBDBB2"
2033
+ },
2034
+ gruvboxLight: {
2035
+ background: "#FBF1C7",
2036
+ foreground: "#3C3836",
2037
+ cursor: "#3C3836",
2038
+ black: "#FBF1C7",
2039
+ red: "#9D0006",
2040
+ green: "#79740E",
2041
+ yellow: "#B57614",
2042
+ blue: "#076678",
2043
+ magenta: "#8F3F71",
2044
+ cyan: "#427B58",
2045
+ white: "#3C3836",
2046
+ brightBlack: "#D5C4A1",
2047
+ brightRed: "#AF3A03",
2048
+ brightGreen: "#B8BB26",
2049
+ brightYellow: "#FABD2F",
2050
+ brightBlue: "#83A598",
2051
+ brightMagenta: "#D3869B",
2052
+ brightCyan: "#8EC07C",
2053
+ brightWhite: "#EBDBB2"
2054
+ },
2055
+ nord: {
2056
+ background: "#2E3440",
2057
+ foreground: "#D8DEE9",
2058
+ cursor: "#88C0D0",
2059
+ black: "#3B4252",
2060
+ red: "#BF616A",
2061
+ green: "#A3BE8C",
2062
+ yellow: "#EBCB8B",
2063
+ blue: "#81A1C1",
2064
+ magenta: "#B48EAD",
2065
+ cyan: "#88C0D0",
2066
+ white: "#E5E9F0",
2067
+ brightBlack: "#4C566A",
2068
+ brightRed: "#BF616A",
2069
+ brightGreen: "#A3BE8C",
2070
+ brightYellow: "#EBCB8B",
2071
+ brightBlue: "#81A1C1",
2072
+ brightMagenta: "#B48EAD",
2073
+ brightCyan: "#8FBCBB",
2074
+ brightWhite: "#ECEFF4"
2075
+ },
2076
+ oneDark: {
2077
+ background: "#282C34",
2078
+ foreground: "#ABB2BF",
2079
+ cursor: "#528BFF",
2080
+ black: "#282C34",
2081
+ red: "#E06C75",
2082
+ green: "#98C379",
2083
+ yellow: "#E5C07B",
2084
+ blue: "#61AFEF",
2085
+ magenta: "#C678DD",
2086
+ cyan: "#56B6C2",
2087
+ white: "#ABB2BF",
2088
+ brightBlack: "#5C6370",
2089
+ brightRed: "#E06C75",
2090
+ brightGreen: "#98C379",
2091
+ brightYellow: "#E5C07B",
2092
+ brightBlue: "#61AFEF",
2093
+ brightMagenta: "#C678DD",
2094
+ brightCyan: "#56B6C2",
2095
+ brightWhite: "#FFFFFF"
2096
+ },
2097
+ material: {
2098
+ background: "#263238",
2099
+ foreground: "#ECEFF1",
2100
+ cursor: "#FFCC00",
2101
+ black: "#263238",
2102
+ red: "#F07178",
2103
+ green: "#C3E88D",
2104
+ yellow: "#FFCB6B",
2105
+ blue: "#82AAFF",
2106
+ magenta: "#C792EA",
2107
+ cyan: "#89DDFF",
2108
+ white: "#EEFFFF",
2109
+ brightBlack: "#546E7A",
2110
+ brightRed: "#F07178",
2111
+ brightGreen: "#C3E88D",
2112
+ brightYellow: "#FFCB6B",
2113
+ brightBlue: "#82AAFF",
2114
+ brightMagenta: "#C792EA",
2115
+ brightCyan: "#89DDFF",
2116
+ brightWhite: "#FFFFFF"
2117
+ },
2118
+ highContrastLight: {
2119
+ background: "#FFFACD",
2120
+ foreground: "#000000",
2121
+ cursor: "#FFA500",
2122
+ selectionBackground: "#FFD700",
2123
+ black: "#3B3A32",
2124
+ red: "#D32F2F",
2125
+ green: "#388E3C",
2126
+ yellow: "#FBC02D",
2127
+ blue: "#1976D2",
2128
+ magenta: "#8E24AA",
2129
+ cyan: "#0097A7",
2130
+ white: "#FFFFFF",
2131
+ brightBlack: "#616161",
2132
+ brightRed: "#FF5252",
2133
+ brightGreen: "#69F0AE",
2134
+ brightYellow: "#FFEB3B",
2135
+ brightBlue: "#64B5F6",
2136
+ brightMagenta: "#BA68C8",
2137
+ brightCyan: "#4DD0E1",
2138
+ brightWhite: "#FAFAFA"
2139
+ },
2140
+ tokyoNight: {
2141
+ background: "#1a1b26",
2142
+ foreground: "#c0caf5",
2143
+ cursor: "#c0caf5",
2144
+ selectionBackground: "#33467c",
2145
+ black: "#15161e",
2146
+ red: "#f7768e",
2147
+ green: "#9ece6a",
2148
+ yellow: "#e0af68",
2149
+ blue: "#7aa2f7",
2150
+ magenta: "#bb9af7",
2151
+ cyan: "#7dcfff",
2152
+ white: "#a9b1d6",
2153
+ brightBlack: "#414868",
2154
+ brightRed: "#f7768e",
2155
+ brightGreen: "#9ece6a",
2156
+ brightYellow: "#e0af68",
2157
+ brightBlue: "#7aa2f7",
2158
+ brightMagenta: "#bb9af7",
2159
+ brightCyan: "#7dcfff",
2160
+ brightWhite: "#c0caf5"
2161
+ },
2162
+ catppuccinMocha: {
2163
+ background: "#1e1e2e",
2164
+ foreground: "#cdd6f4",
2165
+ cursor: "#f5e0dc",
2166
+ selectionBackground: "#45475a",
2167
+ black: "#45475a",
2168
+ red: "#f38ba8",
2169
+ green: "#a6e3a1",
2170
+ yellow: "#f9e2af",
2171
+ blue: "#89b4fa",
2172
+ magenta: "#f5c2e7",
2173
+ cyan: "#94e2d5",
2174
+ white: "#bac2de",
2175
+ brightBlack: "#585b70",
2176
+ brightRed: "#f38ba8",
2177
+ brightGreen: "#a6e3a1",
2178
+ brightYellow: "#f9e2af",
2179
+ brightBlue: "#89b4fa",
2180
+ brightMagenta: "#f5c2e7",
2181
+ brightCyan: "#94e2d5",
2182
+ brightWhite: "#a6adc8"
2183
+ },
2184
+ catppuccinFrappe: {
2185
+ background: "#303446",
2186
+ foreground: "#c6d0f5",
2187
+ cursor: "#f2d5cf",
2188
+ selectionBackground: "#51576d",
2189
+ black: "#51576d",
2190
+ red: "#e78284",
2191
+ green: "#a6d189",
2192
+ yellow: "#e5c890",
2193
+ blue: "#8caaee",
2194
+ magenta: "#f4b8e4",
2195
+ cyan: "#81c8be",
2196
+ white: "#b5bfe2",
2197
+ brightBlack: "#626880",
2198
+ brightRed: "#e78284",
2199
+ brightGreen: "#a6d189",
2200
+ brightYellow: "#e5c890",
2201
+ brightBlue: "#8caaee",
2202
+ brightMagenta: "#f4b8e4",
2203
+ brightCyan: "#81c8be",
2204
+ brightWhite: "#a5adce"
2205
+ },
2206
+ rosePine: {
2207
+ background: "#191724",
2208
+ foreground: "#e0def4",
2209
+ cursor: "#524f67",
2210
+ selectionBackground: "#2a283e",
2211
+ black: "#26233a",
2212
+ red: "#eb6f92",
2213
+ green: "#31748f",
2214
+ yellow: "#f6c177",
2215
+ blue: "#9ccfd8",
2216
+ magenta: "#c4a7e7",
2217
+ cyan: "#ebbcba",
2218
+ white: "#e0def4",
2219
+ brightBlack: "#6e6a86",
2220
+ brightRed: "#eb6f92",
2221
+ brightGreen: "#31748f",
2222
+ brightYellow: "#f6c177",
2223
+ brightBlue: "#9ccfd8",
2224
+ brightMagenta: "#c4a7e7",
2225
+ brightCyan: "#ebbcba",
2226
+ brightWhite: "#e0def4"
2227
+ },
2228
+ kanagawa: {
2229
+ background: "#1f1f28",
2230
+ foreground: "#dcd7ba",
2231
+ cursor: "#c8c093",
2232
+ selectionBackground: "#2d4f67",
2233
+ black: "#16161d",
2234
+ red: "#c34043",
2235
+ green: "#76946a",
2236
+ yellow: "#c0a36e",
2237
+ blue: "#7e9cd8",
2238
+ magenta: "#957fb8",
2239
+ cyan: "#6a9589",
2240
+ white: "#c8c093",
2241
+ brightBlack: "#727169",
2242
+ brightRed: "#e82424",
2243
+ brightGreen: "#98bb6c",
2244
+ brightYellow: "#e6c384",
2245
+ brightBlue: "#7fb4ca",
2246
+ brightMagenta: "#938aa9",
2247
+ brightCyan: "#7aa89f",
2248
+ brightWhite: "#dcd7ba"
2249
+ },
2250
+ everforestDark: {
2251
+ background: "#2d353b",
2252
+ foreground: "#d3c6aa",
2253
+ cursor: "#d3c6aa",
2254
+ selectionBackground: "#543a48",
2255
+ black: "#475258",
2256
+ red: "#e67e80",
2257
+ green: "#a7c080",
2258
+ yellow: "#dbbc7f",
2259
+ blue: "#7fbbb3",
2260
+ magenta: "#d699b6",
2261
+ cyan: "#83c092",
2262
+ white: "#d3c6aa",
2263
+ brightBlack: "#475258",
2264
+ brightRed: "#e67e80",
2265
+ brightGreen: "#a7c080",
2266
+ brightYellow: "#dbbc7f",
2267
+ brightBlue: "#7fbbb3",
2268
+ brightMagenta: "#d699b6",
2269
+ brightCyan: "#83c092",
2270
+ brightWhite: "#d3c6aa"
2271
+ },
2272
+ ayuDark: {
2273
+ background: "#0b0e14",
2274
+ foreground: "#bfbdb6",
2275
+ cursor: "#e6b450",
2276
+ selectionBackground: "#1b3a4b",
2277
+ black: "#01060e",
2278
+ red: "#ea6c73",
2279
+ green: "#91b362",
2280
+ yellow: "#f9af4f",
2281
+ blue: "#53bdfa",
2282
+ magenta: "#fae994",
2283
+ cyan: "#90e1c6",
2284
+ white: "#c7c7c7",
2285
+ brightBlack: "#686868",
2286
+ brightRed: "#f07178",
2287
+ brightGreen: "#c2d94c",
2288
+ brightYellow: "#ffb454",
2289
+ brightBlue: "#59c2ff",
2290
+ brightMagenta: "#ffee99",
2291
+ brightCyan: "#95e6cb",
2292
+ brightWhite: "#ffffff"
2293
+ },
2294
+ catppuccinLatte: {
2295
+ background: "#eff1f5",
2296
+ foreground: "#4c4f69",
2297
+ cursor: "#dc8a78",
2298
+ selectionBackground: "#acb0be",
2299
+ black: "#5c5f77",
2300
+ red: "#d20f39",
2301
+ green: "#40a02b",
2302
+ yellow: "#df8e1d",
2303
+ blue: "#1e66f5",
2304
+ magenta: "#ea76cb",
2305
+ cyan: "#179299",
2306
+ white: "#acb0be",
2307
+ brightBlack: "#6c6f85",
2308
+ brightRed: "#d20f39",
2309
+ brightGreen: "#40a02b",
2310
+ brightYellow: "#df8e1d",
2311
+ brightBlue: "#1e66f5",
2312
+ brightMagenta: "#ea76cb",
2313
+ brightCyan: "#179299",
2314
+ brightWhite: "#bcc0cc"
2315
+ },
2316
+ rosePineDawn: {
2317
+ background: "#faf4ed",
2318
+ foreground: "#575279",
2319
+ cursor: "#9893a5",
2320
+ selectionBackground: "#dfdad9",
2321
+ black: "#f2e9e1",
2322
+ red: "#b4637a",
2323
+ green: "#286983",
2324
+ yellow: "#ea9d34",
2325
+ blue: "#56949f",
2326
+ magenta: "#907aa9",
2327
+ cyan: "#d7827e",
2328
+ white: "#575279",
2329
+ brightBlack: "#9893a5",
2330
+ brightRed: "#b4637a",
2331
+ brightGreen: "#286983",
2332
+ brightYellow: "#ea9d34",
2333
+ brightBlue: "#56949f",
2334
+ brightMagenta: "#907aa9",
2335
+ brightCyan: "#d7827e",
2336
+ brightWhite: "#575279"
2337
+ },
2338
+ everforestLight: {
2339
+ background: "#fdf6e3",
2340
+ foreground: "#5c6a72",
2341
+ cursor: "#5c6a72",
2342
+ selectionBackground: "#e6e2cc",
2343
+ black: "#5c6a72",
2344
+ red: "#f85552",
2345
+ green: "#8da101",
2346
+ yellow: "#dfa000",
2347
+ blue: "#3a94c5",
2348
+ magenta: "#df69ba",
2349
+ cyan: "#35a77c",
2350
+ white: "#dfddc8",
2351
+ brightBlack: "#708089",
2352
+ brightRed: "#f85552",
2353
+ brightGreen: "#8da101",
2354
+ brightYellow: "#dfa000",
2355
+ brightBlue: "#3a94c5",
2356
+ brightMagenta: "#df69ba",
2357
+ brightCyan: "#35a77c",
2358
+ brightWhite: "#e8e5d0"
2359
+ },
2360
+ githubLight: {
2361
+ background: "#ffffff",
2362
+ foreground: "#24292f",
2363
+ cursor: "#044289",
2364
+ selectionBackground: "#0969da33",
2365
+ black: "#24292f",
2366
+ red: "#cf222e",
2367
+ green: "#116329",
2368
+ yellow: "#4d2d00",
2369
+ blue: "#0969da",
2370
+ magenta: "#8250df",
2371
+ cyan: "#1b7c83",
2372
+ white: "#6e7781",
2373
+ brightBlack: "#57606a",
2374
+ brightRed: "#a40e26",
2375
+ brightGreen: "#1a7f37",
2376
+ brightYellow: "#633c01",
2377
+ brightBlue: "#218bff",
2378
+ brightMagenta: "#a475f9",
2379
+ brightCyan: "#3192aa",
2380
+ brightWhite: "#8c959f"
2381
+ },
2382
+ cyberpunk: {
2383
+ background: "#0a0a1a",
2384
+ foreground: "#0abdc6",
2385
+ cursor: "#ff2079",
2386
+ selectionBackground: "#1a1a3a",
2387
+ black: "#000000",
2388
+ red: "#ff2079",
2389
+ green: "#00ff9c",
2390
+ yellow: "#fed230",
2391
+ blue: "#0abdc6",
2392
+ magenta: "#ea00d9",
2393
+ cyan: "#0abdc6",
2394
+ white: "#c7c7c7",
2395
+ brightBlack: "#686868",
2396
+ brightRed: "#ff4a9e",
2397
+ brightGreen: "#3df5b6",
2398
+ brightYellow: "#fef465",
2399
+ brightBlue: "#3ff1de",
2400
+ brightMagenta: "#ff79f0",
2401
+ brightCyan: "#3ff1de",
2402
+ brightWhite: "#ffffff"
2403
+ },
2404
+ retroGreen: {
2405
+ background: "#0a0a0a",
2406
+ foreground: "#33ff00",
2407
+ cursor: "#33ff00",
2408
+ selectionBackground: "#1a3a1a",
2409
+ black: "#0a0a0a",
2410
+ red: "#ff0000",
2411
+ green: "#33ff00",
2412
+ yellow: "#ffff00",
2413
+ blue: "#0066ff",
2414
+ magenta: "#cc00ff",
2415
+ cyan: "#00ffff",
2416
+ white: "#33ff00",
2417
+ brightBlack: "#1a5c1a",
2418
+ brightRed: "#ff3333",
2419
+ brightGreen: "#66ff33",
2420
+ brightYellow: "#ffff66",
2421
+ brightBlue: "#3399ff",
2422
+ brightMagenta: "#e550ff",
2423
+ brightCyan: "#66ffff",
2424
+ brightWhite: "#66ff33"
2425
+ },
2426
+ retroAmber: {
2427
+ background: "#0a0a00",
2428
+ foreground: "#ffb000",
2429
+ cursor: "#ffb000",
2430
+ selectionBackground: "#3a2a00",
2431
+ black: "#0a0a00",
2432
+ red: "#ff0000",
2433
+ green: "#ffb000",
2434
+ yellow: "#ffcc00",
2435
+ blue: "#cc8800",
2436
+ magenta: "#ff8800",
2437
+ cyan: "#ffcc66",
2438
+ white: "#ffb000",
2439
+ brightBlack: "#665500",
2440
+ brightRed: "#ff3333",
2441
+ brightGreen: "#ffc033",
2442
+ brightYellow: "#ffdd33",
2443
+ brightBlue: "#ddaa33",
2444
+ brightMagenta: "#ffaa33",
2445
+ brightCyan: "#ffdd99",
2446
+ brightWhite: "#ffc033"
2447
+ },
2448
+ matrix: {
2449
+ background: "#000000",
2450
+ foreground: "#00ff41",
2451
+ cursor: "#00ff41",
2452
+ selectionBackground: "#003300",
2453
+ black: "#000000",
2454
+ red: "#00ff41",
2455
+ green: "#00ff41",
2456
+ yellow: "#00ff41",
2457
+ blue: "#00cc33",
2458
+ magenta: "#009926",
2459
+ cyan: "#00ff41",
2460
+ white: "#00ff41",
2461
+ brightBlack: "#005500",
2462
+ brightRed: "#33ff66",
2463
+ brightGreen: "#33ff66",
2464
+ brightYellow: "#33ff66",
2465
+ brightBlue: "#00ff41",
2466
+ brightMagenta: "#00cc33",
2467
+ brightCyan: "#33ff66",
2468
+ brightWhite: "#66ff88"
2469
+ },
2470
+ synthwave: {
2471
+ background: "#2b213a",
2472
+ foreground: "#f0e4fc",
2473
+ cursor: "#72f1b8",
2474
+ selectionBackground: "#463465",
2475
+ black: "#2b213a",
2476
+ red: "#fe4450",
2477
+ green: "#72f1b8",
2478
+ yellow: "#fede5d",
2479
+ blue: "#2ee2fa",
2480
+ magenta: "#ff7edb",
2481
+ cyan: "#03edf9",
2482
+ white: "#f0e4fc",
2483
+ brightBlack: "#614d85",
2484
+ brightRed: "#fe4450",
2485
+ brightGreen: "#72f1b8",
2486
+ brightYellow: "#fede5d",
2487
+ brightBlue: "#2ee2fa",
2488
+ brightMagenta: "#ff7edb",
2489
+ brightCyan: "#03edf9",
2490
+ brightWhite: "#ffffff"
2491
+ },
2492
+ highContrastDark: {
2493
+ background: "#000000",
2494
+ foreground: "#ffffff",
2495
+ cursor: "#ffffff",
2496
+ selectionBackground: "#264f78",
2497
+ selectionForeground: "#ffffff",
2498
+ black: "#000000",
2499
+ red: "#ff0000",
2500
+ green: "#00ff00",
2501
+ yellow: "#ffff00",
2502
+ blue: "#3b78ff",
2503
+ magenta: "#ff00ff",
2504
+ cyan: "#00ffff",
2505
+ white: "#ffffff",
2506
+ brightBlack: "#808080",
2507
+ brightRed: "#ff3333",
2508
+ brightGreen: "#33ff33",
2509
+ brightYellow: "#ffff33",
2510
+ brightBlue: "#6699ff",
2511
+ brightMagenta: "#ff33ff",
2512
+ brightCyan: "#33ffff",
2513
+ brightWhite: "#ffffff"
2514
+ }
2515
+ };
2516
+ DefaultThemes.yellow = DefaultThemes.highContrastLight;
2517
+ var DefaultThemeInfos = {
2518
+ default: {
2519
+ theme: DefaultThemes.default,
2520
+ category: "dark",
2521
+ tags: ["built-in"],
2522
+ description: "Dark indigo theme with soft pastels"
2523
+ },
2524
+ classic: {
2525
+ theme: DefaultThemes.classic,
2526
+ category: "dark",
2527
+ tags: ["built-in"],
2528
+ description: "Classic Windows terminal palette"
2529
+ },
2530
+ dracula: {
2531
+ theme: DefaultThemes.dracula,
2532
+ category: "dark",
2533
+ tags: ["popular"],
2534
+ description: "Popular dark theme with vibrant colors"
2535
+ },
2536
+ monokai: {
2537
+ theme: DefaultThemes.monokai,
2538
+ category: "dark",
2539
+ tags: ["popular"],
2540
+ description: "Classic code editor dark theme"
2541
+ },
2542
+ solarizedDark: {
2543
+ theme: DefaultThemes.solarizedDark,
2544
+ category: "dark",
2545
+ tags: ["popular"],
2546
+ description: "Ethan Schoonover's precision dark palette"
2547
+ },
2548
+ solarizedLight: {
2549
+ theme: DefaultThemes.solarizedLight,
2550
+ category: "light",
2551
+ tags: ["popular"],
2552
+ description: "Ethan Schoonover's precision light palette"
2553
+ },
2554
+ gruvboxDark: {
2555
+ theme: DefaultThemes.gruvboxDark,
2556
+ category: "dark",
2557
+ tags: ["popular"],
2558
+ description: "Retro groove dark color scheme"
2559
+ },
2560
+ gruvboxLight: {
2561
+ theme: DefaultThemes.gruvboxLight,
2562
+ category: "light",
2563
+ tags: ["popular"],
2564
+ description: "Retro groove light color scheme"
2565
+ },
2566
+ nord: {
2567
+ theme: DefaultThemes.nord,
2568
+ category: "dark",
2569
+ tags: ["popular"],
2570
+ description: "Arctic, north-bluish clean palette"
2571
+ },
2572
+ oneDark: {
2573
+ theme: DefaultThemes.oneDark,
2574
+ category: "dark",
2575
+ tags: ["popular"],
2576
+ description: "Atom's iconic dark theme"
2577
+ },
2578
+ material: {
2579
+ theme: DefaultThemes.material,
2580
+ category: "dark",
2581
+ tags: ["popular"],
2582
+ description: "Material Design inspired dark theme"
2583
+ },
2584
+ highContrastLight: {
2585
+ theme: DefaultThemes.highContrastLight,
2586
+ category: "light",
2587
+ tags: ["accessibility"],
2588
+ description: "High contrast light theme for accessibility"
2589
+ },
2590
+ tokyoNight: {
2591
+ theme: DefaultThemes.tokyoNight,
2592
+ category: "dark",
2593
+ tags: ["popular"],
2594
+ description: "Cool blue-purple dark theme"
2595
+ },
2596
+ catppuccinMocha: {
2597
+ theme: DefaultThemes.catppuccinMocha,
2598
+ category: "dark",
2599
+ tags: ["popular", "pastel"],
2600
+ description: "Soothing pastel dark theme (warmest)"
2601
+ },
2602
+ catppuccinFrappe: {
2603
+ theme: DefaultThemes.catppuccinFrappe,
2604
+ category: "dark",
2605
+ tags: ["popular", "pastel"],
2606
+ description: "Soothing pastel mid-dark theme"
2607
+ },
2608
+ catppuccinLatte: {
2609
+ theme: DefaultThemes.catppuccinLatte,
2610
+ category: "light",
2611
+ tags: ["popular", "pastel"],
2612
+ description: "Soothing pastel light theme"
2613
+ },
2614
+ rosePine: {
2615
+ theme: DefaultThemes.rosePine,
2616
+ category: "dark",
2617
+ tags: ["popular"],
2618
+ description: "All natural pine, faux fur, and a bit of soho vibes"
2619
+ },
2620
+ rosePineDawn: {
2621
+ theme: DefaultThemes.rosePineDawn,
2622
+ category: "light",
2623
+ tags: ["popular"],
2624
+ description: "Rose Pine light variant"
2625
+ },
2626
+ kanagawa: {
2627
+ theme: DefaultThemes.kanagawa,
2628
+ category: "dark",
2629
+ tags: ["popular"],
2630
+ description: "Dark theme inspired by Katsushika Hokusai"
2631
+ },
2632
+ everforestDark: {
2633
+ theme: DefaultThemes.everforestDark,
2634
+ category: "dark",
2635
+ tags: ["popular"],
2636
+ description: "Comfortable green-tinted dark theme"
2637
+ },
2638
+ everforestLight: {
2639
+ theme: DefaultThemes.everforestLight,
2640
+ category: "light",
2641
+ tags: ["popular"],
2642
+ description: "Comfortable green-tinted light theme"
2643
+ },
2644
+ ayuDark: {
2645
+ theme: DefaultThemes.ayuDark,
2646
+ category: "dark",
2647
+ tags: ["popular"],
2648
+ description: "Simple, bright and elegant dark theme"
2649
+ },
2650
+ githubLight: {
2651
+ theme: DefaultThemes.githubLight,
2652
+ category: "light",
2653
+ tags: ["popular"],
2654
+ description: "GitHub's clean light interface theme"
2655
+ },
2656
+ cyberpunk: {
2657
+ theme: DefaultThemes.cyberpunk,
2658
+ category: "dark",
2659
+ tags: ["retro", "fun"],
2660
+ description: "Neon-lit cyberpunk aesthetic"
2661
+ },
2662
+ retroGreen: {
2663
+ theme: DefaultThemes.retroGreen,
2664
+ category: "dark",
2665
+ tags: ["retro", "fun"],
2666
+ description: "Classic green phosphor CRT monitor"
2667
+ },
2668
+ retroAmber: {
2669
+ theme: DefaultThemes.retroAmber,
2670
+ category: "dark",
2671
+ tags: ["retro", "fun"],
2672
+ description: "Warm amber CRT monitor"
2673
+ },
2674
+ matrix: {
2675
+ theme: DefaultThemes.matrix,
2676
+ category: "dark",
2677
+ tags: ["retro", "fun"],
2678
+ description: "Enter the Matrix - green on black"
2679
+ },
2680
+ synthwave: {
2681
+ theme: DefaultThemes.synthwave,
2682
+ category: "dark",
2683
+ tags: ["retro", "fun"],
2684
+ description: "80s synthwave purple/pink aesthetic"
2685
+ },
2686
+ highContrastDark: {
2687
+ theme: DefaultThemes.highContrastDark,
2688
+ category: "dark",
2689
+ tags: ["accessibility"],
2690
+ description: "Maximum contrast dark theme"
2691
+ }
2692
+ };
2693
+
2694
+ // src/lib/version.ts
2695
+ var LIBRARY_VERSION = "2.0.0-beta.1";
2696
+ var API_VERSION = 2;
2697
+
2698
+ // src/lib/interfaces/i-file-system-service.ts
2699
+ var IFileSystemService_TOKEN = "cli-file-system-service";
2700
+
2701
+ // src/lib/services/indexed-db-file-system.service.ts
2702
+ var DB_NAME = "qodalis-cli-filesystem";
2703
+ var STORE_NAME = "filesystem";
2704
+ var ROOT_KEY = "root";
2705
+ var CWD_KEY = "cwd";
2706
+ var HOME_KEY = "home";
2707
+ var DEFAULT_HOME = "/home/user";
2708
+ function createSeedFileSystem() {
2709
+ const now = Date.now();
2710
+ return {
2711
+ name: "",
2712
+ type: "directory",
2713
+ children: [
2714
+ {
2715
+ name: "home",
2716
+ type: "directory",
2717
+ children: [],
2718
+ createdAt: now,
2719
+ modifiedAt: now,
2720
+ size: 0,
2721
+ permissions: "rwxr-xr-x"
2722
+ },
2723
+ {
2724
+ name: "tmp",
2725
+ type: "directory",
2726
+ children: [],
2727
+ createdAt: now,
2728
+ modifiedAt: now,
2729
+ size: 0,
2730
+ permissions: "rwxrwxrwx"
2731
+ },
2732
+ {
2733
+ name: "etc",
2734
+ type: "directory",
2735
+ children: [],
2736
+ createdAt: now,
2737
+ modifiedAt: now,
2738
+ size: 0,
2739
+ permissions: "rwxr-xr-x"
2740
+ }
2741
+ ],
2742
+ createdAt: now,
2743
+ modifiedAt: now,
2744
+ size: 0,
2745
+ permissions: "rwxr-xr-x"
2746
+ };
2747
+ }
2748
+ var IndexedDbFileSystemService = class {
2749
+ constructor() {
2750
+ this.root = createSeedFileSystem();
2751
+ this.cwd = DEFAULT_HOME;
2752
+ this.homePath = DEFAULT_HOME;
2753
+ this.currentUid = null;
2754
+ this.currentGroups = [];
2755
+ }
2756
+ // --- User context ---
2757
+ setCurrentUser(uid, groups) {
2758
+ this.currentUid = uid;
2759
+ this.currentGroups = groups;
2760
+ }
2761
+ getDefaultOwnership() {
2762
+ if (!this.currentUid) return void 0;
2763
+ return {
2764
+ uid: this.currentUid,
2765
+ gid: this.currentGroups[0] || "users"
2766
+ };
2767
+ }
2768
+ // --- Navigation ---
2769
+ getCurrentDirectory() {
2770
+ return this.cwd;
2771
+ }
2772
+ setCurrentDirectory(path) {
2773
+ const resolved = this.resolvePath(path);
2774
+ const node = this.getNode(resolved);
2775
+ if (!node) {
2776
+ throw new Error(`cd: ${path}: No such file or directory`);
2777
+ }
2778
+ if (node.type !== "directory") {
2779
+ throw new Error(`cd: ${path}: Not a directory`);
2780
+ }
2781
+ this.cwd = resolved;
2782
+ }
2783
+ getHomePath() {
2784
+ return this.homePath;
2785
+ }
2786
+ setHomePath(path) {
2787
+ this.homePath = path;
2788
+ }
2789
+ resolvePath(path) {
2790
+ if (path === "~" || path === "") {
2791
+ return this.homePath;
2792
+ }
2793
+ if (path.startsWith("~/")) {
2794
+ path = this.homePath + path.substring(1);
2795
+ }
2796
+ const parts = path.startsWith("/") ? path.split("/") : (this.cwd + "/" + path).split("/");
2797
+ const resolved = [];
2798
+ for (const part of parts) {
2799
+ if (part === "" || part === ".") {
2800
+ continue;
2801
+ } else if (part === "..") {
2802
+ resolved.pop();
2803
+ } else {
2804
+ resolved.push(part);
2805
+ }
2806
+ }
2807
+ return "/" + resolved.join("/");
2808
+ }
2809
+ // --- Read operations ---
2810
+ getNode(path) {
2811
+ const resolved = path === "/" ? "/" : this.resolvePath(path);
2812
+ if (resolved === "/") {
2813
+ return this.root;
2814
+ }
2815
+ const parts = resolved.split("/").filter(Boolean);
2816
+ let current = this.root;
2817
+ for (const part of parts) {
2818
+ if (current.type !== "directory" || !current.children) {
2819
+ return null;
2820
+ }
2821
+ const child = current.children.find((c) => c.name === part);
2822
+ if (!child) {
2823
+ return null;
2824
+ }
2825
+ current = child;
2826
+ }
2827
+ return current;
2828
+ }
2829
+ listDirectory(path) {
2830
+ const node = this.getNode(path);
2831
+ if (!node) {
2832
+ throw new Error(`ls: ${path}: No such file or directory`);
2833
+ }
2834
+ if (node.type !== "directory") {
2835
+ throw new Error(`ls: ${path}: Not a directory`);
2836
+ }
2837
+ return node.children || [];
2838
+ }
2839
+ readFile(path) {
2840
+ const node = this.getNode(path);
2841
+ if (!node) {
2842
+ throw new Error(`cat: ${path}: No such file or directory`);
2843
+ }
2844
+ if (node.type === "directory") {
2845
+ throw new Error(`cat: ${path}: Is a directory`);
2846
+ }
2847
+ return node.content ?? "";
2848
+ }
2849
+ exists(path) {
2850
+ return this.getNode(path) !== null;
2851
+ }
2852
+ isDirectory(path) {
2853
+ const node = this.getNode(path);
2854
+ return node !== null && node.type === "directory";
2855
+ }
2856
+ // --- Write operations ---
2857
+ createDirectory(path, recursive = false) {
2858
+ const resolved = this.resolvePath(path);
2859
+ const parts = resolved.split("/").filter(Boolean);
2860
+ if (parts.length === 0) {
2861
+ throw new Error(`mkdir: cannot create directory '/': File exists`);
2862
+ }
2863
+ if (recursive) {
2864
+ let current = this.root;
2865
+ for (const part of parts) {
2866
+ if (!current.children) {
2867
+ current.children = [];
2868
+ }
2869
+ let child = current.children.find((c) => c.name === part);
2870
+ if (!child) {
2871
+ const now = Date.now();
2872
+ child = {
2873
+ name: part,
2874
+ type: "directory",
2875
+ children: [],
2876
+ createdAt: now,
2877
+ modifiedAt: now,
2878
+ size: 0,
2879
+ permissions: "rwxr-xr-x",
2880
+ ownership: this.getDefaultOwnership()
2881
+ };
2882
+ current.children.push(child);
2883
+ current.modifiedAt = now;
2884
+ } else if (child.type !== "directory") {
2885
+ throw new Error(`mkdir: ${part}: Not a directory`);
2886
+ }
2887
+ current = child;
2888
+ }
2889
+ } else {
2890
+ const parentPath = "/" + parts.slice(0, -1).join("/");
2891
+ const dirName = parts[parts.length - 1];
2892
+ const parent = this.getNode(parentPath);
2893
+ if (!parent) {
2894
+ throw new Error(
2895
+ `mkdir: ${parentPath}: No such file or directory`
2896
+ );
2897
+ }
2898
+ if (parent.type !== "directory") {
2899
+ throw new Error(`mkdir: ${parentPath}: Not a directory`);
2900
+ }
2901
+ if (parent.children?.find((c) => c.name === dirName)) {
2902
+ throw new Error(`mkdir: ${path}: File exists`);
2903
+ }
2904
+ const now = Date.now();
2905
+ if (!parent.children) {
2906
+ parent.children = [];
2907
+ }
2908
+ parent.children.push({
2909
+ name: dirName,
2910
+ type: "directory",
2911
+ children: [],
2912
+ createdAt: now,
2913
+ modifiedAt: now,
2914
+ size: 0,
2915
+ permissions: "rwxr-xr-x",
2916
+ ownership: this.getDefaultOwnership()
2917
+ });
2918
+ parent.modifiedAt = now;
2919
+ }
2920
+ }
2921
+ createFile(path, content = "") {
2922
+ const resolved = this.resolvePath(path);
2923
+ const parts = resolved.split("/").filter(Boolean);
2924
+ if (parts.length === 0) {
2925
+ throw new Error(`touch: cannot create file at root`);
2926
+ }
2927
+ const parentPath = "/" + parts.slice(0, -1).join("/");
2928
+ const fileName = parts[parts.length - 1];
2929
+ const parent = this.getNode(parentPath);
2930
+ if (!parent) {
2931
+ throw new Error(`touch: ${parentPath}: No such file or directory`);
2932
+ }
2933
+ if (parent.type !== "directory") {
2934
+ throw new Error(`touch: ${parentPath}: Not a directory`);
2935
+ }
2936
+ const existing = parent.children?.find((c) => c.name === fileName);
2937
+ const now = Date.now();
2938
+ if (existing) {
2939
+ existing.modifiedAt = now;
2940
+ } else {
2941
+ if (!parent.children) {
2942
+ parent.children = [];
2943
+ }
2944
+ parent.children.push({
2945
+ name: fileName,
2946
+ type: "file",
2947
+ content,
2948
+ createdAt: now,
2949
+ modifiedAt: now,
2950
+ size: new Blob([content]).size,
2951
+ permissions: "rw-r--r--",
2952
+ ownership: this.getDefaultOwnership()
2953
+ });
2954
+ parent.modifiedAt = now;
2955
+ }
2956
+ }
2957
+ writeFile(path, content, append = false) {
2958
+ const resolved = this.resolvePath(path);
2959
+ const node = this.getNode(resolved);
2960
+ if (node) {
2961
+ if (node.type === "directory") {
2962
+ throw new Error(`write: ${path}: Is a directory`);
2963
+ }
2964
+ const now = Date.now();
2965
+ node.content = append ? (node.content ?? "") + content : content;
2966
+ node.size = new Blob([node.content]).size;
2967
+ node.modifiedAt = now;
2968
+ } else {
2969
+ this.createFile(resolved, content);
2970
+ }
2971
+ }
2972
+ remove(path, recursive = false) {
2973
+ const resolved = this.resolvePath(path);
2974
+ if (resolved === "/") {
2975
+ throw new Error(`rm: cannot remove root directory`);
2976
+ }
2977
+ const parts = resolved.split("/").filter(Boolean);
2978
+ const parentPath = "/" + parts.slice(0, -1).join("/");
2979
+ const name = parts[parts.length - 1];
2980
+ const parent = this.getNode(parentPath);
2981
+ if (!parent || !parent.children) {
2982
+ throw new Error(`rm: ${path}: No such file or directory`);
2983
+ }
2984
+ const index = parent.children.findIndex((c) => c.name === name);
2985
+ if (index === -1) {
2986
+ throw new Error(`rm: ${path}: No such file or directory`);
2987
+ }
2988
+ const target = parent.children[index];
2989
+ if (target.type === "directory" && !recursive) {
2990
+ throw new Error(`rm: ${path}: Is a directory`);
2991
+ }
2992
+ parent.children.splice(index, 1);
2993
+ parent.modifiedAt = Date.now();
2994
+ }
2995
+ copy(src, dest, recursive = false) {
2996
+ const srcResolved = this.resolvePath(src);
2997
+ const srcNode = this.getNode(srcResolved);
2998
+ if (!srcNode) {
2999
+ throw new Error(`cp: ${src}: No such file or directory`);
3000
+ }
3001
+ if (srcNode.type === "directory" && !recursive) {
3002
+ throw new Error(
3003
+ `cp: -r not specified; omitting directory '${src}'`
3004
+ );
3005
+ }
3006
+ const destResolved = this.resolvePath(dest);
3007
+ const destNode = this.getNode(destResolved);
3008
+ if (destNode && destNode.type === "directory") {
3009
+ const clone = this.cloneNode(srcNode);
3010
+ if (!destNode.children) {
3011
+ destNode.children = [];
3012
+ }
3013
+ const existingIdx = destNode.children.findIndex(
3014
+ (c) => c.name === clone.name
3015
+ );
3016
+ if (existingIdx !== -1) {
3017
+ destNode.children.splice(existingIdx, 1);
3018
+ }
3019
+ destNode.children.push(clone);
3020
+ destNode.modifiedAt = Date.now();
3021
+ } else {
3022
+ const parts = destResolved.split("/").filter(Boolean);
3023
+ const parentPath = "/" + parts.slice(0, -1).join("/");
3024
+ const newName = parts[parts.length - 1];
3025
+ const parent = this.getNode(parentPath);
3026
+ if (!parent || parent.type !== "directory") {
3027
+ throw new Error(`cp: ${parentPath}: No such file or directory`);
3028
+ }
3029
+ const clone = this.cloneNode(srcNode);
3030
+ clone.name = newName;
3031
+ if (!parent.children) {
3032
+ parent.children = [];
3033
+ }
3034
+ const existingIdx = parent.children.findIndex(
3035
+ (c) => c.name === newName
3036
+ );
3037
+ if (existingIdx !== -1) {
3038
+ parent.children.splice(existingIdx, 1);
3039
+ }
3040
+ parent.children.push(clone);
3041
+ parent.modifiedAt = Date.now();
3042
+ }
3043
+ }
3044
+ move(src, dest) {
3045
+ const srcResolved = this.resolvePath(src);
3046
+ if (srcResolved === "/") {
3047
+ throw new Error(`mv: cannot move root directory`);
3048
+ }
3049
+ const srcNode = this.getNode(srcResolved);
3050
+ if (!srcNode) {
3051
+ throw new Error(`mv: ${src}: No such file or directory`);
3052
+ }
3053
+ const destResolved = this.resolvePath(dest);
3054
+ const destNode = this.getNode(destResolved);
3055
+ const srcParts = srcResolved.split("/").filter(Boolean);
3056
+ const srcParentPath = "/" + srcParts.slice(0, -1).join("/");
3057
+ const srcParent = this.getNode(srcParentPath);
3058
+ if (!srcParent || !srcParent.children) {
3059
+ throw new Error(`mv: ${src}: No such file or directory`);
3060
+ }
3061
+ const srcIndex = srcParent.children.findIndex(
3062
+ (c) => c.name === srcNode.name
3063
+ );
3064
+ if (destNode && destNode.type === "directory") {
3065
+ if (!destNode.children) {
3066
+ destNode.children = [];
3067
+ }
3068
+ const existingIdx = destNode.children.findIndex(
3069
+ (c) => c.name === srcNode.name
3070
+ );
3071
+ if (existingIdx !== -1) {
3072
+ destNode.children.splice(existingIdx, 1);
3073
+ }
3074
+ srcParent.children.splice(srcIndex, 1);
3075
+ destNode.children.push(srcNode);
3076
+ destNode.modifiedAt = Date.now();
3077
+ } else {
3078
+ const destParts = destResolved.split("/").filter(Boolean);
3079
+ const destParentPath = "/" + destParts.slice(0, -1).join("/");
3080
+ const newName = destParts[destParts.length - 1];
3081
+ const destParent = this.getNode(destParentPath);
3082
+ if (!destParent || destParent.type !== "directory") {
3083
+ throw new Error(
3084
+ `mv: ${destParentPath}: No such file or directory`
3085
+ );
3086
+ }
3087
+ srcParent.children.splice(srcIndex, 1);
3088
+ srcNode.name = newName;
3089
+ if (!destParent.children) {
3090
+ destParent.children = [];
3091
+ }
3092
+ const existingIdx = destParent.children.findIndex(
3093
+ (c) => c.name === newName
3094
+ );
3095
+ if (existingIdx !== -1) {
3096
+ destParent.children.splice(existingIdx, 1);
3097
+ }
3098
+ destParent.children.push(srcNode);
3099
+ destParent.modifiedAt = Date.now();
3100
+ }
3101
+ srcParent.modifiedAt = Date.now();
3102
+ }
3103
+ // --- Permissions ---
3104
+ chmod(path, permissions) {
3105
+ const resolved = this.resolvePath(path);
3106
+ const node = this.getNode(resolved);
3107
+ if (!node) {
3108
+ throw new Error(`chmod: ${path}: No such file or directory`);
3109
+ }
3110
+ node.permissions = permissions;
3111
+ }
3112
+ chown(path, ownership) {
3113
+ const resolved = this.resolvePath(path);
3114
+ const node = this.getNode(resolved);
3115
+ if (!node) {
3116
+ throw new Error(`chown: ${path}: No such file or directory`);
3117
+ }
3118
+ node.ownership = ownership;
3119
+ }
3120
+ // --- Persistence ---
3121
+ async initialize() {
3122
+ const db = await this.openDb();
3123
+ try {
3124
+ const tx = db.transaction(STORE_NAME, "readonly");
3125
+ const store = tx.objectStore(STORE_NAME);
3126
+ const rootData = await this.idbGet(store, ROOT_KEY);
3127
+ const cwdData = await this.idbGet(store, CWD_KEY);
3128
+ const homeData = await this.idbGet(store, HOME_KEY);
3129
+ if (rootData) {
3130
+ this.root = rootData;
3131
+ }
3132
+ if (cwdData) {
3133
+ this.cwd = cwdData;
3134
+ }
3135
+ if (homeData) {
3136
+ this.homePath = homeData;
3137
+ }
3138
+ } finally {
3139
+ db.close();
3140
+ }
3141
+ }
3142
+ async persist() {
3143
+ const db = await this.openDb();
3144
+ try {
3145
+ const tx = db.transaction(STORE_NAME, "readwrite");
3146
+ const store = tx.objectStore(STORE_NAME);
3147
+ store.put(this.root, ROOT_KEY);
3148
+ store.put(this.cwd, CWD_KEY);
3149
+ store.put(this.homePath, HOME_KEY);
3150
+ await new Promise((resolve, reject) => {
3151
+ tx.oncomplete = () => resolve();
3152
+ tx.onerror = () => reject(tx.error);
3153
+ });
3154
+ } finally {
3155
+ db.close();
3156
+ }
3157
+ }
3158
+ // --- Private helpers ---
3159
+ cloneNode(node) {
3160
+ const now = Date.now();
3161
+ const clone = {
3162
+ name: node.name,
3163
+ type: node.type,
3164
+ createdAt: now,
3165
+ modifiedAt: now,
3166
+ size: node.size,
3167
+ permissions: node.permissions,
3168
+ ownership: node.ownership ? { ...node.ownership } : void 0
3169
+ };
3170
+ if (node.type === "file") {
3171
+ clone.content = node.content;
3172
+ } else {
3173
+ clone.children = (node.children || []).map(
3174
+ (c) => this.cloneNode(c)
3175
+ );
3176
+ }
3177
+ return clone;
3178
+ }
3179
+ openDb() {
3180
+ return new Promise((resolve, reject) => {
3181
+ const request = indexedDB.open(DB_NAME, 1);
3182
+ request.onupgradeneeded = () => {
3183
+ const db = request.result;
3184
+ if (!db.objectStoreNames.contains(STORE_NAME)) {
3185
+ db.createObjectStore(STORE_NAME);
3186
+ }
3187
+ };
3188
+ request.onsuccess = () => resolve(request.result);
3189
+ request.onerror = () => reject(request.error);
3190
+ });
3191
+ }
3192
+ idbGet(store, key) {
3193
+ return new Promise((resolve, reject) => {
3194
+ const request = store.get(key);
3195
+ request.onsuccess = () => resolve(request.result ?? null);
3196
+ request.onerror = () => reject(request.error);
3197
+ });
3198
+ }
3199
+ };
3200
+
3201
+ // src/lib/completion/file-path-completion-provider.ts
3202
+ var FILE_COMMANDS = /* @__PURE__ */ new Set([
3203
+ "ls",
3204
+ "cd",
3205
+ "cat",
3206
+ "cp",
3207
+ "mv",
3208
+ "rm",
3209
+ "touch",
3210
+ "mkdir",
3211
+ "rmdir",
3212
+ "tree",
3213
+ "echo",
3214
+ "nano",
3215
+ "edit",
3216
+ "grep",
3217
+ "find",
3218
+ "head",
3219
+ "tail",
3220
+ "wc"
3221
+ ]);
3222
+ var FilePathCompletionProvider = class {
3223
+ constructor(fs) {
3224
+ this.fs = fs;
3225
+ this.priority = 50;
3226
+ }
3227
+ getCompletions(context) {
3228
+ const { tokens, tokenIndex, token } = context;
3229
+ if (tokenIndex === 0) {
3230
+ return [];
3231
+ }
3232
+ const command = tokens[0];
3233
+ if (!FILE_COMMANDS.has(command)) {
3234
+ return [];
3235
+ }
3236
+ if (token.startsWith("-")) {
3237
+ return [];
3238
+ }
3239
+ return this.completePath(token);
3240
+ }
3241
+ completePath(partial) {
3242
+ let dirPath;
3243
+ let namePrefix;
3244
+ if (partial.includes("/")) {
3245
+ const lastSlash = partial.lastIndexOf("/");
3246
+ dirPath = partial.slice(0, lastSlash) || "/";
3247
+ namePrefix = partial.slice(lastSlash + 1);
3248
+ } else {
3249
+ dirPath = this.fs.getCurrentDirectory();
3250
+ namePrefix = partial;
3251
+ }
3252
+ let resolvedDir;
3253
+ try {
3254
+ resolvedDir = this.fs.resolvePath(dirPath);
3255
+ } catch {
3256
+ return [];
3257
+ }
3258
+ if (!this.fs.exists(resolvedDir) || !this.fs.isDirectory(resolvedDir)) {
3259
+ return [];
3260
+ }
3261
+ const entries = this.fs.listDirectory(resolvedDir);
3262
+ const lowerPrefix = namePrefix.toLowerCase();
3263
+ const results = [];
3264
+ for (const entry of entries) {
3265
+ if (entry.name.toLowerCase().startsWith(lowerPrefix)) {
3266
+ let completion;
3267
+ if (partial.includes("/")) {
3268
+ const lastSlash = partial.lastIndexOf("/");
3269
+ completion = partial.slice(0, lastSlash + 1) + entry.name;
3270
+ } else {
3271
+ completion = entry.name;
3272
+ }
3273
+ if (entry.type === "directory") {
3274
+ completion += "/";
3275
+ }
3276
+ results.push(completion);
3277
+ }
3278
+ }
3279
+ return results.sort();
3280
+ }
3281
+ };
3282
+
3283
+ // src/lib/processors/cli-ls-command-processor.ts
3284
+ var CliLsCommandProcessor = class {
3285
+ constructor() {
3286
+ this.command = "ls";
3287
+ this.description = "List directory contents";
3288
+ this.author = DefaultLibraryAuthor;
3289
+ this.version = LIBRARY_VERSION;
3290
+ this.acceptsRawInput = true;
3291
+ this.metadata = { icon: "\u{1F4CB}", module: "file management" };
3292
+ this.parameters = [
3293
+ {
3294
+ name: "all",
3295
+ aliases: ["a"],
3296
+ description: "Show hidden files (starting with .)",
3297
+ required: false,
3298
+ type: "boolean"
3299
+ },
3300
+ {
3301
+ name: "long",
3302
+ aliases: ["l"],
3303
+ description: "Use long listing format",
3304
+ required: false,
3305
+ type: "boolean"
3306
+ }
3307
+ ];
3308
+ }
3309
+ async processCommand(command, context) {
3310
+ const fs = context.services.get(
3311
+ IFileSystemService_TOKEN
3312
+ );
3313
+ const targetPath = command.value || fs.getCurrentDirectory();
3314
+ const showAll = command.args["all"] || command.args["a"];
3315
+ const longFormat = command.args["long"] || command.args["l"];
3316
+ try {
3317
+ const entries = fs.listDirectory(targetPath);
3318
+ const filtered = showAll ? entries : entries.filter((e) => !e.name.startsWith("."));
3319
+ if (filtered.length === 0) {
3320
+ return;
3321
+ }
3322
+ filtered.sort((a, b) => {
3323
+ if (a.type !== b.type) {
3324
+ return a.type === "directory" ? -1 : 1;
3325
+ }
3326
+ return a.name.localeCompare(b.name);
3327
+ });
3328
+ if (longFormat) {
3329
+ this.writeLongFormat(filtered, context);
3330
+ } else {
3331
+ this.writeShortFormat(filtered, context);
3332
+ }
3333
+ } catch (e) {
3334
+ context.writer.writeError(e.message);
3335
+ }
3336
+ }
3337
+ writeDescription(context) {
3338
+ context.writer.writeln(this.description);
3339
+ context.writer.writeln();
3340
+ context.writer.writeln("Usage: ls [path] [--all] [--long]");
3341
+ }
3342
+ writeLongFormat(entries, context) {
3343
+ const { writer } = context;
3344
+ for (const entry of entries) {
3345
+ const typeChar = entry.type === "directory" ? "d" : "-";
3346
+ const perms = entry.permissions || (entry.type === "directory" ? "rwxr-xr-x" : "rw-r--r--");
3347
+ const owner = entry.ownership?.uid || "-";
3348
+ const group = entry.ownership?.gid || "-";
3349
+ const size = entry.type === "file" ? entry.size.toString() : "-";
3350
+ const date = new Date(entry.modifiedAt);
3351
+ const dateStr = date.toLocaleDateString("en-US", {
3352
+ month: "short",
3353
+ day: "2-digit",
3354
+ hour: "2-digit",
3355
+ minute: "2-digit"
3356
+ });
3357
+ const name = entry.type === "directory" ? writer.wrapInColor(entry.name, CliForegroundColor.Cyan) : entry.name;
3358
+ writer.writeln(
3359
+ `${typeChar}${perms} ${owner.padEnd(8)} ${group.padEnd(8)} ${size.padStart(6)} ${dateStr} ${name}`
3360
+ );
3361
+ }
3362
+ }
3363
+ writeShortFormat(entries, context) {
3364
+ const { writer } = context;
3365
+ const names = entries.map(
3366
+ (e) => e.type === "directory" ? writer.wrapInColor(e.name, CliForegroundColor.Cyan) : e.name
3367
+ );
3368
+ writer.writeln(names.join(" "));
3369
+ }
3370
+ };
3371
+
3372
+ // src/lib/processors/cli-cd-command-processor.ts
3373
+ var CliCdCommandProcessor = class {
3374
+ constructor() {
3375
+ this.command = "cd";
3376
+ this.description = "Change the current working directory";
3377
+ this.author = DefaultLibraryAuthor;
3378
+ this.version = LIBRARY_VERSION;
3379
+ this.acceptsRawInput = true;
3380
+ this.metadata = { icon: "\u{1F4C1}", module: "file management" };
3381
+ }
3382
+ async processCommand(command, context) {
3383
+ const fs = context.services.get(
3384
+ IFileSystemService_TOKEN
3385
+ );
3386
+ const target = command.value || "~";
3387
+ try {
3388
+ fs.setCurrentDirectory(target);
3389
+ await fs.persist();
3390
+ } catch (e) {
3391
+ context.writer.writeError(e.message);
3392
+ }
3393
+ }
3394
+ };
3395
+
3396
+ // src/lib/processors/cli-pwd-command-processor.ts
3397
+ var CliPwdCommandProcessor = class {
3398
+ constructor() {
3399
+ this.command = "pwd";
3400
+ this.description = "Print the current working directory";
3401
+ this.author = DefaultLibraryAuthor;
3402
+ this.version = LIBRARY_VERSION;
3403
+ this.metadata = { icon: "\u{1F4C2}", module: "file management" };
3404
+ }
3405
+ async processCommand(command, context) {
3406
+ const fs = context.services.get(
3407
+ IFileSystemService_TOKEN
3408
+ );
3409
+ context.writer.writeln(fs.getCurrentDirectory());
3410
+ }
3411
+ };
3412
+
3413
+ // src/lib/processors/cli-mkdir-command-processor.ts
3414
+ var CliMkdirCommandProcessor = class {
3415
+ constructor() {
3416
+ this.command = "mkdir";
3417
+ this.description = "Create directories";
3418
+ this.author = DefaultLibraryAuthor;
3419
+ this.version = LIBRARY_VERSION;
3420
+ this.acceptsRawInput = true;
3421
+ this.valueRequired = true;
3422
+ this.metadata = { icon: "\u{1F4C1}", module: "file management" };
3423
+ this.parameters = [
3424
+ {
3425
+ name: "parents",
3426
+ aliases: ["p"],
3427
+ description: "Create parent directories as needed",
3428
+ required: false,
3429
+ type: "boolean"
3430
+ }
3431
+ ];
3432
+ }
3433
+ async processCommand(command, context) {
3434
+ const fs = context.services.get(
3435
+ IFileSystemService_TOKEN
3436
+ );
3437
+ const path = command.value;
3438
+ const recursive = command.args["parents"] || command.args["p"];
3439
+ if (!path) {
3440
+ context.writer.writeError("mkdir: missing operand");
3441
+ return;
3442
+ }
3443
+ try {
3444
+ fs.createDirectory(path, recursive);
3445
+ await fs.persist();
3446
+ } catch (e) {
3447
+ context.writer.writeError(e.message);
3448
+ }
3449
+ }
3450
+ };
3451
+
3452
+ // src/lib/processors/cli-rmdir-command-processor.ts
3453
+ var CliRmdirCommandProcessor = class {
3454
+ constructor() {
3455
+ this.command = "rmdir";
3456
+ this.description = "Remove empty directories";
3457
+ this.author = DefaultLibraryAuthor;
3458
+ this.version = LIBRARY_VERSION;
3459
+ this.acceptsRawInput = true;
3460
+ this.valueRequired = true;
3461
+ this.metadata = { icon: "\u{1F5D1}", module: "file management" };
3462
+ }
3463
+ async processCommand(command, context) {
3464
+ const fs = context.services.get(
3465
+ IFileSystemService_TOKEN
3466
+ );
3467
+ const path = command.value;
3468
+ if (!path) {
3469
+ context.writer.writeError("rmdir: missing operand");
3470
+ return;
3471
+ }
3472
+ try {
3473
+ const node = fs.getNode(path);
3474
+ if (!node) {
3475
+ context.writer.writeError(
3476
+ `rmdir: ${path}: No such file or directory`
3477
+ );
3478
+ return;
3479
+ }
3480
+ if (node.type !== "directory") {
3481
+ context.writer.writeError(`rmdir: ${path}: Not a directory`);
3482
+ return;
3483
+ }
3484
+ if (node.children && node.children.length > 0) {
3485
+ context.writer.writeError(
3486
+ `rmdir: ${path}: Directory not empty`
3487
+ );
3488
+ return;
3489
+ }
3490
+ fs.remove(path);
3491
+ await fs.persist();
3492
+ } catch (e) {
3493
+ context.writer.writeError(e.message);
3494
+ }
3495
+ }
3496
+ };
3497
+
3498
+ // src/lib/processors/cli-touch-command-processor.ts
3499
+ var CliTouchCommandProcessor = class {
3500
+ constructor() {
3501
+ this.command = "touch";
3502
+ this.description = "Create an empty file or update its timestamp";
3503
+ this.author = DefaultLibraryAuthor;
3504
+ this.version = LIBRARY_VERSION;
3505
+ this.acceptsRawInput = true;
3506
+ this.valueRequired = true;
3507
+ this.metadata = { icon: "\u{1F4C4}", module: "file management" };
3508
+ }
3509
+ async processCommand(command, context) {
3510
+ const fs = context.services.get(
3511
+ IFileSystemService_TOKEN
3512
+ );
3513
+ const path = command.value;
3514
+ if (!path) {
3515
+ context.writer.writeError("touch: missing file operand");
3516
+ return;
3517
+ }
3518
+ try {
3519
+ fs.createFile(path);
3520
+ await fs.persist();
3521
+ } catch (e) {
3522
+ context.writer.writeError(e.message);
3523
+ }
3524
+ }
3525
+ };
3526
+
3527
+ // src/lib/processors/cli-cat-command-processor.ts
3528
+ var CliCatCommandProcessor = class {
3529
+ constructor() {
3530
+ this.command = "cat";
3531
+ this.description = "Display file contents";
3532
+ this.author = DefaultLibraryAuthor;
3533
+ this.version = LIBRARY_VERSION;
3534
+ this.acceptsRawInput = true;
3535
+ this.valueRequired = true;
3536
+ this.metadata = { icon: "\u{1F4D6}", module: "file management" };
3537
+ }
3538
+ async processCommand(command, context) {
3539
+ const fs = context.services.get(
3540
+ IFileSystemService_TOKEN
3541
+ );
3542
+ const path = command.value;
3543
+ if (!path) {
3544
+ context.writer.writeError("cat: missing file operand");
3545
+ return;
3546
+ }
3547
+ try {
3548
+ const content = fs.readFile(path);
3549
+ if (content !== null) {
3550
+ context.writer.writeln(content);
3551
+ }
3552
+ } catch (e) {
3553
+ context.writer.writeError(e.message);
3554
+ }
3555
+ }
3556
+ };
3557
+
3558
+ // src/lib/processors/cli-echo-command-processor.ts
3559
+ var CliEchoCommandProcessor = class {
3560
+ constructor() {
3561
+ this.command = "echo";
3562
+ this.description = "Display text or redirect output to a file";
3563
+ this.author = DefaultLibraryAuthor;
3564
+ this.version = LIBRARY_VERSION;
3565
+ this.acceptsRawInput = true;
3566
+ this.extendsProcessor = true;
3567
+ this.metadata = { icon: "\u{1F4AC}", module: "file management" };
3568
+ }
3569
+ async processCommand(command, context) {
3570
+ const afterEcho = command.value || "";
3571
+ const hasRedirection = />>?\s*.+$/.test(afterEcho);
3572
+ if (!hasRedirection) {
3573
+ if (this.originalProcessor) {
3574
+ await this.originalProcessor.processCommand(command, context);
3575
+ } else {
3576
+ context.writer.writeln(afterEcho);
3577
+ }
3578
+ return;
3579
+ }
3580
+ const fs = context.services.get(
3581
+ IFileSystemService_TOKEN
3582
+ );
3583
+ let text;
3584
+ let filePath;
3585
+ let append = false;
3586
+ const appendMatch = afterEcho.match(/^(.*?)\s*>>\s*(.+)$/);
3587
+ const overwriteMatch = afterEcho.match(/^(.*?)\s*>\s*(.+)$/);
3588
+ if (appendMatch) {
3589
+ text = appendMatch[1].trim();
3590
+ filePath = appendMatch[2].trim();
3591
+ append = true;
3592
+ } else {
3593
+ text = overwriteMatch[1].trim();
3594
+ filePath = overwriteMatch[2].trim();
3595
+ }
3596
+ if (text.startsWith('"') && text.endsWith('"') || text.startsWith("'") && text.endsWith("'")) {
3597
+ text = text.slice(1, -1);
3598
+ }
3599
+ text = text.replace(/\\([\\nrtv0])/g, (_, ch) => {
3600
+ switch (ch) {
3601
+ case "n":
3602
+ return "\n";
3603
+ case "t":
3604
+ return " ";
3605
+ case "r":
3606
+ return "\r";
3607
+ case "v":
3608
+ return "\v";
3609
+ case "0":
3610
+ return "\0";
3611
+ case "\\":
3612
+ return "\\";
3613
+ default:
3614
+ return ch;
3615
+ }
3616
+ });
3617
+ try {
3618
+ fs.writeFile(filePath, text + "\n", append);
3619
+ await fs.persist();
3620
+ } catch (e) {
3621
+ context.writer.writeError(e.message);
3622
+ }
3623
+ }
3624
+ };
3625
+
3626
+ // src/lib/processors/cli-rm-command-processor.ts
3627
+ var CliRmCommandProcessor = class {
3628
+ constructor() {
3629
+ this.command = "rm";
3630
+ this.description = "Remove files or directories";
3631
+ this.author = DefaultLibraryAuthor;
3632
+ this.version = LIBRARY_VERSION;
3633
+ this.acceptsRawInput = true;
3634
+ this.valueRequired = true;
3635
+ this.metadata = { icon: "\u{1F5D1}", module: "file management" };
3636
+ this.parameters = [
3637
+ {
3638
+ name: "recursive",
3639
+ aliases: ["r", "R"],
3640
+ description: "Remove directories and their contents recursively",
3641
+ required: false,
3642
+ type: "boolean"
3643
+ },
3644
+ {
3645
+ name: "force",
3646
+ aliases: ["f"],
3647
+ description: "Ignore nonexistent files, never prompt",
3648
+ required: false,
3649
+ type: "boolean"
3650
+ }
3651
+ ];
3652
+ }
3653
+ async processCommand(command, context) {
3654
+ const fs = context.services.get(
3655
+ IFileSystemService_TOKEN
3656
+ );
3657
+ const path = command.value;
3658
+ const recursive = command.args["recursive"] || command.args["r"] || command.args["R"];
3659
+ const force = command.args["force"] || command.args["f"];
3660
+ if (!path) {
3661
+ context.writer.writeError("rm: missing operand");
3662
+ return;
3663
+ }
3664
+ try {
3665
+ if (!fs.exists(path)) {
3666
+ if (!force) {
3667
+ context.writer.writeError(
3668
+ `rm: ${path}: No such file or directory`
3669
+ );
3670
+ }
3671
+ return;
3672
+ }
3673
+ if (fs.isDirectory(path) && !recursive) {
3674
+ context.writer.writeError(`rm: ${path}: Is a directory`);
3675
+ return;
3676
+ }
3677
+ fs.remove(path, recursive);
3678
+ await fs.persist();
3679
+ } catch (e) {
3680
+ context.writer.writeError(e.message);
3681
+ }
3682
+ }
3683
+ };
3684
+
3685
+ // src/lib/processors/cli-cp-command-processor.ts
3686
+ var CliCpCommandProcessor = class {
3687
+ constructor() {
3688
+ this.command = "cp";
3689
+ this.description = "Copy files and directories";
3690
+ this.author = DefaultLibraryAuthor;
3691
+ this.version = LIBRARY_VERSION;
3692
+ this.acceptsRawInput = true;
3693
+ this.metadata = { icon: "\u{1F4CB}", module: "file management" };
3694
+ this.parameters = [
3695
+ {
3696
+ name: "recursive",
3697
+ aliases: ["r", "R"],
3698
+ description: "Copy directories recursively",
3699
+ required: false,
3700
+ type: "boolean"
3701
+ }
3702
+ ];
3703
+ }
3704
+ async processCommand(command, context) {
3705
+ const fs = context.services.get(
3706
+ IFileSystemService_TOKEN
3707
+ );
3708
+ const recursive = command.args["recursive"] || command.args["r"] || command.args["R"];
3709
+ const parts = this.parseArgs(command);
3710
+ if (parts.length < 2) {
3711
+ context.writer.writeError("cp: missing destination file operand");
3712
+ context.writer.writeln(
3713
+ "Usage: cp [--recursive] <source> <destination>"
3714
+ );
3715
+ return;
3716
+ }
3717
+ const src = parts[0];
3718
+ const dest = parts[1];
3719
+ try {
3720
+ fs.copy(src, dest, recursive);
3721
+ await fs.persist();
3722
+ } catch (e) {
3723
+ context.writer.writeError(e.message);
3724
+ }
3725
+ }
3726
+ parseArgs(command) {
3727
+ const raw = command.value || "";
3728
+ return raw.split(/\s+/).filter((t) => t && !t.startsWith("--") && !t.startsWith("-"));
3729
+ }
3730
+ };
3731
+
3732
+ // src/lib/processors/cli-mv-command-processor.ts
3733
+ var CliMvCommandProcessor = class {
3734
+ constructor() {
3735
+ this.command = "mv";
3736
+ this.description = "Move or rename files and directories";
3737
+ this.author = DefaultLibraryAuthor;
3738
+ this.version = LIBRARY_VERSION;
3739
+ this.acceptsRawInput = true;
3740
+ this.metadata = { icon: "\u{1F4E6}", module: "file management" };
3741
+ }
3742
+ async processCommand(command, context) {
3743
+ const fs = context.services.get(
3744
+ IFileSystemService_TOKEN
3745
+ );
3746
+ const parts = this.parseArgs(command);
3747
+ if (parts.length < 2) {
3748
+ context.writer.writeError("mv: missing destination file operand");
3749
+ context.writer.writeln("Usage: mv <source> <destination>");
3750
+ return;
3751
+ }
3752
+ const src = parts[0];
3753
+ const dest = parts[1];
3754
+ try {
3755
+ fs.move(src, dest);
3756
+ await fs.persist();
3757
+ } catch (e) {
3758
+ context.writer.writeError(e.message);
3759
+ }
3760
+ }
3761
+ parseArgs(command) {
3762
+ const raw = command.value || "";
3763
+ return raw.split(/\s+/).filter((t) => t && !t.startsWith("--") && !t.startsWith("-"));
3764
+ }
3765
+ };
3766
+
3767
+ // src/lib/processors/cli-tree-command-processor.ts
3768
+ var CliTreeCommandProcessor = class {
3769
+ constructor() {
3770
+ this.command = "tree";
3771
+ this.description = "Display directory tree structure";
3772
+ this.author = DefaultLibraryAuthor;
3773
+ this.version = LIBRARY_VERSION;
3774
+ this.acceptsRawInput = true;
3775
+ this.metadata = { icon: "\u{1F333}", module: "file management" };
3776
+ this.parameters = [
3777
+ {
3778
+ name: "depth",
3779
+ aliases: ["L"],
3780
+ description: "Max display depth of the directory tree",
3781
+ required: false,
3782
+ type: "number"
3783
+ }
3784
+ ];
3785
+ }
3786
+ async processCommand(command, context) {
3787
+ const fs = context.services.get(
3788
+ IFileSystemService_TOKEN
3789
+ );
3790
+ const targetPath = command.value || fs.getCurrentDirectory();
3791
+ const maxDepth = command.args["depth"] ? parseInt(command.args["depth"]) : command.args["L"] ? parseInt(command.args["L"]) : Infinity;
3792
+ try {
3793
+ const node = fs.getNode(targetPath);
3794
+ if (!node) {
3795
+ context.writer.writeError(
3796
+ `tree: ${targetPath}: No such file or directory`
3797
+ );
3798
+ return;
3799
+ }
3800
+ if (node.type !== "directory") {
3801
+ context.writer.writeError(
3802
+ `tree: ${targetPath}: Not a directory`
3803
+ );
3804
+ return;
3805
+ }
3806
+ const resolvedPath = fs.resolvePath(targetPath);
3807
+ context.writer.writeln(
3808
+ context.writer.wrapInColor(
3809
+ resolvedPath,
3810
+ CliForegroundColor.Cyan
3811
+ )
3812
+ );
3813
+ const counts = { dirs: 0, files: 0 };
3814
+ this.printTree(node, "", true, 0, maxDepth, context, counts);
3815
+ context.writer.writeln();
3816
+ context.writer.writeln(
3817
+ `${counts.dirs} directories, ${counts.files} files`
3818
+ );
3819
+ } catch (e) {
3820
+ context.writer.writeError(e.message);
3821
+ }
3822
+ }
3823
+ printTree(node, prefix, isRoot, depth, maxDepth, context, counts) {
3824
+ if (!node.children || depth >= maxDepth) {
3825
+ return;
3826
+ }
3827
+ const children = [...node.children].sort((a, b) => {
3828
+ if (a.type !== b.type) {
3829
+ return a.type === "directory" ? -1 : 1;
3830
+ }
3831
+ return a.name.localeCompare(b.name);
3832
+ });
3833
+ for (let i = 0; i < children.length; i++) {
3834
+ const child = children[i];
3835
+ const isLast = i === children.length - 1;
3836
+ const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
3837
+ const childPrefix = isLast ? " " : "\u2502 ";
3838
+ const displayName = child.type === "directory" ? context.writer.wrapInColor(
3839
+ child.name,
3840
+ CliForegroundColor.Cyan
3841
+ ) : child.name;
3842
+ context.writer.writeln(`${prefix}${connector}${displayName}`);
3843
+ if (child.type === "directory") {
3844
+ counts.dirs++;
3845
+ this.printTree(
3846
+ child,
3847
+ prefix + childPrefix,
3848
+ false,
3849
+ depth + 1,
3850
+ maxDepth,
3851
+ context,
3852
+ counts
3853
+ );
3854
+ } else {
3855
+ counts.files++;
3856
+ }
3857
+ }
3858
+ }
3859
+ };
3860
+
3861
+ // src/lib/processors/cli-head-command-processor.ts
3862
+ var CliHeadCommandProcessor = class {
3863
+ constructor() {
3864
+ this.command = "head";
3865
+ this.description = "Display the first lines of a file";
3866
+ this.author = DefaultLibraryAuthor;
3867
+ this.version = LIBRARY_VERSION;
3868
+ this.acceptsRawInput = true;
3869
+ this.valueRequired = true;
3870
+ this.metadata = { icon: "\u2B06\uFE0F", module: "file management" };
3871
+ this.parameters = [
3872
+ {
3873
+ name: "lines",
3874
+ aliases: ["n"],
3875
+ description: "Number of lines to display (default: 10)",
3876
+ required: false,
3877
+ type: "number"
3878
+ }
3879
+ ];
3880
+ }
3881
+ async processCommand(command, context) {
3882
+ const fs = context.services.get(
3883
+ IFileSystemService_TOKEN
3884
+ );
3885
+ const count = parseInt(
3886
+ command.args["lines"] || command.args["n"] || "10",
3887
+ 10
3888
+ );
3889
+ const paths = this.parsePaths(command);
3890
+ if (paths.length === 0) {
3891
+ if (command.data != null) {
3892
+ const content = typeof command.data === "string" ? command.data : JSON.stringify(command.data);
3893
+ const lines = content.split("\n");
3894
+ const selected = lines.slice(0, count);
3895
+ context.writer.writeln(selected.join("\n"));
3896
+ return;
3897
+ }
3898
+ context.writer.writeError("head: missing file operand");
3899
+ return;
3900
+ }
3901
+ for (let i = 0; i < paths.length; i++) {
3902
+ const path = paths[i];
3903
+ try {
3904
+ if (fs.isDirectory(path)) {
3905
+ context.writer.writeError(`head: ${path}: Is a directory`);
3906
+ continue;
3907
+ }
3908
+ const content = fs.readFile(path);
3909
+ if (content === null) continue;
3910
+ if (paths.length > 1) {
3911
+ if (i > 0) context.writer.writeln();
3912
+ context.writer.writeln(`==> ${path} <==`);
3913
+ }
3914
+ const lines = content.split("\n");
3915
+ const selected = lines.slice(0, count);
3916
+ context.writer.writeln(selected.join("\n"));
3917
+ } catch (e) {
3918
+ context.writer.writeError(`head: ${e.message}`);
3919
+ }
3920
+ }
3921
+ }
3922
+ parsePaths(command) {
3923
+ const raw = command.value || "";
3924
+ return raw.split(/\s+/).filter(Boolean);
3925
+ }
3926
+ };
3927
+
3928
+ // src/lib/processors/cli-tail-command-processor.ts
3929
+ var CliTailCommandProcessor = class {
3930
+ constructor() {
3931
+ this.command = "tail";
3932
+ this.description = "Display the last lines of a file";
3933
+ this.author = DefaultLibraryAuthor;
3934
+ this.version = LIBRARY_VERSION;
3935
+ this.acceptsRawInput = true;
3936
+ this.valueRequired = true;
3937
+ this.metadata = { icon: "\u2B07\uFE0F", module: "file management" };
3938
+ this.parameters = [
3939
+ {
3940
+ name: "lines",
3941
+ aliases: ["n"],
3942
+ description: "Number of lines to display (default: 10)",
3943
+ required: false,
3944
+ type: "number"
3945
+ }
3946
+ ];
3947
+ }
3948
+ async processCommand(command, context) {
3949
+ const fs = context.services.get(
3950
+ IFileSystemService_TOKEN
3951
+ );
3952
+ const count = parseInt(
3953
+ command.args["lines"] || command.args["n"] || "10",
3954
+ 10
3955
+ );
3956
+ const paths = this.parsePaths(command);
3957
+ if (paths.length === 0) {
3958
+ if (command.data != null) {
3959
+ const content = typeof command.data === "string" ? command.data : JSON.stringify(command.data);
3960
+ const lines = content.split("\n");
3961
+ const selected = lines.slice(-count);
3962
+ context.writer.writeln(selected.join("\n"));
3963
+ return;
3964
+ }
3965
+ context.writer.writeError("tail: missing file operand");
3966
+ return;
3967
+ }
3968
+ for (let i = 0; i < paths.length; i++) {
3969
+ const path = paths[i];
3970
+ try {
3971
+ if (fs.isDirectory(path)) {
3972
+ context.writer.writeError(`tail: ${path}: Is a directory`);
3973
+ continue;
3974
+ }
3975
+ const content = fs.readFile(path);
3976
+ if (content === null) continue;
3977
+ if (paths.length > 1) {
3978
+ if (i > 0) context.writer.writeln();
3979
+ context.writer.writeln(`==> ${path} <==`);
3980
+ }
3981
+ const lines = content.split("\n");
3982
+ const selected = lines.slice(-count);
3983
+ context.writer.writeln(selected.join("\n"));
3984
+ } catch (e) {
3985
+ context.writer.writeError(`tail: ${e.message}`);
3986
+ }
3987
+ }
3988
+ }
3989
+ parsePaths(command) {
3990
+ const raw = command.value || "";
3991
+ return raw.split(/\s+/).filter(Boolean);
3992
+ }
3993
+ };
3994
+
3995
+ // src/lib/processors/cli-wc-command-processor.ts
3996
+ var CliWcCommandProcessor = class {
3997
+ constructor() {
3998
+ this.command = "wc";
3999
+ this.description = "Print line, word, and character counts";
4000
+ this.author = DefaultLibraryAuthor;
4001
+ this.version = LIBRARY_VERSION;
4002
+ this.acceptsRawInput = true;
4003
+ this.valueRequired = true;
4004
+ this.metadata = { icon: "#\uFE0F\u20E3", module: "file management" };
4005
+ this.parameters = [
4006
+ {
4007
+ name: "lines",
4008
+ aliases: ["l"],
4009
+ description: "Print only the line count",
4010
+ required: false,
4011
+ type: "boolean"
4012
+ },
4013
+ {
4014
+ name: "words",
4015
+ aliases: ["w"],
4016
+ description: "Print only the word count",
4017
+ required: false,
4018
+ type: "boolean"
4019
+ },
4020
+ {
4021
+ name: "chars",
4022
+ aliases: ["c"],
4023
+ description: "Print only the character count",
4024
+ required: false,
4025
+ type: "boolean"
4026
+ }
4027
+ ];
4028
+ }
4029
+ async processCommand(command, context) {
4030
+ const fs = context.services.get(
4031
+ IFileSystemService_TOKEN
4032
+ );
4033
+ const showLines = command.args["lines"] || command.args["l"] || false;
4034
+ const showWords = command.args["words"] || command.args["w"] || false;
4035
+ const showChars = command.args["chars"] || command.args["c"] || false;
4036
+ const showAll = !showLines && !showWords && !showChars;
4037
+ const paths = this.parsePaths(command);
4038
+ if (paths.length === 0) {
4039
+ if (command.data != null) {
4040
+ const content = typeof command.data === "string" ? command.data : JSON.stringify(command.data);
4041
+ const lineCount = content === "" ? 0 : content.split("\n").length;
4042
+ const wordCount = content.trim() === "" ? 0 : content.trim().split(/\s+/).length;
4043
+ const charCount = content.length;
4044
+ const parts = [];
4045
+ if (showAll || showLines) parts.push(String(lineCount).padStart(8));
4046
+ if (showAll || showWords) parts.push(String(wordCount).padStart(8));
4047
+ if (showAll || showChars) parts.push(String(charCount).padStart(8));
4048
+ context.writer.writeln(parts.join(""));
4049
+ return;
4050
+ }
4051
+ context.writer.writeError("wc: missing file operand");
4052
+ return;
4053
+ }
4054
+ let totalLines = 0;
4055
+ let totalWords = 0;
4056
+ let totalChars = 0;
4057
+ for (const path of paths) {
4058
+ try {
4059
+ if (fs.isDirectory(path)) {
4060
+ context.writer.writeError(`wc: ${path}: Is a directory`);
4061
+ continue;
4062
+ }
4063
+ const content = fs.readFile(path) ?? "";
4064
+ const lineCount = content === "" ? 0 : content.split("\n").length;
4065
+ const wordCount = content.trim() === "" ? 0 : content.trim().split(/\s+/).length;
4066
+ const charCount = content.length;
4067
+ totalLines += lineCount;
4068
+ totalWords += wordCount;
4069
+ totalChars += charCount;
4070
+ const parts = [];
4071
+ if (showAll || showLines) parts.push(String(lineCount).padStart(8));
4072
+ if (showAll || showWords) parts.push(String(wordCount).padStart(8));
4073
+ if (showAll || showChars) parts.push(String(charCount).padStart(8));
4074
+ parts.push(` ${path}`);
4075
+ context.writer.writeln(parts.join(""));
4076
+ } catch (e) {
4077
+ context.writer.writeError(`wc: ${e.message}`);
4078
+ }
4079
+ }
4080
+ if (paths.length > 1) {
4081
+ const parts = [];
4082
+ if (showAll || showLines) parts.push(String(totalLines).padStart(8));
4083
+ if (showAll || showWords) parts.push(String(totalWords).padStart(8));
4084
+ if (showAll || showChars) parts.push(String(totalChars).padStart(8));
4085
+ parts.push(" total");
4086
+ context.writer.writeln(parts.join(""));
4087
+ }
4088
+ }
4089
+ parsePaths(command) {
4090
+ const raw = command.value || "";
4091
+ return raw.split(/\s+/).filter(Boolean);
4092
+ }
4093
+ };
4094
+
4095
+ // src/lib/processors/cli-find-command-processor.ts
4096
+ var CliFindCommandProcessor = class {
4097
+ constructor() {
4098
+ this.command = "find";
4099
+ this.description = "Search for files and directories by name or type";
4100
+ this.author = DefaultLibraryAuthor;
4101
+ this.version = LIBRARY_VERSION;
4102
+ this.acceptsRawInput = true;
4103
+ this.metadata = { icon: "\u{1F50D}", module: "file management" };
4104
+ this.parameters = [
4105
+ {
4106
+ name: "name",
4107
+ description: "Match filename pattern (glob: * and ? supported)",
4108
+ required: false,
4109
+ type: "string"
4110
+ },
4111
+ {
4112
+ name: "type",
4113
+ description: "Filter by type: f (file) or d (directory)",
4114
+ required: false,
4115
+ type: "string"
4116
+ },
4117
+ {
4118
+ name: "maxdepth",
4119
+ description: "Maximum directory depth to search",
4120
+ required: false,
4121
+ type: "number"
4122
+ }
4123
+ ];
4124
+ }
4125
+ async processCommand(command, context) {
4126
+ const fs = context.services.get(
4127
+ IFileSystemService_TOKEN
4128
+ );
4129
+ const searchPath = this.parseSearchPath(command) || fs.getCurrentDirectory();
4130
+ const namePattern = command.args["name"] || null;
4131
+ const typeFilter = command.args["type"] || null;
4132
+ const maxDepth = command.args["maxdepth"] ? parseInt(command.args["maxdepth"], 10) : Infinity;
4133
+ try {
4134
+ const node = fs.getNode(searchPath);
4135
+ if (!node) {
4136
+ context.writer.writeError(
4137
+ `find: '${searchPath}': No such file or directory`
4138
+ );
4139
+ return;
4140
+ }
4141
+ if (node.type !== "directory") {
4142
+ context.writer.writeError(
4143
+ `find: '${searchPath}': Not a directory`
4144
+ );
4145
+ return;
4146
+ }
4147
+ const resolvedBase = fs.resolvePath(searchPath);
4148
+ const nameRegex = namePattern ? this.globToRegex(namePattern) : null;
4149
+ const results = [];
4150
+ this.walk(
4151
+ node,
4152
+ resolvedBase,
4153
+ 0,
4154
+ maxDepth,
4155
+ nameRegex,
4156
+ typeFilter,
4157
+ results
4158
+ );
4159
+ for (const r of results) {
4160
+ context.writer.writeln(r);
4161
+ }
4162
+ } catch (e) {
4163
+ context.writer.writeError(`find: ${e.message}`);
4164
+ }
4165
+ }
4166
+ parseSearchPath(command) {
4167
+ const raw = command.value || "";
4168
+ const tokens = raw.split(/\s+/).filter(Boolean);
4169
+ return tokens.length > 0 ? tokens[0] : null;
4170
+ }
4171
+ globToRegex(pattern) {
4172
+ const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&");
4173
+ const regexStr = escaped.replace(/\*/g, ".*").replace(/\?/g, ".");
4174
+ return new RegExp(`^${regexStr}$`, "i");
4175
+ }
4176
+ walk(node, currentPath, depth, maxDepth, nameRegex, typeFilter, results) {
4177
+ if (!node.children) return;
4178
+ for (const child of node.children) {
4179
+ const childPath = currentPath === "/" ? `/${child.name}` : `${currentPath}/${child.name}`;
4180
+ let matches = true;
4181
+ if (nameRegex && !nameRegex.test(child.name)) {
4182
+ matches = false;
4183
+ }
4184
+ if (typeFilter === "f" && child.type !== "file") {
4185
+ matches = false;
4186
+ }
4187
+ if (typeFilter === "d" && child.type !== "directory") {
4188
+ matches = false;
4189
+ }
4190
+ if (matches) {
4191
+ results.push(childPath);
4192
+ }
4193
+ if (child.type === "directory" && depth < maxDepth) {
4194
+ this.walk(
4195
+ child,
4196
+ childPath,
4197
+ depth + 1,
4198
+ maxDepth,
4199
+ nameRegex,
4200
+ typeFilter,
4201
+ results
4202
+ );
4203
+ }
4204
+ }
4205
+ }
4206
+ };
4207
+
4208
+ // src/lib/processors/cli-grep-command-processor.ts
4209
+ var CliGrepCommandProcessor = class {
4210
+ constructor() {
4211
+ this.command = "grep";
4212
+ this.description = "Search file contents for a pattern";
4213
+ this.author = DefaultLibraryAuthor;
4214
+ this.version = LIBRARY_VERSION;
4215
+ this.acceptsRawInput = true;
4216
+ this.metadata = { icon: "\u{1F50E}", module: "file management" };
4217
+ this.parameters = [
4218
+ {
4219
+ name: "ignore-case",
4220
+ aliases: ["i"],
4221
+ description: "Case-insensitive matching",
4222
+ required: false,
4223
+ type: "boolean"
4224
+ },
4225
+ {
4226
+ name: "recursive",
4227
+ aliases: ["r", "R"],
4228
+ description: "Recursively search directories",
4229
+ required: false,
4230
+ type: "boolean"
4231
+ },
4232
+ {
4233
+ name: "line-number",
4234
+ aliases: ["n"],
4235
+ description: "Show line numbers",
4236
+ required: false,
4237
+ type: "boolean"
4238
+ },
4239
+ {
4240
+ name: "count",
4241
+ aliases: ["c"],
4242
+ description: "Show only a count of matching lines per file",
4243
+ required: false,
4244
+ type: "boolean"
4245
+ },
4246
+ {
4247
+ name: "files-with-matches",
4248
+ aliases: ["l"],
4249
+ description: "Show only filenames containing matches",
4250
+ required: false,
4251
+ type: "boolean"
4252
+ },
4253
+ {
4254
+ name: "invert-match",
4255
+ aliases: ["v"],
4256
+ description: "Select non-matching lines",
4257
+ required: false,
4258
+ type: "boolean"
4259
+ }
4260
+ ];
4261
+ }
4262
+ async processCommand(command, context) {
4263
+ const fs = context.services.get(
4264
+ IFileSystemService_TOKEN
4265
+ );
4266
+ const ignoreCase = command.args["ignore-case"] || command.args["i"] || false;
4267
+ const recursive = command.args["recursive"] || command.args["r"] || command.args["R"] || false;
4268
+ const showLineNum = command.args["line-number"] || command.args["n"] || false;
4269
+ const countOnly = command.args["count"] || command.args["c"] || false;
4270
+ const filesOnly = command.args["files-with-matches"] || command.args["l"] || false;
4271
+ const invert = command.args["invert-match"] || command.args["v"] || false;
4272
+ const { pattern, paths } = this.parseArgs(command);
4273
+ if (!pattern) {
4274
+ context.writer.writeError(
4275
+ "grep: missing pattern. Usage: grep [options] <pattern> <file>"
4276
+ );
4277
+ return;
4278
+ }
4279
+ if (paths.length === 0) {
4280
+ if (command.data != null) {
4281
+ let regex2;
4282
+ try {
4283
+ regex2 = new RegExp(pattern, ignoreCase ? "gi" : "g");
4284
+ } catch {
4285
+ context.writer.writeError(`grep: invalid pattern '${pattern}'`);
4286
+ return;
4287
+ }
4288
+ const content = typeof command.data === "string" ? command.data : JSON.stringify(command.data);
4289
+ this.grepContent(content, null, regex2, {
4290
+ ignoreCase,
4291
+ showLineNum,
4292
+ countOnly,
4293
+ filesOnly,
4294
+ invert
4295
+ }, context, false);
4296
+ return;
4297
+ }
4298
+ context.writer.writeError(
4299
+ "grep: missing file operand. Usage: grep [options] <pattern> <file>"
4300
+ );
4301
+ return;
4302
+ }
4303
+ let regex;
4304
+ try {
4305
+ regex = new RegExp(pattern, ignoreCase ? "gi" : "g");
4306
+ } catch {
4307
+ context.writer.writeError(`grep: invalid pattern '${pattern}'`);
4308
+ return;
4309
+ }
4310
+ const filePaths = [];
4311
+ for (const p of paths) {
4312
+ try {
4313
+ if (!fs.exists(p)) {
4314
+ context.writer.writeError(
4315
+ `grep: ${p}: No such file or directory`
4316
+ );
4317
+ continue;
4318
+ }
4319
+ if (fs.isDirectory(p)) {
4320
+ if (!recursive) {
4321
+ context.writer.writeError(
4322
+ `grep: ${p}: Is a directory`
4323
+ );
4324
+ continue;
4325
+ }
4326
+ this.collectFiles(fs, fs.resolvePath(p), fs.getNode(p), filePaths);
4327
+ } else {
4328
+ filePaths.push(fs.resolvePath(p));
4329
+ }
4330
+ } catch (e) {
4331
+ context.writer.writeError(`grep: ${e.message}`);
4332
+ }
4333
+ }
4334
+ const multiFile = filePaths.length > 1;
4335
+ for (const filePath of filePaths) {
4336
+ try {
4337
+ const content = fs.readFile(filePath) ?? "";
4338
+ this.grepContent(content, filePath, regex, {
4339
+ ignoreCase,
4340
+ showLineNum,
4341
+ countOnly,
4342
+ filesOnly,
4343
+ invert
4344
+ }, context, multiFile);
4345
+ } catch (e) {
4346
+ context.writer.writeError(`grep: ${filePath}: ${e.message}`);
4347
+ }
4348
+ }
4349
+ }
4350
+ grepContent(content, filePath, regex, options, context, multiFile) {
4351
+ const lines = content.split("\n");
4352
+ let matchCount = 0;
4353
+ const matchingLines = [];
4354
+ for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
4355
+ const line = lines[lineIdx];
4356
+ regex.lastIndex = 0;
4357
+ const hasMatch = regex.test(line);
4358
+ const isMatch = options.invert ? !hasMatch : hasMatch;
4359
+ if (isMatch) {
4360
+ matchCount++;
4361
+ matchingLines.push({ num: lineIdx + 1, text: line });
4362
+ }
4363
+ }
4364
+ if (options.filesOnly) {
4365
+ if (matchCount > 0 && filePath) {
4366
+ context.writer.writeln(filePath);
4367
+ }
4368
+ } else if (options.countOnly) {
4369
+ const prefix = multiFile && filePath ? `${filePath}:` : "";
4370
+ context.writer.writeln(`${prefix}${matchCount}`);
4371
+ } else {
4372
+ for (const m of matchingLines) {
4373
+ const parts = [];
4374
+ if (multiFile && filePath) {
4375
+ parts.push(context.writer.wrapInColor(filePath, CliForegroundColor.Magenta));
4376
+ parts.push(":");
4377
+ }
4378
+ if (options.showLineNum) {
4379
+ parts.push(context.writer.wrapInColor(String(m.num), CliForegroundColor.Green));
4380
+ parts.push(":");
4381
+ }
4382
+ if (!options.invert) {
4383
+ regex.lastIndex = 0;
4384
+ const highlighted = m.text.replace(
4385
+ regex,
4386
+ (match) => context.writer.wrapInColor(match, CliForegroundColor.Red)
4387
+ );
4388
+ parts.push(highlighted);
4389
+ } else {
4390
+ parts.push(m.text);
4391
+ }
4392
+ context.writer.writeln(parts.join(""));
4393
+ }
4394
+ }
4395
+ }
4396
+ parseArgs(command) {
4397
+ const raw = command.value || "";
4398
+ const tokens = raw.split(/\s+/).filter(Boolean);
4399
+ if (tokens.length === 0) {
4400
+ return { pattern: null, paths: [] };
4401
+ }
4402
+ if (tokens.length === 1) {
4403
+ return { pattern: tokens[0], paths: [] };
4404
+ }
4405
+ return {
4406
+ pattern: tokens[0],
4407
+ paths: tokens.slice(1)
4408
+ };
4409
+ }
4410
+ collectFiles(fs, basePath, node, result) {
4411
+ if (!node.children) return;
4412
+ for (const child of node.children) {
4413
+ const childPath = basePath === "/" ? `/${child.name}` : `${basePath}/${child.name}`;
4414
+ if (child.type === "file") {
4415
+ result.push(childPath);
4416
+ } else if (child.type === "directory") {
4417
+ this.collectFiles(fs, childPath, child, result);
4418
+ }
4419
+ }
4420
+ }
4421
+ };
4422
+
4423
+ // src/lib/processors/cli-sh-command-processor.ts
4424
+ var CliShCommandProcessor = class {
4425
+ constructor() {
4426
+ this.command = "sh";
4427
+ this.aliases = ["source", "."];
4428
+ this.description = "Execute a script file";
4429
+ this.author = DefaultLibraryAuthor;
4430
+ this.version = LIBRARY_VERSION;
4431
+ this.acceptsRawInput = true;
4432
+ this.metadata = { icon: "\u{1F4DC}", module: "file management" };
4433
+ this.parameters = [
4434
+ {
4435
+ name: "e",
4436
+ aliases: ["stop-on-error"],
4437
+ description: "Stop execution on first error (default)",
4438
+ required: false,
4439
+ type: "boolean"
4440
+ }
4441
+ ];
4442
+ }
4443
+ async processCommand(command, context) {
4444
+ const fs = context.services.get(
4445
+ IFileSystemService_TOKEN
4446
+ );
4447
+ let filePath = (command.value || "").trim();
4448
+ if (!filePath && command.rawCommand) {
4449
+ const raw = command.rawCommand.trim();
4450
+ const firstSpace = raw.indexOf(" ");
4451
+ if (firstSpace > -1) {
4452
+ filePath = raw.slice(firstSpace + 1).trim();
4453
+ }
4454
+ }
4455
+ if (!filePath) {
4456
+ context.writer.writeError("sh: missing file operand");
4457
+ context.process.exit(1, { silent: true });
4458
+ return;
4459
+ }
4460
+ const resolved = fs.resolvePath(filePath);
4461
+ const node = fs.getNode(resolved);
4462
+ if (!node) {
4463
+ context.writer.writeError(
4464
+ `sh: ${filePath}: No such file or directory`
4465
+ );
4466
+ context.process.exit(1, { silent: true });
4467
+ return;
4468
+ }
4469
+ if (node.type !== "file") {
4470
+ context.writer.writeError(
4471
+ `sh: ${filePath}: Is a directory`
4472
+ );
4473
+ context.process.exit(1, { silent: true });
4474
+ return;
4475
+ }
4476
+ const content = fs.readFile(resolved);
4477
+ if (content === null || content === void 0) {
4478
+ context.writer.writeError(
4479
+ `sh: ${filePath}: Cannot read file`
4480
+ );
4481
+ context.process.exit(1, { silent: true });
4482
+ return;
4483
+ }
4484
+ await executeScript(content, context);
4485
+ }
4486
+ writeDescription(context) {
4487
+ const { writer } = context;
4488
+ writer.writeln(this.description);
4489
+ writer.writeln();
4490
+ writer.writeln("Usage:");
4491
+ writer.writeln(
4492
+ ` ${writer.wrapInColor("sh <script.sh>", CliForegroundColor.Cyan)}`
4493
+ );
4494
+ writer.writeln(
4495
+ ` ${writer.wrapInColor("source <script.sh>", CliForegroundColor.Cyan)}`
4496
+ );
4497
+ writer.writeln(
4498
+ ` ${writer.wrapInColor(". <script.sh>", CliForegroundColor.Cyan)}`
4499
+ );
4500
+ writer.writeln(
4501
+ ` ${writer.wrapInColor("./script.sh", CliForegroundColor.Cyan)} (requires execute permission)`
4502
+ );
4503
+ writer.writeln();
4504
+ writer.writeln("Script syntax:");
4505
+ writer.writeln(" # Lines starting with # are comments");
4506
+ writer.writeln(" VAR=value # Variable assignment");
4507
+ writer.writeln(" echo $VAR # Variable substitution");
4508
+ writer.writeln(" set -e # Stop on error (default)");
4509
+ writer.writeln(" set +e # Continue on errors");
4510
+ writer.writeln();
4511
+ writer.writeln("Example script:");
4512
+ writer.writeln(
4513
+ writer.wrapInColor(
4514
+ " #!/bin/sh\n # Setup script\n NAME=world\n echo Hello $NAME\n mkdir -p /tmp/test\n echo done > /tmp/test/status.txt",
4515
+ CliForegroundColor.Green
4516
+ )
4517
+ );
4518
+ }
4519
+ };
4520
+ async function executeScript(content, context) {
4521
+ const lines = content.split("\n");
4522
+ const variables = {};
4523
+ let stopOnError = true;
4524
+ for (const rawLine of lines) {
4525
+ const line = rawLine.trim();
4526
+ if (!line || line.startsWith("#")) {
4527
+ continue;
4528
+ }
4529
+ if (line === "set -e") {
4530
+ stopOnError = true;
4531
+ continue;
4532
+ }
4533
+ if (line === "set +e") {
4534
+ stopOnError = false;
4535
+ continue;
4536
+ }
4537
+ const assignMatch = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
4538
+ if (assignMatch) {
4539
+ const varName = assignMatch[1];
4540
+ let varValue = assignMatch[2];
4541
+ if (varValue.startsWith('"') && varValue.endsWith('"') || varValue.startsWith("'") && varValue.endsWith("'")) {
4542
+ varValue = varValue.slice(1, -1);
4543
+ }
4544
+ varValue = substituteVariables(varValue, variables);
4545
+ variables[varName] = varValue;
4546
+ continue;
4547
+ }
4548
+ const expanded = substituteVariables(line, variables);
4549
+ await context.executor.executeCommand(expanded, context);
4550
+ const exitCode = context.process.exitCode;
4551
+ if (stopOnError && exitCode !== void 0 && exitCode !== 0) {
4552
+ context.writer.writeError(
4553
+ `sh: script aborted at line: ${line}`
4554
+ );
4555
+ return;
4556
+ }
4557
+ }
4558
+ }
4559
+ function substituteVariables(input, variables) {
4560
+ let result = input.replace(
4561
+ /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,
4562
+ (_, name) => variables[name] ?? ""
4563
+ );
4564
+ result = result.replace(
4565
+ /\$([A-Za-z_][A-Za-z0-9_]*)/g,
4566
+ (_, name) => variables[name] ?? ""
4567
+ );
4568
+ return result;
4569
+ }
4570
+
4571
+ // src/cli-entrypoint.ts
4572
+ var fsService = new IndexedDbFileSystemService();
4573
+ var module = {
4574
+ apiVersion: API_VERSION,
4575
+ name: "@qodalis/cli-files",
4576
+ processors: [
4577
+ new CliLsCommandProcessor(),
4578
+ new CliCdCommandProcessor(),
4579
+ new CliPwdCommandProcessor(),
4580
+ new CliMkdirCommandProcessor(),
4581
+ new CliRmdirCommandProcessor(),
4582
+ new CliTouchCommandProcessor(),
4583
+ new CliCatCommandProcessor(),
4584
+ new CliEchoCommandProcessor(),
4585
+ new CliRmCommandProcessor(),
4586
+ new CliCpCommandProcessor(),
4587
+ new CliMvCommandProcessor(),
4588
+ new CliTreeCommandProcessor(),
4589
+ new CliHeadCommandProcessor(),
4590
+ new CliTailCommandProcessor(),
4591
+ new CliWcCommandProcessor(),
4592
+ new CliFindCommandProcessor(),
4593
+ new CliGrepCommandProcessor(),
4594
+ new CliShCommandProcessor()
4595
+ ],
4596
+ services: [
4597
+ {
4598
+ provide: IFileSystemService_TOKEN,
4599
+ useValue: fsService
4600
+ },
4601
+ {
4602
+ provide: ICliCompletionProvider_TOKEN,
4603
+ useValue: new FilePathCompletionProvider(fsService),
4604
+ multi: true
4605
+ }
4606
+ ],
4607
+ async onInit(context) {
4608
+ const fs = context.services.get(
4609
+ IFileSystemService_TOKEN
4610
+ );
4611
+ await fs.initialize();
4612
+ context.promptPathProvider = () => fs.getCurrentDirectory();
4613
+ }
4614
+ };
4615
+ bootCliModule(module);
4616
+ })();