passive-docs-index 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -8627,6 +8627,70 @@ var require_prompts3 = __commonJS((exports, module) => {
8627
8627
  module.exports = isNodeLT("8.6.0") ? require_dist() : require_lib();
8628
8628
  });
8629
8629
 
8630
+ // src/lib/errors.ts
8631
+ var PDIError, ConfigError, Context7Error, NotInitializedError;
8632
+ var init_errors = __esm(() => {
8633
+ PDIError = class PDIError extends Error {
8634
+ code;
8635
+ hint;
8636
+ cause;
8637
+ constructor(message, options) {
8638
+ super(message);
8639
+ this.name = "PDIError";
8640
+ this.code = options?.code ?? "PDI_ERROR";
8641
+ this.hint = options?.hint;
8642
+ this.cause = options?.cause;
8643
+ }
8644
+ };
8645
+ ConfigError = class ConfigError extends PDIError {
8646
+ configPath;
8647
+ validationIssues;
8648
+ constructor(message, options) {
8649
+ super(message, {
8650
+ code: "CONFIG_INVALID",
8651
+ hint: options?.hint,
8652
+ cause: options?.cause
8653
+ });
8654
+ this.name = "ConfigError";
8655
+ this.configPath = options?.configPath;
8656
+ this.validationIssues = options?.validationIssues;
8657
+ }
8658
+ formatValidationIssues() {
8659
+ if (!this.validationIssues || this.validationIssues.length === 0) {
8660
+ return "";
8661
+ }
8662
+ return this.validationIssues.map((issue2) => {
8663
+ const expected = issue2.expected ? `, expected ${issue2.expected}` : "";
8664
+ return ` - ${issue2.path}: ${issue2.message}${expected}`;
8665
+ }).join(`
8666
+ `);
8667
+ }
8668
+ };
8669
+ Context7Error = class Context7Error extends PDIError {
8670
+ category;
8671
+ source;
8672
+ constructor(message, options) {
8673
+ super(message, {
8674
+ code: "CONTEXT7_ERROR",
8675
+ hint: options?.hint,
8676
+ cause: options?.cause
8677
+ });
8678
+ this.name = "Context7Error";
8679
+ this.category = options?.category ?? "unknown";
8680
+ this.source = options?.source ?? "none";
8681
+ }
8682
+ };
8683
+ NotInitializedError = class NotInitializedError extends PDIError {
8684
+ constructor() {
8685
+ super("PDI not initialized in this project.", {
8686
+ code: "NOT_INITIALIZED",
8687
+ hint: "Run `pdi init` to initialize."
8688
+ });
8689
+ this.name = "NotInitializedError";
8690
+ }
8691
+ };
8692
+ });
8693
+
8630
8694
  // src/lib/mcp-client.ts
8631
8695
  import { execSync, spawn } from "node:child_process";
8632
8696
  import { existsSync as existsSync2, readdirSync } from "node:fs";
@@ -8907,7 +8971,7 @@ var init_mcp_client2 = __esm(() => {
8907
8971
  // node_modules/@upstash/context7-sdk/dist/client.js
8908
8972
  var exports_client = {};
8909
8973
  __export(exports_client, {
8910
- Context7Error: () => Context7Error,
8974
+ Context7Error: () => Context7Error2,
8911
8975
  Context7: () => Context7
8912
8976
  });
8913
8977
  function formatCodeSnippet(snippet) {
@@ -8979,7 +9043,7 @@ function formatLibrariesAsText(libraries) {
8979
9043
  ----------
8980
9044
  `);
8981
9045
  }
8982
- var Context7Error, HttpClient = class {
9046
+ var Context7Error2, HttpClient = class {
8983
9047
  baseUrl;
8984
9048
  headers;
8985
9049
  options;
@@ -9046,7 +9110,7 @@ var Context7Error, HttpClient = class {
9046
9110
  }
9047
9111
  if (!res.ok) {
9048
9112
  const errorBody = await res.json();
9049
- throw new Context7Error(errorBody.error || errorBody.message || res.statusText);
9113
+ throw new Context7Error2(errorBody.error || errorBody.message || res.statusText);
9050
9114
  }
9051
9115
  const contentType = res.headers.get("content-type");
9052
9116
  if (contentType?.includes("application/json")) {
@@ -9101,7 +9165,7 @@ var Context7Error, HttpClient = class {
9101
9165
  constructor(config2 = {}) {
9102
9166
  const apiKey = config2.apiKey || process.env.CONTEXT7_API_KEY;
9103
9167
  if (!apiKey) {
9104
- throw new Context7Error("API key is required. Pass it in the config or set CONTEXT7_API_KEY environment variable.");
9168
+ throw new Context7Error2("API key is required. Pass it in the config or set CONTEXT7_API_KEY environment variable.");
9105
9169
  }
9106
9170
  if (!apiKey.startsWith(API_KEY_PREFIX)) {
9107
9171
  console.warn(`API key should start with '${API_KEY_PREFIX}'`);
@@ -9128,7 +9192,7 @@ var Context7Error, HttpClient = class {
9128
9192
  }
9129
9193
  };
9130
9194
  var init_client = __esm(() => {
9131
- Context7Error = class extends Error {
9195
+ Context7Error2 = class extends Error {
9132
9196
  constructor(message) {
9133
9197
  super(message);
9134
9198
  this.name = "Context7Error";
@@ -9153,7 +9217,7 @@ var init_client = __esm(() => {
9153
9217
  body: this.request.body
9154
9218
  });
9155
9219
  if (result === undefined) {
9156
- throw new Context7Error("Request did not return a result");
9220
+ throw new Context7Error2("Request did not return a result");
9157
9221
  }
9158
9222
  if (this.responseType === "txt" && typeof result === "string") {
9159
9223
  return result;
@@ -9168,7 +9232,7 @@ var init_client = __esm(() => {
9168
9232
  responseType;
9169
9233
  constructor(query, libraryName, options) {
9170
9234
  if (!query || !libraryName) {
9171
- throw new Context7Error("query and libraryName are required");
9235
+ throw new Context7Error2("query and libraryName are required");
9172
9236
  }
9173
9237
  const queryParams = {};
9174
9238
  queryParams.query = query;
@@ -9183,7 +9247,7 @@ var init_client = __esm(() => {
9183
9247
  query: this.request.query
9184
9248
  });
9185
9249
  if (result === undefined) {
9186
- throw new Context7Error("Request did not return a result");
9250
+ throw new Context7Error2("Request did not return a result");
9187
9251
  }
9188
9252
  const libraries = result.results.map(formatLibrary);
9189
9253
  if (this.responseType === "txt") {
@@ -9205,8 +9269,59 @@ __export(exports_context7_client, {
9205
9269
  resetClients: () => resetClients,
9206
9270
  queryContext7: () => queryContext72,
9207
9271
  isHttpClientAvailable: () => isHttpClientAvailable,
9272
+ classifyContext7Error: () => classifyContext7Error,
9208
9273
  checkAvailability: () => checkAvailability
9209
9274
  });
9275
+ function classifyContext7Error(error48, source) {
9276
+ const message = error48 instanceof Error ? error48.message : String(error48);
9277
+ const cause = error48 instanceof Error ? error48 : undefined;
9278
+ const lowerMessage = message.toLowerCase();
9279
+ if (lowerMessage.includes("401") || lowerMessage.includes("403") || lowerMessage.includes("unauthorized") || lowerMessage.includes("invalid") && lowerMessage.includes("key") || lowerMessage.includes("forbidden")) {
9280
+ return new Context7Error("Context7 API key is invalid or expired.", {
9281
+ category: "auth",
9282
+ source,
9283
+ hint: "Run `pdi auth` to reconfigure your API key, or set CONTEXT7_API_KEY in your environment.",
9284
+ cause
9285
+ });
9286
+ }
9287
+ if (lowerMessage.includes("429") || lowerMessage.includes("rate limit") || lowerMessage.includes("too many requests")) {
9288
+ return new Context7Error("Context7 rate limit reached.", {
9289
+ category: "rate_limit",
9290
+ source,
9291
+ hint: "Wait a moment and try again. Consider using `pdi update` with fewer frameworks at once.",
9292
+ cause
9293
+ });
9294
+ }
9295
+ if (lowerMessage.includes("timeout") || lowerMessage.includes("econnrefused") || lowerMessage.includes("enotfound") || lowerMessage.includes("fetch failed") || lowerMessage.includes("failed to fetch") || lowerMessage.includes("network") || lowerMessage.includes("aborted") || lowerMessage.includes("econnreset")) {
9296
+ return new Context7Error("Cannot reach Context7 servers.", {
9297
+ category: "network",
9298
+ source,
9299
+ hint: "Check your internet connection. If the issue persists, try again later.",
9300
+ cause
9301
+ });
9302
+ }
9303
+ if (lowerMessage.includes("library_redirected") || lowerMessage.includes("redirected")) {
9304
+ return new Context7Error("Library ID has changed in Context7.", {
9305
+ category: "redirect",
9306
+ source,
9307
+ hint: "Run `pdi add <framework> --force` to update with the new library ID.",
9308
+ cause
9309
+ });
9310
+ }
9311
+ if (lowerMessage.includes("no documentation found") || lowerMessage.includes("not found") || lowerMessage.includes("404")) {
9312
+ return new Context7Error("No documentation found for this query.", {
9313
+ category: "not_found",
9314
+ source,
9315
+ hint: "The library may not be indexed by Context7, or the query returned no results.",
9316
+ cause
9317
+ });
9318
+ }
9319
+ return new Context7Error(message, {
9320
+ category: "unknown",
9321
+ source,
9322
+ cause
9323
+ });
9324
+ }
9210
9325
  function setHttpClientFactory(factory) {
9211
9326
  httpClientFactory = factory;
9212
9327
  }
@@ -9338,9 +9453,10 @@ async function queryViaHttp(libraryId, query, apiKeyOverride) {
9338
9453
  source: "http"
9339
9454
  };
9340
9455
  }
9456
+ const classified = classifyContext7Error(error48, "http");
9341
9457
  return {
9342
9458
  success: false,
9343
- error: errorMessage,
9459
+ error: classified.hint ? `${classified.message} ${classified.hint}` : classified.message,
9344
9460
  source: "http"
9345
9461
  };
9346
9462
  }
@@ -9384,9 +9500,10 @@ async function queryViaMcp(libraryId, query, mcpClient) {
9384
9500
  source: "mcp"
9385
9501
  };
9386
9502
  } catch (error48) {
9503
+ const classified = classifyContext7Error(error48, "mcp");
9387
9504
  return {
9388
9505
  success: false,
9389
- error: error48 instanceof Error ? error48.message : "MCP query failed",
9506
+ error: classified.hint ? `${classified.message} ${classified.hint}` : classified.message,
9390
9507
  source: "mcp"
9391
9508
  };
9392
9509
  }
@@ -9415,7 +9532,7 @@ async function queryContext72(libraryId, query, config2) {
9415
9532
  }
9416
9533
  return {
9417
9534
  success: false,
9418
- error: httpAvailable ? `HTTP failed, MCP failed: ${mcpResult.error}` : `No API key set, MCP failed: ${mcpResult.error}`,
9535
+ error: httpAvailable ? "Documentation fetch failed. Check connection and API key with `pdi doctor`." : "No documentation source available. Run `pdi auth` to configure Context7 API.",
9419
9536
  source: "none"
9420
9537
  };
9421
9538
  }
@@ -9477,6 +9594,7 @@ var defaultHttpClientFactory = async (apiKey) => {
9477
9594
  return new Context72({ apiKey });
9478
9595
  }, httpClientFactory, httpClient = null, httpClientApiKey = null, libraryIdCache, defaultMcpClient;
9479
9596
  var init_context7_client = __esm(() => {
9597
+ init_errors();
9480
9598
  init_mcp_client2();
9481
9599
  init_mcp_client();
9482
9600
  httpClientFactory = defaultHttpClientFactory;
@@ -9484,206 +9602,1989 @@ var init_context7_client = __esm(() => {
9484
9602
  defaultMcpClient = new McpCliClient;
9485
9603
  });
9486
9604
 
9487
- // node_modules/chalk/source/vendor/ansi-styles/index.js
9488
- var ANSI_BACKGROUND_OFFSET = 10;
9489
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
9490
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
9491
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
9492
- var styles = {
9493
- modifier: {
9494
- reset: [0, 0],
9495
- bold: [1, 22],
9496
- dim: [2, 22],
9497
- italic: [3, 23],
9498
- underline: [4, 24],
9499
- overline: [53, 55],
9500
- inverse: [7, 27],
9501
- hidden: [8, 28],
9502
- strikethrough: [9, 29]
9503
- },
9504
- color: {
9505
- black: [30, 39],
9506
- red: [31, 39],
9507
- green: [32, 39],
9508
- yellow: [33, 39],
9509
- blue: [34, 39],
9510
- magenta: [35, 39],
9511
- cyan: [36, 39],
9512
- white: [37, 39],
9513
- blackBright: [90, 39],
9514
- gray: [90, 39],
9515
- grey: [90, 39],
9516
- redBright: [91, 39],
9517
- greenBright: [92, 39],
9518
- yellowBright: [93, 39],
9519
- blueBright: [94, 39],
9520
- magentaBright: [95, 39],
9521
- cyanBright: [96, 39],
9522
- whiteBright: [97, 39]
9523
- },
9524
- bgColor: {
9525
- bgBlack: [40, 49],
9526
- bgRed: [41, 49],
9527
- bgGreen: [42, 49],
9528
- bgYellow: [43, 49],
9529
- bgBlue: [44, 49],
9530
- bgMagenta: [45, 49],
9531
- bgCyan: [46, 49],
9532
- bgWhite: [47, 49],
9533
- bgBlackBright: [100, 49],
9534
- bgGray: [100, 49],
9535
- bgGrey: [100, 49],
9536
- bgRedBright: [101, 49],
9537
- bgGreenBright: [102, 49],
9538
- bgYellowBright: [103, 49],
9539
- bgBlueBright: [104, 49],
9540
- bgMagentaBright: [105, 49],
9541
- bgCyanBright: [106, 49],
9542
- bgWhiteBright: [107, 49]
9543
- }
9544
- };
9545
- var modifierNames = Object.keys(styles.modifier);
9546
- var foregroundColorNames = Object.keys(styles.color);
9547
- var backgroundColorNames = Object.keys(styles.bgColor);
9548
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
9549
- function assembleStyles() {
9550
- const codes = new Map;
9551
- for (const [groupName, group] of Object.entries(styles)) {
9552
- for (const [styleName, style] of Object.entries(group)) {
9553
- styles[styleName] = {
9554
- open: `\x1B[${style[0]}m`,
9555
- close: `\x1B[${style[1]}m`
9556
- };
9557
- group[styleName] = styles[styleName];
9558
- codes.set(style[0], style[1]);
9559
- }
9560
- Object.defineProperty(styles, groupName, {
9561
- value: group,
9562
- enumerable: false
9563
- });
9564
- }
9565
- Object.defineProperty(styles, "codes", {
9566
- value: codes,
9567
- enumerable: false
9568
- });
9569
- styles.color.close = "\x1B[39m";
9570
- styles.bgColor.close = "\x1B[49m";
9571
- styles.color.ansi = wrapAnsi16();
9572
- styles.color.ansi256 = wrapAnsi256();
9573
- styles.color.ansi16m = wrapAnsi16m();
9574
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
9575
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
9576
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
9577
- Object.defineProperties(styles, {
9578
- rgbToAnsi256: {
9579
- value(red, green, blue) {
9580
- if (red === green && green === blue) {
9581
- if (red < 8) {
9582
- return 16;
9583
- }
9584
- if (red > 248) {
9585
- return 231;
9586
- }
9587
- return Math.round((red - 8) / 247 * 24) + 232;
9588
- }
9589
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
9590
- },
9591
- enumerable: false
9592
- },
9593
- hexToRgb: {
9594
- value(hex) {
9595
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
9596
- if (!matches) {
9597
- return [0, 0, 0];
9598
- }
9599
- let [colorString] = matches;
9600
- if (colorString.length === 3) {
9601
- colorString = [...colorString].map((character) => character + character).join("");
9602
- }
9603
- const integer = Number.parseInt(colorString, 16);
9604
- return [
9605
- integer >> 16 & 255,
9606
- integer >> 8 & 255,
9607
- integer & 255
9608
- ];
9609
- },
9610
- enumerable: false
9611
- },
9612
- hexToAnsi256: {
9613
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
9614
- enumerable: false
9615
- },
9616
- ansi256ToAnsi: {
9617
- value(code) {
9618
- if (code < 8) {
9619
- return 30 + code;
9620
- }
9621
- if (code < 16) {
9622
- return 90 + (code - 8);
9623
- }
9624
- let red;
9625
- let green;
9626
- let blue;
9627
- if (code >= 232) {
9628
- red = ((code - 232) * 10 + 8) / 255;
9629
- green = red;
9630
- blue = red;
9605
+ // node_modules/semver/internal/constants.js
9606
+ var require_constants = __commonJS((exports, module) => {
9607
+ var SEMVER_SPEC_VERSION = "2.0.0";
9608
+ var MAX_LENGTH = 256;
9609
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
9610
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
9611
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
9612
+ var RELEASE_TYPES = [
9613
+ "major",
9614
+ "premajor",
9615
+ "minor",
9616
+ "preminor",
9617
+ "patch",
9618
+ "prepatch",
9619
+ "prerelease"
9620
+ ];
9621
+ module.exports = {
9622
+ MAX_LENGTH,
9623
+ MAX_SAFE_COMPONENT_LENGTH,
9624
+ MAX_SAFE_BUILD_LENGTH,
9625
+ MAX_SAFE_INTEGER,
9626
+ RELEASE_TYPES,
9627
+ SEMVER_SPEC_VERSION,
9628
+ FLAG_INCLUDE_PRERELEASE: 1,
9629
+ FLAG_LOOSE: 2
9630
+ };
9631
+ });
9632
+
9633
+ // node_modules/semver/internal/debug.js
9634
+ var require_debug = __commonJS((exports, module) => {
9635
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
9636
+ module.exports = debug;
9637
+ });
9638
+
9639
+ // node_modules/semver/internal/re.js
9640
+ var require_re = __commonJS((exports, module) => {
9641
+ var {
9642
+ MAX_SAFE_COMPONENT_LENGTH,
9643
+ MAX_SAFE_BUILD_LENGTH,
9644
+ MAX_LENGTH
9645
+ } = require_constants();
9646
+ var debug = require_debug();
9647
+ exports = module.exports = {};
9648
+ var re = exports.re = [];
9649
+ var safeRe = exports.safeRe = [];
9650
+ var src = exports.src = [];
9651
+ var safeSrc = exports.safeSrc = [];
9652
+ var t = exports.t = {};
9653
+ var R = 0;
9654
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
9655
+ var safeRegexReplacements = [
9656
+ ["\\s", 1],
9657
+ ["\\d", MAX_LENGTH],
9658
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
9659
+ ];
9660
+ var makeSafeRegex = (value) => {
9661
+ for (const [token, max] of safeRegexReplacements) {
9662
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
9663
+ }
9664
+ return value;
9665
+ };
9666
+ var createToken = (name, value, isGlobal) => {
9667
+ const safe = makeSafeRegex(value);
9668
+ const index = R++;
9669
+ debug(name, index, value);
9670
+ t[name] = index;
9671
+ src[index] = value;
9672
+ safeSrc[index] = safe;
9673
+ re[index] = new RegExp(value, isGlobal ? "g" : undefined);
9674
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : undefined);
9675
+ };
9676
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
9677
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
9678
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
9679
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
9680
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
9681
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
9682
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
9683
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
9684
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
9685
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
9686
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
9687
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
9688
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
9689
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
9690
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
9691
+ createToken("GTLT", "((?:<|>)?=?)");
9692
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
9693
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
9694
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
9695
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
9696
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
9697
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
9698
+ createToken("COERCEPLAIN", `${"(^|[^\\d])" + "(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
9699
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
9700
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?` + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`);
9701
+ createToken("COERCERTL", src[t.COERCE], true);
9702
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
9703
+ createToken("LONETILDE", "(?:~>?)");
9704
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
9705
+ exports.tildeTrimReplace = "$1~";
9706
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
9707
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
9708
+ createToken("LONECARET", "(?:\\^)");
9709
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
9710
+ exports.caretTrimReplace = "$1^";
9711
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
9712
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
9713
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
9714
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
9715
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
9716
+ exports.comparatorTrimReplace = "$1$2$3";
9717
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
9718
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`);
9719
+ createToken("STAR", "(<|>)?=?\\s*\\*");
9720
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
9721
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
9722
+ });
9723
+
9724
+ // node_modules/semver/internal/parse-options.js
9725
+ var require_parse_options = __commonJS((exports, module) => {
9726
+ var looseOption = Object.freeze({ loose: true });
9727
+ var emptyOpts = Object.freeze({});
9728
+ var parseOptions = (options) => {
9729
+ if (!options) {
9730
+ return emptyOpts;
9731
+ }
9732
+ if (typeof options !== "object") {
9733
+ return looseOption;
9734
+ }
9735
+ return options;
9736
+ };
9737
+ module.exports = parseOptions;
9738
+ });
9739
+
9740
+ // node_modules/semver/internal/identifiers.js
9741
+ var require_identifiers = __commonJS((exports, module) => {
9742
+ var numeric = /^[0-9]+$/;
9743
+ var compareIdentifiers = (a, b) => {
9744
+ if (typeof a === "number" && typeof b === "number") {
9745
+ return a === b ? 0 : a < b ? -1 : 1;
9746
+ }
9747
+ const anum = numeric.test(a);
9748
+ const bnum = numeric.test(b);
9749
+ if (anum && bnum) {
9750
+ a = +a;
9751
+ b = +b;
9752
+ }
9753
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
9754
+ };
9755
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
9756
+ module.exports = {
9757
+ compareIdentifiers,
9758
+ rcompareIdentifiers
9759
+ };
9760
+ });
9761
+
9762
+ // node_modules/semver/classes/semver.js
9763
+ var require_semver = __commonJS((exports, module) => {
9764
+ var debug = require_debug();
9765
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
9766
+ var { safeRe: re, t } = require_re();
9767
+ var parseOptions = require_parse_options();
9768
+ var { compareIdentifiers } = require_identifiers();
9769
+
9770
+ class SemVer {
9771
+ constructor(version2, options) {
9772
+ options = parseOptions(options);
9773
+ if (version2 instanceof SemVer) {
9774
+ if (version2.loose === !!options.loose && version2.includePrerelease === !!options.includePrerelease) {
9775
+ return version2;
9631
9776
  } else {
9632
- code -= 16;
9633
- const remainder = code % 36;
9634
- red = Math.floor(code / 36) / 5;
9635
- green = Math.floor(remainder / 6) / 5;
9636
- blue = remainder % 6 / 5;
9637
- }
9638
- const value = Math.max(red, green, blue) * 2;
9639
- if (value === 0) {
9640
- return 30;
9641
- }
9642
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
9643
- if (value === 2) {
9644
- result += 60;
9777
+ version2 = version2.version;
9645
9778
  }
9646
- return result;
9647
- },
9648
- enumerable: false
9649
- },
9650
- rgbToAnsi: {
9651
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
9652
- enumerable: false
9653
- },
9654
- hexToAnsi: {
9655
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
9656
- enumerable: false
9779
+ } else if (typeof version2 !== "string") {
9780
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version2}".`);
9781
+ }
9782
+ if (version2.length > MAX_LENGTH) {
9783
+ throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
9784
+ }
9785
+ debug("SemVer", version2, options);
9786
+ this.options = options;
9787
+ this.loose = !!options.loose;
9788
+ this.includePrerelease = !!options.includePrerelease;
9789
+ const m = version2.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
9790
+ if (!m) {
9791
+ throw new TypeError(`Invalid Version: ${version2}`);
9792
+ }
9793
+ this.raw = version2;
9794
+ this.major = +m[1];
9795
+ this.minor = +m[2];
9796
+ this.patch = +m[3];
9797
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
9798
+ throw new TypeError("Invalid major version");
9799
+ }
9800
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
9801
+ throw new TypeError("Invalid minor version");
9802
+ }
9803
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
9804
+ throw new TypeError("Invalid patch version");
9805
+ }
9806
+ if (!m[4]) {
9807
+ this.prerelease = [];
9808
+ } else {
9809
+ this.prerelease = m[4].split(".").map((id) => {
9810
+ if (/^[0-9]+$/.test(id)) {
9811
+ const num = +id;
9812
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
9813
+ return num;
9814
+ }
9815
+ }
9816
+ return id;
9817
+ });
9818
+ }
9819
+ this.build = m[5] ? m[5].split(".") : [];
9820
+ this.format();
9657
9821
  }
9658
- });
9659
- return styles;
9660
- }
9661
- var ansiStyles = assembleStyles();
9662
- var ansi_styles_default = ansiStyles;
9663
-
9664
- // node_modules/chalk/source/vendor/supports-color/index.js
9665
- import process2 from "node:process";
9666
- import os from "node:os";
9667
- import tty from "node:tty";
9668
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
9669
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
9670
- const position = argv.indexOf(prefix + flag);
9671
- const terminatorPosition = argv.indexOf("--");
9672
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
9673
- }
9674
- var { env } = process2;
9675
- var flagForceColor;
9676
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
9677
- flagForceColor = 0;
9678
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
9679
- flagForceColor = 1;
9680
- }
9681
- function envForceColor() {
9682
- if ("FORCE_COLOR" in env) {
9683
- if (env.FORCE_COLOR === "true") {
9684
- return 1;
9822
+ format() {
9823
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
9824
+ if (this.prerelease.length) {
9825
+ this.version += `-${this.prerelease.join(".")}`;
9826
+ }
9827
+ return this.version;
9685
9828
  }
9686
- if (env.FORCE_COLOR === "false") {
9829
+ toString() {
9830
+ return this.version;
9831
+ }
9832
+ compare(other) {
9833
+ debug("SemVer.compare", this.version, this.options, other);
9834
+ if (!(other instanceof SemVer)) {
9835
+ if (typeof other === "string" && other === this.version) {
9836
+ return 0;
9837
+ }
9838
+ other = new SemVer(other, this.options);
9839
+ }
9840
+ if (other.version === this.version) {
9841
+ return 0;
9842
+ }
9843
+ return this.compareMain(other) || this.comparePre(other);
9844
+ }
9845
+ compareMain(other) {
9846
+ if (!(other instanceof SemVer)) {
9847
+ other = new SemVer(other, this.options);
9848
+ }
9849
+ if (this.major < other.major) {
9850
+ return -1;
9851
+ }
9852
+ if (this.major > other.major) {
9853
+ return 1;
9854
+ }
9855
+ if (this.minor < other.minor) {
9856
+ return -1;
9857
+ }
9858
+ if (this.minor > other.minor) {
9859
+ return 1;
9860
+ }
9861
+ if (this.patch < other.patch) {
9862
+ return -1;
9863
+ }
9864
+ if (this.patch > other.patch) {
9865
+ return 1;
9866
+ }
9867
+ return 0;
9868
+ }
9869
+ comparePre(other) {
9870
+ if (!(other instanceof SemVer)) {
9871
+ other = new SemVer(other, this.options);
9872
+ }
9873
+ if (this.prerelease.length && !other.prerelease.length) {
9874
+ return -1;
9875
+ } else if (!this.prerelease.length && other.prerelease.length) {
9876
+ return 1;
9877
+ } else if (!this.prerelease.length && !other.prerelease.length) {
9878
+ return 0;
9879
+ }
9880
+ let i = 0;
9881
+ do {
9882
+ const a = this.prerelease[i];
9883
+ const b = other.prerelease[i];
9884
+ debug("prerelease compare", i, a, b);
9885
+ if (a === undefined && b === undefined) {
9886
+ return 0;
9887
+ } else if (b === undefined) {
9888
+ return 1;
9889
+ } else if (a === undefined) {
9890
+ return -1;
9891
+ } else if (a === b) {
9892
+ continue;
9893
+ } else {
9894
+ return compareIdentifiers(a, b);
9895
+ }
9896
+ } while (++i);
9897
+ }
9898
+ compareBuild(other) {
9899
+ if (!(other instanceof SemVer)) {
9900
+ other = new SemVer(other, this.options);
9901
+ }
9902
+ let i = 0;
9903
+ do {
9904
+ const a = this.build[i];
9905
+ const b = other.build[i];
9906
+ debug("build compare", i, a, b);
9907
+ if (a === undefined && b === undefined) {
9908
+ return 0;
9909
+ } else if (b === undefined) {
9910
+ return 1;
9911
+ } else if (a === undefined) {
9912
+ return -1;
9913
+ } else if (a === b) {
9914
+ continue;
9915
+ } else {
9916
+ return compareIdentifiers(a, b);
9917
+ }
9918
+ } while (++i);
9919
+ }
9920
+ inc(release, identifier, identifierBase) {
9921
+ if (release.startsWith("pre")) {
9922
+ if (!identifier && identifierBase === false) {
9923
+ throw new Error("invalid increment argument: identifier is empty");
9924
+ }
9925
+ if (identifier) {
9926
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
9927
+ if (!match || match[1] !== identifier) {
9928
+ throw new Error(`invalid identifier: ${identifier}`);
9929
+ }
9930
+ }
9931
+ }
9932
+ switch (release) {
9933
+ case "premajor":
9934
+ this.prerelease.length = 0;
9935
+ this.patch = 0;
9936
+ this.minor = 0;
9937
+ this.major++;
9938
+ this.inc("pre", identifier, identifierBase);
9939
+ break;
9940
+ case "preminor":
9941
+ this.prerelease.length = 0;
9942
+ this.patch = 0;
9943
+ this.minor++;
9944
+ this.inc("pre", identifier, identifierBase);
9945
+ break;
9946
+ case "prepatch":
9947
+ this.prerelease.length = 0;
9948
+ this.inc("patch", identifier, identifierBase);
9949
+ this.inc("pre", identifier, identifierBase);
9950
+ break;
9951
+ case "prerelease":
9952
+ if (this.prerelease.length === 0) {
9953
+ this.inc("patch", identifier, identifierBase);
9954
+ }
9955
+ this.inc("pre", identifier, identifierBase);
9956
+ break;
9957
+ case "release":
9958
+ if (this.prerelease.length === 0) {
9959
+ throw new Error(`version ${this.raw} is not a prerelease`);
9960
+ }
9961
+ this.prerelease.length = 0;
9962
+ break;
9963
+ case "major":
9964
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
9965
+ this.major++;
9966
+ }
9967
+ this.minor = 0;
9968
+ this.patch = 0;
9969
+ this.prerelease = [];
9970
+ break;
9971
+ case "minor":
9972
+ if (this.patch !== 0 || this.prerelease.length === 0) {
9973
+ this.minor++;
9974
+ }
9975
+ this.patch = 0;
9976
+ this.prerelease = [];
9977
+ break;
9978
+ case "patch":
9979
+ if (this.prerelease.length === 0) {
9980
+ this.patch++;
9981
+ }
9982
+ this.prerelease = [];
9983
+ break;
9984
+ case "pre": {
9985
+ const base = Number(identifierBase) ? 1 : 0;
9986
+ if (this.prerelease.length === 0) {
9987
+ this.prerelease = [base];
9988
+ } else {
9989
+ let i = this.prerelease.length;
9990
+ while (--i >= 0) {
9991
+ if (typeof this.prerelease[i] === "number") {
9992
+ this.prerelease[i]++;
9993
+ i = -2;
9994
+ }
9995
+ }
9996
+ if (i === -1) {
9997
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
9998
+ throw new Error("invalid increment argument: identifier already exists");
9999
+ }
10000
+ this.prerelease.push(base);
10001
+ }
10002
+ }
10003
+ if (identifier) {
10004
+ let prerelease = [identifier, base];
10005
+ if (identifierBase === false) {
10006
+ prerelease = [identifier];
10007
+ }
10008
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
10009
+ if (isNaN(this.prerelease[1])) {
10010
+ this.prerelease = prerelease;
10011
+ }
10012
+ } else {
10013
+ this.prerelease = prerelease;
10014
+ }
10015
+ }
10016
+ break;
10017
+ }
10018
+ default:
10019
+ throw new Error(`invalid increment argument: ${release}`);
10020
+ }
10021
+ this.raw = this.format();
10022
+ if (this.build.length) {
10023
+ this.raw += `+${this.build.join(".")}`;
10024
+ }
10025
+ return this;
10026
+ }
10027
+ }
10028
+ module.exports = SemVer;
10029
+ });
10030
+
10031
+ // node_modules/semver/functions/parse.js
10032
+ var require_parse = __commonJS((exports, module) => {
10033
+ var SemVer = require_semver();
10034
+ var parse5 = (version2, options, throwErrors = false) => {
10035
+ if (version2 instanceof SemVer) {
10036
+ return version2;
10037
+ }
10038
+ try {
10039
+ return new SemVer(version2, options);
10040
+ } catch (er) {
10041
+ if (!throwErrors) {
10042
+ return null;
10043
+ }
10044
+ throw er;
10045
+ }
10046
+ };
10047
+ module.exports = parse5;
10048
+ });
10049
+
10050
+ // node_modules/semver/functions/valid.js
10051
+ var require_valid = __commonJS((exports, module) => {
10052
+ var parse5 = require_parse();
10053
+ var valid = (version2, options) => {
10054
+ const v = parse5(version2, options);
10055
+ return v ? v.version : null;
10056
+ };
10057
+ module.exports = valid;
10058
+ });
10059
+
10060
+ // node_modules/semver/functions/clean.js
10061
+ var require_clean = __commonJS((exports, module) => {
10062
+ var parse5 = require_parse();
10063
+ var clean = (version2, options) => {
10064
+ const s = parse5(version2.trim().replace(/^[=v]+/, ""), options);
10065
+ return s ? s.version : null;
10066
+ };
10067
+ module.exports = clean;
10068
+ });
10069
+
10070
+ // node_modules/semver/functions/inc.js
10071
+ var require_inc = __commonJS((exports, module) => {
10072
+ var SemVer = require_semver();
10073
+ var inc = (version2, release, options, identifier, identifierBase) => {
10074
+ if (typeof options === "string") {
10075
+ identifierBase = identifier;
10076
+ identifier = options;
10077
+ options = undefined;
10078
+ }
10079
+ try {
10080
+ return new SemVer(version2 instanceof SemVer ? version2.version : version2, options).inc(release, identifier, identifierBase).version;
10081
+ } catch (er) {
10082
+ return null;
10083
+ }
10084
+ };
10085
+ module.exports = inc;
10086
+ });
10087
+
10088
+ // node_modules/semver/functions/diff.js
10089
+ var require_diff = __commonJS((exports, module) => {
10090
+ var parse5 = require_parse();
10091
+ var diff = (version1, version2) => {
10092
+ const v1 = parse5(version1, null, true);
10093
+ const v2 = parse5(version2, null, true);
10094
+ const comparison = v1.compare(v2);
10095
+ if (comparison === 0) {
10096
+ return null;
10097
+ }
10098
+ const v1Higher = comparison > 0;
10099
+ const highVersion = v1Higher ? v1 : v2;
10100
+ const lowVersion = v1Higher ? v2 : v1;
10101
+ const highHasPre = !!highVersion.prerelease.length;
10102
+ const lowHasPre = !!lowVersion.prerelease.length;
10103
+ if (lowHasPre && !highHasPre) {
10104
+ if (!lowVersion.patch && !lowVersion.minor) {
10105
+ return "major";
10106
+ }
10107
+ if (lowVersion.compareMain(highVersion) === 0) {
10108
+ if (lowVersion.minor && !lowVersion.patch) {
10109
+ return "minor";
10110
+ }
10111
+ return "patch";
10112
+ }
10113
+ }
10114
+ const prefix = highHasPre ? "pre" : "";
10115
+ if (v1.major !== v2.major) {
10116
+ return prefix + "major";
10117
+ }
10118
+ if (v1.minor !== v2.minor) {
10119
+ return prefix + "minor";
10120
+ }
10121
+ if (v1.patch !== v2.patch) {
10122
+ return prefix + "patch";
10123
+ }
10124
+ return "prerelease";
10125
+ };
10126
+ module.exports = diff;
10127
+ });
10128
+
10129
+ // node_modules/semver/functions/major.js
10130
+ var require_major = __commonJS((exports, module) => {
10131
+ var SemVer = require_semver();
10132
+ var major = (a, loose) => new SemVer(a, loose).major;
10133
+ module.exports = major;
10134
+ });
10135
+
10136
+ // node_modules/semver/functions/minor.js
10137
+ var require_minor = __commonJS((exports, module) => {
10138
+ var SemVer = require_semver();
10139
+ var minor = (a, loose) => new SemVer(a, loose).minor;
10140
+ module.exports = minor;
10141
+ });
10142
+
10143
+ // node_modules/semver/functions/patch.js
10144
+ var require_patch = __commonJS((exports, module) => {
10145
+ var SemVer = require_semver();
10146
+ var patch = (a, loose) => new SemVer(a, loose).patch;
10147
+ module.exports = patch;
10148
+ });
10149
+
10150
+ // node_modules/semver/functions/prerelease.js
10151
+ var require_prerelease = __commonJS((exports, module) => {
10152
+ var parse5 = require_parse();
10153
+ var prerelease = (version2, options) => {
10154
+ const parsed = parse5(version2, options);
10155
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
10156
+ };
10157
+ module.exports = prerelease;
10158
+ });
10159
+
10160
+ // node_modules/semver/functions/compare.js
10161
+ var require_compare = __commonJS((exports, module) => {
10162
+ var SemVer = require_semver();
10163
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
10164
+ module.exports = compare;
10165
+ });
10166
+
10167
+ // node_modules/semver/functions/rcompare.js
10168
+ var require_rcompare = __commonJS((exports, module) => {
10169
+ var compare = require_compare();
10170
+ var rcompare = (a, b, loose) => compare(b, a, loose);
10171
+ module.exports = rcompare;
10172
+ });
10173
+
10174
+ // node_modules/semver/functions/compare-loose.js
10175
+ var require_compare_loose = __commonJS((exports, module) => {
10176
+ var compare = require_compare();
10177
+ var compareLoose = (a, b) => compare(a, b, true);
10178
+ module.exports = compareLoose;
10179
+ });
10180
+
10181
+ // node_modules/semver/functions/compare-build.js
10182
+ var require_compare_build = __commonJS((exports, module) => {
10183
+ var SemVer = require_semver();
10184
+ var compareBuild = (a, b, loose) => {
10185
+ const versionA = new SemVer(a, loose);
10186
+ const versionB = new SemVer(b, loose);
10187
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
10188
+ };
10189
+ module.exports = compareBuild;
10190
+ });
10191
+
10192
+ // node_modules/semver/functions/sort.js
10193
+ var require_sort = __commonJS((exports, module) => {
10194
+ var compareBuild = require_compare_build();
10195
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
10196
+ module.exports = sort;
10197
+ });
10198
+
10199
+ // node_modules/semver/functions/rsort.js
10200
+ var require_rsort = __commonJS((exports, module) => {
10201
+ var compareBuild = require_compare_build();
10202
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
10203
+ module.exports = rsort;
10204
+ });
10205
+
10206
+ // node_modules/semver/functions/gt.js
10207
+ var require_gt = __commonJS((exports, module) => {
10208
+ var compare = require_compare();
10209
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
10210
+ module.exports = gt;
10211
+ });
10212
+
10213
+ // node_modules/semver/functions/lt.js
10214
+ var require_lt = __commonJS((exports, module) => {
10215
+ var compare = require_compare();
10216
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
10217
+ module.exports = lt;
10218
+ });
10219
+
10220
+ // node_modules/semver/functions/eq.js
10221
+ var require_eq = __commonJS((exports, module) => {
10222
+ var compare = require_compare();
10223
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
10224
+ module.exports = eq;
10225
+ });
10226
+
10227
+ // node_modules/semver/functions/neq.js
10228
+ var require_neq = __commonJS((exports, module) => {
10229
+ var compare = require_compare();
10230
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
10231
+ module.exports = neq;
10232
+ });
10233
+
10234
+ // node_modules/semver/functions/gte.js
10235
+ var require_gte = __commonJS((exports, module) => {
10236
+ var compare = require_compare();
10237
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
10238
+ module.exports = gte;
10239
+ });
10240
+
10241
+ // node_modules/semver/functions/lte.js
10242
+ var require_lte = __commonJS((exports, module) => {
10243
+ var compare = require_compare();
10244
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
10245
+ module.exports = lte;
10246
+ });
10247
+
10248
+ // node_modules/semver/functions/cmp.js
10249
+ var require_cmp = __commonJS((exports, module) => {
10250
+ var eq = require_eq();
10251
+ var neq = require_neq();
10252
+ var gt = require_gt();
10253
+ var gte = require_gte();
10254
+ var lt = require_lt();
10255
+ var lte = require_lte();
10256
+ var cmp = (a, op, b, loose) => {
10257
+ switch (op) {
10258
+ case "===":
10259
+ if (typeof a === "object") {
10260
+ a = a.version;
10261
+ }
10262
+ if (typeof b === "object") {
10263
+ b = b.version;
10264
+ }
10265
+ return a === b;
10266
+ case "!==":
10267
+ if (typeof a === "object") {
10268
+ a = a.version;
10269
+ }
10270
+ if (typeof b === "object") {
10271
+ b = b.version;
10272
+ }
10273
+ return a !== b;
10274
+ case "":
10275
+ case "=":
10276
+ case "==":
10277
+ return eq(a, b, loose);
10278
+ case "!=":
10279
+ return neq(a, b, loose);
10280
+ case ">":
10281
+ return gt(a, b, loose);
10282
+ case ">=":
10283
+ return gte(a, b, loose);
10284
+ case "<":
10285
+ return lt(a, b, loose);
10286
+ case "<=":
10287
+ return lte(a, b, loose);
10288
+ default:
10289
+ throw new TypeError(`Invalid operator: ${op}`);
10290
+ }
10291
+ };
10292
+ module.exports = cmp;
10293
+ });
10294
+
10295
+ // node_modules/semver/functions/coerce.js
10296
+ var require_coerce = __commonJS((exports, module) => {
10297
+ var SemVer = require_semver();
10298
+ var parse5 = require_parse();
10299
+ var { safeRe: re, t } = require_re();
10300
+ var coerce = (version2, options) => {
10301
+ if (version2 instanceof SemVer) {
10302
+ return version2;
10303
+ }
10304
+ if (typeof version2 === "number") {
10305
+ version2 = String(version2);
10306
+ }
10307
+ if (typeof version2 !== "string") {
10308
+ return null;
10309
+ }
10310
+ options = options || {};
10311
+ let match = null;
10312
+ if (!options.rtl) {
10313
+ match = version2.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
10314
+ } else {
10315
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
10316
+ let next;
10317
+ while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
10318
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
10319
+ match = next;
10320
+ }
10321
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
10322
+ }
10323
+ coerceRtlRegex.lastIndex = -1;
10324
+ }
10325
+ if (match === null) {
10326
+ return null;
10327
+ }
10328
+ const major = match[2];
10329
+ const minor = match[3] || "0";
10330
+ const patch = match[4] || "0";
10331
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
10332
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
10333
+ return parse5(`${major}.${minor}.${patch}${prerelease}${build}`, options);
10334
+ };
10335
+ module.exports = coerce;
10336
+ });
10337
+
10338
+ // node_modules/semver/internal/lrucache.js
10339
+ var require_lrucache = __commonJS((exports, module) => {
10340
+ class LRUCache {
10341
+ constructor() {
10342
+ this.max = 1000;
10343
+ this.map = new Map;
10344
+ }
10345
+ get(key) {
10346
+ const value = this.map.get(key);
10347
+ if (value === undefined) {
10348
+ return;
10349
+ } else {
10350
+ this.map.delete(key);
10351
+ this.map.set(key, value);
10352
+ return value;
10353
+ }
10354
+ }
10355
+ delete(key) {
10356
+ return this.map.delete(key);
10357
+ }
10358
+ set(key, value) {
10359
+ const deleted = this.delete(key);
10360
+ if (!deleted && value !== undefined) {
10361
+ if (this.map.size >= this.max) {
10362
+ const firstKey = this.map.keys().next().value;
10363
+ this.delete(firstKey);
10364
+ }
10365
+ this.map.set(key, value);
10366
+ }
10367
+ return this;
10368
+ }
10369
+ }
10370
+ module.exports = LRUCache;
10371
+ });
10372
+
10373
+ // node_modules/semver/classes/range.js
10374
+ var require_range = __commonJS((exports, module) => {
10375
+ var SPACE_CHARACTERS = /\s+/g;
10376
+
10377
+ class Range {
10378
+ constructor(range, options) {
10379
+ options = parseOptions(options);
10380
+ if (range instanceof Range) {
10381
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
10382
+ return range;
10383
+ } else {
10384
+ return new Range(range.raw, options);
10385
+ }
10386
+ }
10387
+ if (range instanceof Comparator) {
10388
+ this.raw = range.value;
10389
+ this.set = [[range]];
10390
+ this.formatted = undefined;
10391
+ return this;
10392
+ }
10393
+ this.options = options;
10394
+ this.loose = !!options.loose;
10395
+ this.includePrerelease = !!options.includePrerelease;
10396
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
10397
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
10398
+ if (!this.set.length) {
10399
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
10400
+ }
10401
+ if (this.set.length > 1) {
10402
+ const first = this.set[0];
10403
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
10404
+ if (this.set.length === 0) {
10405
+ this.set = [first];
10406
+ } else if (this.set.length > 1) {
10407
+ for (const c of this.set) {
10408
+ if (c.length === 1 && isAny(c[0])) {
10409
+ this.set = [c];
10410
+ break;
10411
+ }
10412
+ }
10413
+ }
10414
+ }
10415
+ this.formatted = undefined;
10416
+ }
10417
+ get range() {
10418
+ if (this.formatted === undefined) {
10419
+ this.formatted = "";
10420
+ for (let i = 0;i < this.set.length; i++) {
10421
+ if (i > 0) {
10422
+ this.formatted += "||";
10423
+ }
10424
+ const comps = this.set[i];
10425
+ for (let k = 0;k < comps.length; k++) {
10426
+ if (k > 0) {
10427
+ this.formatted += " ";
10428
+ }
10429
+ this.formatted += comps[k].toString().trim();
10430
+ }
10431
+ }
10432
+ }
10433
+ return this.formatted;
10434
+ }
10435
+ format() {
10436
+ return this.range;
10437
+ }
10438
+ toString() {
10439
+ return this.range;
10440
+ }
10441
+ parseRange(range) {
10442
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
10443
+ const memoKey = memoOpts + ":" + range;
10444
+ const cached2 = cache.get(memoKey);
10445
+ if (cached2) {
10446
+ return cached2;
10447
+ }
10448
+ const loose = this.options.loose;
10449
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
10450
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
10451
+ debug("hyphen replace", range);
10452
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
10453
+ debug("comparator trim", range);
10454
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
10455
+ debug("tilde trim", range);
10456
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
10457
+ debug("caret trim", range);
10458
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
10459
+ if (loose) {
10460
+ rangeList = rangeList.filter((comp) => {
10461
+ debug("loose invalid filter", comp, this.options);
10462
+ return !!comp.match(re[t.COMPARATORLOOSE]);
10463
+ });
10464
+ }
10465
+ debug("range list", rangeList);
10466
+ const rangeMap = new Map;
10467
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
10468
+ for (const comp of comparators) {
10469
+ if (isNullSet(comp)) {
10470
+ return [comp];
10471
+ }
10472
+ rangeMap.set(comp.value, comp);
10473
+ }
10474
+ if (rangeMap.size > 1 && rangeMap.has("")) {
10475
+ rangeMap.delete("");
10476
+ }
10477
+ const result = [...rangeMap.values()];
10478
+ cache.set(memoKey, result);
10479
+ return result;
10480
+ }
10481
+ intersects(range, options) {
10482
+ if (!(range instanceof Range)) {
10483
+ throw new TypeError("a Range is required");
10484
+ }
10485
+ return this.set.some((thisComparators) => {
10486
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
10487
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
10488
+ return rangeComparators.every((rangeComparator) => {
10489
+ return thisComparator.intersects(rangeComparator, options);
10490
+ });
10491
+ });
10492
+ });
10493
+ });
10494
+ }
10495
+ test(version2) {
10496
+ if (!version2) {
10497
+ return false;
10498
+ }
10499
+ if (typeof version2 === "string") {
10500
+ try {
10501
+ version2 = new SemVer(version2, this.options);
10502
+ } catch (er) {
10503
+ return false;
10504
+ }
10505
+ }
10506
+ for (let i = 0;i < this.set.length; i++) {
10507
+ if (testSet(this.set[i], version2, this.options)) {
10508
+ return true;
10509
+ }
10510
+ }
10511
+ return false;
10512
+ }
10513
+ }
10514
+ module.exports = Range;
10515
+ var LRU = require_lrucache();
10516
+ var cache = new LRU;
10517
+ var parseOptions = require_parse_options();
10518
+ var Comparator = require_comparator();
10519
+ var debug = require_debug();
10520
+ var SemVer = require_semver();
10521
+ var {
10522
+ safeRe: re,
10523
+ t,
10524
+ comparatorTrimReplace,
10525
+ tildeTrimReplace,
10526
+ caretTrimReplace
10527
+ } = require_re();
10528
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
10529
+ var isNullSet = (c) => c.value === "<0.0.0-0";
10530
+ var isAny = (c) => c.value === "";
10531
+ var isSatisfiable = (comparators, options) => {
10532
+ let result = true;
10533
+ const remainingComparators = comparators.slice();
10534
+ let testComparator = remainingComparators.pop();
10535
+ while (result && remainingComparators.length) {
10536
+ result = remainingComparators.every((otherComparator) => {
10537
+ return testComparator.intersects(otherComparator, options);
10538
+ });
10539
+ testComparator = remainingComparators.pop();
10540
+ }
10541
+ return result;
10542
+ };
10543
+ var parseComparator = (comp, options) => {
10544
+ comp = comp.replace(re[t.BUILD], "");
10545
+ debug("comp", comp, options);
10546
+ comp = replaceCarets(comp, options);
10547
+ debug("caret", comp);
10548
+ comp = replaceTildes(comp, options);
10549
+ debug("tildes", comp);
10550
+ comp = replaceXRanges(comp, options);
10551
+ debug("xrange", comp);
10552
+ comp = replaceStars(comp, options);
10553
+ debug("stars", comp);
10554
+ return comp;
10555
+ };
10556
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
10557
+ var replaceTildes = (comp, options) => {
10558
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
10559
+ };
10560
+ var replaceTilde = (comp, options) => {
10561
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
10562
+ return comp.replace(r, (_, M, m, p, pr) => {
10563
+ debug("tilde", comp, _, M, m, p, pr);
10564
+ let ret;
10565
+ if (isX(M)) {
10566
+ ret = "";
10567
+ } else if (isX(m)) {
10568
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
10569
+ } else if (isX(p)) {
10570
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
10571
+ } else if (pr) {
10572
+ debug("replaceTilde pr", pr);
10573
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
10574
+ } else {
10575
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
10576
+ }
10577
+ debug("tilde return", ret);
10578
+ return ret;
10579
+ });
10580
+ };
10581
+ var replaceCarets = (comp, options) => {
10582
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
10583
+ };
10584
+ var replaceCaret = (comp, options) => {
10585
+ debug("caret", comp, options);
10586
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
10587
+ const z2 = options.includePrerelease ? "-0" : "";
10588
+ return comp.replace(r, (_, M, m, p, pr) => {
10589
+ debug("caret", comp, _, M, m, p, pr);
10590
+ let ret;
10591
+ if (isX(M)) {
10592
+ ret = "";
10593
+ } else if (isX(m)) {
10594
+ ret = `>=${M}.0.0${z2} <${+M + 1}.0.0-0`;
10595
+ } else if (isX(p)) {
10596
+ if (M === "0") {
10597
+ ret = `>=${M}.${m}.0${z2} <${M}.${+m + 1}.0-0`;
10598
+ } else {
10599
+ ret = `>=${M}.${m}.0${z2} <${+M + 1}.0.0-0`;
10600
+ }
10601
+ } else if (pr) {
10602
+ debug("replaceCaret pr", pr);
10603
+ if (M === "0") {
10604
+ if (m === "0") {
10605
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
10606
+ } else {
10607
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
10608
+ }
10609
+ } else {
10610
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
10611
+ }
10612
+ } else {
10613
+ debug("no pr");
10614
+ if (M === "0") {
10615
+ if (m === "0") {
10616
+ ret = `>=${M}.${m}.${p}${z2} <${M}.${m}.${+p + 1}-0`;
10617
+ } else {
10618
+ ret = `>=${M}.${m}.${p}${z2} <${M}.${+m + 1}.0-0`;
10619
+ }
10620
+ } else {
10621
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
10622
+ }
10623
+ }
10624
+ debug("caret return", ret);
10625
+ return ret;
10626
+ });
10627
+ };
10628
+ var replaceXRanges = (comp, options) => {
10629
+ debug("replaceXRanges", comp, options);
10630
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
10631
+ };
10632
+ var replaceXRange = (comp, options) => {
10633
+ comp = comp.trim();
10634
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
10635
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
10636
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
10637
+ const xM = isX(M);
10638
+ const xm = xM || isX(m);
10639
+ const xp = xm || isX(p);
10640
+ const anyX = xp;
10641
+ if (gtlt === "=" && anyX) {
10642
+ gtlt = "";
10643
+ }
10644
+ pr = options.includePrerelease ? "-0" : "";
10645
+ if (xM) {
10646
+ if (gtlt === ">" || gtlt === "<") {
10647
+ ret = "<0.0.0-0";
10648
+ } else {
10649
+ ret = "*";
10650
+ }
10651
+ } else if (gtlt && anyX) {
10652
+ if (xm) {
10653
+ m = 0;
10654
+ }
10655
+ p = 0;
10656
+ if (gtlt === ">") {
10657
+ gtlt = ">=";
10658
+ if (xm) {
10659
+ M = +M + 1;
10660
+ m = 0;
10661
+ p = 0;
10662
+ } else {
10663
+ m = +m + 1;
10664
+ p = 0;
10665
+ }
10666
+ } else if (gtlt === "<=") {
10667
+ gtlt = "<";
10668
+ if (xm) {
10669
+ M = +M + 1;
10670
+ } else {
10671
+ m = +m + 1;
10672
+ }
10673
+ }
10674
+ if (gtlt === "<") {
10675
+ pr = "-0";
10676
+ }
10677
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
10678
+ } else if (xm) {
10679
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
10680
+ } else if (xp) {
10681
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
10682
+ }
10683
+ debug("xRange return", ret);
10684
+ return ret;
10685
+ });
10686
+ };
10687
+ var replaceStars = (comp, options) => {
10688
+ debug("replaceStars", comp, options);
10689
+ return comp.trim().replace(re[t.STAR], "");
10690
+ };
10691
+ var replaceGTE0 = (comp, options) => {
10692
+ debug("replaceGTE0", comp, options);
10693
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
10694
+ };
10695
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
10696
+ if (isX(fM)) {
10697
+ from = "";
10698
+ } else if (isX(fm)) {
10699
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
10700
+ } else if (isX(fp)) {
10701
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
10702
+ } else if (fpr) {
10703
+ from = `>=${from}`;
10704
+ } else {
10705
+ from = `>=${from}${incPr ? "-0" : ""}`;
10706
+ }
10707
+ if (isX(tM)) {
10708
+ to = "";
10709
+ } else if (isX(tm)) {
10710
+ to = `<${+tM + 1}.0.0-0`;
10711
+ } else if (isX(tp)) {
10712
+ to = `<${tM}.${+tm + 1}.0-0`;
10713
+ } else if (tpr) {
10714
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
10715
+ } else if (incPr) {
10716
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
10717
+ } else {
10718
+ to = `<=${to}`;
10719
+ }
10720
+ return `${from} ${to}`.trim();
10721
+ };
10722
+ var testSet = (set2, version2, options) => {
10723
+ for (let i = 0;i < set2.length; i++) {
10724
+ if (!set2[i].test(version2)) {
10725
+ return false;
10726
+ }
10727
+ }
10728
+ if (version2.prerelease.length && !options.includePrerelease) {
10729
+ for (let i = 0;i < set2.length; i++) {
10730
+ debug(set2[i].semver);
10731
+ if (set2[i].semver === Comparator.ANY) {
10732
+ continue;
10733
+ }
10734
+ if (set2[i].semver.prerelease.length > 0) {
10735
+ const allowed = set2[i].semver;
10736
+ if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
10737
+ return true;
10738
+ }
10739
+ }
10740
+ }
10741
+ return false;
10742
+ }
10743
+ return true;
10744
+ };
10745
+ });
10746
+
10747
+ // node_modules/semver/classes/comparator.js
10748
+ var require_comparator = __commonJS((exports, module) => {
10749
+ var ANY = Symbol("SemVer ANY");
10750
+
10751
+ class Comparator {
10752
+ static get ANY() {
10753
+ return ANY;
10754
+ }
10755
+ constructor(comp, options) {
10756
+ options = parseOptions(options);
10757
+ if (comp instanceof Comparator) {
10758
+ if (comp.loose === !!options.loose) {
10759
+ return comp;
10760
+ } else {
10761
+ comp = comp.value;
10762
+ }
10763
+ }
10764
+ comp = comp.trim().split(/\s+/).join(" ");
10765
+ debug("comparator", comp, options);
10766
+ this.options = options;
10767
+ this.loose = !!options.loose;
10768
+ this.parse(comp);
10769
+ if (this.semver === ANY) {
10770
+ this.value = "";
10771
+ } else {
10772
+ this.value = this.operator + this.semver.version;
10773
+ }
10774
+ debug("comp", this);
10775
+ }
10776
+ parse(comp) {
10777
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
10778
+ const m = comp.match(r);
10779
+ if (!m) {
10780
+ throw new TypeError(`Invalid comparator: ${comp}`);
10781
+ }
10782
+ this.operator = m[1] !== undefined ? m[1] : "";
10783
+ if (this.operator === "=") {
10784
+ this.operator = "";
10785
+ }
10786
+ if (!m[2]) {
10787
+ this.semver = ANY;
10788
+ } else {
10789
+ this.semver = new SemVer(m[2], this.options.loose);
10790
+ }
10791
+ }
10792
+ toString() {
10793
+ return this.value;
10794
+ }
10795
+ test(version2) {
10796
+ debug("Comparator.test", version2, this.options.loose);
10797
+ if (this.semver === ANY || version2 === ANY) {
10798
+ return true;
10799
+ }
10800
+ if (typeof version2 === "string") {
10801
+ try {
10802
+ version2 = new SemVer(version2, this.options);
10803
+ } catch (er) {
10804
+ return false;
10805
+ }
10806
+ }
10807
+ return cmp(version2, this.operator, this.semver, this.options);
10808
+ }
10809
+ intersects(comp, options) {
10810
+ if (!(comp instanceof Comparator)) {
10811
+ throw new TypeError("a Comparator is required");
10812
+ }
10813
+ if (this.operator === "") {
10814
+ if (this.value === "") {
10815
+ return true;
10816
+ }
10817
+ return new Range(comp.value, options).test(this.value);
10818
+ } else if (comp.operator === "") {
10819
+ if (comp.value === "") {
10820
+ return true;
10821
+ }
10822
+ return new Range(this.value, options).test(comp.semver);
10823
+ }
10824
+ options = parseOptions(options);
10825
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
10826
+ return false;
10827
+ }
10828
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
10829
+ return false;
10830
+ }
10831
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
10832
+ return true;
10833
+ }
10834
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
10835
+ return true;
10836
+ }
10837
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
10838
+ return true;
10839
+ }
10840
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
10841
+ return true;
10842
+ }
10843
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
10844
+ return true;
10845
+ }
10846
+ return false;
10847
+ }
10848
+ }
10849
+ module.exports = Comparator;
10850
+ var parseOptions = require_parse_options();
10851
+ var { safeRe: re, t } = require_re();
10852
+ var cmp = require_cmp();
10853
+ var debug = require_debug();
10854
+ var SemVer = require_semver();
10855
+ var Range = require_range();
10856
+ });
10857
+
10858
+ // node_modules/semver/functions/satisfies.js
10859
+ var require_satisfies = __commonJS((exports, module) => {
10860
+ var Range = require_range();
10861
+ var satisfies = (version2, range, options) => {
10862
+ try {
10863
+ range = new Range(range, options);
10864
+ } catch (er) {
10865
+ return false;
10866
+ }
10867
+ return range.test(version2);
10868
+ };
10869
+ module.exports = satisfies;
10870
+ });
10871
+
10872
+ // node_modules/semver/ranges/to-comparators.js
10873
+ var require_to_comparators = __commonJS((exports, module) => {
10874
+ var Range = require_range();
10875
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
10876
+ module.exports = toComparators;
10877
+ });
10878
+
10879
+ // node_modules/semver/ranges/max-satisfying.js
10880
+ var require_max_satisfying = __commonJS((exports, module) => {
10881
+ var SemVer = require_semver();
10882
+ var Range = require_range();
10883
+ var maxSatisfying = (versions2, range, options) => {
10884
+ let max = null;
10885
+ let maxSV = null;
10886
+ let rangeObj = null;
10887
+ try {
10888
+ rangeObj = new Range(range, options);
10889
+ } catch (er) {
10890
+ return null;
10891
+ }
10892
+ versions2.forEach((v) => {
10893
+ if (rangeObj.test(v)) {
10894
+ if (!max || maxSV.compare(v) === -1) {
10895
+ max = v;
10896
+ maxSV = new SemVer(max, options);
10897
+ }
10898
+ }
10899
+ });
10900
+ return max;
10901
+ };
10902
+ module.exports = maxSatisfying;
10903
+ });
10904
+
10905
+ // node_modules/semver/ranges/min-satisfying.js
10906
+ var require_min_satisfying = __commonJS((exports, module) => {
10907
+ var SemVer = require_semver();
10908
+ var Range = require_range();
10909
+ var minSatisfying = (versions2, range, options) => {
10910
+ let min = null;
10911
+ let minSV = null;
10912
+ let rangeObj = null;
10913
+ try {
10914
+ rangeObj = new Range(range, options);
10915
+ } catch (er) {
10916
+ return null;
10917
+ }
10918
+ versions2.forEach((v) => {
10919
+ if (rangeObj.test(v)) {
10920
+ if (!min || minSV.compare(v) === 1) {
10921
+ min = v;
10922
+ minSV = new SemVer(min, options);
10923
+ }
10924
+ }
10925
+ });
10926
+ return min;
10927
+ };
10928
+ module.exports = minSatisfying;
10929
+ });
10930
+
10931
+ // node_modules/semver/ranges/min-version.js
10932
+ var require_min_version = __commonJS((exports, module) => {
10933
+ var SemVer = require_semver();
10934
+ var Range = require_range();
10935
+ var gt = require_gt();
10936
+ var minVersion = (range, loose) => {
10937
+ range = new Range(range, loose);
10938
+ let minver = new SemVer("0.0.0");
10939
+ if (range.test(minver)) {
10940
+ return minver;
10941
+ }
10942
+ minver = new SemVer("0.0.0-0");
10943
+ if (range.test(minver)) {
10944
+ return minver;
10945
+ }
10946
+ minver = null;
10947
+ for (let i = 0;i < range.set.length; ++i) {
10948
+ const comparators = range.set[i];
10949
+ let setMin = null;
10950
+ comparators.forEach((comparator) => {
10951
+ const compver = new SemVer(comparator.semver.version);
10952
+ switch (comparator.operator) {
10953
+ case ">":
10954
+ if (compver.prerelease.length === 0) {
10955
+ compver.patch++;
10956
+ } else {
10957
+ compver.prerelease.push(0);
10958
+ }
10959
+ compver.raw = compver.format();
10960
+ case "":
10961
+ case ">=":
10962
+ if (!setMin || gt(compver, setMin)) {
10963
+ setMin = compver;
10964
+ }
10965
+ break;
10966
+ case "<":
10967
+ case "<=":
10968
+ break;
10969
+ default:
10970
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
10971
+ }
10972
+ });
10973
+ if (setMin && (!minver || gt(minver, setMin))) {
10974
+ minver = setMin;
10975
+ }
10976
+ }
10977
+ if (minver && range.test(minver)) {
10978
+ return minver;
10979
+ }
10980
+ return null;
10981
+ };
10982
+ module.exports = minVersion;
10983
+ });
10984
+
10985
+ // node_modules/semver/ranges/valid.js
10986
+ var require_valid2 = __commonJS((exports, module) => {
10987
+ var Range = require_range();
10988
+ var validRange = (range, options) => {
10989
+ try {
10990
+ return new Range(range, options).range || "*";
10991
+ } catch (er) {
10992
+ return null;
10993
+ }
10994
+ };
10995
+ module.exports = validRange;
10996
+ });
10997
+
10998
+ // node_modules/semver/ranges/outside.js
10999
+ var require_outside = __commonJS((exports, module) => {
11000
+ var SemVer = require_semver();
11001
+ var Comparator = require_comparator();
11002
+ var { ANY } = Comparator;
11003
+ var Range = require_range();
11004
+ var satisfies = require_satisfies();
11005
+ var gt = require_gt();
11006
+ var lt = require_lt();
11007
+ var lte = require_lte();
11008
+ var gte = require_gte();
11009
+ var outside = (version2, range, hilo, options) => {
11010
+ version2 = new SemVer(version2, options);
11011
+ range = new Range(range, options);
11012
+ let gtfn, ltefn, ltfn, comp, ecomp;
11013
+ switch (hilo) {
11014
+ case ">":
11015
+ gtfn = gt;
11016
+ ltefn = lte;
11017
+ ltfn = lt;
11018
+ comp = ">";
11019
+ ecomp = ">=";
11020
+ break;
11021
+ case "<":
11022
+ gtfn = lt;
11023
+ ltefn = gte;
11024
+ ltfn = gt;
11025
+ comp = "<";
11026
+ ecomp = "<=";
11027
+ break;
11028
+ default:
11029
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
11030
+ }
11031
+ if (satisfies(version2, range, options)) {
11032
+ return false;
11033
+ }
11034
+ for (let i = 0;i < range.set.length; ++i) {
11035
+ const comparators = range.set[i];
11036
+ let high = null;
11037
+ let low = null;
11038
+ comparators.forEach((comparator) => {
11039
+ if (comparator.semver === ANY) {
11040
+ comparator = new Comparator(">=0.0.0");
11041
+ }
11042
+ high = high || comparator;
11043
+ low = low || comparator;
11044
+ if (gtfn(comparator.semver, high.semver, options)) {
11045
+ high = comparator;
11046
+ } else if (ltfn(comparator.semver, low.semver, options)) {
11047
+ low = comparator;
11048
+ }
11049
+ });
11050
+ if (high.operator === comp || high.operator === ecomp) {
11051
+ return false;
11052
+ }
11053
+ if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
11054
+ return false;
11055
+ } else if (low.operator === ecomp && ltfn(version2, low.semver)) {
11056
+ return false;
11057
+ }
11058
+ }
11059
+ return true;
11060
+ };
11061
+ module.exports = outside;
11062
+ });
11063
+
11064
+ // node_modules/semver/ranges/gtr.js
11065
+ var require_gtr = __commonJS((exports, module) => {
11066
+ var outside = require_outside();
11067
+ var gtr = (version2, range, options) => outside(version2, range, ">", options);
11068
+ module.exports = gtr;
11069
+ });
11070
+
11071
+ // node_modules/semver/ranges/ltr.js
11072
+ var require_ltr = __commonJS((exports, module) => {
11073
+ var outside = require_outside();
11074
+ var ltr = (version2, range, options) => outside(version2, range, "<", options);
11075
+ module.exports = ltr;
11076
+ });
11077
+
11078
+ // node_modules/semver/ranges/intersects.js
11079
+ var require_intersects = __commonJS((exports, module) => {
11080
+ var Range = require_range();
11081
+ var intersects = (r1, r2, options) => {
11082
+ r1 = new Range(r1, options);
11083
+ r2 = new Range(r2, options);
11084
+ return r1.intersects(r2, options);
11085
+ };
11086
+ module.exports = intersects;
11087
+ });
11088
+
11089
+ // node_modules/semver/ranges/simplify.js
11090
+ var require_simplify = __commonJS((exports, module) => {
11091
+ var satisfies = require_satisfies();
11092
+ var compare = require_compare();
11093
+ module.exports = (versions2, range, options) => {
11094
+ const set2 = [];
11095
+ let first = null;
11096
+ let prev = null;
11097
+ const v = versions2.sort((a, b) => compare(a, b, options));
11098
+ for (const version2 of v) {
11099
+ const included = satisfies(version2, range, options);
11100
+ if (included) {
11101
+ prev = version2;
11102
+ if (!first) {
11103
+ first = version2;
11104
+ }
11105
+ } else {
11106
+ if (prev) {
11107
+ set2.push([first, prev]);
11108
+ }
11109
+ prev = null;
11110
+ first = null;
11111
+ }
11112
+ }
11113
+ if (first) {
11114
+ set2.push([first, null]);
11115
+ }
11116
+ const ranges = [];
11117
+ for (const [min, max] of set2) {
11118
+ if (min === max) {
11119
+ ranges.push(min);
11120
+ } else if (!max && min === v[0]) {
11121
+ ranges.push("*");
11122
+ } else if (!max) {
11123
+ ranges.push(`>=${min}`);
11124
+ } else if (min === v[0]) {
11125
+ ranges.push(`<=${max}`);
11126
+ } else {
11127
+ ranges.push(`${min} - ${max}`);
11128
+ }
11129
+ }
11130
+ const simplified = ranges.join(" || ");
11131
+ const original = typeof range.raw === "string" ? range.raw : String(range);
11132
+ return simplified.length < original.length ? simplified : range;
11133
+ };
11134
+ });
11135
+
11136
+ // node_modules/semver/ranges/subset.js
11137
+ var require_subset = __commonJS((exports, module) => {
11138
+ var Range = require_range();
11139
+ var Comparator = require_comparator();
11140
+ var { ANY } = Comparator;
11141
+ var satisfies = require_satisfies();
11142
+ var compare = require_compare();
11143
+ var subset = (sub, dom, options = {}) => {
11144
+ if (sub === dom) {
11145
+ return true;
11146
+ }
11147
+ sub = new Range(sub, options);
11148
+ dom = new Range(dom, options);
11149
+ let sawNonNull = false;
11150
+ OUTER:
11151
+ for (const simpleSub of sub.set) {
11152
+ for (const simpleDom of dom.set) {
11153
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
11154
+ sawNonNull = sawNonNull || isSub !== null;
11155
+ if (isSub) {
11156
+ continue OUTER;
11157
+ }
11158
+ }
11159
+ if (sawNonNull) {
11160
+ return false;
11161
+ }
11162
+ }
11163
+ return true;
11164
+ };
11165
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
11166
+ var minimumVersion = [new Comparator(">=0.0.0")];
11167
+ var simpleSubset = (sub, dom, options) => {
11168
+ if (sub === dom) {
11169
+ return true;
11170
+ }
11171
+ if (sub.length === 1 && sub[0].semver === ANY) {
11172
+ if (dom.length === 1 && dom[0].semver === ANY) {
11173
+ return true;
11174
+ } else if (options.includePrerelease) {
11175
+ sub = minimumVersionWithPreRelease;
11176
+ } else {
11177
+ sub = minimumVersion;
11178
+ }
11179
+ }
11180
+ if (dom.length === 1 && dom[0].semver === ANY) {
11181
+ if (options.includePrerelease) {
11182
+ return true;
11183
+ } else {
11184
+ dom = minimumVersion;
11185
+ }
11186
+ }
11187
+ const eqSet = new Set;
11188
+ let gt, lt;
11189
+ for (const c of sub) {
11190
+ if (c.operator === ">" || c.operator === ">=") {
11191
+ gt = higherGT(gt, c, options);
11192
+ } else if (c.operator === "<" || c.operator === "<=") {
11193
+ lt = lowerLT(lt, c, options);
11194
+ } else {
11195
+ eqSet.add(c.semver);
11196
+ }
11197
+ }
11198
+ if (eqSet.size > 1) {
11199
+ return null;
11200
+ }
11201
+ let gtltComp;
11202
+ if (gt && lt) {
11203
+ gtltComp = compare(gt.semver, lt.semver, options);
11204
+ if (gtltComp > 0) {
11205
+ return null;
11206
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
11207
+ return null;
11208
+ }
11209
+ }
11210
+ for (const eq of eqSet) {
11211
+ if (gt && !satisfies(eq, String(gt), options)) {
11212
+ return null;
11213
+ }
11214
+ if (lt && !satisfies(eq, String(lt), options)) {
11215
+ return null;
11216
+ }
11217
+ for (const c of dom) {
11218
+ if (!satisfies(eq, String(c), options)) {
11219
+ return false;
11220
+ }
11221
+ }
11222
+ return true;
11223
+ }
11224
+ let higher, lower;
11225
+ let hasDomLT, hasDomGT;
11226
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
11227
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
11228
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
11229
+ needDomLTPre = false;
11230
+ }
11231
+ for (const c of dom) {
11232
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
11233
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
11234
+ if (gt) {
11235
+ if (needDomGTPre) {
11236
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
11237
+ needDomGTPre = false;
11238
+ }
11239
+ }
11240
+ if (c.operator === ">" || c.operator === ">=") {
11241
+ higher = higherGT(gt, c, options);
11242
+ if (higher === c && higher !== gt) {
11243
+ return false;
11244
+ }
11245
+ } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) {
11246
+ return false;
11247
+ }
11248
+ }
11249
+ if (lt) {
11250
+ if (needDomLTPre) {
11251
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
11252
+ needDomLTPre = false;
11253
+ }
11254
+ }
11255
+ if (c.operator === "<" || c.operator === "<=") {
11256
+ lower = lowerLT(lt, c, options);
11257
+ if (lower === c && lower !== lt) {
11258
+ return false;
11259
+ }
11260
+ } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) {
11261
+ return false;
11262
+ }
11263
+ }
11264
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
11265
+ return false;
11266
+ }
11267
+ }
11268
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
11269
+ return false;
11270
+ }
11271
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
11272
+ return false;
11273
+ }
11274
+ if (needDomGTPre || needDomLTPre) {
11275
+ return false;
11276
+ }
11277
+ return true;
11278
+ };
11279
+ var higherGT = (a, b, options) => {
11280
+ if (!a) {
11281
+ return b;
11282
+ }
11283
+ const comp = compare(a.semver, b.semver, options);
11284
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
11285
+ };
11286
+ var lowerLT = (a, b, options) => {
11287
+ if (!a) {
11288
+ return b;
11289
+ }
11290
+ const comp = compare(a.semver, b.semver, options);
11291
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
11292
+ };
11293
+ module.exports = subset;
11294
+ });
11295
+
11296
+ // node_modules/semver/index.js
11297
+ var require_semver2 = __commonJS((exports, module) => {
11298
+ var internalRe = require_re();
11299
+ var constants = require_constants();
11300
+ var SemVer = require_semver();
11301
+ var identifiers = require_identifiers();
11302
+ var parse5 = require_parse();
11303
+ var valid = require_valid();
11304
+ var clean = require_clean();
11305
+ var inc = require_inc();
11306
+ var diff = require_diff();
11307
+ var major = require_major();
11308
+ var minor = require_minor();
11309
+ var patch = require_patch();
11310
+ var prerelease = require_prerelease();
11311
+ var compare = require_compare();
11312
+ var rcompare = require_rcompare();
11313
+ var compareLoose = require_compare_loose();
11314
+ var compareBuild = require_compare_build();
11315
+ var sort = require_sort();
11316
+ var rsort = require_rsort();
11317
+ var gt = require_gt();
11318
+ var lt = require_lt();
11319
+ var eq = require_eq();
11320
+ var neq = require_neq();
11321
+ var gte = require_gte();
11322
+ var lte = require_lte();
11323
+ var cmp = require_cmp();
11324
+ var coerce = require_coerce();
11325
+ var Comparator = require_comparator();
11326
+ var Range = require_range();
11327
+ var satisfies = require_satisfies();
11328
+ var toComparators = require_to_comparators();
11329
+ var maxSatisfying = require_max_satisfying();
11330
+ var minSatisfying = require_min_satisfying();
11331
+ var minVersion = require_min_version();
11332
+ var validRange = require_valid2();
11333
+ var outside = require_outside();
11334
+ var gtr = require_gtr();
11335
+ var ltr = require_ltr();
11336
+ var intersects = require_intersects();
11337
+ var simplifyRange = require_simplify();
11338
+ var subset = require_subset();
11339
+ module.exports = {
11340
+ parse: parse5,
11341
+ valid,
11342
+ clean,
11343
+ inc,
11344
+ diff,
11345
+ major,
11346
+ minor,
11347
+ patch,
11348
+ prerelease,
11349
+ compare,
11350
+ rcompare,
11351
+ compareLoose,
11352
+ compareBuild,
11353
+ sort,
11354
+ rsort,
11355
+ gt,
11356
+ lt,
11357
+ eq,
11358
+ neq,
11359
+ gte,
11360
+ lte,
11361
+ cmp,
11362
+ coerce,
11363
+ Comparator,
11364
+ Range,
11365
+ satisfies,
11366
+ toComparators,
11367
+ maxSatisfying,
11368
+ minSatisfying,
11369
+ minVersion,
11370
+ validRange,
11371
+ outside,
11372
+ gtr,
11373
+ ltr,
11374
+ intersects,
11375
+ simplifyRange,
11376
+ subset,
11377
+ SemVer,
11378
+ re: internalRe.re,
11379
+ src: internalRe.src,
11380
+ tokens: internalRe.t,
11381
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
11382
+ RELEASE_TYPES: constants.RELEASE_TYPES,
11383
+ compareIdentifiers: identifiers.compareIdentifiers,
11384
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
11385
+ };
11386
+ });
11387
+
11388
+ // node_modules/chalk/source/vendor/ansi-styles/index.js
11389
+ var ANSI_BACKGROUND_OFFSET = 10;
11390
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
11391
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
11392
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
11393
+ var styles = {
11394
+ modifier: {
11395
+ reset: [0, 0],
11396
+ bold: [1, 22],
11397
+ dim: [2, 22],
11398
+ italic: [3, 23],
11399
+ underline: [4, 24],
11400
+ overline: [53, 55],
11401
+ inverse: [7, 27],
11402
+ hidden: [8, 28],
11403
+ strikethrough: [9, 29]
11404
+ },
11405
+ color: {
11406
+ black: [30, 39],
11407
+ red: [31, 39],
11408
+ green: [32, 39],
11409
+ yellow: [33, 39],
11410
+ blue: [34, 39],
11411
+ magenta: [35, 39],
11412
+ cyan: [36, 39],
11413
+ white: [37, 39],
11414
+ blackBright: [90, 39],
11415
+ gray: [90, 39],
11416
+ grey: [90, 39],
11417
+ redBright: [91, 39],
11418
+ greenBright: [92, 39],
11419
+ yellowBright: [93, 39],
11420
+ blueBright: [94, 39],
11421
+ magentaBright: [95, 39],
11422
+ cyanBright: [96, 39],
11423
+ whiteBright: [97, 39]
11424
+ },
11425
+ bgColor: {
11426
+ bgBlack: [40, 49],
11427
+ bgRed: [41, 49],
11428
+ bgGreen: [42, 49],
11429
+ bgYellow: [43, 49],
11430
+ bgBlue: [44, 49],
11431
+ bgMagenta: [45, 49],
11432
+ bgCyan: [46, 49],
11433
+ bgWhite: [47, 49],
11434
+ bgBlackBright: [100, 49],
11435
+ bgGray: [100, 49],
11436
+ bgGrey: [100, 49],
11437
+ bgRedBright: [101, 49],
11438
+ bgGreenBright: [102, 49],
11439
+ bgYellowBright: [103, 49],
11440
+ bgBlueBright: [104, 49],
11441
+ bgMagentaBright: [105, 49],
11442
+ bgCyanBright: [106, 49],
11443
+ bgWhiteBright: [107, 49]
11444
+ }
11445
+ };
11446
+ var modifierNames = Object.keys(styles.modifier);
11447
+ var foregroundColorNames = Object.keys(styles.color);
11448
+ var backgroundColorNames = Object.keys(styles.bgColor);
11449
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
11450
+ function assembleStyles() {
11451
+ const codes = new Map;
11452
+ for (const [groupName, group] of Object.entries(styles)) {
11453
+ for (const [styleName, style] of Object.entries(group)) {
11454
+ styles[styleName] = {
11455
+ open: `\x1B[${style[0]}m`,
11456
+ close: `\x1B[${style[1]}m`
11457
+ };
11458
+ group[styleName] = styles[styleName];
11459
+ codes.set(style[0], style[1]);
11460
+ }
11461
+ Object.defineProperty(styles, groupName, {
11462
+ value: group,
11463
+ enumerable: false
11464
+ });
11465
+ }
11466
+ Object.defineProperty(styles, "codes", {
11467
+ value: codes,
11468
+ enumerable: false
11469
+ });
11470
+ styles.color.close = "\x1B[39m";
11471
+ styles.bgColor.close = "\x1B[49m";
11472
+ styles.color.ansi = wrapAnsi16();
11473
+ styles.color.ansi256 = wrapAnsi256();
11474
+ styles.color.ansi16m = wrapAnsi16m();
11475
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
11476
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
11477
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
11478
+ Object.defineProperties(styles, {
11479
+ rgbToAnsi256: {
11480
+ value(red, green, blue) {
11481
+ if (red === green && green === blue) {
11482
+ if (red < 8) {
11483
+ return 16;
11484
+ }
11485
+ if (red > 248) {
11486
+ return 231;
11487
+ }
11488
+ return Math.round((red - 8) / 247 * 24) + 232;
11489
+ }
11490
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
11491
+ },
11492
+ enumerable: false
11493
+ },
11494
+ hexToRgb: {
11495
+ value(hex) {
11496
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
11497
+ if (!matches) {
11498
+ return [0, 0, 0];
11499
+ }
11500
+ let [colorString] = matches;
11501
+ if (colorString.length === 3) {
11502
+ colorString = [...colorString].map((character) => character + character).join("");
11503
+ }
11504
+ const integer = Number.parseInt(colorString, 16);
11505
+ return [
11506
+ integer >> 16 & 255,
11507
+ integer >> 8 & 255,
11508
+ integer & 255
11509
+ ];
11510
+ },
11511
+ enumerable: false
11512
+ },
11513
+ hexToAnsi256: {
11514
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
11515
+ enumerable: false
11516
+ },
11517
+ ansi256ToAnsi: {
11518
+ value(code) {
11519
+ if (code < 8) {
11520
+ return 30 + code;
11521
+ }
11522
+ if (code < 16) {
11523
+ return 90 + (code - 8);
11524
+ }
11525
+ let red;
11526
+ let green;
11527
+ let blue;
11528
+ if (code >= 232) {
11529
+ red = ((code - 232) * 10 + 8) / 255;
11530
+ green = red;
11531
+ blue = red;
11532
+ } else {
11533
+ code -= 16;
11534
+ const remainder = code % 36;
11535
+ red = Math.floor(code / 36) / 5;
11536
+ green = Math.floor(remainder / 6) / 5;
11537
+ blue = remainder % 6 / 5;
11538
+ }
11539
+ const value = Math.max(red, green, blue) * 2;
11540
+ if (value === 0) {
11541
+ return 30;
11542
+ }
11543
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
11544
+ if (value === 2) {
11545
+ result += 60;
11546
+ }
11547
+ return result;
11548
+ },
11549
+ enumerable: false
11550
+ },
11551
+ rgbToAnsi: {
11552
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
11553
+ enumerable: false
11554
+ },
11555
+ hexToAnsi: {
11556
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
11557
+ enumerable: false
11558
+ }
11559
+ });
11560
+ return styles;
11561
+ }
11562
+ var ansiStyles = assembleStyles();
11563
+ var ansi_styles_default = ansiStyles;
11564
+
11565
+ // node_modules/chalk/source/vendor/supports-color/index.js
11566
+ import process2 from "node:process";
11567
+ import os from "node:os";
11568
+ import tty from "node:tty";
11569
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
11570
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
11571
+ const position = argv.indexOf(prefix + flag);
11572
+ const terminatorPosition = argv.indexOf("--");
11573
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
11574
+ }
11575
+ var { env } = process2;
11576
+ var flagForceColor;
11577
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
11578
+ flagForceColor = 0;
11579
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
11580
+ flagForceColor = 1;
11581
+ }
11582
+ function envForceColor() {
11583
+ if ("FORCE_COLOR" in env) {
11584
+ if (env.FORCE_COLOR === "true") {
11585
+ return 1;
11586
+ }
11587
+ if (env.FORCE_COLOR === "false") {
9687
11588
  return 0;
9688
11589
  }
9689
11590
  return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
@@ -24582,6 +26483,9 @@ var PROJECT_TYPE_INDICATORS = {
24582
26483
  cli: ["commander", "yargs", "meow", "cac"]
24583
26484
  };
24584
26485
 
26486
+ // src/lib/config.ts
26487
+ init_errors();
26488
+
24585
26489
  // src/lib/templates.ts
24586
26490
  var HONO_TEMPLATE = {
24587
26491
  name: "hono",
@@ -25312,18 +27216,39 @@ async function readConfig(projectRoot) {
25312
27216
  }
25313
27217
  try {
25314
27218
  const content = await readFile(configPath, "utf-8");
25315
- const parsed = JSON.parse(content);
27219
+ let parsed;
27220
+ try {
27221
+ parsed = JSON.parse(content);
27222
+ } catch (parseError) {
27223
+ throw new ConfigError("Config file contains invalid JSON", {
27224
+ configPath,
27225
+ hint: `Check ${configPath} for syntax errors (missing commas, brackets, quotes), or run \`pdi init --force\` to regenerate.`,
27226
+ cause: parseError instanceof Error ? parseError : undefined
27227
+ });
27228
+ }
25316
27229
  const result = PDIConfigSchema.safeParse(parsed);
25317
27230
  if (!result.success) {
25318
- const issues = result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
25319
- throw new Error(`Invalid config: ${issues}`);
27231
+ const issues = result.error.issues.map((i) => ({
27232
+ path: i.path.join("."),
27233
+ message: i.message,
27234
+ expected: "expected" in i ? String(i.expected) : undefined
27235
+ }));
27236
+ throw new ConfigError("Config validation failed", {
27237
+ configPath,
27238
+ validationIssues: issues,
27239
+ hint: `Fix the fields above in ${configPath}, or run \`pdi init --force\` to regenerate.`
27240
+ });
25320
27241
  }
25321
27242
  return result.data;
25322
27243
  } catch (error48) {
25323
- if (error48 instanceof Error && error48.message.startsWith("Invalid config")) {
27244
+ if (error48 instanceof ConfigError) {
25324
27245
  throw error48;
25325
27246
  }
25326
- throw new Error(`Failed to read config: ${error48 instanceof Error ? error48.message : "Unknown error"}`);
27247
+ throw new ConfigError("Failed to read config file", {
27248
+ configPath,
27249
+ hint: `Check file permissions for ${configPath}.`,
27250
+ cause: error48 instanceof Error ? error48 : undefined
27251
+ });
25327
27252
  }
25328
27253
  }
25329
27254
  async function writeConfig(projectRoot, config2) {
@@ -25500,6 +27425,7 @@ ${content}`;
25500
27425
 
25501
27426
  // src/commands/add.ts
25502
27427
  init_context7_client();
27428
+ init_errors();
25503
27429
 
25504
27430
  // src/lib/fs-utils.ts
25505
27431
  import { existsSync as existsSync3 } from "node:fs";
@@ -25862,11 +27788,13 @@ async function addCommand(frameworks, options) {
25862
27788
  const projectRoot = options.projectRoot || process.cwd();
25863
27789
  const spinner = ora();
25864
27790
  if (!configExists(projectRoot)) {
25865
- throw new Error("PDI not initialized. Run: pdi init");
27791
+ throw new NotInitializedError;
25866
27792
  }
25867
27793
  let config2 = await readConfig(projectRoot);
25868
27794
  if (!config2) {
25869
- throw new Error("Failed to read config");
27795
+ throw new ConfigError("Config file exists but returned null", {
27796
+ hint: "Run `pdi init --force` to regenerate config."
27797
+ });
25870
27798
  }
25871
27799
  let selectedFrameworks = frameworks;
25872
27800
  if (selectedFrameworks.length === 0) {
@@ -26290,15 +28218,18 @@ async function loadApiKeyFromConfig() {
26290
28218
  // src/commands/clean.ts
26291
28219
  import { join as join6 } from "node:path";
26292
28220
  var import_prompts3 = __toESM(require_prompts3(), 1);
28221
+ init_errors();
26293
28222
  async function cleanCommand(options = {}) {
26294
28223
  const projectRoot = options.projectRoot || process.cwd();
26295
28224
  const spinner = ora();
26296
28225
  if (!configExists(projectRoot)) {
26297
- throw new Error("PDI not initialized. Run: pdi init");
28226
+ throw new NotInitializedError;
26298
28227
  }
26299
28228
  let config2 = await readConfig(projectRoot);
26300
28229
  if (!config2) {
26301
- throw new Error("Failed to read config");
28230
+ throw new ConfigError("Config file exists but returned null", {
28231
+ hint: "Run `pdi init --force` to regenerate config."
28232
+ });
26302
28233
  }
26303
28234
  const packageJson = await readPackageJson(projectRoot);
26304
28235
  const installed = packageJson ? detectDependencies(packageJson) : [];
@@ -26620,6 +28551,7 @@ Summary
26620
28551
  import { readdir as readdir2, readFile as readFile5, stat as stat2 } from "node:fs/promises";
26621
28552
  import { extname, join as join8, relative as relative2 } from "node:path";
26622
28553
  var import_prompts4 = __toESM(require_prompts3(), 1);
28554
+ init_errors();
26623
28555
  var PATTERN_DETECTORS = [
26624
28556
  {
26625
28557
  name: "Two-Schema Database Pattern",
@@ -27137,11 +29069,13 @@ async function generateCommand(type, options) {
27137
29069
  throw new Error(`Unknown type: ${type}. Available: internal`);
27138
29070
  }
27139
29071
  if (!configExists(projectRoot)) {
27140
- throw new Error("PDI not initialized. Run: pdi init");
29072
+ throw new NotInitializedError;
27141
29073
  }
27142
29074
  let config2 = await readConfig(projectRoot);
27143
29075
  if (!config2) {
27144
- throw new Error("Failed to read config");
29076
+ throw new ConfigError("Config file exists but returned null", {
29077
+ hint: "Run `pdi init --force` to regenerate config."
29078
+ });
27145
29079
  }
27146
29080
  console.log(source_default.bold(`Analyzing codebase...
27147
29081
  `));
@@ -27238,70 +29172,465 @@ async function initCommand(options) {
27238
29172
  console.log(source_default.dim("Use --force to reinitialize."));
27239
29173
  return;
27240
29174
  }
27241
- spinner.start("Reading package.json...");
27242
- const packageJson = await readPackageJson(projectRoot);
27243
- if (!packageJson) {
27244
- spinner.fail("No package.json found");
27245
- console.log(source_default.dim("Please run this command in a Node.js project directory."));
27246
- return;
29175
+ spinner.start("Reading package.json...");
29176
+ const packageJson = await readPackageJson(projectRoot);
29177
+ if (!packageJson) {
29178
+ spinner.fail("No package.json found");
29179
+ console.log(source_default.dim("Please run this command in a Node.js project directory."));
29180
+ return;
29181
+ }
29182
+ spinner.succeed("Found package.json");
29183
+ const projectType = detectProjectType(packageJson);
29184
+ const projectName = packageJson.name || "unnamed-project";
29185
+ console.log(source_default.dim(`Project: ${projectName} (${projectType})`));
29186
+ spinner.start("Creating .claude-docs/ structure...");
29187
+ const docsPath = join9(projectRoot, CLAUDE_DOCS_DIR);
29188
+ const frameworksPath = join9(docsPath, FRAMEWORKS_DIR);
29189
+ const internalPath = join9(docsPath, INTERNAL_DIR);
29190
+ await ensureDir(docsPath);
29191
+ await ensureDir(frameworksPath);
29192
+ if (options.internal) {
29193
+ await ensureDir(internalPath);
29194
+ }
29195
+ spinner.succeed("Created .claude-docs/");
29196
+ spinner.start("Creating config.json...");
29197
+ const config2 = createDefaultConfig(projectName, projectType);
29198
+ await writeConfig(projectRoot, config2);
29199
+ spinner.succeed("Created config.json");
29200
+ const gitignoreUpdated = await updateGitignore(projectRoot);
29201
+ if (gitignoreUpdated) {
29202
+ console.log(source_default.dim("Updated .gitignore"));
29203
+ }
29204
+ if (!options.noDetect) {
29205
+ console.log("");
29206
+ console.log(source_default.bold("Detected dependencies:"));
29207
+ const detected = detectDependencies(packageJson);
29208
+ if (detected.length === 0) {
29209
+ console.log(source_default.dim(" No supported frameworks detected."));
29210
+ } else {
29211
+ for (const dep of detected) {
29212
+ const templateStatus = hasTemplate(dep.framework?.name || "") ? source_default.green("docs available") : source_default.yellow("no template");
29213
+ const frameworkName = dep.framework?.displayName || dep.name;
29214
+ const version2 = dep.framework?.name ? getMajorVersion(dep.version) : dep.version;
29215
+ console.log(` ${source_default.dim("├──")} ${frameworkName}@${dep.version} → ${frameworkName.toLowerCase()}@${version2} ${templateStatus}`);
29216
+ }
29217
+ console.log("");
29218
+ const frameworkNames = detected.filter((d) => d.framework && hasTemplate(d.framework.name)).map((d) => d.framework.name);
29219
+ if (frameworkNames.length > 0) {
29220
+ console.log(source_default.bold("Next steps:"));
29221
+ console.log(` ${source_default.cyan(`pdi add ${frameworkNames.join(" ")}`)}`);
29222
+ console.log(source_default.dim(" Or run: pdi sync (auto-add all detected)"));
29223
+ }
29224
+ }
29225
+ }
29226
+ console.log("");
29227
+ console.log(source_default.green("✓ PDI initialized successfully"));
29228
+ }
29229
+
29230
+ // src/commands/status.ts
29231
+ init_errors();
29232
+
29233
+ // src/lib/freshness.ts
29234
+ var import_semver = __toESM(require_semver2(), 1);
29235
+
29236
+ // node_modules/yocto-queue/index.js
29237
+ class Node {
29238
+ value;
29239
+ next;
29240
+ constructor(value) {
29241
+ this.value = value;
29242
+ }
29243
+ }
29244
+
29245
+ class Queue {
29246
+ #head;
29247
+ #tail;
29248
+ #size;
29249
+ constructor() {
29250
+ this.clear();
29251
+ }
29252
+ enqueue(value) {
29253
+ const node = new Node(value);
29254
+ if (this.#head) {
29255
+ this.#tail.next = node;
29256
+ this.#tail = node;
29257
+ } else {
29258
+ this.#head = node;
29259
+ this.#tail = node;
29260
+ }
29261
+ this.#size++;
29262
+ }
29263
+ dequeue() {
29264
+ const current = this.#head;
29265
+ if (!current) {
29266
+ return;
29267
+ }
29268
+ this.#head = this.#head.next;
29269
+ this.#size--;
29270
+ if (!this.#head) {
29271
+ this.#tail = undefined;
29272
+ }
29273
+ return current.value;
29274
+ }
29275
+ peek() {
29276
+ if (!this.#head) {
29277
+ return;
29278
+ }
29279
+ return this.#head.value;
29280
+ }
29281
+ clear() {
29282
+ this.#head = undefined;
29283
+ this.#tail = undefined;
29284
+ this.#size = 0;
29285
+ }
29286
+ get size() {
29287
+ return this.#size;
29288
+ }
29289
+ *[Symbol.iterator]() {
29290
+ let current = this.#head;
29291
+ while (current) {
29292
+ yield current.value;
29293
+ current = current.next;
29294
+ }
29295
+ }
29296
+ *drain() {
29297
+ while (this.#head) {
29298
+ yield this.dequeue();
29299
+ }
29300
+ }
29301
+ }
29302
+
29303
+ // node_modules/p-limit/index.js
29304
+ function pLimit(concurrency) {
29305
+ validateConcurrency(concurrency);
29306
+ const queue = new Queue;
29307
+ let activeCount = 0;
29308
+ const resumeNext = () => {
29309
+ if (activeCount < concurrency && queue.size > 0) {
29310
+ queue.dequeue()();
29311
+ activeCount++;
29312
+ }
29313
+ };
29314
+ const next = () => {
29315
+ activeCount--;
29316
+ resumeNext();
29317
+ };
29318
+ const run = async (function_, resolve, arguments_) => {
29319
+ const result = (async () => function_(...arguments_))();
29320
+ resolve(result);
29321
+ try {
29322
+ await result;
29323
+ } catch {}
29324
+ next();
29325
+ };
29326
+ const enqueue = (function_, resolve, arguments_) => {
29327
+ new Promise((internalResolve) => {
29328
+ queue.enqueue(internalResolve);
29329
+ }).then(run.bind(undefined, function_, resolve, arguments_));
29330
+ (async () => {
29331
+ await Promise.resolve();
29332
+ if (activeCount < concurrency) {
29333
+ resumeNext();
29334
+ }
29335
+ })();
29336
+ };
29337
+ const generator = (function_, ...arguments_) => new Promise((resolve) => {
29338
+ enqueue(function_, resolve, arguments_);
29339
+ });
29340
+ Object.defineProperties(generator, {
29341
+ activeCount: {
29342
+ get: () => activeCount
29343
+ },
29344
+ pendingCount: {
29345
+ get: () => queue.size
29346
+ },
29347
+ clearQueue: {
29348
+ value() {
29349
+ queue.clear();
29350
+ }
29351
+ },
29352
+ concurrency: {
29353
+ get: () => concurrency,
29354
+ set(newConcurrency) {
29355
+ validateConcurrency(newConcurrency);
29356
+ concurrency = newConcurrency;
29357
+ queueMicrotask(() => {
29358
+ while (activeCount < concurrency && queue.size > 0) {
29359
+ resumeNext();
29360
+ }
29361
+ });
29362
+ }
29363
+ }
29364
+ });
29365
+ return generator;
29366
+ }
29367
+ function validateConcurrency(concurrency) {
29368
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
29369
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
29370
+ }
29371
+ }
29372
+
29373
+ // src/lib/registry-client.ts
29374
+ var NPM_REGISTRY_URL = "https://registry.npmjs.org";
29375
+ var ABBREVIATED_METADATA_ACCEPT = "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*";
29376
+ var REQUEST_TIMEOUT_MS = 5000;
29377
+ var MAX_CONCURRENCY = 5;
29378
+ async function fetchLatestVersion(packageName) {
29379
+ const encodedName = encodePackageName(packageName);
29380
+ const url2 = `${NPM_REGISTRY_URL}/${encodedName}`;
29381
+ const response = await fetch(url2, {
29382
+ headers: {
29383
+ Accept: ABBREVIATED_METADATA_ACCEPT
29384
+ },
29385
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
29386
+ });
29387
+ if (response.status === 404) {
29388
+ return null;
29389
+ }
29390
+ if (!response.ok) {
29391
+ throw new Error(`npm registry error for "${packageName}": HTTP ${response.status}`);
29392
+ }
29393
+ const data = await response.json();
29394
+ return data["dist-tags"]?.latest ?? null;
29395
+ }
29396
+ async function fetchLatestVersions(packageNames) {
29397
+ const results = new Map;
29398
+ if (packageNames.length === 0) {
29399
+ return results;
29400
+ }
29401
+ const limit = pLimit(MAX_CONCURRENCY);
29402
+ const tasks = packageNames.map((name) => limit(async () => {
29403
+ try {
29404
+ const version2 = await fetchLatestVersion(name);
29405
+ results.set(name, version2);
29406
+ } catch (error48) {
29407
+ console.error(`Failed to fetch version for "${name}":`, error48 instanceof Error ? error48.message : error48);
29408
+ results.set(name, null);
29409
+ }
29410
+ }));
29411
+ await Promise.all(tasks);
29412
+ return results;
29413
+ }
29414
+ function encodePackageName(name) {
29415
+ return encodeURIComponent(name);
29416
+ }
29417
+
29418
+ // src/lib/freshness.ts
29419
+ var EXIT_CODES = {
29420
+ SUCCESS: 0,
29421
+ STALE: 1,
29422
+ MISSING: 2,
29423
+ ORPHANED: 3,
29424
+ MIXED: 4,
29425
+ NETWORK_ERROR: 5
29426
+ };
29427
+ var DEFAULT_STALE_DAYS = 30;
29428
+ function checkVersionFreshness(indexedVersion, latestVersion) {
29429
+ const coercedIndexed = import_semver.default.coerce(indexedVersion);
29430
+ const coercedLatest = import_semver.default.coerce(latestVersion);
29431
+ if (!(coercedIndexed && coercedLatest)) {
29432
+ return { isStale: false, diffType: "uncoercible" };
29433
+ }
29434
+ const diff = import_semver.default.diff(coercedIndexed, coercedLatest);
29435
+ if (!diff) {
29436
+ return { isStale: false, diffType: null };
29437
+ }
29438
+ const staleTypes = new Set(["major", "minor", "premajor", "preminor"]);
29439
+ return {
29440
+ isStale: staleTypes.has(diff),
29441
+ diffType: diff
29442
+ };
29443
+ }
29444
+ async function checkFreshness(config2, packageJson, options) {
29445
+ const staleDays = options?.staleDays ?? DEFAULT_STALE_DAYS;
29446
+ const fetchVersions = options?.fetchVersionsFn ?? fetchLatestVersions;
29447
+ const results = [];
29448
+ const allDeps = {
29449
+ ...packageJson?.dependencies ?? {},
29450
+ ...packageJson?.devDependencies ?? {}
29451
+ };
29452
+ const frameworkToNpm = buildFrameworkToNpmMap();
29453
+ const npmToFramework = buildNpmToFrameworkMap();
29454
+ const npmPackagesToFetch = [];
29455
+ for (const frameworkName of Object.keys(config2.frameworks)) {
29456
+ const npmPkg = frameworkToNpm.get(frameworkName);
29457
+ if (npmPkg) {
29458
+ npmPackagesToFetch.push(npmPkg);
29459
+ }
29460
+ }
29461
+ let latestVersions;
29462
+ try {
29463
+ latestVersions = await fetchVersions(npmPackagesToFetch);
29464
+ } catch (error48) {
29465
+ console.error("Failed to fetch versions from registry:", error48);
29466
+ return {
29467
+ results: [],
29468
+ exitCode: EXIT_CODES.NETWORK_ERROR,
29469
+ summary: {
29470
+ total: 0,
29471
+ stale: 0,
29472
+ missing: 0,
29473
+ orphaned: 0,
29474
+ upToDate: 0,
29475
+ unknown: 0
29476
+ }
29477
+ };
27247
29478
  }
27248
- spinner.succeed("Found package.json");
27249
- const projectType = detectProjectType(packageJson);
27250
- const projectName = packageJson.name || "unnamed-project";
27251
- console.log(source_default.dim(`Project: ${projectName} (${projectType})`));
27252
- spinner.start("Creating .claude-docs/ structure...");
27253
- const docsPath = join9(projectRoot, CLAUDE_DOCS_DIR);
27254
- const frameworksPath = join9(docsPath, FRAMEWORKS_DIR);
27255
- const internalPath = join9(docsPath, INTERNAL_DIR);
27256
- await ensureDir(docsPath);
27257
- await ensureDir(frameworksPath);
27258
- if (options.internal) {
27259
- await ensureDir(internalPath);
29479
+ const processedFrameworks = new Set;
29480
+ for (const [frameworkName, frameworkConfig] of Object.entries(config2.frameworks)) {
29481
+ processedFrameworks.add(frameworkName);
29482
+ const npmPkg = frameworkToNpm.get(frameworkName);
29483
+ const knownFw = findKnownFramework(frameworkName);
29484
+ const displayName = knownFw?.displayName ?? frameworkName;
29485
+ const isInDeps = npmPkg ? npmPkg in allDeps : (frameworkName in allDeps);
29486
+ if (!isInDeps) {
29487
+ results.push({
29488
+ framework: frameworkName,
29489
+ displayName,
29490
+ indexedVersion: frameworkConfig.version,
29491
+ latestVersion: npmPkg ? latestVersions.get(npmPkg) ?? null : null,
29492
+ status: "orphaned",
29493
+ diffType: null
29494
+ });
29495
+ continue;
29496
+ }
29497
+ if (npmPkg) {
29498
+ const latest = latestVersions.get(npmPkg) ?? null;
29499
+ if (latest) {
29500
+ const { isStale, diffType } = checkVersionFreshness(frameworkConfig.version, latest);
29501
+ results.push({
29502
+ framework: frameworkName,
29503
+ displayName,
29504
+ indexedVersion: frameworkConfig.version,
29505
+ latestVersion: latest,
29506
+ status: isStale ? "stale" : "up-to-date",
29507
+ diffType
29508
+ });
29509
+ } else {
29510
+ results.push({
29511
+ framework: frameworkName,
29512
+ displayName,
29513
+ indexedVersion: frameworkConfig.version,
29514
+ latestVersion: null,
29515
+ status: "unknown",
29516
+ diffType: "fetch-failed"
29517
+ });
29518
+ }
29519
+ } else {
29520
+ const lastUpdateDate = new Date(frameworkConfig.lastUpdate);
29521
+ const isValidDate = !Number.isNaN(lastUpdateDate.getTime());
29522
+ if (!isValidDate) {
29523
+ results.push({
29524
+ framework: frameworkName,
29525
+ displayName,
29526
+ indexedVersion: frameworkConfig.version,
29527
+ latestVersion: null,
29528
+ status: "stale",
29529
+ diffType: "invalid-timestamp"
29530
+ });
29531
+ continue;
29532
+ }
29533
+ const daysSinceUpdate = Math.floor((Date.now() - lastUpdateDate.getTime()) / (1000 * 60 * 60 * 24));
29534
+ const isStale = daysSinceUpdate > staleDays;
29535
+ results.push({
29536
+ framework: frameworkName,
29537
+ displayName,
29538
+ indexedVersion: frameworkConfig.version,
29539
+ latestVersion: null,
29540
+ status: isStale ? "stale" : "up-to-date",
29541
+ diffType: isStale ? "timestamp" : null
29542
+ });
29543
+ }
27260
29544
  }
27261
- spinner.succeed("Created .claude-docs/");
27262
- spinner.start("Creating config.json...");
27263
- const config2 = createDefaultConfig(projectName, projectType);
27264
- await writeConfig(projectRoot, config2);
27265
- spinner.succeed("Created config.json");
27266
- const gitignoreUpdated = await updateGitignore(projectRoot);
27267
- if (gitignoreUpdated) {
27268
- console.log(source_default.dim("Updated .gitignore"));
29545
+ for (const depName of Object.keys(allDeps)) {
29546
+ const matched = npmToFramework.get(depName);
29547
+ if (matched && !processedFrameworks.has(matched.name)) {
29548
+ processedFrameworks.add(matched.name);
29549
+ results.push({
29550
+ framework: matched.name,
29551
+ displayName: matched.displayName,
29552
+ indexedVersion: "",
29553
+ latestVersion: null,
29554
+ status: "missing",
29555
+ diffType: null
29556
+ });
29557
+ }
27269
29558
  }
27270
- if (!options.noDetect) {
27271
- console.log("");
27272
- console.log(source_default.bold("Detected dependencies:"));
27273
- const detected = detectDependencies(packageJson);
27274
- if (detected.length === 0) {
27275
- console.log(source_default.dim(" No supported frameworks detected."));
27276
- } else {
27277
- for (const dep of detected) {
27278
- const templateStatus = hasTemplate(dep.framework?.name || "") ? source_default.green("docs available") : source_default.yellow("no template");
27279
- const frameworkName = dep.framework?.displayName || dep.name;
27280
- const version2 = dep.framework?.name ? getMajorVersion(dep.version) : dep.version;
27281
- console.log(` ${source_default.dim("├──")} ${frameworkName}@${dep.version} → ${frameworkName.toLowerCase()}@${version2} ${templateStatus}`);
29559
+ const summary = {
29560
+ total: results.length,
29561
+ stale: results.filter((r) => r.status === "stale").length,
29562
+ missing: results.filter((r) => r.status === "missing").length,
29563
+ orphaned: results.filter((r) => r.status === "orphaned").length,
29564
+ upToDate: results.filter((r) => r.status === "up-to-date").length,
29565
+ unknown: results.filter((r) => r.status === "unknown").length
29566
+ };
29567
+ const exitCode = computeExitCode(summary);
29568
+ return { results, exitCode, summary };
29569
+ }
29570
+ function buildFrameworkToNpmMap() {
29571
+ const map2 = new Map;
29572
+ for (const fw of KNOWN_FRAMEWORKS) {
29573
+ const source = fw.pattern.source;
29574
+ if (source.startsWith("^") && source.endsWith("$")) {
29575
+ const npmPkg = source.slice(1, -1).replace(/\\\//g, "/");
29576
+ if (!map2.has(fw.name)) {
29577
+ map2.set(fw.name, npmPkg);
27282
29578
  }
27283
- console.log("");
27284
- const frameworkNames = detected.filter((d) => d.framework && hasTemplate(d.framework.name)).map((d) => d.framework.name);
27285
- if (frameworkNames.length > 0) {
27286
- console.log(source_default.bold("Next steps:"));
27287
- console.log(` ${source_default.cyan(`pdi add ${frameworkNames.join(" ")}`)}`);
27288
- console.log(source_default.dim(" Or run: pdi sync (auto-add all detected)"));
29579
+ }
29580
+ }
29581
+ return map2;
29582
+ }
29583
+ function buildNpmToFrameworkMap() {
29584
+ const map2 = new Map;
29585
+ for (const fw of KNOWN_FRAMEWORKS) {
29586
+ const source = fw.pattern.source;
29587
+ if (source.startsWith("^") && source.endsWith("$")) {
29588
+ const npmPkg = source.slice(1, -1).replace(/\\\//g, "/");
29589
+ if (!map2.has(npmPkg)) {
29590
+ map2.set(npmPkg, { name: fw.name, displayName: fw.displayName });
27289
29591
  }
27290
29592
  }
27291
29593
  }
27292
- console.log("");
27293
- console.log(source_default.green("✓ PDI initialized successfully"));
29594
+ return map2;
29595
+ }
29596
+ function findKnownFramework(frameworkName) {
29597
+ return KNOWN_FRAMEWORKS.find((fw) => fw.name === frameworkName);
29598
+ }
29599
+ function computeExitCode(summary) {
29600
+ const problemTypes = [
29601
+ summary.stale > 0,
29602
+ summary.missing > 0,
29603
+ summary.orphaned > 0
29604
+ ].filter(Boolean).length;
29605
+ if (problemTypes === 0) {
29606
+ return EXIT_CODES.SUCCESS;
29607
+ }
29608
+ if (problemTypes > 1) {
29609
+ return EXIT_CODES.MIXED;
29610
+ }
29611
+ if (summary.stale > 0) {
29612
+ return EXIT_CODES.STALE;
29613
+ }
29614
+ if (summary.missing > 0) {
29615
+ return EXIT_CODES.MISSING;
29616
+ }
29617
+ if (summary.orphaned > 0) {
29618
+ return EXIT_CODES.ORPHANED;
29619
+ }
29620
+ return EXIT_CODES.SUCCESS;
27294
29621
  }
27295
29622
 
27296
29623
  // src/commands/status.ts
27297
29624
  async function statusCommand(options = {}) {
27298
29625
  const projectRoot = options.projectRoot || process.cwd();
27299
29626
  if (!configExists(projectRoot)) {
27300
- throw new Error("PDI not initialized. Run: pdi init");
29627
+ throw new NotInitializedError;
27301
29628
  }
27302
29629
  const config2 = await readConfig(projectRoot);
27303
29630
  if (!config2) {
27304
- throw new Error("Failed to read config");
29631
+ throw new ConfigError("Config file exists but returned null", {
29632
+ hint: "Run `pdi init --force` to regenerate config."
29633
+ });
27305
29634
  }
27306
29635
  const packageJson = await readPackageJson(projectRoot);
27307
29636
  const installedDeps = packageJson ? detectDependencies(packageJson) : [];
@@ -27312,6 +29641,61 @@ async function statusCommand(options = {}) {
27312
29641
  const internalIndex = buildInternalIndex(internalDocs);
27313
29642
  const sections = buildIndexSections(`.claude-docs/${FRAMEWORKS_DIR}`, ".claude-docs/internal", frameworksIndex, internalIndex);
27314
29643
  const indexSizeKb = calculateIndexSize(sections);
29644
+ let freshnessOutput;
29645
+ try {
29646
+ freshnessOutput = await checkFreshness(config2, packageJson);
29647
+ } catch (error48) {
29648
+ if (options.format === "json") {
29649
+ console.log(JSON.stringify({
29650
+ project: config2.project.name,
29651
+ timestamp: new Date().toISOString(),
29652
+ status: "issues_found",
29653
+ exitCode: EXIT_CODES.NETWORK_ERROR,
29654
+ issues: [
29655
+ {
29656
+ type: "network_error",
29657
+ message: error48 instanceof Error ? error48.message : String(error48)
29658
+ }
29659
+ ],
29660
+ summary: {
29661
+ total: 0,
29662
+ upToDate: 0,
29663
+ stale: 0,
29664
+ missing: 0,
29665
+ orphaned: 0,
29666
+ unknown: 0
29667
+ }
29668
+ }, null, 2));
29669
+ } else {
29670
+ console.error("");
29671
+ console.error(source_default.red("Freshness check failed:"), error48 instanceof Error ? error48.message : String(error48));
29672
+ }
29673
+ if (options.check) {
29674
+ process.exit(EXIT_CODES.NETWORK_ERROR);
29675
+ }
29676
+ return;
29677
+ }
29678
+ if (options.format === "json") {
29679
+ const issues = freshnessOutput.results.filter((r) => r.status !== "up-to-date").map((r) => ({
29680
+ framework: r.framework,
29681
+ displayName: r.displayName,
29682
+ type: r.status,
29683
+ indexedVersion: r.indexedVersion || undefined,
29684
+ latestVersion: r.latestVersion || undefined
29685
+ }));
29686
+ console.log(JSON.stringify({
29687
+ project: config2.project.name,
29688
+ timestamp: new Date().toISOString(),
29689
+ status: freshnessOutput.exitCode === 0 ? "ok" : "issues_found",
29690
+ exitCode: freshnessOutput.exitCode,
29691
+ issues,
29692
+ summary: freshnessOutput.summary
29693
+ }, null, 2));
29694
+ if (options.check && freshnessOutput.exitCode !== 0) {
29695
+ process.exit(freshnessOutput.exitCode);
29696
+ }
29697
+ return;
29698
+ }
27315
29699
  console.log("");
27316
29700
  console.log(source_default.bold(`PDI Status for ${config2.project.name}`));
27317
29701
  console.log(source_default.dim("═".repeat(40)));
@@ -27375,24 +29759,53 @@ async function statusCommand(options = {}) {
27375
29759
  Run: pdi add ${missingFrameworks.map((d) => d.framework?.name).join(" ")}`));
27376
29760
  }
27377
29761
  console.log("");
29762
+ console.log(source_default.bold("Freshness Check"));
29763
+ console.log(source_default.dim("─".repeat(40)));
29764
+ if (freshnessOutput.results.length > 0) {
29765
+ console.log(` ${"Framework".padEnd(20)} ${"Indexed".padEnd(10)} ${"Latest".padEnd(10)} Status`);
29766
+ console.log(source_default.dim(` ${"─".repeat(20)} ${"─".repeat(10)} ${"─".repeat(10)} ${"─".repeat(12)}`));
29767
+ for (const r of freshnessOutput.results) {
29768
+ const statusColor = r.status === "up-to-date" ? source_default.green : r.status === "unknown" ? source_default.dim : r.status === "stale" ? source_default.yellow : source_default.red;
29769
+ console.log(` ${r.displayName.padEnd(20)} ${(r.indexedVersion || "—").padEnd(10)} ${(r.latestVersion || "—").padEnd(10)} ${statusColor(r.status)}`);
29770
+ }
29771
+ const { summary } = freshnessOutput;
29772
+ console.log("");
29773
+ let summaryText = ` ${summary.upToDate} up-to-date, ${summary.stale} stale, ${summary.missing} missing, ${summary.orphaned} orphaned`;
29774
+ if (summary.unknown > 0) {
29775
+ summaryText += `, ${summary.unknown} unknown`;
29776
+ }
29777
+ console.log(source_default.dim(summaryText));
29778
+ } else {
29779
+ console.log(source_default.dim(" No frameworks to check"));
29780
+ }
29781
+ if (options.check && freshnessOutput.exitCode !== 0) {
29782
+ process.exit(freshnessOutput.exitCode);
29783
+ }
29784
+ console.log("");
27378
29785
  }
27379
29786
 
27380
29787
  // src/commands/sync.ts
27381
29788
  import { join as join10 } from "node:path";
27382
29789
  var import_prompts5 = __toESM(require_prompts3(), 1);
29790
+ init_errors();
27383
29791
  async function syncCommand(options) {
27384
29792
  const projectRoot = options.projectRoot || process.cwd();
27385
29793
  const spinner = ora();
27386
29794
  if (!configExists(projectRoot)) {
27387
- throw new Error("PDI not initialized. Run: pdi init");
29795
+ throw new NotInitializedError;
27388
29796
  }
27389
29797
  let config2 = await readConfig(projectRoot);
27390
29798
  if (!config2) {
27391
- throw new Error("Failed to read config");
29799
+ throw new ConfigError("Config file exists but returned null", {
29800
+ hint: "Run `pdi init --force` to regenerate config."
29801
+ });
27392
29802
  }
27393
29803
  const packageJson = await readPackageJson(projectRoot);
27394
29804
  if (!packageJson) {
27395
- throw new Error("No package.json found");
29805
+ throw new PDIError("No package.json found", {
29806
+ code: "NO_PACKAGE_JSON",
29807
+ hint: "Run this command in a Node.js project directory with a package.json file."
29808
+ });
27396
29809
  }
27397
29810
  console.log(source_default.bold("Checking package.json..."));
27398
29811
  console.log("");
@@ -27537,155 +29950,21 @@ async function syncCommand(options) {
27537
29950
  console.log(source_default.green("✓ Sync completed"));
27538
29951
  }
27539
29952
 
27540
- // node_modules/yocto-queue/index.js
27541
- class Node {
27542
- value;
27543
- next;
27544
- constructor(value) {
27545
- this.value = value;
27546
- }
27547
- }
27548
-
27549
- class Queue {
27550
- #head;
27551
- #tail;
27552
- #size;
27553
- constructor() {
27554
- this.clear();
27555
- }
27556
- enqueue(value) {
27557
- const node = new Node(value);
27558
- if (this.#head) {
27559
- this.#tail.next = node;
27560
- this.#tail = node;
27561
- } else {
27562
- this.#head = node;
27563
- this.#tail = node;
27564
- }
27565
- this.#size++;
27566
- }
27567
- dequeue() {
27568
- const current = this.#head;
27569
- if (!current) {
27570
- return;
27571
- }
27572
- this.#head = this.#head.next;
27573
- this.#size--;
27574
- if (!this.#head) {
27575
- this.#tail = undefined;
27576
- }
27577
- return current.value;
27578
- }
27579
- peek() {
27580
- if (!this.#head) {
27581
- return;
27582
- }
27583
- return this.#head.value;
27584
- }
27585
- clear() {
27586
- this.#head = undefined;
27587
- this.#tail = undefined;
27588
- this.#size = 0;
27589
- }
27590
- get size() {
27591
- return this.#size;
27592
- }
27593
- *[Symbol.iterator]() {
27594
- let current = this.#head;
27595
- while (current) {
27596
- yield current.value;
27597
- current = current.next;
27598
- }
27599
- }
27600
- *drain() {
27601
- while (this.#head) {
27602
- yield this.dequeue();
27603
- }
27604
- }
27605
- }
27606
-
27607
- // node_modules/p-limit/index.js
27608
- function pLimit(concurrency) {
27609
- validateConcurrency(concurrency);
27610
- const queue = new Queue;
27611
- let activeCount = 0;
27612
- const resumeNext = () => {
27613
- if (activeCount < concurrency && queue.size > 0) {
27614
- queue.dequeue()();
27615
- activeCount++;
27616
- }
27617
- };
27618
- const next = () => {
27619
- activeCount--;
27620
- resumeNext();
27621
- };
27622
- const run = async (function_, resolve, arguments_) => {
27623
- const result = (async () => function_(...arguments_))();
27624
- resolve(result);
27625
- try {
27626
- await result;
27627
- } catch {}
27628
- next();
27629
- };
27630
- const enqueue = (function_, resolve, arguments_) => {
27631
- new Promise((internalResolve) => {
27632
- queue.enqueue(internalResolve);
27633
- }).then(run.bind(undefined, function_, resolve, arguments_));
27634
- (async () => {
27635
- await Promise.resolve();
27636
- if (activeCount < concurrency) {
27637
- resumeNext();
27638
- }
27639
- })();
27640
- };
27641
- const generator = (function_, ...arguments_) => new Promise((resolve) => {
27642
- enqueue(function_, resolve, arguments_);
27643
- });
27644
- Object.defineProperties(generator, {
27645
- activeCount: {
27646
- get: () => activeCount
27647
- },
27648
- pendingCount: {
27649
- get: () => queue.size
27650
- },
27651
- clearQueue: {
27652
- value() {
27653
- queue.clear();
27654
- }
27655
- },
27656
- concurrency: {
27657
- get: () => concurrency,
27658
- set(newConcurrency) {
27659
- validateConcurrency(newConcurrency);
27660
- concurrency = newConcurrency;
27661
- queueMicrotask(() => {
27662
- while (activeCount < concurrency && queue.size > 0) {
27663
- resumeNext();
27664
- }
27665
- });
27666
- }
27667
- }
27668
- });
27669
- return generator;
27670
- }
27671
- function validateConcurrency(concurrency) {
27672
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
27673
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
27674
- }
27675
- }
27676
-
27677
29953
  // src/commands/update.ts
27678
29954
  var import_prompts6 = __toESM(require_prompts3(), 1);
27679
29955
  init_context7_client();
29956
+ init_errors();
27680
29957
  async function updateCommand(frameworks, options) {
27681
29958
  const projectRoot = options.projectRoot || process.cwd();
27682
29959
  const spinner = ora();
27683
29960
  if (!configExists(projectRoot)) {
27684
- throw new Error("PDI not initialized. Run: pdi init");
29961
+ throw new NotInitializedError;
27685
29962
  }
27686
29963
  let config2 = await readConfig(projectRoot);
27687
29964
  if (!config2) {
27688
- throw new Error("Failed to read config");
29965
+ throw new ConfigError("Config file exists but returned null", {
29966
+ hint: "Run `pdi init --force` to regenerate config."
29967
+ });
27689
29968
  }
27690
29969
  let frameworksToUpdate;
27691
29970
  if (frameworks.length === 0) {
@@ -27846,6 +30125,40 @@ Skipping ${template.displayName}@${version2} (updated ${Math.round(hoursSinceUpd
27846
30125
  }
27847
30126
  }
27848
30127
 
30128
+ // src/lib/error-handler.ts
30129
+ init_errors();
30130
+ function handleCommandError(error48) {
30131
+ if (error48 instanceof ConfigError) {
30132
+ console.error(source_default.red("Config Error:"), error48.message);
30133
+ if (error48.validationIssues && error48.validationIssues.length > 0) {
30134
+ console.error(source_default.dim(error48.formatValidationIssues()));
30135
+ }
30136
+ } else if (error48 instanceof NotInitializedError) {
30137
+ console.error(source_default.red("Error:"), error48.message);
30138
+ } else if (error48 instanceof Context7Error) {
30139
+ console.error(source_default.red("Context7 Error:"), error48.message);
30140
+ } else if (error48 instanceof PDIError) {
30141
+ console.error(source_default.red("Error:"), error48.message);
30142
+ } else if (error48 instanceof Error) {
30143
+ console.error(source_default.red("Error:"), error48.message);
30144
+ if (error48.cause instanceof Error) {
30145
+ console.error(source_default.dim(` Caused by: ${error48.cause.message}`));
30146
+ }
30147
+ } else {
30148
+ console.error(source_default.red("Error:"), String(error48));
30149
+ }
30150
+ if (error48 instanceof PDIError && error48.hint) {
30151
+ console.error(source_default.dim(`
30152
+ Fix: ${error48.hint}`));
30153
+ }
30154
+ if (process.env.PDI_DEBUG && error48 instanceof Error && error48.stack) {
30155
+ console.error(source_default.dim(`
30156
+ Stack trace:`));
30157
+ console.error(source_default.dim(error48.stack));
30158
+ }
30159
+ process.exit(1);
30160
+ }
30161
+
27849
30162
  // src/cli.ts
27850
30163
  try {
27851
30164
  await loadApiKeyFromConfig();
@@ -27860,47 +30173,42 @@ program2.command("init").description("Initialize PDI in the current project").op
27860
30173
  try {
27861
30174
  await initCommand(options);
27862
30175
  } catch (error48) {
27863
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27864
- process.exit(1);
30176
+ handleCommandError(error48);
27865
30177
  }
27866
30178
  });
27867
30179
  program2.command("add").description("Add documentation for frameworks (interactive if no args)").argument("[frameworks...]", "Framework names to add (e.g., hono drizzle zod)").option("-v, --version <version>", "Specify version (e.g., 4.x)").option("--minimal", "Download only essential docs").option("-f, --force", "Overwrite existing docs").option("--no-index", "Do not update CLAUDE.md index").option("--offline", "Generate placeholders only (skip MCP)").action(async (frameworks, options) => {
27868
30180
  try {
27869
30181
  await addCommand(frameworks || [], options);
27870
30182
  } catch (error48) {
27871
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27872
- process.exit(1);
30183
+ handleCommandError(error48);
27873
30184
  }
27874
30185
  });
27875
30186
  program2.command("sync").description("Synchronize docs with package.json dependencies").option("-y, --yes", "Accept all changes without prompting").option("--check", "Only check for changes, do not apply").option("--prune", "Remove docs for uninstalled packages").action(async (options) => {
27876
30187
  try {
27877
30188
  await syncCommand(options);
27878
30189
  } catch (error48) {
27879
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27880
- process.exit(1);
30190
+ handleCommandError(error48);
27881
30191
  }
27882
30192
  });
27883
- program2.command("status").description("Show current PDI status").action(async () => {
30193
+ program2.command("status").description("Show current PDI status and doc freshness").option("--check", "Exit with non-zero code if issues found (for CI)").option("--format <format>", "Output format: table or json", "table").action(async (options) => {
27884
30194
  try {
27885
- await statusCommand();
30195
+ await statusCommand(options);
27886
30196
  } catch (error48) {
27887
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27888
- process.exit(1);
30197
+ handleCommandError(error48);
27889
30198
  }
27890
30199
  });
27891
30200
  program2.command("clean").description("Remove orphan docs and optimize index").option("-y, --yes", "Remove without prompting").option("--dry-run", "Show what would be removed without doing it").action(async (options) => {
27892
30201
  try {
27893
30202
  await cleanCommand(options);
27894
30203
  } catch (error48) {
27895
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27896
- process.exit(1);
30204
+ handleCommandError(error48);
27897
30205
  }
27898
30206
  });
27899
30207
  program2.command("list").description("List available framework templates").option("--category <category>", "Filter by category").action((options) => {
27900
30208
  const templates = listTemplates();
27901
30209
  console.log(source_default.bold(`
27902
30210
  Available Framework Templates`));
27903
- console.log(source_default.dim("".repeat(40)));
30211
+ console.log(source_default.dim("=".repeat(40)));
27904
30212
  console.log("");
27905
30213
  const categories = new Map;
27906
30214
  for (const template of templates) {
@@ -27926,32 +30234,28 @@ program2.command("update").description("Update docs to latest versions (HTTP fir
27926
30234
  try {
27927
30235
  await updateCommand(frameworks, options);
27928
30236
  } catch (error48) {
27929
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27930
- process.exit(1);
30237
+ handleCommandError(error48);
27931
30238
  }
27932
30239
  });
27933
30240
  program2.command("generate").description("Generate internal pattern documentation").argument("<type>", "Type of docs to generate (internal)").option("--category <category>", "Specific category to generate").option("--dry-run", "Show what would be generated").option("--ai", "Use AI to enhance descriptions (requires API key)").action(async (type, options) => {
27934
30241
  try {
27935
30242
  await generateCommand(type, options);
27936
30243
  } catch (error48) {
27937
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27938
- process.exit(1);
30244
+ handleCommandError(error48);
27939
30245
  }
27940
30246
  });
27941
30247
  program2.command("auth").description("Configure Context7 API key").option("-s, --status", "Show authentication status").option("--logout", "Remove saved API key").action(async (options) => {
27942
30248
  try {
27943
30249
  await authCommand(options);
27944
30250
  } catch (error48) {
27945
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27946
- process.exit(1);
30251
+ handleCommandError(error48);
27947
30252
  }
27948
30253
  });
27949
30254
  program2.command("doctor").description("Diagnose configuration and provide recommendations").action(async () => {
27950
30255
  try {
27951
30256
  await doctorCommand();
27952
30257
  } catch (error48) {
27953
- console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
27954
- process.exit(1);
30258
+ handleCommandError(error48);
27955
30259
  }
27956
30260
  });
27957
30261
  program2.parse();