mano-coding 0.1.36 → 0.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin.js +2658 -317
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -3681,7 +3681,8 @@ var init_zh = __esm({
3681
3681
  "tty.confirmPrompt": "\n\u786E\u8BA4\u540E\u5C06\u6267\u884C\u4EE5\u4E0A\u64CD\u4F5C\u3002\n",
3682
3682
  "tty.proceedPrompt": "\u662F\u5426\u6267\u884C\u6B64 Plan\uFF1F",
3683
3683
  // update-notice.ts
3684
- "update.notice": "aicoding {0} \u53EF\u7528\uFF08\u5F53\u524D {1}\uFF09\u3002\u8FD0\u884C aicoding self-upgrade \u5347\u7EA7\u3002",
3684
+ "update.notice": "mano-coding {0} \u53EF\u7528\uFF08\u5F53\u524D {1}\uFF09\u3002\u8FD0\u884C mano-coding self-upgrade \u5347\u7EA7\u3002",
3685
+ "update.notice.paused": "mano-coding {0} \u53EF\u7528\uFF08\u5F53\u524D {1}\uFF09\u3002\u540E\u53F0\u81EA\u52A8\u5347\u7EA7\u5DF2\u6682\u505C\uFF08\u8FDE\u7EED\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A{2}\uFF09\u3002\u8FD0\u884C mano-coding self-upgrade \u5347\u7EA7\u3002",
3685
3686
  // plan-execution.ts
3686
3687
  "plan.integrityMissing": "Capability '{0}/{1}' \u6CA1\u6709\u5DF2\u9A8C\u8BC1\u7684\u5305\u5B8C\u6574\u6027",
3687
3688
  "plan.integrityConflict": "\u5B89\u88C5\u5B8C\u6574\u6027\u51B2\u7A81\uFF1A{0}/{1}@{2}",
@@ -22880,7 +22881,7 @@ import { join as join3 } from "node:path";
22880
22881
  function isCliUpdateCache(value) {
22881
22882
  if (!value || typeof value !== "object") return false;
22882
22883
  const item = value;
22883
- return item["schemaVersion"] === 1 && typeof item["registryOrigin"] === "string" && typeof item["checkedAt"] === "string" && typeof item["latestVersion"] === "string" && (item["latestIntegrity"] === void 0 || typeof item["latestIntegrity"] === "string") && (item["latestEnginesNode"] === void 0 || typeof item["latestEnginesNode"] === "string") && (item["lastNotifiedAt"] === void 0 || typeof item["lastNotifiedAt"] === "string");
22884
+ return item["schemaVersion"] === 1 && typeof item["registryOrigin"] === "string" && typeof item["checkedAt"] === "string" && typeof item["latestVersion"] === "string" && (item["latestIntegrity"] === void 0 || typeof item["latestIntegrity"] === "string") && (item["latestEnginesNode"] === void 0 || typeof item["latestEnginesNode"] === "string") && (item["lastNotifiedAt"] === void 0 || typeof item["lastNotifiedAt"] === "string") && (item["autoUpdateFailureCount"] === void 0 || typeof item["autoUpdateFailureCount"] === "number") && (item["autoUpdateLastError"] === void 0 || typeof item["autoUpdateLastError"] === "string") && (item["autoUpdatePaused"] === void 0 || typeof item["autoUpdatePaused"] === "boolean");
22884
22885
  }
22885
22886
  var CliUpdateCacheRepository;
22886
22887
  var init_cli_update_repository = __esm({
@@ -22910,6 +22911,31 @@ var init_cli_update_repository = __esm({
22910
22911
  if (!cache) return;
22911
22912
  await this.write({ ...cache, lastNotifiedAt: now.toISOString() });
22912
22913
  }
22914
+ /**
22915
+ * 记录自动升级失败,累加连续失败次数,并在达到阈值(默认 3 次)时标记暂停
22916
+ */
22917
+ async recordAutoUpdateFailure(errorMessage, maxFailures = 3) {
22918
+ const cache = await this.read();
22919
+ if (!cache) return;
22920
+ const count = (cache.autoUpdateFailureCount ?? 0) + 1;
22921
+ const paused = count >= maxFailures;
22922
+ await this.write({
22923
+ ...cache,
22924
+ autoUpdateFailureCount: count,
22925
+ autoUpdateLastError: errorMessage,
22926
+ autoUpdatePaused: paused
22927
+ });
22928
+ }
22929
+ /**
22930
+ * 重置自动升级失败状态(在升级成功或手动 self-upgrade 成功后调用)
22931
+ */
22932
+ async resetAutoUpdateFailure() {
22933
+ const cache = await this.read();
22934
+ if (!cache) return;
22935
+ if (!cache.autoUpdateFailureCount && !cache.autoUpdateLastError && !cache.autoUpdatePaused) return;
22936
+ const { autoUpdateFailureCount, autoUpdateLastError, autoUpdatePaused, ...rest } = cache;
22937
+ await this.write(rest);
22938
+ }
22913
22939
  async clear() {
22914
22940
  await withStateLock(this.path, async () => {
22915
22941
  await unlink4(this.path).catch((error) => {
@@ -23237,8 +23263,10 @@ function selectRelease(entry, versionRange) {
23237
23263
  return import_semver2.default.satisfies(r.version, normalizedRange);
23238
23264
  });
23239
23265
  if (candidates.length === 0) {
23266
+ const availableChannels = Object.entries(entry.channels ?? {}).filter(([ch]) => ch !== "stable").map(([ch, ver]) => `${ch} (${ver})`);
23267
+ const hint = availableChannels.length > 0 && versionRange === "stable" ? ` (\u5F53\u524D\u53EF\u7528\u9884\u53D1\u5E03\u901A\u9053: ${availableChannels.join(", ")}\uFF0C\u53EF\u901A\u8FC7 ${packageId}@<channel> \u5B89\u88C5)` : "";
23240
23268
  throw new RegistryError(
23241
- `Package ${packageId} \u6CA1\u6709\u6EE1\u8DB3\u7248\u672C\u8303\u56F4 '${versionRange}' \u7684 Release`,
23269
+ `Package ${packageId} \u6CA1\u6709\u6EE1\u8DB3\u7248\u672C\u8303\u56F4 '${versionRange}' \u7684 Release${hint}`,
23242
23270
  "REGISTRY_NO_MATCHING_RELEASE",
23243
23271
  packageId
23244
23272
  );
@@ -27151,7 +27179,8 @@ var init_config_manager = __esm({
27151
27179
  }
27152
27180
  async get(key) {
27153
27181
  const config = await this.read();
27154
- return config[key];
27182
+ const val = config[key];
27183
+ return val !== void 0 ? String(val) : void 0;
27155
27184
  }
27156
27185
  async set(key, value) {
27157
27186
  const config = await this.read();
@@ -27190,6 +27219,51 @@ var init_config_manager = __esm({
27190
27219
  }
27191
27220
  return DEFAULT_GITLAB_HOST;
27192
27221
  }
27222
+ /**
27223
+ * 读取企业托管配置(只读)
27224
+ * 优先从环境变量 AICODING_MANAGED_CONFIG 或 MANO_MANAGED_CONFIG 指定的文件读取;
27225
+ * 若未指定,则尝试读取系统级配置路径
27226
+ */
27227
+ async readManagedConfig() {
27228
+ const envManagedPath = process.env["AICODING_MANAGED_CONFIG"] ?? process.env["MANO_MANAGED_CONFIG"];
27229
+ const defaultManagedPath = process.platform === "win32" ? join8(process.env["ProgramData"] ?? "C:\\ProgramData", "mano", "config.json") : "/etc/mano/config.json";
27230
+ const managedPath = envManagedPath ?? defaultManagedPath;
27231
+ try {
27232
+ const content = await readFile10(managedPath, "utf-8");
27233
+ const parsed = JSON.parse(content);
27234
+ return typeof parsed === "object" && parsed !== null ? parsed : void 0;
27235
+ } catch {
27236
+ return void 0;
27237
+ }
27238
+ }
27239
+ /**
27240
+ * 检查自动升级是否启用:
27241
+ * 1. 检查企业托管配置(最高优先级,管理员统一下发)
27242
+ * 2. 检查针对性环境变量 AICODING_AUTO_UPDATE 或 MANO_AUTO_UPDATE
27243
+ * 3. 检查 ~/.manorc 中的 autoUpdate 配置
27244
+ * 4. 默认启用(返回 true,对齐 OpenCode 默认开启体验)
27245
+ */
27246
+ async isAutoUpdateEnabled() {
27247
+ const managed = await this.readManagedConfig();
27248
+ if (managed && managed.autoUpdate !== void 0) {
27249
+ const managedVal = String(managed.autoUpdate).toLowerCase().trim();
27250
+ if (managedVal === "false" || managedVal === "0" || managedVal === "no") return false;
27251
+ if (managedVal === "true" || managedVal === "1" || managedVal === "yes") return true;
27252
+ }
27253
+ const envAuto = process.env["AICODING_AUTO_UPDATE"] ?? process.env["MANO_AUTO_UPDATE"];
27254
+ if (envAuto !== void 0 && envAuto.trim().length > 0) {
27255
+ const envVal = envAuto.toLowerCase().trim();
27256
+ if (envVal === "false" || envVal === "0" || envVal === "no") return false;
27257
+ if (envVal === "true" || envVal === "1" || envVal === "yes") return true;
27258
+ }
27259
+ const userVal = await this.get("autoUpdate");
27260
+ if (userVal !== void 0) {
27261
+ const strVal = String(userVal).toLowerCase().trim();
27262
+ if (strVal === "false" || strVal === "0" || strVal === "no") return false;
27263
+ if (strVal === "true" || strVal === "1" || strVal === "yes") return true;
27264
+ }
27265
+ return true;
27266
+ }
27193
27267
  };
27194
27268
  defaultConfigManager = new ConfigManager();
27195
27269
  }
@@ -46707,214 +46781,2275 @@ var init_searchable_select = __esm({
46707
46781
  }
46708
46782
  });
46709
46783
 
46710
- // packages/cli/src/commands/spinner.ts
46711
- async function withSpinner(text, action, options) {
46712
- const spinner = new Spinner(text, { enabled: options?.enabled });
46713
- spinner.start();
46714
- try {
46715
- const result = await action(spinner);
46716
- const successMsg = typeof options?.successText === "function" ? options.successText(result) : options?.successText ?? text;
46717
- spinner.succeed(successMsg);
46718
- return result;
46719
- } catch (error) {
46720
- spinner.fail(options?.failText);
46721
- throw error;
46784
+ // node_modules/semver/internal/constants.js
46785
+ var require_constants2 = __commonJS({
46786
+ "node_modules/semver/internal/constants.js"(exports, module) {
46787
+ "use strict";
46788
+ var SEMVER_SPEC_VERSION = "2.0.0";
46789
+ var MAX_LENGTH = 256;
46790
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
46791
+ 9007199254740991;
46792
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
46793
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
46794
+ var RELEASE_TYPES = [
46795
+ "major",
46796
+ "premajor",
46797
+ "minor",
46798
+ "preminor",
46799
+ "patch",
46800
+ "prepatch",
46801
+ "prerelease"
46802
+ ];
46803
+ module.exports = {
46804
+ MAX_LENGTH,
46805
+ MAX_SAFE_COMPONENT_LENGTH,
46806
+ MAX_SAFE_BUILD_LENGTH,
46807
+ MAX_SAFE_INTEGER,
46808
+ RELEASE_TYPES,
46809
+ SEMVER_SPEC_VERSION,
46810
+ FLAG_INCLUDE_PRERELEASE: 1,
46811
+ FLAG_LOOSE: 2
46812
+ };
46722
46813
  }
46723
- }
46724
- var Spinner;
46725
- var init_spinner = __esm({
46726
- "packages/cli/src/commands/spinner.ts"() {
46814
+ });
46815
+
46816
+ // node_modules/semver/internal/debug.js
46817
+ var require_debug2 = __commonJS({
46818
+ "node_modules/semver/internal/debug.js"(exports, module) {
46727
46819
  "use strict";
46728
- init_src2();
46729
- Spinner = class {
46730
- text;
46731
- timer = null;
46732
- frameIndex = 0;
46733
- isSpinning = false;
46734
- enabled;
46735
- frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
46736
- interval = 80;
46737
- constructor(text = "", options = {}) {
46738
- this.text = text;
46739
- this.enabled = options.enabled ?? (Boolean(process.stdout.isTTY) && process.env.NODE_ENV !== "test" && !process.env.CI);
46820
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
46821
+ };
46822
+ module.exports = debug;
46823
+ }
46824
+ });
46825
+
46826
+ // node_modules/semver/internal/re.js
46827
+ var require_re2 = __commonJS({
46828
+ "node_modules/semver/internal/re.js"(exports, module) {
46829
+ "use strict";
46830
+ var {
46831
+ MAX_SAFE_COMPONENT_LENGTH,
46832
+ MAX_SAFE_BUILD_LENGTH,
46833
+ MAX_LENGTH
46834
+ } = require_constants2();
46835
+ var debug = require_debug2();
46836
+ exports = module.exports = {};
46837
+ var re2 = exports.re = [];
46838
+ var safeRe = exports.safeRe = [];
46839
+ var src = exports.src = [];
46840
+ var safeSrc = exports.safeSrc = [];
46841
+ var t2 = exports.t = {};
46842
+ var R2 = 0;
46843
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
46844
+ var safeRegexReplacements = [
46845
+ ["\\s", 1],
46846
+ ["\\d", MAX_LENGTH],
46847
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
46848
+ ];
46849
+ var makeSafeRegex = (value) => {
46850
+ for (const [token, max] of safeRegexReplacements) {
46851
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
46740
46852
  }
46741
- start(text) {
46742
- if (text !== void 0) this.text = text;
46743
- if (!this.enabled || this.isSpinning) return this;
46744
- this.isSpinning = true;
46745
- this.frameIndex = 0;
46746
- process.stdout.write("\x1B[?25l");
46747
- this.render();
46748
- this.timer = setInterval(() => {
46749
- this.frameIndex = (this.frameIndex + 1) % this.frames.length;
46750
- this.render();
46751
- }, this.interval);
46752
- return this;
46853
+ return value;
46854
+ };
46855
+ var createToken = (name, value, isGlobal) => {
46856
+ const safe = makeSafeRegex(value);
46857
+ const index = R2++;
46858
+ debug(name, index, value);
46859
+ t2[name] = index;
46860
+ src[index] = value;
46861
+ safeSrc[index] = safe;
46862
+ re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
46863
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
46864
+ };
46865
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
46866
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
46867
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
46868
+ createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
46869
+ createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
46870
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIER]})`);
46871
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIERLOOSE]})`);
46872
+ createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
46873
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
46874
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
46875
+ createToken("BUILD", `(?:\\+(${src[t2.BUILDIDENTIFIER]}(?:\\.${src[t2.BUILDIDENTIFIER]})*))`);
46876
+ createToken("FULLPLAIN", `v?${src[t2.MAINVERSION]}${src[t2.PRERELEASE]}?${src[t2.BUILD]}?`);
46877
+ createToken("FULL", `^${src[t2.FULLPLAIN]}$`);
46878
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t2.MAINVERSIONLOOSE]}${src[t2.PRERELEASELOOSE]}?${src[t2.BUILD]}?`);
46879
+ createToken("LOOSE", `^${src[t2.LOOSEPLAIN]}$`);
46880
+ createToken("GTLT", "((?:<|>)?=?)");
46881
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t2.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
46882
+ createToken("XRANGEIDENTIFIER", `${src[t2.NUMERICIDENTIFIER]}|x|X|\\*`);
46883
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:${src[t2.PRERELEASE]})?${src[t2.BUILD]}?)?)?`);
46884
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`);
46885
+ createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`);
46886
+ createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`);
46887
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
46888
+ createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`);
46889
+ createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`);
46890
+ createToken("COERCERTL", src[t2.COERCE], true);
46891
+ createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
46892
+ createToken("LONETILDE", "(?:~>?)");
46893
+ createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
46894
+ exports.tildeTrimReplace = "$1~";
46895
+ createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
46896
+ createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
46897
+ createToken("LONECARET", "(?:\\^)");
46898
+ createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
46899
+ exports.caretTrimReplace = "$1^";
46900
+ createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
46901
+ createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
46902
+ createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
46903
+ createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
46904
+ createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
46905
+ exports.comparatorTrimReplace = "$1$2$3";
46906
+ createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
46907
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
46908
+ createToken("STAR", "(<|>)?=?\\s*\\*");
46909
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
46910
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
46911
+ }
46912
+ });
46913
+
46914
+ // node_modules/semver/internal/parse-options.js
46915
+ var require_parse_options2 = __commonJS({
46916
+ "node_modules/semver/internal/parse-options.js"(exports, module) {
46917
+ "use strict";
46918
+ var looseOption = Object.freeze({ loose: true });
46919
+ var emptyOpts = Object.freeze({});
46920
+ var parseOptions = (options) => {
46921
+ if (!options) {
46922
+ return emptyOpts;
46753
46923
  }
46754
- update(text) {
46755
- this.text = text;
46756
- if (this.isSpinning && this.enabled) {
46757
- this.render();
46758
- }
46759
- return this;
46924
+ if (typeof options !== "object") {
46925
+ return looseOption;
46760
46926
  }
46761
- succeed(text) {
46762
- return this.stopAndPersist("\u2714", text ?? this.text, "\x1B[32m");
46927
+ return options;
46928
+ };
46929
+ module.exports = parseOptions;
46930
+ }
46931
+ });
46932
+
46933
+ // node_modules/semver/internal/identifiers.js
46934
+ var require_identifiers2 = __commonJS({
46935
+ "node_modules/semver/internal/identifiers.js"(exports, module) {
46936
+ "use strict";
46937
+ var numeric = /^[0-9]+$/;
46938
+ var compareIdentifiers = (a, b2) => {
46939
+ if (typeof a === "number" && typeof b2 === "number") {
46940
+ return a === b2 ? 0 : a < b2 ? -1 : 1;
46763
46941
  }
46764
- fail(text) {
46765
- return this.stopAndPersist("\u2716", text ?? this.text, "\x1B[31m");
46942
+ const anum = numeric.test(a);
46943
+ const bnum = numeric.test(b2);
46944
+ if (anum && bnum) {
46945
+ a = +a;
46946
+ b2 = +b2;
46766
46947
  }
46767
- warn(text) {
46768
- return this.stopAndPersist("\u26A0", text ?? this.text, "\x1B[33m");
46948
+ return a === b2 ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b2 ? -1 : 1;
46949
+ };
46950
+ var rcompareIdentifiers = (a, b2) => compareIdentifiers(b2, a);
46951
+ module.exports = {
46952
+ compareIdentifiers,
46953
+ rcompareIdentifiers
46954
+ };
46955
+ }
46956
+ });
46957
+
46958
+ // node_modules/semver/classes/semver.js
46959
+ var require_semver3 = __commonJS({
46960
+ "node_modules/semver/classes/semver.js"(exports, module) {
46961
+ "use strict";
46962
+ var debug = require_debug2();
46963
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
46964
+ var { safeRe: re2, t: t2 } = require_re2();
46965
+ var parseOptions = require_parse_options2();
46966
+ var { compareIdentifiers } = require_identifiers2();
46967
+ var isPrereleaseIdentifier = (prerelease, identifier) => {
46968
+ const identifiers = identifier.split(".");
46969
+ if (identifiers.length > prerelease.length) {
46970
+ return false;
46769
46971
  }
46770
- info(text) {
46771
- return this.stopAndPersist("\u2139", text ?? this.text, "\x1B[34m");
46972
+ for (let i = 0; i < identifiers.length; i++) {
46973
+ if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
46974
+ return false;
46975
+ }
46772
46976
  }
46773
- stop() {
46774
- if (!this.isSpinning) return this;
46775
- if (this.timer) {
46776
- clearInterval(this.timer);
46777
- this.timer = null;
46977
+ return true;
46978
+ };
46979
+ var SemVer = class _SemVer {
46980
+ constructor(version, options) {
46981
+ options = parseOptions(options);
46982
+ if (version instanceof _SemVer) {
46983
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
46984
+ return version;
46985
+ } else {
46986
+ version = version.version;
46987
+ }
46988
+ } else if (typeof version !== "string") {
46989
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
46778
46990
  }
46779
- this.isSpinning = false;
46780
- if (this.enabled) {
46781
- process.stdout.write("\r\x1B[2K\x1B[?25h");
46991
+ if (version.length > MAX_LENGTH) {
46992
+ throw new TypeError(
46993
+ `version is longer than ${MAX_LENGTH} characters`
46994
+ );
46782
46995
  }
46783
- return this;
46996
+ debug("SemVer", version, options);
46997
+ this.options = options;
46998
+ this.loose = !!options.loose;
46999
+ this.includePrerelease = !!options.includePrerelease;
47000
+ const m2 = version.trim().match(options.loose ? re2[t2.LOOSE] : re2[t2.FULL]);
47001
+ if (!m2) {
47002
+ throw new TypeError(`Invalid Version: ${version}`);
47003
+ }
47004
+ this.raw = version;
47005
+ this.major = +m2[1];
47006
+ this.minor = +m2[2];
47007
+ this.patch = +m2[3];
47008
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
47009
+ throw new TypeError("Invalid major version");
47010
+ }
47011
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
47012
+ throw new TypeError("Invalid minor version");
47013
+ }
47014
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
47015
+ throw new TypeError("Invalid patch version");
47016
+ }
47017
+ if (!m2[4]) {
47018
+ this.prerelease = [];
47019
+ } else {
47020
+ this.prerelease = m2[4].split(".").map((id) => {
47021
+ if (/^[0-9]+$/.test(id)) {
47022
+ const num = +id;
47023
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
47024
+ return num;
47025
+ }
47026
+ }
47027
+ return id;
47028
+ });
47029
+ }
47030
+ this.build = m2[5] ? m2[5].split(".") : [];
47031
+ this.format();
46784
47032
  }
46785
- stopAndPersist(symbol, text, color = "") {
46786
- this.stop();
46787
- if (this.enabled) {
46788
- const reset = "\x1B[0m";
46789
- const cleanText = text.replace(/^[✔✖⚠ℹ\s]+/, "");
46790
- const output = `${color}${symbol}${reset} ${redactString(cleanText)}
46791
- `;
46792
- process.stdout.write(output);
47033
+ format() {
47034
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
47035
+ if (this.prerelease.length) {
47036
+ this.version += `-${this.prerelease.join(".")}`;
46793
47037
  }
46794
- return this;
47038
+ return this.version;
46795
47039
  }
46796
- render() {
46797
- const frame = this.frames[this.frameIndex];
46798
- const cyan = "\x1B[36m";
46799
- const reset = "\x1B[0m";
46800
- process.stdout.write(`\r\x1B[2K${cyan}${frame}${reset} ${redactString(this.text)}`);
47040
+ toString() {
47041
+ return this.version;
46801
47042
  }
46802
- };
46803
- }
46804
- });
46805
-
46806
- // packages/cli/src/commands/task-helper.ts
46807
- async function runTasksWithDynamicUI(tasks, ctx, options = {}) {
46808
- if (tasks.length === 0) return;
46809
- const isInteractive = !options.json && !options.verbose && Boolean(process.stdout.isTTY) && process.env.NODE_ENV !== "test";
46810
- if (!options.json && options.title) {
46811
- writeHumanOutput(`
46812
- ${options.title}
46813
- `);
46814
- }
46815
- if (isInteractive) {
46816
- let currentSpinner = null;
46817
- try {
46818
- await executeTasks(tasks, ctx, {
46819
- verbose: false,
46820
- onTaskStart: (task, index, total) => {
46821
- const taskLabel = task.name ? `${task.name} (${task.id})` : task.id;
46822
- currentSpinner = new Spinner(`[${index + 1}/${total}] \u6B63\u5728\u6267\u884C\u4EFB\u52A1: ${taskLabel}...`);
46823
- currentSpinner.start();
46824
- },
46825
- onTaskSuccess: (task, index, total) => {
46826
- const taskLabel = task.name ? `${task.name}` : task.id;
46827
- if (currentSpinner) {
46828
- currentSpinner.succeed(`[${index + 1}/${total}] \u4EFB\u52A1\u5B8C\u6210: ${taskLabel}`);
46829
- }
46830
- },
46831
- onTaskFail: (task, index, total, _error, logFile) => {
46832
- const taskLabel = task.name ? `${task.name}` : task.id;
46833
- if (currentSpinner) {
46834
- currentSpinner.fail(`[${index + 1}/${total}] \u4EFB\u52A1\u6267\u884C\u5931\u8D25: ${taskLabel}`);
46835
- }
46836
- if (logFile) {
46837
- writeHumanOutput(` \u8BE6\u7EC6\u65E5\u5FD7\u5DF2\u4FDD\u5B58\u81F3: ${logFile}
46838
- `);
47043
+ compare(other) {
47044
+ debug("SemVer.compare", this.version, this.options, other);
47045
+ if (!(other instanceof _SemVer)) {
47046
+ if (typeof other === "string" && other === this.version) {
47047
+ return 0;
46839
47048
  }
47049
+ other = new _SemVer(other, this.options);
46840
47050
  }
46841
- });
46842
- } catch (err) {
46843
- currentSpinner?.stop();
46844
- throw err;
46845
- }
46846
- } else {
46847
- await executeTasks(tasks, ctx, {
46848
- verbose: Boolean(options.verbose),
46849
- stdio: options.json ? "ignore" : void 0,
46850
- onTaskStart: (task, index, total) => {
46851
- if (!options.json && options.verbose) {
46852
- writeHumanOutput(`
46853
- > [${index + 1}/${total}] \u5F00\u59CB\u6267\u884C\u4EFB\u52A1: ${task.name ?? task.id}
46854
- `);
47051
+ if (other.version === this.version) {
47052
+ return 0;
46855
47053
  }
46856
- },
46857
- onTaskSuccess: (task, index, total) => {
46858
- if (!options.json && !options.verbose) {
46859
- writeHumanOutput(`\u2714 [${index + 1}/${total}] \u4EFB\u52A1\u5B8C\u6210: ${task.name ?? task.id}
46860
- `);
47054
+ return this.compareMain(other) || this.comparePre(other);
47055
+ }
47056
+ compareMain(other) {
47057
+ if (!(other instanceof _SemVer)) {
47058
+ other = new _SemVer(other, this.options);
46861
47059
  }
46862
- },
46863
- onTaskFail: (task, index, total, _err, logFile) => {
46864
- if (!options.json) {
46865
- writeHumanOutput(`\u2716 [${index + 1}/${total}] \u4EFB\u52A1\u6267\u884C\u5931\u8D25: ${task.name ?? task.id}
46866
- `);
46867
- if (logFile) {
46868
- writeHumanOutput(` \u8BE6\u7EC6\u65E5\u5FD7\u5DF2\u4FDD\u5B58\u81F3: ${logFile}
46869
- `);
47060
+ if (this.major < other.major) {
47061
+ return -1;
47062
+ }
47063
+ if (this.major > other.major) {
47064
+ return 1;
47065
+ }
47066
+ if (this.minor < other.minor) {
47067
+ return -1;
47068
+ }
47069
+ if (this.minor > other.minor) {
47070
+ return 1;
47071
+ }
47072
+ if (this.patch < other.patch) {
47073
+ return -1;
47074
+ }
47075
+ if (this.patch > other.patch) {
47076
+ return 1;
47077
+ }
47078
+ return 0;
47079
+ }
47080
+ comparePre(other) {
47081
+ if (!(other instanceof _SemVer)) {
47082
+ other = new _SemVer(other, this.options);
47083
+ }
47084
+ if (this.prerelease.length && !other.prerelease.length) {
47085
+ return -1;
47086
+ } else if (!this.prerelease.length && other.prerelease.length) {
47087
+ return 1;
47088
+ } else if (!this.prerelease.length && !other.prerelease.length) {
47089
+ return 0;
47090
+ }
47091
+ let i = 0;
47092
+ do {
47093
+ const a = this.prerelease[i];
47094
+ const b2 = other.prerelease[i];
47095
+ debug("prerelease compare", i, a, b2);
47096
+ if (a === void 0 && b2 === void 0) {
47097
+ return 0;
47098
+ } else if (b2 === void 0) {
47099
+ return 1;
47100
+ } else if (a === void 0) {
47101
+ return -1;
47102
+ } else if (a === b2) {
47103
+ continue;
47104
+ } else {
47105
+ return compareIdentifiers(a, b2);
46870
47106
  }
47107
+ } while (++i);
47108
+ }
47109
+ compareBuild(other) {
47110
+ if (!(other instanceof _SemVer)) {
47111
+ other = new _SemVer(other, this.options);
46871
47112
  }
47113
+ let i = 0;
47114
+ do {
47115
+ const a = this.build[i];
47116
+ const b2 = other.build[i];
47117
+ debug("build compare", i, a, b2);
47118
+ if (a === void 0 && b2 === void 0) {
47119
+ return 0;
47120
+ } else if (b2 === void 0) {
47121
+ return 1;
47122
+ } else if (a === void 0) {
47123
+ return -1;
47124
+ } else if (a === b2) {
47125
+ continue;
47126
+ } else {
47127
+ return compareIdentifiers(a, b2);
47128
+ }
47129
+ } while (++i);
46872
47130
  }
46873
- });
46874
- }
46875
- }
46876
- var init_task_helper = __esm({
46877
- "packages/cli/src/commands/task-helper.ts"() {
46878
- "use strict";
46879
- init_spinner();
46880
- init_src2();
46881
- init_cli_output();
46882
- }
46883
- });
46884
-
46885
- // packages/cli/src/commands/tty-confirm.ts
46886
- var tty_confirm_exports = {};
46887
- __export(tty_confirm_exports, {
46888
- buildPermissionDiff: () => buildPermissionDiff,
46889
- confirmPlanInteractive: () => confirmPlanInteractive,
46890
- findMissingAuthorizations: () => findMissingAuthorizations,
46891
- findUnexpectedAllows: () => findUnexpectedAllows
46892
- });
46893
- async function confirmPlanInteractive(opts) {
46894
- const plan = opts.plan;
46895
- const requested = [...plan.permissions];
46896
- const allowed = new Set(opts.allowedPermissions);
46897
- const toConfirm = requested.filter((p2) => !allowed.has(p2));
46898
- process.stderr.write(`
46899
- \u5373\u5C06\u6267\u884C ${opts.command}\uFF1A
46900
- `);
46901
- if (plan.projectRoot) {
46902
- process.stderr.write(` \u76EE\u5F55\uFF1A${plan.projectRoot}
46903
- `);
46904
- }
46905
- process.stderr.write(` \u53D7\u7BA1\u8D44\u6E90\uFF1A${plan.files.length} \u4E2A\u6587\u4EF6\u3001${plan.configEntries.length} \u9879\u914D\u7F6E
46906
- `);
46907
- if (opts.output.verbose) {
46908
- for (const file of plan.files.slice(0, 10)) process.stderr.write(` - ${file.path}
46909
- `);
46910
- if (plan.files.length > 10) process.stderr.write(` - \u53E6\u6709 ${plan.files.length - 10} \u4E2A\u6587\u4EF6
46911
- `);
46912
- process.stderr.write(` \u53D7\u7BA1\u6BB5\uFF1A${plan.managedSections.length}
46913
- `);
46914
- process.stderr.write(` Plan \u6458\u8981\uFF1A${plan.planDigest}
46915
- `);
46916
- }
46917
- const extraPermissions = requested.filter((permission) => permission !== "project.write");
47131
+ // preminor will bump the version up to the next minor release, and immediately
47132
+ // down to pre-release. premajor and prepatch work the same way.
47133
+ inc(release, identifier, identifierBase) {
47134
+ if (release.startsWith("pre")) {
47135
+ if (!identifier && identifierBase === false) {
47136
+ throw new Error("invalid increment argument: identifier is empty");
47137
+ }
47138
+ if (identifier) {
47139
+ const match = `-${identifier}`.match(this.options.loose ? re2[t2.PRERELEASELOOSE] : re2[t2.PRERELEASE]);
47140
+ if (!match || match[1] !== identifier) {
47141
+ throw new Error(`invalid identifier: ${identifier}`);
47142
+ }
47143
+ }
47144
+ }
47145
+ switch (release) {
47146
+ case "premajor":
47147
+ this.prerelease.length = 0;
47148
+ this.patch = 0;
47149
+ this.minor = 0;
47150
+ this.major++;
47151
+ this.inc("pre", identifier, identifierBase);
47152
+ break;
47153
+ case "preminor":
47154
+ this.prerelease.length = 0;
47155
+ this.patch = 0;
47156
+ this.minor++;
47157
+ this.inc("pre", identifier, identifierBase);
47158
+ break;
47159
+ case "prepatch":
47160
+ this.prerelease.length = 0;
47161
+ this.inc("patch", identifier, identifierBase);
47162
+ this.inc("pre", identifier, identifierBase);
47163
+ break;
47164
+ // If the input is a non-prerelease version, this acts the same as
47165
+ // prepatch.
47166
+ case "prerelease":
47167
+ if (this.prerelease.length === 0) {
47168
+ this.inc("patch", identifier, identifierBase);
47169
+ }
47170
+ this.inc("pre", identifier, identifierBase);
47171
+ break;
47172
+ case "release":
47173
+ if (this.prerelease.length === 0) {
47174
+ throw new Error(`version ${this.raw} is not a prerelease`);
47175
+ }
47176
+ this.prerelease.length = 0;
47177
+ break;
47178
+ case "major":
47179
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
47180
+ this.major++;
47181
+ }
47182
+ this.minor = 0;
47183
+ this.patch = 0;
47184
+ this.prerelease = [];
47185
+ break;
47186
+ case "minor":
47187
+ if (this.patch !== 0 || this.prerelease.length === 0) {
47188
+ this.minor++;
47189
+ }
47190
+ this.patch = 0;
47191
+ this.prerelease = [];
47192
+ break;
47193
+ case "patch":
47194
+ if (this.prerelease.length === 0) {
47195
+ this.patch++;
47196
+ }
47197
+ this.prerelease = [];
47198
+ break;
47199
+ // This probably shouldn't be used publicly.
47200
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
47201
+ case "pre": {
47202
+ const base = Number(identifierBase) ? 1 : 0;
47203
+ if (this.prerelease.length === 0) {
47204
+ this.prerelease = [base];
47205
+ } else {
47206
+ let i = this.prerelease.length;
47207
+ while (--i >= 0) {
47208
+ if (typeof this.prerelease[i] === "number") {
47209
+ this.prerelease[i]++;
47210
+ i = -2;
47211
+ }
47212
+ }
47213
+ if (i === -1) {
47214
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
47215
+ throw new Error("invalid increment argument: identifier already exists");
47216
+ }
47217
+ this.prerelease.push(base);
47218
+ }
47219
+ }
47220
+ if (identifier) {
47221
+ let prerelease = [identifier, base];
47222
+ if (identifierBase === false) {
47223
+ prerelease = [identifier];
47224
+ }
47225
+ if (isPrereleaseIdentifier(this.prerelease, identifier)) {
47226
+ const prereleaseBase = this.prerelease[identifier.split(".").length];
47227
+ if (isNaN(prereleaseBase)) {
47228
+ this.prerelease = prerelease;
47229
+ }
47230
+ } else {
47231
+ this.prerelease = prerelease;
47232
+ }
47233
+ }
47234
+ break;
47235
+ }
47236
+ default:
47237
+ throw new Error(`invalid increment argument: ${release}`);
47238
+ }
47239
+ this.raw = this.format();
47240
+ if (this.build.length) {
47241
+ this.raw += `+${this.build.join(".")}`;
47242
+ }
47243
+ return this;
47244
+ }
47245
+ };
47246
+ module.exports = SemVer;
47247
+ }
47248
+ });
47249
+
47250
+ // node_modules/semver/functions/parse.js
47251
+ var require_parse2 = __commonJS({
47252
+ "node_modules/semver/functions/parse.js"(exports, module) {
47253
+ "use strict";
47254
+ var SemVer = require_semver3();
47255
+ var parse = (version, options, throwErrors = false) => {
47256
+ if (version instanceof SemVer) {
47257
+ return version;
47258
+ }
47259
+ try {
47260
+ return new SemVer(version, options);
47261
+ } catch (er2) {
47262
+ if (!throwErrors) {
47263
+ return null;
47264
+ }
47265
+ throw er2;
47266
+ }
47267
+ };
47268
+ module.exports = parse;
47269
+ }
47270
+ });
47271
+
47272
+ // node_modules/semver/functions/valid.js
47273
+ var require_valid3 = __commonJS({
47274
+ "node_modules/semver/functions/valid.js"(exports, module) {
47275
+ "use strict";
47276
+ var parse = require_parse2();
47277
+ var valid2 = (version, options) => {
47278
+ const v2 = parse(version, options);
47279
+ return v2 ? v2.version : null;
47280
+ };
47281
+ module.exports = valid2;
47282
+ }
47283
+ });
47284
+
47285
+ // node_modules/semver/functions/clean.js
47286
+ var require_clean2 = __commonJS({
47287
+ "node_modules/semver/functions/clean.js"(exports, module) {
47288
+ "use strict";
47289
+ var parse = require_parse2();
47290
+ var clean = (version, options) => {
47291
+ const s3 = parse(version.trim().replace(/^[=v]+/, ""), options);
47292
+ return s3 ? s3.version : null;
47293
+ };
47294
+ module.exports = clean;
47295
+ }
47296
+ });
47297
+
47298
+ // node_modules/semver/functions/inc.js
47299
+ var require_inc2 = __commonJS({
47300
+ "node_modules/semver/functions/inc.js"(exports, module) {
47301
+ "use strict";
47302
+ var SemVer = require_semver3();
47303
+ var inc = (version, release, options, identifier, identifierBase) => {
47304
+ if (typeof options === "string") {
47305
+ identifierBase = identifier;
47306
+ identifier = options;
47307
+ options = void 0;
47308
+ }
47309
+ try {
47310
+ return new SemVer(
47311
+ version instanceof SemVer ? version.version : version,
47312
+ options
47313
+ ).inc(release, identifier, identifierBase).version;
47314
+ } catch (er2) {
47315
+ return null;
47316
+ }
47317
+ };
47318
+ module.exports = inc;
47319
+ }
47320
+ });
47321
+
47322
+ // node_modules/semver/functions/diff.js
47323
+ var require_diff2 = __commonJS({
47324
+ "node_modules/semver/functions/diff.js"(exports, module) {
47325
+ "use strict";
47326
+ var parse = require_parse2();
47327
+ var diff = (version1, version2) => {
47328
+ const v1 = parse(version1, null, true);
47329
+ const v2 = parse(version2, null, true);
47330
+ const comparison = v1.compare(v2);
47331
+ if (comparison === 0) {
47332
+ return null;
47333
+ }
47334
+ const v1Higher = comparison > 0;
47335
+ const highVersion = v1Higher ? v1 : v2;
47336
+ const lowVersion = v1Higher ? v2 : v1;
47337
+ const highHasPre = !!highVersion.prerelease.length;
47338
+ const lowHasPre = !!lowVersion.prerelease.length;
47339
+ if (lowHasPre && !highHasPre) {
47340
+ if (!lowVersion.patch && !lowVersion.minor) {
47341
+ return "major";
47342
+ }
47343
+ if (lowVersion.compareMain(highVersion) === 0) {
47344
+ if (lowVersion.minor && !lowVersion.patch) {
47345
+ return "minor";
47346
+ }
47347
+ return "patch";
47348
+ }
47349
+ }
47350
+ const prefix = highHasPre ? "pre" : "";
47351
+ if (v1.major !== v2.major) {
47352
+ return prefix + "major";
47353
+ }
47354
+ if (v1.minor !== v2.minor) {
47355
+ return prefix + "minor";
47356
+ }
47357
+ if (v1.patch !== v2.patch) {
47358
+ return prefix + "patch";
47359
+ }
47360
+ return "prerelease";
47361
+ };
47362
+ module.exports = diff;
47363
+ }
47364
+ });
47365
+
47366
+ // node_modules/semver/functions/major.js
47367
+ var require_major2 = __commonJS({
47368
+ "node_modules/semver/functions/major.js"(exports, module) {
47369
+ "use strict";
47370
+ var SemVer = require_semver3();
47371
+ var major = (a, loose) => new SemVer(a, loose).major;
47372
+ module.exports = major;
47373
+ }
47374
+ });
47375
+
47376
+ // node_modules/semver/functions/minor.js
47377
+ var require_minor2 = __commonJS({
47378
+ "node_modules/semver/functions/minor.js"(exports, module) {
47379
+ "use strict";
47380
+ var SemVer = require_semver3();
47381
+ var minor = (a, loose) => new SemVer(a, loose).minor;
47382
+ module.exports = minor;
47383
+ }
47384
+ });
47385
+
47386
+ // node_modules/semver/functions/patch.js
47387
+ var require_patch2 = __commonJS({
47388
+ "node_modules/semver/functions/patch.js"(exports, module) {
47389
+ "use strict";
47390
+ var SemVer = require_semver3();
47391
+ var patch = (a, loose) => new SemVer(a, loose).patch;
47392
+ module.exports = patch;
47393
+ }
47394
+ });
47395
+
47396
+ // node_modules/semver/functions/prerelease.js
47397
+ var require_prerelease2 = __commonJS({
47398
+ "node_modules/semver/functions/prerelease.js"(exports, module) {
47399
+ "use strict";
47400
+ var parse = require_parse2();
47401
+ var prerelease = (version, options) => {
47402
+ const parsed = parse(version, options);
47403
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
47404
+ };
47405
+ module.exports = prerelease;
47406
+ }
47407
+ });
47408
+
47409
+ // node_modules/semver/functions/compare.js
47410
+ var require_compare2 = __commonJS({
47411
+ "node_modules/semver/functions/compare.js"(exports, module) {
47412
+ "use strict";
47413
+ var SemVer = require_semver3();
47414
+ var compare = (a, b2, loose) => new SemVer(a, loose).compare(new SemVer(b2, loose));
47415
+ module.exports = compare;
47416
+ }
47417
+ });
47418
+
47419
+ // node_modules/semver/functions/rcompare.js
47420
+ var require_rcompare2 = __commonJS({
47421
+ "node_modules/semver/functions/rcompare.js"(exports, module) {
47422
+ "use strict";
47423
+ var compare = require_compare2();
47424
+ var rcompare = (a, b2, loose) => compare(b2, a, loose);
47425
+ module.exports = rcompare;
47426
+ }
47427
+ });
47428
+
47429
+ // node_modules/semver/functions/compare-loose.js
47430
+ var require_compare_loose2 = __commonJS({
47431
+ "node_modules/semver/functions/compare-loose.js"(exports, module) {
47432
+ "use strict";
47433
+ var compare = require_compare2();
47434
+ var compareLoose = (a, b2) => compare(a, b2, true);
47435
+ module.exports = compareLoose;
47436
+ }
47437
+ });
47438
+
47439
+ // node_modules/semver/functions/compare-build.js
47440
+ var require_compare_build2 = __commonJS({
47441
+ "node_modules/semver/functions/compare-build.js"(exports, module) {
47442
+ "use strict";
47443
+ var SemVer = require_semver3();
47444
+ var compareBuild = (a, b2, loose) => {
47445
+ const versionA = new SemVer(a, loose);
47446
+ const versionB = new SemVer(b2, loose);
47447
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
47448
+ };
47449
+ module.exports = compareBuild;
47450
+ }
47451
+ });
47452
+
47453
+ // node_modules/semver/functions/sort.js
47454
+ var require_sort2 = __commonJS({
47455
+ "node_modules/semver/functions/sort.js"(exports, module) {
47456
+ "use strict";
47457
+ var compareBuild = require_compare_build2();
47458
+ var sort = (list, loose) => list.sort((a, b2) => compareBuild(a, b2, loose));
47459
+ module.exports = sort;
47460
+ }
47461
+ });
47462
+
47463
+ // node_modules/semver/functions/rsort.js
47464
+ var require_rsort2 = __commonJS({
47465
+ "node_modules/semver/functions/rsort.js"(exports, module) {
47466
+ "use strict";
47467
+ var compareBuild = require_compare_build2();
47468
+ var rsort = (list, loose) => list.sort((a, b2) => compareBuild(b2, a, loose));
47469
+ module.exports = rsort;
47470
+ }
47471
+ });
47472
+
47473
+ // node_modules/semver/functions/gt.js
47474
+ var require_gt2 = __commonJS({
47475
+ "node_modules/semver/functions/gt.js"(exports, module) {
47476
+ "use strict";
47477
+ var compare = require_compare2();
47478
+ var gt3 = (a, b2, loose) => compare(a, b2, loose) > 0;
47479
+ module.exports = gt3;
47480
+ }
47481
+ });
47482
+
47483
+ // node_modules/semver/functions/lt.js
47484
+ var require_lt2 = __commonJS({
47485
+ "node_modules/semver/functions/lt.js"(exports, module) {
47486
+ "use strict";
47487
+ var compare = require_compare2();
47488
+ var lt2 = (a, b2, loose) => compare(a, b2, loose) < 0;
47489
+ module.exports = lt2;
47490
+ }
47491
+ });
47492
+
47493
+ // node_modules/semver/functions/eq.js
47494
+ var require_eq2 = __commonJS({
47495
+ "node_modules/semver/functions/eq.js"(exports, module) {
47496
+ "use strict";
47497
+ var compare = require_compare2();
47498
+ var eq = (a, b2, loose) => compare(a, b2, loose) === 0;
47499
+ module.exports = eq;
47500
+ }
47501
+ });
47502
+
47503
+ // node_modules/semver/functions/neq.js
47504
+ var require_neq2 = __commonJS({
47505
+ "node_modules/semver/functions/neq.js"(exports, module) {
47506
+ "use strict";
47507
+ var compare = require_compare2();
47508
+ var neq = (a, b2, loose) => compare(a, b2, loose) !== 0;
47509
+ module.exports = neq;
47510
+ }
47511
+ });
47512
+
47513
+ // node_modules/semver/functions/gte.js
47514
+ var require_gte2 = __commonJS({
47515
+ "node_modules/semver/functions/gte.js"(exports, module) {
47516
+ "use strict";
47517
+ var compare = require_compare2();
47518
+ var gte = (a, b2, loose) => compare(a, b2, loose) >= 0;
47519
+ module.exports = gte;
47520
+ }
47521
+ });
47522
+
47523
+ // node_modules/semver/functions/lte.js
47524
+ var require_lte2 = __commonJS({
47525
+ "node_modules/semver/functions/lte.js"(exports, module) {
47526
+ "use strict";
47527
+ var compare = require_compare2();
47528
+ var lte = (a, b2, loose) => compare(a, b2, loose) <= 0;
47529
+ module.exports = lte;
47530
+ }
47531
+ });
47532
+
47533
+ // node_modules/semver/functions/cmp.js
47534
+ var require_cmp2 = __commonJS({
47535
+ "node_modules/semver/functions/cmp.js"(exports, module) {
47536
+ "use strict";
47537
+ var eq = require_eq2();
47538
+ var neq = require_neq2();
47539
+ var gt3 = require_gt2();
47540
+ var gte = require_gte2();
47541
+ var lt2 = require_lt2();
47542
+ var lte = require_lte2();
47543
+ var cmp = (a, op, b2, loose) => {
47544
+ switch (op) {
47545
+ case "===":
47546
+ if (typeof a === "object") {
47547
+ a = a.version;
47548
+ }
47549
+ if (typeof b2 === "object") {
47550
+ b2 = b2.version;
47551
+ }
47552
+ return a === b2;
47553
+ case "!==":
47554
+ if (typeof a === "object") {
47555
+ a = a.version;
47556
+ }
47557
+ if (typeof b2 === "object") {
47558
+ b2 = b2.version;
47559
+ }
47560
+ return a !== b2;
47561
+ case "":
47562
+ case "=":
47563
+ case "==":
47564
+ return eq(a, b2, loose);
47565
+ case "!=":
47566
+ return neq(a, b2, loose);
47567
+ case ">":
47568
+ return gt3(a, b2, loose);
47569
+ case ">=":
47570
+ return gte(a, b2, loose);
47571
+ case "<":
47572
+ return lt2(a, b2, loose);
47573
+ case "<=":
47574
+ return lte(a, b2, loose);
47575
+ default:
47576
+ throw new TypeError(`Invalid operator: ${op}`);
47577
+ }
47578
+ };
47579
+ module.exports = cmp;
47580
+ }
47581
+ });
47582
+
47583
+ // node_modules/semver/functions/coerce.js
47584
+ var require_coerce2 = __commonJS({
47585
+ "node_modules/semver/functions/coerce.js"(exports, module) {
47586
+ "use strict";
47587
+ var SemVer = require_semver3();
47588
+ var parse = require_parse2();
47589
+ var { safeRe: re2, t: t2 } = require_re2();
47590
+ var coerce = (version, options) => {
47591
+ if (version instanceof SemVer) {
47592
+ return version;
47593
+ }
47594
+ if (typeof version === "number") {
47595
+ version = String(version);
47596
+ }
47597
+ if (typeof version !== "string") {
47598
+ return null;
47599
+ }
47600
+ options = options || {};
47601
+ let match = null;
47602
+ if (!options.rtl) {
47603
+ match = version.match(options.includePrerelease ? re2[t2.COERCEFULL] : re2[t2.COERCE]);
47604
+ } else {
47605
+ const coerceRtlRegex = options.includePrerelease ? re2[t2.COERCERTLFULL] : re2[t2.COERCERTL];
47606
+ let next;
47607
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
47608
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
47609
+ match = next;
47610
+ }
47611
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
47612
+ }
47613
+ coerceRtlRegex.lastIndex = -1;
47614
+ }
47615
+ if (match === null) {
47616
+ return null;
47617
+ }
47618
+ const major = match[2];
47619
+ const minor = match[3] || "0";
47620
+ const patch = match[4] || "0";
47621
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
47622
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
47623
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
47624
+ };
47625
+ module.exports = coerce;
47626
+ }
47627
+ });
47628
+
47629
+ // node_modules/semver/functions/truncate.js
47630
+ var require_truncate2 = __commonJS({
47631
+ "node_modules/semver/functions/truncate.js"(exports, module) {
47632
+ "use strict";
47633
+ var parse = require_parse2();
47634
+ var constants = require_constants2();
47635
+ var SemVer = require_semver3();
47636
+ var truncate = (version, truncation, options) => {
47637
+ if (!constants.RELEASE_TYPES.includes(truncation)) {
47638
+ return null;
47639
+ }
47640
+ const clonedVersion = cloneInputVersion(version, options);
47641
+ return clonedVersion && doTruncation(clonedVersion, truncation);
47642
+ };
47643
+ var cloneInputVersion = (version, options) => {
47644
+ const versionStringToParse = version instanceof SemVer ? version.version : version;
47645
+ return parse(versionStringToParse, options);
47646
+ };
47647
+ var doTruncation = (version, truncation) => {
47648
+ if (isPrerelease(truncation)) {
47649
+ return version.version;
47650
+ }
47651
+ version.prerelease = [];
47652
+ switch (truncation) {
47653
+ case "major":
47654
+ version.minor = 0;
47655
+ version.patch = 0;
47656
+ break;
47657
+ case "minor":
47658
+ version.patch = 0;
47659
+ break;
47660
+ }
47661
+ return version.format();
47662
+ };
47663
+ var isPrerelease = (type) => {
47664
+ return type.startsWith("pre");
47665
+ };
47666
+ module.exports = truncate;
47667
+ }
47668
+ });
47669
+
47670
+ // node_modules/semver/internal/lrucache.js
47671
+ var require_lrucache2 = __commonJS({
47672
+ "node_modules/semver/internal/lrucache.js"(exports, module) {
47673
+ "use strict";
47674
+ var LRUCache = class {
47675
+ constructor() {
47676
+ this.max = 1e3;
47677
+ this.map = /* @__PURE__ */ new Map();
47678
+ }
47679
+ get(key) {
47680
+ const value = this.map.get(key);
47681
+ if (value === void 0) {
47682
+ return void 0;
47683
+ } else {
47684
+ this.map.delete(key);
47685
+ this.map.set(key, value);
47686
+ return value;
47687
+ }
47688
+ }
47689
+ delete(key) {
47690
+ return this.map.delete(key);
47691
+ }
47692
+ set(key, value) {
47693
+ const deleted = this.delete(key);
47694
+ if (!deleted && value !== void 0) {
47695
+ if (this.map.size >= this.max) {
47696
+ const firstKey = this.map.keys().next().value;
47697
+ this.delete(firstKey);
47698
+ }
47699
+ this.map.set(key, value);
47700
+ }
47701
+ return this;
47702
+ }
47703
+ };
47704
+ module.exports = LRUCache;
47705
+ }
47706
+ });
47707
+
47708
+ // node_modules/semver/classes/range.js
47709
+ var require_range2 = __commonJS({
47710
+ "node_modules/semver/classes/range.js"(exports, module) {
47711
+ "use strict";
47712
+ var SPACE_CHARACTERS = /\s+/g;
47713
+ var Range = class _Range {
47714
+ constructor(range, options) {
47715
+ options = parseOptions(options);
47716
+ if (range instanceof _Range) {
47717
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
47718
+ return range;
47719
+ } else {
47720
+ return new _Range(range.raw, options);
47721
+ }
47722
+ }
47723
+ if (range instanceof Comparator) {
47724
+ this.raw = range.value;
47725
+ this.set = [[range]];
47726
+ this.formatted = void 0;
47727
+ return this;
47728
+ }
47729
+ this.options = options;
47730
+ this.loose = !!options.loose;
47731
+ this.includePrerelease = !!options.includePrerelease;
47732
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
47733
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
47734
+ if (!this.set.length) {
47735
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
47736
+ }
47737
+ if (this.set.length > 1) {
47738
+ const first = this.set[0];
47739
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
47740
+ if (this.set.length === 0) {
47741
+ this.set = [first];
47742
+ } else if (this.set.length > 1) {
47743
+ for (const c of this.set) {
47744
+ if (c.length === 1 && isAny(c[0])) {
47745
+ this.set = [c];
47746
+ break;
47747
+ }
47748
+ }
47749
+ }
47750
+ }
47751
+ this.formatted = void 0;
47752
+ }
47753
+ get range() {
47754
+ if (this.formatted === void 0) {
47755
+ this.formatted = "";
47756
+ for (let i = 0; i < this.set.length; i++) {
47757
+ if (i > 0) {
47758
+ this.formatted += "||";
47759
+ }
47760
+ const comps = this.set[i];
47761
+ for (let k2 = 0; k2 < comps.length; k2++) {
47762
+ if (k2 > 0) {
47763
+ this.formatted += " ";
47764
+ }
47765
+ this.formatted += comps[k2].toString().trim();
47766
+ }
47767
+ }
47768
+ }
47769
+ return this.formatted;
47770
+ }
47771
+ format() {
47772
+ return this.range;
47773
+ }
47774
+ toString() {
47775
+ return this.range;
47776
+ }
47777
+ parseRange(range) {
47778
+ range = range.replace(BUILDSTRIPRE, "");
47779
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
47780
+ const memoKey = memoOpts + ":" + range;
47781
+ const cached = cache.get(memoKey);
47782
+ if (cached) {
47783
+ return cached;
47784
+ }
47785
+ const loose = this.options.loose;
47786
+ const hr2 = loose ? re2[t2.HYPHENRANGELOOSE] : re2[t2.HYPHENRANGE];
47787
+ range = range.replace(hr2, hyphenReplace(this.options.includePrerelease));
47788
+ debug("hyphen replace", range);
47789
+ range = range.replace(re2[t2.COMPARATORTRIM], comparatorTrimReplace);
47790
+ debug("comparator trim", range);
47791
+ range = range.replace(re2[t2.TILDETRIM], tildeTrimReplace);
47792
+ debug("tilde trim", range);
47793
+ range = range.replace(re2[t2.CARETTRIM], caretTrimReplace);
47794
+ debug("caret trim", range);
47795
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
47796
+ if (loose) {
47797
+ rangeList = rangeList.filter((comp) => {
47798
+ debug("loose invalid filter", comp, this.options);
47799
+ return !!comp.match(re2[t2.COMPARATORLOOSE]);
47800
+ });
47801
+ }
47802
+ debug("range list", rangeList);
47803
+ const rangeMap = /* @__PURE__ */ new Map();
47804
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
47805
+ for (const comp of comparators) {
47806
+ if (isNullSet(comp)) {
47807
+ return [comp];
47808
+ }
47809
+ rangeMap.set(comp.value, comp);
47810
+ }
47811
+ if (rangeMap.size > 1 && rangeMap.has("")) {
47812
+ rangeMap.delete("");
47813
+ }
47814
+ const result = [...rangeMap.values()];
47815
+ cache.set(memoKey, result);
47816
+ return result;
47817
+ }
47818
+ intersects(range, options) {
47819
+ if (!(range instanceof _Range)) {
47820
+ throw new TypeError("a Range is required");
47821
+ }
47822
+ return this.set.some((thisComparators) => {
47823
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
47824
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
47825
+ return rangeComparators.every((rangeComparator) => {
47826
+ return thisComparator.intersects(rangeComparator, options);
47827
+ });
47828
+ });
47829
+ });
47830
+ });
47831
+ }
47832
+ // if ANY of the sets match ALL of its comparators, then pass
47833
+ test(version) {
47834
+ if (!version) {
47835
+ return false;
47836
+ }
47837
+ if (typeof version === "string") {
47838
+ try {
47839
+ version = new SemVer(version, this.options);
47840
+ } catch (er2) {
47841
+ return false;
47842
+ }
47843
+ }
47844
+ for (let i = 0; i < this.set.length; i++) {
47845
+ if (testSet(this.set[i], version, this.options)) {
47846
+ return true;
47847
+ }
47848
+ }
47849
+ return false;
47850
+ }
47851
+ };
47852
+ module.exports = Range;
47853
+ var LRU = require_lrucache2();
47854
+ var cache = new LRU();
47855
+ var parseOptions = require_parse_options2();
47856
+ var Comparator = require_comparator2();
47857
+ var debug = require_debug2();
47858
+ var SemVer = require_semver3();
47859
+ var {
47860
+ safeRe: re2,
47861
+ src,
47862
+ t: t2,
47863
+ comparatorTrimReplace,
47864
+ tildeTrimReplace,
47865
+ caretTrimReplace
47866
+ } = require_re2();
47867
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants2();
47868
+ var BUILDSTRIPRE = new RegExp(src[t2.BUILD], "g");
47869
+ var isNullSet = (c) => c.value === "<0.0.0-0";
47870
+ var isAny = (c) => c.value === "";
47871
+ var isSatisfiable = (comparators, options) => {
47872
+ let result = true;
47873
+ const remainingComparators = comparators.slice();
47874
+ let testComparator = remainingComparators.pop();
47875
+ while (result && remainingComparators.length) {
47876
+ result = remainingComparators.every((otherComparator) => {
47877
+ return testComparator.intersects(otherComparator, options);
47878
+ });
47879
+ testComparator = remainingComparators.pop();
47880
+ }
47881
+ return result;
47882
+ };
47883
+ var parseComparator = (comp, options) => {
47884
+ comp = comp.replace(re2[t2.BUILD], "");
47885
+ debug("comp", comp, options);
47886
+ comp = replaceCarets(comp, options);
47887
+ debug("caret", comp);
47888
+ comp = replaceTildes(comp, options);
47889
+ debug("tildes", comp);
47890
+ comp = replaceXRanges(comp, options);
47891
+ debug("xrange", comp);
47892
+ comp = replaceStars(comp, options);
47893
+ debug("stars", comp);
47894
+ return comp;
47895
+ };
47896
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
47897
+ var invalidXRangeOrder = (M2, m2, p2) => isX(M2) && !isX(m2) || isX(m2) && p2 && !isX(p2);
47898
+ var replaceTildes = (comp, options) => {
47899
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
47900
+ };
47901
+ var replaceTilde = (comp, options) => {
47902
+ const r = options.loose ? re2[t2.TILDELOOSE] : re2[t2.TILDE];
47903
+ const z2 = options.includePrerelease ? "-0" : "";
47904
+ return comp.replace(r, (_2, M2, m2, p2, pr2) => {
47905
+ debug("tilde", comp, _2, M2, m2, p2, pr2);
47906
+ let ret;
47907
+ if (isX(M2)) {
47908
+ ret = "";
47909
+ } else if (isX(m2)) {
47910
+ ret = `>=${M2}.0.0${z2} <${+M2 + 1}.0.0-0`;
47911
+ } else if (isX(p2)) {
47912
+ ret = `>=${M2}.${m2}.0${z2} <${M2}.${+m2 + 1}.0-0`;
47913
+ } else if (pr2) {
47914
+ debug("replaceTilde pr", pr2);
47915
+ ret = `>=${M2}.${m2}.${p2}-${pr2} <${M2}.${+m2 + 1}.0-0`;
47916
+ } else {
47917
+ ret = `>=${M2}.${m2}.${p2} <${M2}.${+m2 + 1}.0-0`;
47918
+ }
47919
+ debug("tilde return", ret);
47920
+ return ret;
47921
+ });
47922
+ };
47923
+ var replaceCarets = (comp, options) => {
47924
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
47925
+ };
47926
+ var replaceCaret = (comp, options) => {
47927
+ debug("caret", comp, options);
47928
+ const r = options.loose ? re2[t2.CARETLOOSE] : re2[t2.CARET];
47929
+ const z2 = options.includePrerelease ? "-0" : "";
47930
+ return comp.replace(r, (_2, M2, m2, p2, pr2) => {
47931
+ debug("caret", comp, _2, M2, m2, p2, pr2);
47932
+ let ret;
47933
+ if (isX(M2)) {
47934
+ ret = "";
47935
+ } else if (isX(m2)) {
47936
+ ret = `>=${M2}.0.0${z2} <${+M2 + 1}.0.0-0`;
47937
+ } else if (isX(p2)) {
47938
+ if (M2 === "0") {
47939
+ ret = `>=${M2}.${m2}.0${z2} <${M2}.${+m2 + 1}.0-0`;
47940
+ } else {
47941
+ ret = `>=${M2}.${m2}.0${z2} <${+M2 + 1}.0.0-0`;
47942
+ }
47943
+ } else if (pr2) {
47944
+ debug("replaceCaret pr", pr2);
47945
+ if (M2 === "0") {
47946
+ if (m2 === "0") {
47947
+ ret = `>=${M2}.${m2}.${p2}-${pr2} <${M2}.${m2}.${+p2 + 1}-0`;
47948
+ } else {
47949
+ ret = `>=${M2}.${m2}.${p2}-${pr2} <${M2}.${+m2 + 1}.0-0`;
47950
+ }
47951
+ } else {
47952
+ ret = `>=${M2}.${m2}.${p2}-${pr2} <${+M2 + 1}.0.0-0`;
47953
+ }
47954
+ } else {
47955
+ debug("no pr");
47956
+ if (M2 === "0") {
47957
+ if (m2 === "0") {
47958
+ ret = `>=${M2}.${m2}.${p2} <${M2}.${m2}.${+p2 + 1}-0`;
47959
+ } else {
47960
+ ret = `>=${M2}.${m2}.${p2} <${M2}.${+m2 + 1}.0-0`;
47961
+ }
47962
+ } else {
47963
+ ret = `>=${M2}.${m2}.${p2} <${+M2 + 1}.0.0-0`;
47964
+ }
47965
+ }
47966
+ debug("caret return", ret);
47967
+ return ret;
47968
+ });
47969
+ };
47970
+ var replaceXRanges = (comp, options) => {
47971
+ debug("replaceXRanges", comp, options);
47972
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
47973
+ };
47974
+ var replaceXRange = (comp, options) => {
47975
+ comp = comp.trim();
47976
+ const r = options.loose ? re2[t2.XRANGELOOSE] : re2[t2.XRANGE];
47977
+ return comp.replace(r, (ret, gtlt, M2, m2, p2, pr2) => {
47978
+ debug("xRange", comp, ret, gtlt, M2, m2, p2, pr2);
47979
+ if (invalidXRangeOrder(M2, m2, p2)) {
47980
+ return comp;
47981
+ }
47982
+ const xM = isX(M2);
47983
+ const xm = xM || isX(m2);
47984
+ const xp = xm || isX(p2);
47985
+ const anyX = xp;
47986
+ if (gtlt === "=" && anyX) {
47987
+ gtlt = "";
47988
+ }
47989
+ pr2 = options.includePrerelease ? "-0" : "";
47990
+ if (xM) {
47991
+ if (gtlt === ">" || gtlt === "<") {
47992
+ ret = "<0.0.0-0";
47993
+ } else {
47994
+ ret = "*";
47995
+ }
47996
+ } else if (gtlt && anyX) {
47997
+ if (xm) {
47998
+ m2 = 0;
47999
+ }
48000
+ p2 = 0;
48001
+ if (gtlt === ">") {
48002
+ gtlt = ">=";
48003
+ if (xm) {
48004
+ M2 = +M2 + 1;
48005
+ m2 = 0;
48006
+ p2 = 0;
48007
+ } else {
48008
+ m2 = +m2 + 1;
48009
+ p2 = 0;
48010
+ }
48011
+ } else if (gtlt === "<=") {
48012
+ gtlt = "<";
48013
+ if (xm) {
48014
+ M2 = +M2 + 1;
48015
+ } else {
48016
+ m2 = +m2 + 1;
48017
+ }
48018
+ }
48019
+ if (gtlt === "<") {
48020
+ pr2 = "-0";
48021
+ }
48022
+ ret = `${gtlt + M2}.${m2}.${p2}${pr2}`;
48023
+ } else if (xm) {
48024
+ ret = `>=${M2}.0.0${pr2} <${+M2 + 1}.0.0-0`;
48025
+ } else if (xp) {
48026
+ ret = `>=${M2}.${m2}.0${pr2} <${M2}.${+m2 + 1}.0-0`;
48027
+ }
48028
+ debug("xRange return", ret);
48029
+ return ret;
48030
+ });
48031
+ };
48032
+ var replaceStars = (comp, options) => {
48033
+ debug("replaceStars", comp, options);
48034
+ return comp.trim().replace(re2[t2.STAR], "");
48035
+ };
48036
+ var replaceGTE0 = (comp, options) => {
48037
+ debug("replaceGTE0", comp, options);
48038
+ return comp.trim().replace(re2[options.includePrerelease ? t2.GTE0PRE : t2.GTE0], "");
48039
+ };
48040
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to2, tM, tm, tp, tpr) => {
48041
+ if (isX(fM)) {
48042
+ from = "";
48043
+ } else if (isX(fm)) {
48044
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
48045
+ } else if (isX(fp)) {
48046
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
48047
+ } else if (fpr) {
48048
+ from = `>=${from}`;
48049
+ } else {
48050
+ from = `>=${from}${incPr ? "-0" : ""}`;
48051
+ }
48052
+ if (isX(tM)) {
48053
+ to2 = "";
48054
+ } else if (isX(tm)) {
48055
+ to2 = `<${+tM + 1}.0.0-0`;
48056
+ } else if (isX(tp)) {
48057
+ to2 = `<${tM}.${+tm + 1}.0-0`;
48058
+ } else if (tpr) {
48059
+ to2 = `<=${tM}.${tm}.${tp}-${tpr}`;
48060
+ } else if (incPr) {
48061
+ to2 = `<${tM}.${tm}.${+tp + 1}-0`;
48062
+ } else {
48063
+ to2 = `<=${to2}`;
48064
+ }
48065
+ return `${from} ${to2}`.trim();
48066
+ };
48067
+ var testSet = (set, version, options) => {
48068
+ for (let i = 0; i < set.length; i++) {
48069
+ if (!set[i].test(version)) {
48070
+ return false;
48071
+ }
48072
+ }
48073
+ if (version.prerelease.length && !options.includePrerelease) {
48074
+ for (let i = 0; i < set.length; i++) {
48075
+ debug(set[i].semver);
48076
+ if (set[i].semver === Comparator.ANY) {
48077
+ continue;
48078
+ }
48079
+ if (set[i].semver.prerelease.length > 0) {
48080
+ const allowed = set[i].semver;
48081
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
48082
+ return true;
48083
+ }
48084
+ }
48085
+ }
48086
+ return false;
48087
+ }
48088
+ return true;
48089
+ };
48090
+ }
48091
+ });
48092
+
48093
+ // node_modules/semver/classes/comparator.js
48094
+ var require_comparator2 = __commonJS({
48095
+ "node_modules/semver/classes/comparator.js"(exports, module) {
48096
+ "use strict";
48097
+ var ANY = Symbol("SemVer ANY");
48098
+ var Comparator = class _Comparator {
48099
+ static get ANY() {
48100
+ return ANY;
48101
+ }
48102
+ constructor(comp, options) {
48103
+ options = parseOptions(options);
48104
+ if (comp instanceof _Comparator) {
48105
+ if (comp.loose === !!options.loose) {
48106
+ return comp;
48107
+ } else {
48108
+ comp = comp.value;
48109
+ }
48110
+ }
48111
+ comp = comp.trim().split(/\s+/).join(" ");
48112
+ debug("comparator", comp, options);
48113
+ this.options = options;
48114
+ this.loose = !!options.loose;
48115
+ this.parse(comp);
48116
+ if (this.semver === ANY) {
48117
+ this.value = "";
48118
+ } else {
48119
+ this.value = this.operator + this.semver.version;
48120
+ }
48121
+ debug("comp", this);
48122
+ }
48123
+ parse(comp) {
48124
+ const r = this.options.loose ? re2[t2.COMPARATORLOOSE] : re2[t2.COMPARATOR];
48125
+ const m2 = comp.match(r);
48126
+ if (!m2) {
48127
+ throw new TypeError(`Invalid comparator: ${comp}`);
48128
+ }
48129
+ this.operator = m2[1] !== void 0 ? m2[1] : "";
48130
+ if (this.operator === "=") {
48131
+ this.operator = "";
48132
+ }
48133
+ if (!m2[2]) {
48134
+ this.semver = ANY;
48135
+ } else {
48136
+ this.semver = new SemVer(m2[2], this.options.loose);
48137
+ }
48138
+ }
48139
+ toString() {
48140
+ return this.value;
48141
+ }
48142
+ test(version) {
48143
+ debug("Comparator.test", version, this.options.loose);
48144
+ if (this.semver === ANY || version === ANY) {
48145
+ return true;
48146
+ }
48147
+ if (typeof version === "string") {
48148
+ try {
48149
+ version = new SemVer(version, this.options);
48150
+ } catch (er2) {
48151
+ return false;
48152
+ }
48153
+ }
48154
+ return cmp(version, this.operator, this.semver, this.options);
48155
+ }
48156
+ intersects(comp, options) {
48157
+ if (!(comp instanceof _Comparator)) {
48158
+ throw new TypeError("a Comparator is required");
48159
+ }
48160
+ if (this.operator === "") {
48161
+ if (this.value === "") {
48162
+ return true;
48163
+ }
48164
+ return new Range(comp.value, options).test(this.value);
48165
+ } else if (comp.operator === "") {
48166
+ if (comp.value === "") {
48167
+ return true;
48168
+ }
48169
+ return new Range(this.value, options).test(comp.semver);
48170
+ }
48171
+ options = parseOptions(options);
48172
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
48173
+ return false;
48174
+ }
48175
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
48176
+ return false;
48177
+ }
48178
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
48179
+ return true;
48180
+ }
48181
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
48182
+ return true;
48183
+ }
48184
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
48185
+ return true;
48186
+ }
48187
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
48188
+ return true;
48189
+ }
48190
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
48191
+ return true;
48192
+ }
48193
+ return false;
48194
+ }
48195
+ };
48196
+ module.exports = Comparator;
48197
+ var parseOptions = require_parse_options2();
48198
+ var { safeRe: re2, t: t2 } = require_re2();
48199
+ var cmp = require_cmp2();
48200
+ var debug = require_debug2();
48201
+ var SemVer = require_semver3();
48202
+ var Range = require_range2();
48203
+ }
48204
+ });
48205
+
48206
+ // node_modules/semver/functions/satisfies.js
48207
+ var require_satisfies2 = __commonJS({
48208
+ "node_modules/semver/functions/satisfies.js"(exports, module) {
48209
+ "use strict";
48210
+ var Range = require_range2();
48211
+ var satisfies2 = (version, range, options) => {
48212
+ try {
48213
+ range = new Range(range, options);
48214
+ } catch (er2) {
48215
+ return false;
48216
+ }
48217
+ return range.test(version);
48218
+ };
48219
+ module.exports = satisfies2;
48220
+ }
48221
+ });
48222
+
48223
+ // node_modules/semver/ranges/to-comparators.js
48224
+ var require_to_comparators2 = __commonJS({
48225
+ "node_modules/semver/ranges/to-comparators.js"(exports, module) {
48226
+ "use strict";
48227
+ var Range = require_range2();
48228
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
48229
+ module.exports = toComparators;
48230
+ }
48231
+ });
48232
+
48233
+ // node_modules/semver/ranges/max-satisfying.js
48234
+ var require_max_satisfying2 = __commonJS({
48235
+ "node_modules/semver/ranges/max-satisfying.js"(exports, module) {
48236
+ "use strict";
48237
+ var SemVer = require_semver3();
48238
+ var Range = require_range2();
48239
+ var maxSatisfying = (versions, range, options) => {
48240
+ let max = null;
48241
+ let maxSV = null;
48242
+ let rangeObj = null;
48243
+ try {
48244
+ rangeObj = new Range(range, options);
48245
+ } catch (er2) {
48246
+ return null;
48247
+ }
48248
+ versions.forEach((v2) => {
48249
+ if (rangeObj.test(v2)) {
48250
+ if (!max || maxSV.compare(v2) === -1) {
48251
+ max = v2;
48252
+ maxSV = new SemVer(max, options);
48253
+ }
48254
+ }
48255
+ });
48256
+ return max;
48257
+ };
48258
+ module.exports = maxSatisfying;
48259
+ }
48260
+ });
48261
+
48262
+ // node_modules/semver/ranges/min-satisfying.js
48263
+ var require_min_satisfying2 = __commonJS({
48264
+ "node_modules/semver/ranges/min-satisfying.js"(exports, module) {
48265
+ "use strict";
48266
+ var SemVer = require_semver3();
48267
+ var Range = require_range2();
48268
+ var minSatisfying = (versions, range, options) => {
48269
+ let min = null;
48270
+ let minSV = null;
48271
+ let rangeObj = null;
48272
+ try {
48273
+ rangeObj = new Range(range, options);
48274
+ } catch (er2) {
48275
+ return null;
48276
+ }
48277
+ versions.forEach((v2) => {
48278
+ if (rangeObj.test(v2)) {
48279
+ if (!min || minSV.compare(v2) === 1) {
48280
+ min = v2;
48281
+ minSV = new SemVer(min, options);
48282
+ }
48283
+ }
48284
+ });
48285
+ return min;
48286
+ };
48287
+ module.exports = minSatisfying;
48288
+ }
48289
+ });
48290
+
48291
+ // node_modules/semver/ranges/min-version.js
48292
+ var require_min_version2 = __commonJS({
48293
+ "node_modules/semver/ranges/min-version.js"(exports, module) {
48294
+ "use strict";
48295
+ var SemVer = require_semver3();
48296
+ var Range = require_range2();
48297
+ var gt3 = require_gt2();
48298
+ var minVersion = (range, loose) => {
48299
+ range = new Range(range, loose);
48300
+ let minver = new SemVer("0.0.0");
48301
+ if (range.test(minver)) {
48302
+ return minver;
48303
+ }
48304
+ minver = new SemVer("0.0.0-0");
48305
+ if (range.test(minver)) {
48306
+ return minver;
48307
+ }
48308
+ minver = null;
48309
+ for (let i = 0; i < range.set.length; ++i) {
48310
+ const comparators = range.set[i];
48311
+ let setMin = null;
48312
+ comparators.forEach((comparator) => {
48313
+ const compver = new SemVer(comparator.semver.version);
48314
+ switch (comparator.operator) {
48315
+ case ">":
48316
+ if (compver.prerelease.length === 0) {
48317
+ compver.patch++;
48318
+ } else {
48319
+ compver.prerelease.push(0);
48320
+ }
48321
+ compver.raw = compver.format();
48322
+ /* fallthrough */
48323
+ case "":
48324
+ case ">=":
48325
+ if (!setMin || gt3(compver, setMin)) {
48326
+ setMin = compver;
48327
+ }
48328
+ break;
48329
+ case "<":
48330
+ case "<=":
48331
+ break;
48332
+ /* istanbul ignore next */
48333
+ default:
48334
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
48335
+ }
48336
+ });
48337
+ if (setMin && (!minver || gt3(minver, setMin))) {
48338
+ minver = setMin;
48339
+ }
48340
+ }
48341
+ if (minver && range.test(minver)) {
48342
+ return minver;
48343
+ }
48344
+ return null;
48345
+ };
48346
+ module.exports = minVersion;
48347
+ }
48348
+ });
48349
+
48350
+ // node_modules/semver/ranges/valid.js
48351
+ var require_valid4 = __commonJS({
48352
+ "node_modules/semver/ranges/valid.js"(exports, module) {
48353
+ "use strict";
48354
+ var Range = require_range2();
48355
+ var validRange = (range, options) => {
48356
+ try {
48357
+ return new Range(range, options).range || "*";
48358
+ } catch (er2) {
48359
+ return null;
48360
+ }
48361
+ };
48362
+ module.exports = validRange;
48363
+ }
48364
+ });
48365
+
48366
+ // node_modules/semver/ranges/outside.js
48367
+ var require_outside2 = __commonJS({
48368
+ "node_modules/semver/ranges/outside.js"(exports, module) {
48369
+ "use strict";
48370
+ var SemVer = require_semver3();
48371
+ var Comparator = require_comparator2();
48372
+ var { ANY } = Comparator;
48373
+ var Range = require_range2();
48374
+ var satisfies2 = require_satisfies2();
48375
+ var gt3 = require_gt2();
48376
+ var lt2 = require_lt2();
48377
+ var lte = require_lte2();
48378
+ var gte = require_gte2();
48379
+ var outside = (version, range, hilo, options) => {
48380
+ version = new SemVer(version, options);
48381
+ range = new Range(range, options);
48382
+ let gtfn, ltefn, ltfn, comp, ecomp;
48383
+ switch (hilo) {
48384
+ case ">":
48385
+ gtfn = gt3;
48386
+ ltefn = lte;
48387
+ ltfn = lt2;
48388
+ comp = ">";
48389
+ ecomp = ">=";
48390
+ break;
48391
+ case "<":
48392
+ gtfn = lt2;
48393
+ ltefn = gte;
48394
+ ltfn = gt3;
48395
+ comp = "<";
48396
+ ecomp = "<=";
48397
+ break;
48398
+ default:
48399
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
48400
+ }
48401
+ if (satisfies2(version, range, options)) {
48402
+ return false;
48403
+ }
48404
+ for (let i = 0; i < range.set.length; ++i) {
48405
+ const comparators = range.set[i];
48406
+ let high = null;
48407
+ let low = null;
48408
+ comparators.forEach((comparator) => {
48409
+ if (comparator.semver === ANY) {
48410
+ comparator = new Comparator(">=0.0.0");
48411
+ }
48412
+ high = high || comparator;
48413
+ low = low || comparator;
48414
+ if (gtfn(comparator.semver, high.semver, options)) {
48415
+ high = comparator;
48416
+ } else if (ltfn(comparator.semver, low.semver, options)) {
48417
+ low = comparator;
48418
+ }
48419
+ });
48420
+ if (high.operator === comp || high.operator === ecomp) {
48421
+ return false;
48422
+ }
48423
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
48424
+ return false;
48425
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
48426
+ return false;
48427
+ }
48428
+ }
48429
+ return true;
48430
+ };
48431
+ module.exports = outside;
48432
+ }
48433
+ });
48434
+
48435
+ // node_modules/semver/ranges/gtr.js
48436
+ var require_gtr2 = __commonJS({
48437
+ "node_modules/semver/ranges/gtr.js"(exports, module) {
48438
+ "use strict";
48439
+ var outside = require_outside2();
48440
+ var gtr = (version, range, options) => outside(version, range, ">", options);
48441
+ module.exports = gtr;
48442
+ }
48443
+ });
48444
+
48445
+ // node_modules/semver/ranges/ltr.js
48446
+ var require_ltr2 = __commonJS({
48447
+ "node_modules/semver/ranges/ltr.js"(exports, module) {
48448
+ "use strict";
48449
+ var outside = require_outside2();
48450
+ var ltr = (version, range, options) => outside(version, range, "<", options);
48451
+ module.exports = ltr;
48452
+ }
48453
+ });
48454
+
48455
+ // node_modules/semver/ranges/intersects.js
48456
+ var require_intersects2 = __commonJS({
48457
+ "node_modules/semver/ranges/intersects.js"(exports, module) {
48458
+ "use strict";
48459
+ var Range = require_range2();
48460
+ var intersects = (r1, r2, options) => {
48461
+ r1 = new Range(r1, options);
48462
+ r2 = new Range(r2, options);
48463
+ return r1.intersects(r2, options);
48464
+ };
48465
+ module.exports = intersects;
48466
+ }
48467
+ });
48468
+
48469
+ // node_modules/semver/ranges/simplify.js
48470
+ var require_simplify2 = __commonJS({
48471
+ "node_modules/semver/ranges/simplify.js"(exports, module) {
48472
+ "use strict";
48473
+ var satisfies2 = require_satisfies2();
48474
+ var compare = require_compare2();
48475
+ module.exports = (versions, range, options) => {
48476
+ const set = [];
48477
+ let first = null;
48478
+ let prev = null;
48479
+ const v2 = versions.sort((a, b2) => compare(a, b2, options));
48480
+ for (const version of v2) {
48481
+ const included = satisfies2(version, range, options);
48482
+ if (included) {
48483
+ prev = version;
48484
+ if (!first) {
48485
+ first = version;
48486
+ }
48487
+ } else {
48488
+ if (prev) {
48489
+ set.push([first, prev]);
48490
+ }
48491
+ prev = null;
48492
+ first = null;
48493
+ }
48494
+ }
48495
+ if (first) {
48496
+ set.push([first, null]);
48497
+ }
48498
+ const ranges = [];
48499
+ for (const [min, max] of set) {
48500
+ if (min === max) {
48501
+ ranges.push(min);
48502
+ } else if (!max && min === v2[0]) {
48503
+ ranges.push("*");
48504
+ } else if (!max) {
48505
+ ranges.push(`>=${min}`);
48506
+ } else if (min === v2[0]) {
48507
+ ranges.push(`<=${max}`);
48508
+ } else {
48509
+ ranges.push(`${min} - ${max}`);
48510
+ }
48511
+ }
48512
+ const simplified = ranges.join(" || ");
48513
+ const original = typeof range.raw === "string" ? range.raw : String(range);
48514
+ return simplified.length < original.length ? simplified : range;
48515
+ };
48516
+ }
48517
+ });
48518
+
48519
+ // node_modules/semver/ranges/subset.js
48520
+ var require_subset2 = __commonJS({
48521
+ "node_modules/semver/ranges/subset.js"(exports, module) {
48522
+ "use strict";
48523
+ var Range = require_range2();
48524
+ var Comparator = require_comparator2();
48525
+ var { ANY } = Comparator;
48526
+ var satisfies2 = require_satisfies2();
48527
+ var compare = require_compare2();
48528
+ var subset = (sub, dom, options = {}) => {
48529
+ if (sub === dom) {
48530
+ return true;
48531
+ }
48532
+ sub = new Range(sub, options);
48533
+ dom = new Range(dom, options);
48534
+ let sawNonNull = false;
48535
+ OUTER: for (const simpleSub of sub.set) {
48536
+ for (const simpleDom of dom.set) {
48537
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
48538
+ sawNonNull = sawNonNull || isSub !== null;
48539
+ if (isSub) {
48540
+ continue OUTER;
48541
+ }
48542
+ }
48543
+ if (sawNonNull) {
48544
+ return false;
48545
+ }
48546
+ }
48547
+ return true;
48548
+ };
48549
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
48550
+ var minimumVersion = [new Comparator(">=0.0.0")];
48551
+ var simpleSubset = (sub, dom, options) => {
48552
+ if (sub === dom) {
48553
+ return true;
48554
+ }
48555
+ if (sub.length === 1 && sub[0].semver === ANY) {
48556
+ if (dom.length === 1 && dom[0].semver === ANY) {
48557
+ return true;
48558
+ } else if (options.includePrerelease) {
48559
+ sub = minimumVersionWithPreRelease;
48560
+ } else {
48561
+ sub = minimumVersion;
48562
+ }
48563
+ }
48564
+ if (dom.length === 1 && dom[0].semver === ANY) {
48565
+ if (options.includePrerelease) {
48566
+ return true;
48567
+ } else {
48568
+ dom = minimumVersion;
48569
+ }
48570
+ }
48571
+ const eqSet = /* @__PURE__ */ new Set();
48572
+ let gt3, lt2;
48573
+ for (const c of sub) {
48574
+ if (c.operator === ">" || c.operator === ">=") {
48575
+ gt3 = higherGT(gt3, c, options);
48576
+ } else if (c.operator === "<" || c.operator === "<=") {
48577
+ lt2 = lowerLT(lt2, c, options);
48578
+ } else {
48579
+ eqSet.add(c.semver);
48580
+ }
48581
+ }
48582
+ if (eqSet.size > 1) {
48583
+ return null;
48584
+ }
48585
+ let gtltComp;
48586
+ if (gt3 && lt2) {
48587
+ gtltComp = compare(gt3.semver, lt2.semver, options);
48588
+ if (gtltComp > 0) {
48589
+ return null;
48590
+ } else if (gtltComp === 0 && (gt3.operator !== ">=" || lt2.operator !== "<=")) {
48591
+ return null;
48592
+ }
48593
+ }
48594
+ for (const eq of eqSet) {
48595
+ if (gt3 && !satisfies2(eq, String(gt3), options)) {
48596
+ return null;
48597
+ }
48598
+ if (lt2 && !satisfies2(eq, String(lt2), options)) {
48599
+ return null;
48600
+ }
48601
+ for (const c of dom) {
48602
+ if (!satisfies2(eq, String(c), options)) {
48603
+ return false;
48604
+ }
48605
+ }
48606
+ return true;
48607
+ }
48608
+ let higher, lower;
48609
+ let hasDomLT, hasDomGT;
48610
+ let needDomLTPre = lt2 && !options.includePrerelease && lt2.semver.prerelease.length ? lt2.semver : false;
48611
+ let needDomGTPre = gt3 && !options.includePrerelease && gt3.semver.prerelease.length ? gt3.semver : false;
48612
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt2.operator === "<" && needDomLTPre.prerelease[0] === 0) {
48613
+ needDomLTPre = false;
48614
+ }
48615
+ for (const c of dom) {
48616
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
48617
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
48618
+ if (gt3) {
48619
+ if (needDomGTPre) {
48620
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
48621
+ needDomGTPre = false;
48622
+ }
48623
+ }
48624
+ if (c.operator === ">" || c.operator === ">=") {
48625
+ higher = higherGT(gt3, c, options);
48626
+ if (higher === c && higher !== gt3) {
48627
+ return false;
48628
+ }
48629
+ } else if (gt3.operator === ">=" && !c.test(gt3.semver)) {
48630
+ return false;
48631
+ }
48632
+ }
48633
+ if (lt2) {
48634
+ if (needDomLTPre) {
48635
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
48636
+ needDomLTPre = false;
48637
+ }
48638
+ }
48639
+ if (c.operator === "<" || c.operator === "<=") {
48640
+ lower = lowerLT(lt2, c, options);
48641
+ if (lower === c && lower !== lt2) {
48642
+ return false;
48643
+ }
48644
+ } else if (lt2.operator === "<=" && !c.test(lt2.semver)) {
48645
+ return false;
48646
+ }
48647
+ }
48648
+ if (!c.operator && (lt2 || gt3) && gtltComp !== 0) {
48649
+ return false;
48650
+ }
48651
+ }
48652
+ if (gt3 && hasDomLT && !lt2 && gtltComp !== 0) {
48653
+ return false;
48654
+ }
48655
+ if (lt2 && hasDomGT && !gt3 && gtltComp !== 0) {
48656
+ return false;
48657
+ }
48658
+ if (needDomGTPre || needDomLTPre) {
48659
+ return false;
48660
+ }
48661
+ return true;
48662
+ };
48663
+ var higherGT = (a, b2, options) => {
48664
+ if (!a) {
48665
+ return b2;
48666
+ }
48667
+ const comp = compare(a.semver, b2.semver, options);
48668
+ return comp > 0 ? a : comp < 0 ? b2 : b2.operator === ">" && a.operator === ">=" ? b2 : a;
48669
+ };
48670
+ var lowerLT = (a, b2, options) => {
48671
+ if (!a) {
48672
+ return b2;
48673
+ }
48674
+ const comp = compare(a.semver, b2.semver, options);
48675
+ return comp < 0 ? a : comp > 0 ? b2 : b2.operator === "<" && a.operator === "<=" ? b2 : a;
48676
+ };
48677
+ module.exports = subset;
48678
+ }
48679
+ });
48680
+
48681
+ // node_modules/semver/index.js
48682
+ var require_semver4 = __commonJS({
48683
+ "node_modules/semver/index.js"(exports, module) {
48684
+ "use strict";
48685
+ var internalRe = require_re2();
48686
+ var constants = require_constants2();
48687
+ var SemVer = require_semver3();
48688
+ var identifiers = require_identifiers2();
48689
+ var parse = require_parse2();
48690
+ var valid2 = require_valid3();
48691
+ var clean = require_clean2();
48692
+ var inc = require_inc2();
48693
+ var diff = require_diff2();
48694
+ var major = require_major2();
48695
+ var minor = require_minor2();
48696
+ var patch = require_patch2();
48697
+ var prerelease = require_prerelease2();
48698
+ var compare = require_compare2();
48699
+ var rcompare = require_rcompare2();
48700
+ var compareLoose = require_compare_loose2();
48701
+ var compareBuild = require_compare_build2();
48702
+ var sort = require_sort2();
48703
+ var rsort = require_rsort2();
48704
+ var gt3 = require_gt2();
48705
+ var lt2 = require_lt2();
48706
+ var eq = require_eq2();
48707
+ var neq = require_neq2();
48708
+ var gte = require_gte2();
48709
+ var lte = require_lte2();
48710
+ var cmp = require_cmp2();
48711
+ var coerce = require_coerce2();
48712
+ var truncate = require_truncate2();
48713
+ var Comparator = require_comparator2();
48714
+ var Range = require_range2();
48715
+ var satisfies2 = require_satisfies2();
48716
+ var toComparators = require_to_comparators2();
48717
+ var maxSatisfying = require_max_satisfying2();
48718
+ var minSatisfying = require_min_satisfying2();
48719
+ var minVersion = require_min_version2();
48720
+ var validRange = require_valid4();
48721
+ var outside = require_outside2();
48722
+ var gtr = require_gtr2();
48723
+ var ltr = require_ltr2();
48724
+ var intersects = require_intersects2();
48725
+ var simplifyRange = require_simplify2();
48726
+ var subset = require_subset2();
48727
+ module.exports = {
48728
+ parse,
48729
+ valid: valid2,
48730
+ clean,
48731
+ inc,
48732
+ diff,
48733
+ major,
48734
+ minor,
48735
+ patch,
48736
+ prerelease,
48737
+ compare,
48738
+ rcompare,
48739
+ compareLoose,
48740
+ compareBuild,
48741
+ sort,
48742
+ rsort,
48743
+ gt: gt3,
48744
+ lt: lt2,
48745
+ eq,
48746
+ neq,
48747
+ gte,
48748
+ lte,
48749
+ cmp,
48750
+ coerce,
48751
+ truncate,
48752
+ Comparator,
48753
+ Range,
48754
+ satisfies: satisfies2,
48755
+ toComparators,
48756
+ maxSatisfying,
48757
+ minSatisfying,
48758
+ minVersion,
48759
+ validRange,
48760
+ outside,
48761
+ gtr,
48762
+ ltr,
48763
+ intersects,
48764
+ simplifyRange,
48765
+ subset,
48766
+ SemVer,
48767
+ re: internalRe.re,
48768
+ src: internalRe.src,
48769
+ tokens: internalRe.t,
48770
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
48771
+ RELEASE_TYPES: constants.RELEASE_TYPES,
48772
+ compareIdentifiers: identifiers.compareIdentifiers,
48773
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
48774
+ };
48775
+ }
48776
+ });
48777
+
48778
+ // packages/cli/src/commands/template-choices.ts
48779
+ function buildTemplateChoices(entries) {
48780
+ const choices = [];
48781
+ for (const entry of entries) {
48782
+ const baseLabel = entry.name ?? entry.displayName ?? entry.id;
48783
+ const baseDescription = entry.description ?? "";
48784
+ const tags = entry.tags ?? [];
48785
+ const channels = entry.channels ?? {};
48786
+ const channelNames = Object.keys(channels);
48787
+ const hasExplicitStableChannel = Boolean(
48788
+ channels.stable && !import_semver8.default.prerelease(channels.stable)
48789
+ );
48790
+ const hasLegacyStableRelease = Boolean(
48791
+ !entry.channels && entry.stable && !import_semver8.default.prerelease(entry.stable)
48792
+ );
48793
+ const hasStable = hasExplicitStableChannel || hasLegacyStableRelease;
48794
+ const prereleaseChannels = [];
48795
+ if (channelNames.length > 0) {
48796
+ for (const ch of channelNames) {
48797
+ if (ch !== "stable") {
48798
+ prereleaseChannels.push(ch);
48799
+ }
48800
+ }
48801
+ } else if (entry.stable && import_semver8.default.prerelease(entry.stable)) {
48802
+ const parsed = import_semver8.default.prerelease(entry.stable);
48803
+ if (parsed && parsed.length > 0 && typeof parsed[0] === "string") {
48804
+ const inferredTag = parsed[0].replace(/\d+$/, "");
48805
+ prereleaseChannels.push(inferredTag || "beta");
48806
+ } else {
48807
+ prereleaseChannels.push("beta");
48808
+ }
48809
+ }
48810
+ if (hasStable) {
48811
+ choices.push({
48812
+ id: entry.id,
48813
+ label: baseLabel,
48814
+ description: baseDescription,
48815
+ tags
48816
+ });
48817
+ }
48818
+ for (const ch of prereleaseChannels) {
48819
+ choices.push({
48820
+ id: `${entry.id}@${ch}`,
48821
+ label: `${baseLabel} [${ch}]`,
48822
+ description: baseDescription,
48823
+ tags
48824
+ });
48825
+ }
48826
+ if (!hasStable && prereleaseChannels.length === 0) {
48827
+ choices.push({
48828
+ id: entry.id,
48829
+ label: baseLabel,
48830
+ description: baseDescription,
48831
+ tags
48832
+ });
48833
+ }
48834
+ }
48835
+ return choices;
48836
+ }
48837
+ var import_semver8;
48838
+ var init_template_choices = __esm({
48839
+ "packages/cli/src/commands/template-choices.ts"() {
48840
+ "use strict";
48841
+ import_semver8 = __toESM(require_semver4(), 1);
48842
+ }
48843
+ });
48844
+
48845
+ // packages/cli/src/commands/spinner.ts
48846
+ async function withSpinner(text, action, options) {
48847
+ const spinner = new Spinner(text, { enabled: options?.enabled });
48848
+ spinner.start();
48849
+ try {
48850
+ const result = await action(spinner);
48851
+ const successMsg = typeof options?.successText === "function" ? options.successText(result) : options?.successText ?? text;
48852
+ spinner.succeed(successMsg);
48853
+ return result;
48854
+ } catch (error) {
48855
+ spinner.fail(options?.failText);
48856
+ throw error;
48857
+ }
48858
+ }
48859
+ var Spinner;
48860
+ var init_spinner = __esm({
48861
+ "packages/cli/src/commands/spinner.ts"() {
48862
+ "use strict";
48863
+ init_src2();
48864
+ Spinner = class {
48865
+ text;
48866
+ timer = null;
48867
+ frameIndex = 0;
48868
+ isSpinning = false;
48869
+ enabled;
48870
+ frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
48871
+ interval = 80;
48872
+ constructor(text = "", options = {}) {
48873
+ this.text = text;
48874
+ this.enabled = options.enabled ?? (Boolean(process.stdout.isTTY) && process.env.NODE_ENV !== "test" && !process.env.CI);
48875
+ }
48876
+ start(text) {
48877
+ if (text !== void 0) this.text = text;
48878
+ if (!this.enabled || this.isSpinning) return this;
48879
+ this.isSpinning = true;
48880
+ this.frameIndex = 0;
48881
+ process.stdout.write("\x1B[?25l");
48882
+ this.render();
48883
+ this.timer = setInterval(() => {
48884
+ this.frameIndex = (this.frameIndex + 1) % this.frames.length;
48885
+ this.render();
48886
+ }, this.interval);
48887
+ return this;
48888
+ }
48889
+ update(text) {
48890
+ this.text = text;
48891
+ if (this.isSpinning && this.enabled) {
48892
+ this.render();
48893
+ }
48894
+ return this;
48895
+ }
48896
+ succeed(text) {
48897
+ return this.stopAndPersist("\u2714", text ?? this.text, "\x1B[32m");
48898
+ }
48899
+ fail(text) {
48900
+ return this.stopAndPersist("\u2716", text ?? this.text, "\x1B[31m");
48901
+ }
48902
+ warn(text) {
48903
+ return this.stopAndPersist("\u26A0", text ?? this.text, "\x1B[33m");
48904
+ }
48905
+ info(text) {
48906
+ return this.stopAndPersist("\u2139", text ?? this.text, "\x1B[34m");
48907
+ }
48908
+ stop() {
48909
+ if (!this.isSpinning) return this;
48910
+ if (this.timer) {
48911
+ clearInterval(this.timer);
48912
+ this.timer = null;
48913
+ }
48914
+ this.isSpinning = false;
48915
+ if (this.enabled) {
48916
+ process.stdout.write("\r\x1B[2K\x1B[?25h");
48917
+ }
48918
+ return this;
48919
+ }
48920
+ stopAndPersist(symbol, text, color = "") {
48921
+ this.stop();
48922
+ if (this.enabled) {
48923
+ const reset = "\x1B[0m";
48924
+ const cleanText = text.replace(/^[✔✖⚠ℹ\s]+/, "");
48925
+ const output = `${color}${symbol}${reset} ${redactString(cleanText)}
48926
+ `;
48927
+ process.stdout.write(output);
48928
+ }
48929
+ return this;
48930
+ }
48931
+ render() {
48932
+ const frame = this.frames[this.frameIndex];
48933
+ const cyan = "\x1B[36m";
48934
+ const reset = "\x1B[0m";
48935
+ process.stdout.write(`\r\x1B[2K${cyan}${frame}${reset} ${redactString(this.text)}`);
48936
+ }
48937
+ };
48938
+ }
48939
+ });
48940
+
48941
+ // packages/cli/src/commands/task-helper.ts
48942
+ async function runTasksWithDynamicUI(tasks, ctx, options = {}) {
48943
+ if (tasks.length === 0) return;
48944
+ const isInteractive = !options.json && !options.verbose && Boolean(process.stdout.isTTY) && process.env.NODE_ENV !== "test";
48945
+ if (!options.json && options.title) {
48946
+ writeHumanOutput(`
48947
+ ${options.title}
48948
+ `);
48949
+ }
48950
+ if (isInteractive) {
48951
+ let currentSpinner = null;
48952
+ try {
48953
+ await executeTasks(tasks, ctx, {
48954
+ verbose: false,
48955
+ onTaskStart: (task, index, total) => {
48956
+ const taskLabel = task.name ? `${task.name} (${task.id})` : task.id;
48957
+ currentSpinner = new Spinner(`[${index + 1}/${total}] \u6B63\u5728\u6267\u884C\u4EFB\u52A1: ${taskLabel}...`);
48958
+ currentSpinner.start();
48959
+ },
48960
+ onTaskSuccess: (task, index, total) => {
48961
+ const taskLabel = task.name ? `${task.name}` : task.id;
48962
+ if (currentSpinner) {
48963
+ currentSpinner.succeed(`[${index + 1}/${total}] \u4EFB\u52A1\u5B8C\u6210: ${taskLabel}`);
48964
+ }
48965
+ },
48966
+ onTaskFail: (task, index, total, _error, logFile) => {
48967
+ const taskLabel = task.name ? `${task.name}` : task.id;
48968
+ if (currentSpinner) {
48969
+ currentSpinner.fail(`[${index + 1}/${total}] \u4EFB\u52A1\u6267\u884C\u5931\u8D25: ${taskLabel}`);
48970
+ }
48971
+ if (logFile) {
48972
+ writeHumanOutput(` \u8BE6\u7EC6\u65E5\u5FD7\u5DF2\u4FDD\u5B58\u81F3: ${logFile}
48973
+ `);
48974
+ }
48975
+ }
48976
+ });
48977
+ } catch (err) {
48978
+ currentSpinner?.stop();
48979
+ throw err;
48980
+ }
48981
+ } else {
48982
+ await executeTasks(tasks, ctx, {
48983
+ verbose: Boolean(options.verbose),
48984
+ stdio: options.json ? "ignore" : void 0,
48985
+ onTaskStart: (task, index, total) => {
48986
+ if (!options.json && options.verbose) {
48987
+ writeHumanOutput(`
48988
+ > [${index + 1}/${total}] \u5F00\u59CB\u6267\u884C\u4EFB\u52A1: ${task.name ?? task.id}
48989
+ `);
48990
+ }
48991
+ },
48992
+ onTaskSuccess: (task, index, total) => {
48993
+ if (!options.json && !options.verbose) {
48994
+ writeHumanOutput(`\u2714 [${index + 1}/${total}] \u4EFB\u52A1\u5B8C\u6210: ${task.name ?? task.id}
48995
+ `);
48996
+ }
48997
+ },
48998
+ onTaskFail: (task, index, total, _err, logFile) => {
48999
+ if (!options.json) {
49000
+ writeHumanOutput(`\u2716 [${index + 1}/${total}] \u4EFB\u52A1\u6267\u884C\u5931\u8D25: ${task.name ?? task.id}
49001
+ `);
49002
+ if (logFile) {
49003
+ writeHumanOutput(` \u8BE6\u7EC6\u65E5\u5FD7\u5DF2\u4FDD\u5B58\u81F3: ${logFile}
49004
+ `);
49005
+ }
49006
+ }
49007
+ }
49008
+ });
49009
+ }
49010
+ }
49011
+ var init_task_helper = __esm({
49012
+ "packages/cli/src/commands/task-helper.ts"() {
49013
+ "use strict";
49014
+ init_spinner();
49015
+ init_src2();
49016
+ init_cli_output();
49017
+ }
49018
+ });
49019
+
49020
+ // packages/cli/src/commands/tty-confirm.ts
49021
+ var tty_confirm_exports = {};
49022
+ __export(tty_confirm_exports, {
49023
+ buildPermissionDiff: () => buildPermissionDiff,
49024
+ confirmPlanInteractive: () => confirmPlanInteractive,
49025
+ findMissingAuthorizations: () => findMissingAuthorizations,
49026
+ findUnexpectedAllows: () => findUnexpectedAllows
49027
+ });
49028
+ async function confirmPlanInteractive(opts) {
49029
+ const plan = opts.plan;
49030
+ const requested = [...plan.permissions];
49031
+ const allowed = new Set(opts.allowedPermissions);
49032
+ const toConfirm = requested.filter((p2) => !allowed.has(p2));
49033
+ process.stderr.write(`
49034
+ \u5373\u5C06\u6267\u884C ${opts.command}\uFF1A
49035
+ `);
49036
+ if (plan.projectRoot) {
49037
+ process.stderr.write(` \u76EE\u5F55\uFF1A${plan.projectRoot}
49038
+ `);
49039
+ }
49040
+ process.stderr.write(` \u53D7\u7BA1\u8D44\u6E90\uFF1A${plan.files.length} \u4E2A\u6587\u4EF6\u3001${plan.configEntries.length} \u9879\u914D\u7F6E
49041
+ `);
49042
+ if (opts.output.verbose) {
49043
+ for (const file of plan.files.slice(0, 10)) process.stderr.write(` - ${file.path}
49044
+ `);
49045
+ if (plan.files.length > 10) process.stderr.write(` - \u53E6\u6709 ${plan.files.length - 10} \u4E2A\u6587\u4EF6
49046
+ `);
49047
+ process.stderr.write(` \u53D7\u7BA1\u6BB5\uFF1A${plan.managedSections.length}
49048
+ `);
49049
+ process.stderr.write(` Plan \u6458\u8981\uFF1A${plan.planDigest}
49050
+ `);
49051
+ }
49052
+ const extraPermissions = requested.filter((permission) => permission !== "project.write");
46918
49053
  if (extraPermissions.length > 0) {
46919
49054
  process.stderr.write(`
46920
49055
  \u989D\u5916\u64CD\u4F5C\uFF1A
@@ -47114,7 +49249,8 @@ async function executeCreate(packageSpecs, directory, options, cliVersion, event
47114
49249
  }
47115
49250
  const client = service.getRegistryClient();
47116
49251
  if (!client.getIndex) throw new CliError(t("create.registryIndexUnsupported"), ExitCode.ResolveFailed, "REGISTRY_INDEX_UNSUPPORTED");
47117
- const choices = (await client.getIndex({ offline: options.offline })).packages.map((entry) => ({ id: entry.id, label: entry.name ?? entry.displayName ?? entry.id, description: entry.description ?? "", tags: entry.tags ?? [] }));
49252
+ const indexResult = await client.getIndex({ offline: options.offline });
49253
+ const choices = buildTemplateChoices(indexResult.packages);
47118
49254
  try {
47119
49255
  const chosen = (await selectSearchable({ message: t("create.chooseTemplate"), choices })).id;
47120
49256
  packageSpecs.push(chosen);
@@ -47580,6 +49716,7 @@ var init_create = __esm({
47580
49716
  init_service_locator();
47581
49717
  init_plan_execution();
47582
49718
  init_searchable_select();
49719
+ init_template_choices();
47583
49720
  init_spinner();
47584
49721
  init_task_helper();
47585
49722
  init_i18n();
@@ -47714,12 +49851,8 @@ async function executeApply(templateSpec, options, cliVersion, events) {
47714
49851
  for (const t2 of existingLock.resolved?.templates ?? []) installedIds.add(t2.id);
47715
49852
  for (const a of existingLock.resolved?.addons ?? []) installedIds.add(a.id);
47716
49853
  }
47717
- const availableChoices = indexResult.packages.filter((entry) => !installedIds.has(entry.id)).map((entry) => ({
47718
- id: entry.id,
47719
- label: entry.name ?? entry.displayName ?? entry.id,
47720
- description: entry.description ?? "",
47721
- tags: entry.tags ?? []
47722
- }));
49854
+ const availablePackages = indexResult.packages.filter((entry) => !installedIds.has(entry.id));
49855
+ const availableChoices = buildTemplateChoices(availablePackages);
47723
49856
  if (availableChoices.length === 0) {
47724
49857
  throw new CliError(t("apply.noAvailableTemplates"), ExitCode.NeedsInputOrDenied, "NO_TEMPLATES_AVAILABLE");
47725
49858
  }
@@ -48146,6 +50279,7 @@ var init_apply = __esm({
48146
50279
  init_i18n();
48147
50280
  init_plan_execution();
48148
50281
  init_searchable_select();
50282
+ init_template_choices();
48149
50283
  }
48150
50284
  });
48151
50285
 
@@ -50587,11 +52721,146 @@ var init_launch = __esm({
50587
52721
  }
50588
52722
  });
50589
52723
 
50590
- // packages/cli/src/commands/self-upgrade.ts
52724
+ // packages/cli/src/commands/self-upgrade-pipeline.ts
50591
52725
  import { spawn as spawn3 } from "node:child_process";
50592
52726
  import { readFile as readFile33, realpath as realpath2 } from "node:fs/promises";
50593
- import { homedir as homedir5 } from "node:os";
50594
52727
  import { extname, join as join27, resolve as resolve27 } from "node:path";
52728
+ async function detectGlobalCliInstallation(cliPath = process.argv[1], runner = runCommand) {
52729
+ if (!cliPath) return void 0;
52730
+ const binPath = await realpath2(cliPath).catch(() => void 0);
52731
+ if (!binPath) return void 0;
52732
+ for (const manager of ["npm", "pnpm"]) {
52733
+ const root = await runner(manager, ["root", "-g"]).catch(() => void 0);
52734
+ if (!root || root.exitCode !== 0) continue;
52735
+ const packageRoot = resolve27(root.stdout.trim(), ...CLI_PACKAGE_NAME.split("/"));
52736
+ const packageJson = await readPackageJson(packageRoot);
52737
+ if (!packageJson || packageJson.name !== CLI_PACKAGE_NAME || !isExactCliVersion(packageJson.version)) continue;
52738
+ const declaredBin = typeof packageJson.bin === "object" && packageJson.bin ? packageJson.bin[CLI_BIN_NAME] : void 0;
52739
+ if (typeof declaredBin !== "string") continue;
52740
+ const expectedBin = await realpath2(resolve27(packageRoot, declaredBin)).catch(() => void 0);
52741
+ if (!expectedBin) continue;
52742
+ if (!isSamePath(expectedBin, binPath) && !await isWindowsCmdShimFor(binPath, expectedBin)) continue;
52743
+ return { manager, managerExecutable: manager, packageRoot, binPath: expectedBin, currentVersion: packageJson.version };
52744
+ }
52745
+ return void 0;
52746
+ }
52747
+ async function verifyCliVersion(binPath, expected, runner = runCommand) {
52748
+ const result = await runner(process.execPath, [binPath, "--version"]).catch(() => void 0);
52749
+ return result?.exitCode === 0 && result.stdout.trim() === expected;
52750
+ }
52751
+ async function performUpgrade(installation, targetVersion, offline, runner = runCommand) {
52752
+ const args = installation.manager === "npm" ? ["install", "-g", `${CLI_PACKAGE_NAME}@${targetVersion}`] : ["add", "-g", `${CLI_PACKAGE_NAME}@${targetVersion}`];
52753
+ if (offline) args.push("--offline");
52754
+ const result = await runner(installation.managerExecutable, args);
52755
+ if (result.exitCode === 0 && await verifyCliVersion(installation.binPath, targetVersion, runner)) {
52756
+ return;
52757
+ }
52758
+ const rollbackArgs = installation.manager === "npm" ? ["install", "-g", `${CLI_PACKAGE_NAME}@${installation.currentVersion}`] : ["add", "-g", `${CLI_PACKAGE_NAME}@${installation.currentVersion}`];
52759
+ const rollback = await runner(installation.managerExecutable, rollbackArgs);
52760
+ const rollbackVerified = rollback.exitCode === 0 && await verifyCliVersion(installation.binPath, installation.currentVersion, runner);
52761
+ if (!rollbackVerified) {
52762
+ throw new CliError(
52763
+ t("selfUpgrade.rollbackFailed", CLI_PACKAGE_NAME, installation.currentVersion),
52764
+ ExitCode.ExecuteFailed,
52765
+ "CLI_UPDATE_ROLLBACK_FAILED"
52766
+ );
52767
+ }
52768
+ throw new CliError(t("selfUpgrade.upgradeFailed"), ExitCode.ExecuteFailed, "CLI_UPDATE_FAILED");
52769
+ }
52770
+ async function fetchCliMetadata(registry, request = fetch, options) {
52771
+ const envTimeout = process.env["AICODING_FETCH_TIMEOUT"] ? Number.parseInt(process.env["AICODING_FETCH_TIMEOUT"], 10) : void 0;
52772
+ const timeoutMs = options?.timeoutMs ?? (Number.isFinite(envTimeout) && (envTimeout ?? 0) > 0 ? envTimeout : 15e3);
52773
+ const maxRetries = options?.retries ?? 1;
52774
+ let lastError;
52775
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
52776
+ const controller = new AbortController();
52777
+ let timedOut = false;
52778
+ const timer = setTimeout(() => {
52779
+ timedOut = true;
52780
+ controller.abort();
52781
+ }, timeoutMs);
52782
+ timer.unref?.();
52783
+ try {
52784
+ const response = await request(`${registry}/${encodeURIComponent(CLI_PACKAGE_NAME)}`, {
52785
+ signal: controller.signal,
52786
+ redirect: "error"
52787
+ });
52788
+ if (!response.ok) throw new Error(`Registry returned HTTP ${response.status}`);
52789
+ return await response.json();
52790
+ } catch (error) {
52791
+ const isAbort = timedOut || error instanceof Error && (error.name === "AbortError" || error.message.includes("aborted"));
52792
+ if (isAbort) {
52793
+ lastError = new Error(t("selfUpgrade.fetchMetadataTimeout", Math.round(timeoutMs / 1e3)));
52794
+ } else {
52795
+ lastError = error;
52796
+ }
52797
+ if (attempt < maxRetries) {
52798
+ await new Promise((resolve28) => setTimeout(resolve28, 200));
52799
+ }
52800
+ } finally {
52801
+ clearTimeout(timer);
52802
+ }
52803
+ }
52804
+ throw lastError;
52805
+ }
52806
+ async function runCommand(command, args) {
52807
+ const useCmd = process.platform === "win32" && (command === "pnpm" || command === "npm");
52808
+ const executable = useCmd ? process.env.ComSpec ?? "cmd.exe" : command;
52809
+ const commandArgs = useCmd ? ["/d", "/c", [command, ...args.map((value) => /[\s&|<>()^%!]/u.test(value) ? `"${value.replaceAll('"', '""')}"` : value)].join(" ")] : args;
52810
+ return new Promise((resolveResult, reject) => {
52811
+ const child = spawn3(executable, commandArgs, { shell: false, windowsHide: true });
52812
+ let stdout = "";
52813
+ let stderrOutput = "";
52814
+ child.stdout.on("data", (chunk) => {
52815
+ stdout = limitOutput(`${stdout}${chunk.toString()}`);
52816
+ });
52817
+ child.stderr.on("data", (chunk) => {
52818
+ stderrOutput = limitOutput(`${stderrOutput}${chunk.toString()}`);
52819
+ });
52820
+ child.on("error", reject);
52821
+ child.on("close", (code) => resolveResult({ exitCode: code ?? 1, stdout, stderr: stderrOutput }));
52822
+ });
52823
+ }
52824
+ function isSamePath(a, b2) {
52825
+ if (process.platform === "win32") {
52826
+ return resolve27(a).replaceAll("/", "\\").toLowerCase() === resolve27(b2).replaceAll("/", "\\").toLowerCase();
52827
+ }
52828
+ return resolve27(a) === resolve27(b2);
52829
+ }
52830
+ async function isWindowsCmdShimFor(shimPath, expectedBin) {
52831
+ if (process.platform !== "win32" || extname(shimPath).toLowerCase() !== ".cmd") return false;
52832
+ const shim = await readFile33(shimPath, "utf8").catch(() => void 0);
52833
+ if (!shim) return false;
52834
+ return shim.replaceAll("/", "\\").toLowerCase().includes(expectedBin.replaceAll("/", "\\").toLowerCase());
52835
+ }
52836
+ async function readPackageJson(root) {
52837
+ try {
52838
+ const value = JSON.parse(await readFile33(join27(root, "package.json"), "utf8"));
52839
+ if (!value || typeof value !== "object") return void 0;
52840
+ const item = value;
52841
+ return typeof item["name"] === "string" && typeof item["version"] === "string" ? { name: item["name"], version: item["version"], bin: item["bin"] } : void 0;
52842
+ } catch {
52843
+ return void 0;
52844
+ }
52845
+ }
52846
+ function limitOutput(value) {
52847
+ return value.length <= OUTPUT_LIMIT ? value : `${value.slice(0, OUTPUT_LIMIT)}
52848
+ [truncated]`;
52849
+ }
52850
+ var OUTPUT_LIMIT;
52851
+ var init_self_upgrade_pipeline = __esm({
52852
+ "packages/cli/src/commands/self-upgrade-pipeline.ts"() {
52853
+ "use strict";
52854
+ init_src2();
52855
+ init_cli_output();
52856
+ init_i18n();
52857
+ OUTPUT_LIMIT = 4096;
52858
+ }
52859
+ });
52860
+
52861
+ // packages/cli/src/commands/self-upgrade.ts
52862
+ import { homedir as homedir5 } from "node:os";
52863
+ import { join as join28 } from "node:path";
50595
52864
  import { createInterface as createInterface2 } from "node:readline/promises";
50596
52865
  import { stdin, stderr } from "node:process";
50597
52866
  function createSelfUpgradeCommand(cliVersion) {
@@ -50653,7 +52922,7 @@ async function executeSelfUpgrade(options, cliVersion) {
50653
52922
  });
50654
52923
  await auditLog.prune().catch(() => void 0);
50655
52924
  try {
50656
- const result = await withStateLock(join27(userDataDir, "cli-update"), async () => {
52925
+ const result = await withStateLock(join28(userDataDir, "cli-update"), async () => {
50657
52926
  const target = await resolveTarget(options, cacheRepository, registry);
50658
52927
  ensureTargetAllowed(target.version, installation.currentVersion, options.allowDowngrade);
50659
52928
  if (!isCliVersionCompatible(process.version, target.enginesNode)) {
@@ -50675,11 +52944,13 @@ async function executeSelfUpgrade(options, cliVersion) {
50675
52944
  await auditLog.append({
50676
52945
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
50677
52946
  command: "self-upgrade",
52947
+ source: "manual",
50678
52948
  currentVersion: installation.currentVersion,
50679
52949
  targetVersion: result.plan.targetVersion,
50680
52950
  result: "success",
50681
52951
  rollbackResult: "not-needed"
50682
52952
  });
52953
+ await cacheRepository.resetAutoUpdateFailure().catch(() => void 0);
50683
52954
  }
50684
52955
  if (options.json) emitSuccessJson("self-upgrade", { dryRun: result.dryRun, ...result.plan, changed: result.changed });
50685
52956
  else if (result.dryRun) writeHumanOutput(
@@ -50691,6 +52962,7 @@ async function executeSelfUpgrade(options, cliVersion) {
50691
52962
  await auditLog.append({
50692
52963
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
50693
52964
  command: "self-upgrade",
52965
+ source: "manual",
50694
52966
  currentVersion: installation.currentVersion,
50695
52967
  result: "failure",
50696
52968
  errorCode: error instanceof CliError ? error.code : "CLI_UPDATE_FAILED"
@@ -50705,7 +52977,7 @@ function validateOptions(options) {
50705
52977
  }
50706
52978
  }
50707
52979
  function getUserDataDir3() {
50708
- return process.env["AICODING_USER_DATA"] ?? join27(homedir5(), ".aicoding");
52980
+ return process.env["AICODING_USER_DATA"] ?? join28(homedir5(), ".aicoding");
50709
52981
  }
50710
52982
  function getRegistryUrl() {
50711
52983
  const raw = process.env["AICODING_NPM_REGISTRY"] || DEFAULT_NPM_REGISTRY;
@@ -50769,18 +53041,6 @@ function buildPlan(installation, targetVersion, integrity, offline) {
50769
53041
  command: [installation.managerExecutable, ...args]
50770
53042
  };
50771
53043
  }
50772
- async function performUpgrade(installation, targetVersion, offline) {
50773
- const args = installation.manager === "npm" ? ["install", "-g", `${CLI_PACKAGE_NAME}@${targetVersion}`] : ["add", "-g", `${CLI_PACKAGE_NAME}@${targetVersion}`];
50774
- if (offline) args.push("--offline");
50775
- const result = await runCommand(installation.managerExecutable, args);
50776
- if (result.exitCode === 0 && await verifyCliVersion(installation.binPath, targetVersion)) return;
50777
- const rollback = await runCommand(installation.managerExecutable, installation.manager === "npm" ? ["install", "-g", `${CLI_PACKAGE_NAME}@${installation.currentVersion}`] : ["add", "-g", `${CLI_PACKAGE_NAME}@${installation.currentVersion}`]);
50778
- const rollbackVerified = rollback.exitCode === 0 && await verifyCliVersion(installation.binPath, installation.currentVersion);
50779
- if (!rollbackVerified) {
50780
- throw new CliError(t("selfUpgrade.rollbackFailed", CLI_PACKAGE_NAME, installation.currentVersion), ExitCode.ExecuteFailed, "CLI_UPDATE_ROLLBACK_FAILED");
50781
- }
50782
- throw new CliError(t("selfUpgrade.upgradeFailed"), ExitCode.ExecuteFailed, "CLI_UPDATE_FAILED");
50783
- }
50784
53044
  async function confirmUpgrade() {
50785
53045
  if (!stdin.isTTY) return false;
50786
53046
  const readline3 = createInterface2({ input: stdin, output: stderr, terminal: true });
@@ -50791,133 +53051,211 @@ async function confirmUpgrade() {
50791
53051
  readline3.close();
50792
53052
  }
50793
53053
  }
50794
- function isSamePath(a, b2) {
50795
- if (process.platform === "win32") {
50796
- return resolve27(a).replaceAll("/", "\\").toLowerCase() === resolve27(b2).replaceAll("/", "\\").toLowerCase();
50797
- }
50798
- return resolve27(a) === resolve27(b2);
53054
+ function messageOf2(error) {
53055
+ return error instanceof Error ? error.message : String(error);
50799
53056
  }
50800
- async function detectGlobalCliInstallation(cliPath = process.argv[1], runner = runCommand) {
50801
- if (!cliPath) return void 0;
50802
- const binPath = await realpath2(cliPath).catch(() => void 0);
50803
- if (!binPath) return void 0;
50804
- for (const manager of ["npm", "pnpm"]) {
50805
- const root = await runner(manager, ["root", "-g"]).catch(() => void 0);
50806
- if (!root || root.exitCode !== 0) continue;
50807
- const packageRoot = resolve27(root.stdout.trim(), ...CLI_PACKAGE_NAME.split("/"));
50808
- const packageJson = await readPackageJson(packageRoot);
50809
- if (!packageJson || packageJson.name !== CLI_PACKAGE_NAME || !isExactCliVersion(packageJson.version)) continue;
50810
- const declaredBin = typeof packageJson.bin === "object" && packageJson.bin ? packageJson.bin[CLI_BIN_NAME] : void 0;
50811
- if (typeof declaredBin !== "string") continue;
50812
- const expectedBin = await realpath2(resolve27(packageRoot, declaredBin)).catch(() => void 0);
50813
- if (!expectedBin) continue;
50814
- if (!isSamePath(expectedBin, binPath) && !await isWindowsCmdShimFor(binPath, expectedBin)) continue;
50815
- return { manager, managerExecutable: manager, packageRoot, binPath: expectedBin, currentVersion: packageJson.version };
53057
+ var DEFAULT_NPM_REGISTRY;
53058
+ var init_self_upgrade = __esm({
53059
+ "packages/cli/src/commands/self-upgrade.ts"() {
53060
+ "use strict";
53061
+ init_esm();
53062
+ init_src2();
53063
+ init_cli_output();
53064
+ init_shared_options();
53065
+ init_i18n();
53066
+ init_self_upgrade_pipeline();
53067
+ DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
53068
+ }
53069
+ });
53070
+
53071
+ // packages/cli/src/commands/auto-update.ts
53072
+ import { spawn as spawn4 } from "node:child_process";
53073
+ import { homedir as homedir6 } from "node:os";
53074
+ import { join as join29 } from "node:path";
53075
+ async function scheduleAutoUpdateWorker(argv, currentVersion, options) {
53076
+ const disabled = argv.includes("--offline") || Boolean(process.env["AICODING_NO_UPDATE_CHECK"]) || Boolean(process.env["CI"]) || argv[2] === "self-upgrade" || argv[2] === "_self-update-worker" || argv[2] === "_launch";
53077
+ if (disabled) return;
53078
+ const configManager = options?.configManager ?? defaultConfigManager;
53079
+ const isEnabled = await configManager.isAutoUpdateEnabled();
53080
+ if (!isEnabled) return;
53081
+ const userDataDir = options?.userDataDir ?? getUserDataDir4();
53082
+ const cacheRepository = new CliUpdateCacheRepository(userDataDir);
53083
+ const cache = await cacheRepository.read();
53084
+ if (cache?.autoUpdatePaused) return;
53085
+ const checkedAt = cache?.checkedAt ? Date.parse(cache.checkedAt) : Number.NaN;
53086
+ const within24h = Number.isFinite(checkedAt) && Date.now() - checkedAt < 24 * 60 * 60 * 1e3;
53087
+ if (within24h && (!cache?.latestVersion || !isCliUpdateAvailable(currentVersion, cache.latestVersion))) {
53088
+ return;
53089
+ }
53090
+ if (options?.spawner) {
53091
+ options.spawner([process.argv[1] ?? "", "_self-update-worker", "--parent-pid", String(process.pid)]);
53092
+ return;
50816
53093
  }
50817
- return void 0;
50818
- }
50819
- async function isWindowsCmdShimFor(shimPath, expectedBin) {
50820
- if (process.platform !== "win32" || extname(shimPath).toLowerCase() !== ".cmd") return false;
50821
- const shim = await readFile33(shimPath, "utf8").catch(() => void 0);
50822
- if (!shim) return false;
50823
- return shim.replaceAll("/", "\\").toLowerCase().includes(expectedBin.replaceAll("/", "\\").toLowerCase());
50824
- }
50825
- async function readPackageJson(root) {
50826
53094
  try {
50827
- const value = JSON.parse(await readFile33(join27(root, "package.json"), "utf8"));
50828
- if (!value || typeof value !== "object") return void 0;
50829
- const item = value;
50830
- return typeof item["name"] === "string" && typeof item["version"] === "string" ? { name: item["name"], version: item["version"], bin: item["bin"] } : void 0;
53095
+ const scriptPath = process.argv[1];
53096
+ if (!scriptPath) return;
53097
+ const child = spawn4(process.execPath, [scriptPath, "_self-update-worker", "--parent-pid", String(process.pid)], {
53098
+ detached: true,
53099
+ stdio: "ignore",
53100
+ windowsHide: true
53101
+ });
53102
+ child.unref();
50831
53103
  } catch {
50832
- return void 0;
50833
53104
  }
50834
53105
  }
50835
- async function verifyCliVersion(binPath, expected) {
50836
- const result = await runCommand(process.execPath, [binPath, "--version"]).catch(() => void 0);
50837
- return result?.exitCode === 0 && result.stdout.trim() === expected;
53106
+ function createSelfUpdateWorkerCommand(cliVersion) {
53107
+ const cmd = new Command("_self-update-worker").description("\u5185\u90E8\u81EA\u52A8\u5347\u7EA7\u5DE5\u4F5C\u8FDB\u7A0B").option("--parent-pid <pid>", "\u7236\u8FDB\u7A0B PID").action(async (opts) => {
53108
+ const parentPid = opts.parentPid ? Number.parseInt(opts.parentPid, 10) : void 0;
53109
+ await executeAutoUpdateWorker({ parentPid, cliVersion }).catch(() => void 0);
53110
+ });
53111
+ return cmd;
50838
53112
  }
50839
- async function fetchCliMetadata(registry, request = fetch, options) {
50840
- const envTimeout = process.env["AICODING_FETCH_TIMEOUT"] ? Number.parseInt(process.env["AICODING_FETCH_TIMEOUT"], 10) : void 0;
50841
- const timeoutMs = options?.timeoutMs ?? (Number.isFinite(envTimeout) && (envTimeout ?? 0) > 0 ? envTimeout : 15e3);
50842
- const maxRetries = options?.retries ?? 1;
50843
- let lastError;
50844
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
50845
- const controller = new AbortController();
50846
- let timedOut = false;
50847
- const timer = setTimeout(() => {
50848
- timedOut = true;
50849
- controller.abort();
50850
- }, timeoutMs);
50851
- timer.unref?.();
50852
- try {
50853
- const response = await request(`${registry}/${encodeURIComponent(CLI_PACKAGE_NAME)}`, {
50854
- signal: controller.signal,
50855
- redirect: "error"
53113
+ async function executeAutoUpdateWorker(options) {
53114
+ if (process.env["AICODING_NO_UPDATE_CHECK"] || process.env["CI"]) return;
53115
+ const userDataDir = options.userDataDir ?? getUserDataDir4();
53116
+ const cacheRepository = new CliUpdateCacheRepository(userDataDir);
53117
+ const cache = await cacheRepository.read();
53118
+ if (cache?.autoUpdatePaused) return;
53119
+ const registry = getRegistryUrl2();
53120
+ if (!registry) return;
53121
+ const checkedAt = cache?.checkedAt ? Date.parse(cache.checkedAt) : Number.NaN;
53122
+ const within24h = Number.isFinite(checkedAt) && Date.now() - checkedAt < 24 * 60 * 60 * 1e3;
53123
+ let targetVersion = cache?.latestVersion;
53124
+ let enginesNode = cache?.latestEnginesNode;
53125
+ if (!within24h || !targetVersion || !isCliUpdateAvailable(options.cliVersion, targetVersion)) {
53126
+ const metadata = await fetchCliMetadata(registry, options.fetcher, { timeoutMs: 3e3, retries: 0 }).catch(() => void 0);
53127
+ if (!metadata) return;
53128
+ const latest = parseLatestCliVersion(metadata);
53129
+ const release = latest ? parseCliReleaseMetadata(metadata, latest) : void 0;
53130
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
53131
+ if (!latest || !release || !isCliUpdateAvailable(options.cliVersion, latest)) {
53132
+ await cacheRepository.write({
53133
+ schemaVersion: 1,
53134
+ registryOrigin: registry,
53135
+ checkedAt: nowIso,
53136
+ latestVersion: latest ?? options.cliVersion,
53137
+ ...cache?.lastNotifiedAt ? { lastNotifiedAt: cache.lastNotifiedAt } : {},
53138
+ ...cache?.autoUpdateFailureCount ? { autoUpdateFailureCount: cache.autoUpdateFailureCount } : {},
53139
+ ...cache?.autoUpdateLastError ? { autoUpdateLastError: cache.autoUpdateLastError } : {},
53140
+ ...cache?.autoUpdatePaused ? { autoUpdatePaused: cache.autoUpdatePaused } : {}
50856
53141
  });
50857
- if (!response.ok) throw new Error(`Registry returned HTTP ${response.status}`);
50858
- return await response.json();
50859
- } catch (error) {
50860
- const isAbort = timedOut || error instanceof Error && (error.name === "AbortError" || error.message.includes("aborted"));
50861
- if (isAbort) {
50862
- lastError = new Error(t("selfUpgrade.fetchMetadataTimeout", Math.round(timeoutMs / 1e3)));
50863
- } else {
50864
- lastError = error;
53142
+ return;
53143
+ }
53144
+ targetVersion = latest;
53145
+ enginesNode = release.enginesNode;
53146
+ await cacheRepository.write({
53147
+ schemaVersion: 1,
53148
+ registryOrigin: registry,
53149
+ checkedAt: nowIso,
53150
+ latestVersion: latest,
53151
+ ...release.integrity ? { latestIntegrity: release.integrity } : {},
53152
+ ...release.enginesNode ? { latestEnginesNode: release.enginesNode } : {},
53153
+ ...cache?.lastNotifiedAt ? { lastNotifiedAt: cache.lastNotifiedAt } : {},
53154
+ ...cache?.autoUpdateFailureCount ? { autoUpdateFailureCount: cache.autoUpdateFailureCount } : {},
53155
+ ...cache?.autoUpdateLastError ? { autoUpdateLastError: cache.autoUpdateLastError } : {},
53156
+ ...cache?.autoUpdatePaused ? { autoUpdatePaused: cache.autoUpdatePaused } : {}
53157
+ });
53158
+ }
53159
+ if (!targetVersion || !isCliUpdateAvailable(options.cliVersion, targetVersion)) return;
53160
+ if (!isCliVersionCompatible(process.version, enginesNode)) return;
53161
+ try {
53162
+ await withStateLock(join29(userDataDir, "cli-update"), async () => {
53163
+ if (options.parentPid && options.parentPid > 0) {
53164
+ const parentExited = await waitForParentProcessExit(options.parentPid, {
53165
+ maxWaitMs: options.maxWaitMs ?? 1e4,
53166
+ initialIntervalMs: options.pollIntervalMs ?? 20,
53167
+ maxIntervalMs: 50
53168
+ });
53169
+ if (!parentExited) return;
50865
53170
  }
50866
- if (attempt < maxRetries) {
50867
- await new Promise((resolve28) => setTimeout(resolve28, 200));
53171
+ const runner = options.runner ?? runCommand;
53172
+ const installation = await detectGlobalCliInstallation(void 0, runner);
53173
+ if (!installation) return;
53174
+ const auditLog = new AuditLog(userDataDir);
53175
+ await auditLog.ensureReady().catch(() => void 0);
53176
+ try {
53177
+ await performUpgrade(installation, targetVersion, false, runner);
53178
+ await auditLog.append({
53179
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
53180
+ command: "self-upgrade",
53181
+ source: "auto",
53182
+ currentVersion: installation.currentVersion,
53183
+ targetVersion,
53184
+ result: "success",
53185
+ rollbackResult: "not-needed"
53186
+ }).catch(() => void 0);
53187
+ await cacheRepository.resetAutoUpdateFailure().catch(() => void 0);
53188
+ } catch (error) {
53189
+ const rollbackFailed = error instanceof CliError && error.code === "CLI_UPDATE_ROLLBACK_FAILED";
53190
+ await auditLog.append({
53191
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
53192
+ command: "self-upgrade",
53193
+ source: "auto",
53194
+ currentVersion: installation.currentVersion,
53195
+ targetVersion,
53196
+ result: "failure",
53197
+ errorCode: error instanceof CliError ? error.code : "CLI_UPDATE_FAILED",
53198
+ rollbackResult: rollbackFailed ? "failed" : "succeeded"
53199
+ }).catch(() => void 0);
53200
+ const errorMsg = error instanceof Error ? error.message : String(error);
53201
+ await cacheRepository.recordAutoUpdateFailure(errorMsg).catch(() => void 0);
50868
53202
  }
50869
- } finally {
50870
- clearTimeout(timer);
50871
- }
53203
+ }, 0);
53204
+ } catch {
50872
53205
  }
50873
- throw lastError;
50874
53206
  }
50875
- async function runCommand(command, args) {
50876
- const useCmd = process.platform === "win32" && (command === "pnpm" || command === "npm");
50877
- const executable = useCmd ? process.env.ComSpec ?? "cmd.exe" : command;
50878
- const commandArgs = useCmd ? ["/d", "/c", [command, ...args.map((value) => /[\s&|<>()^%!]/u.test(value) ? `"${value.replaceAll('"', '""')}"` : value)].join(" ")] : args;
50879
- return new Promise((resolveResult, reject) => {
50880
- const child = spawn3(executable, commandArgs, { shell: false, windowsHide: true });
50881
- let stdout = "";
50882
- let stderrOutput = "";
50883
- child.stdout.on("data", (chunk) => {
50884
- stdout = limitOutput(`${stdout}${chunk.toString()}`);
50885
- });
50886
- child.stderr.on("data", (chunk) => {
50887
- stderrOutput = limitOutput(`${stderrOutput}${chunk.toString()}`);
50888
- });
50889
- child.on("error", reject);
50890
- child.on("close", (code) => resolveResult({ exitCode: code ?? 1, stdout, stderr: stderrOutput }));
50891
- });
53207
+ async function waitForParentProcessExit(pid, options = {}) {
53208
+ const maxWaitMs = options.maxWaitMs ?? 1e4;
53209
+ const initialIntervalMs = options.initialIntervalMs ?? 20;
53210
+ const maxIntervalMs = options.maxIntervalMs ?? 50;
53211
+ const deadline = Date.now() + maxWaitMs;
53212
+ let interval = initialIntervalMs;
53213
+ while (Date.now() < deadline) {
53214
+ let alive = false;
53215
+ try {
53216
+ process.kill(pid, 0);
53217
+ alive = true;
53218
+ } catch {
53219
+ alive = false;
53220
+ }
53221
+ if (!alive) return true;
53222
+ await new Promise((resolve28) => setTimeout(resolve28, interval));
53223
+ interval = Math.min(interval + 10, maxIntervalMs);
53224
+ }
53225
+ return false;
50892
53226
  }
50893
- function limitOutput(value) {
50894
- return value.length <= OUTPUT_LIMIT ? value : `${value.slice(0, OUTPUT_LIMIT)}
50895
- [truncated]`;
53227
+ function getUserDataDir4() {
53228
+ return process.env["AICODING_USER_DATA"] ?? join29(homedir6(), ".aicoding");
50896
53229
  }
50897
- function messageOf2(error) {
50898
- return error instanceof Error ? error.message : String(error);
53230
+ function getRegistryUrl2() {
53231
+ const raw = process.env["AICODING_NPM_REGISTRY"] || DEFAULT_NPM_REGISTRY2;
53232
+ try {
53233
+ const url = new URL(raw);
53234
+ if (url.protocol !== "https:" || url.username || url.password) return "";
53235
+ return url.toString().replace(/\/$/, "");
53236
+ } catch {
53237
+ return "";
53238
+ }
50899
53239
  }
50900
- var DEFAULT_NPM_REGISTRY, OUTPUT_LIMIT;
50901
- var init_self_upgrade = __esm({
50902
- "packages/cli/src/commands/self-upgrade.ts"() {
53240
+ var DEFAULT_NPM_REGISTRY2;
53241
+ var init_auto_update = __esm({
53242
+ "packages/cli/src/commands/auto-update.ts"() {
50903
53243
  "use strict";
50904
53244
  init_esm();
50905
53245
  init_src2();
53246
+ init_self_upgrade_pipeline();
50906
53247
  init_cli_output();
50907
- init_shared_options();
50908
- init_i18n();
50909
- DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
50910
- OUTPUT_LIMIT = 4096;
53248
+ DEFAULT_NPM_REGISTRY2 = "https://registry.npmjs.org";
50911
53249
  }
50912
53250
  });
50913
53251
 
50914
53252
  // packages/cli/src/commands/update-notice.ts
50915
- import { homedir as homedir6 } from "node:os";
50916
- import { join as join28 } from "node:path";
53253
+ import { homedir as homedir7 } from "node:os";
53254
+ import { join as join30 } from "node:path";
50917
53255
  async function getCachedUpdateNotice(argv, currentVersion) {
50918
53256
  const json = argv.includes("--json");
50919
- const disabled = argv.includes("--offline") || argv[2] === "self-upgrade" || Boolean(process.env["AICODING_NO_UPDATE_CHECK"]) || Boolean(process.env["CI"]);
50920
- const repository = new CliUpdateCacheRepository(process.env["AICODING_USER_DATA"] ?? join28(homedir6(), ".aicoding"));
53257
+ const disabled = argv.includes("--offline") || argv[2] === "self-upgrade" || argv[2] === "_self-update-worker" || Boolean(process.env["AICODING_NO_UPDATE_CHECK"]) || Boolean(process.env["CI"]);
53258
+ const repository = new CliUpdateCacheRepository(process.env["AICODING_USER_DATA"] ?? join30(homedir7(), ".aicoding"));
50921
53259
  if (disabled || !json && !process.stdout.isTTY) return { json, markNotified: async () => void 0 };
50922
53260
  const cache = await repository.read();
50923
53261
  const notifiedAt = cache?.lastNotifiedAt ? Date.parse(cache.lastNotifiedAt) : Number.NaN;
@@ -50925,7 +53263,7 @@ async function getCachedUpdateNotice(argv, currentVersion) {
50925
53263
  if (!cache || cache.registryOrigin !== configuredRegistryOrigin() || !due || !isCliUpdateAvailable(currentVersion, cache.latestVersion)) {
50926
53264
  return { json, markNotified: async () => void 0 };
50927
53265
  }
50928
- const warning = t("update.notice", cache.latestVersion, currentVersion);
53266
+ const warning = cache.autoUpdatePaused ? t("update.notice.paused", cache.latestVersion, currentVersion, cache.autoUpdateLastError ?? "\u672A\u77E5\u539F\u56E0") : t("update.notice", cache.latestVersion, currentVersion);
50929
53267
  return { warning, json, markNotified: () => repository.markNotified(/* @__PURE__ */ new Date()) };
50930
53268
  }
50931
53269
  function configuredRegistryOrigin() {
@@ -50949,7 +53287,7 @@ import { createRequire as createRequire2 } from "node:module";
50949
53287
  import { readFileSync as readFileSync4 } from "node:fs";
50950
53288
  import { fileURLToPath as fileURLToPath5 } from "node:url";
50951
53289
  function resolveVersion() {
50952
- if (true) return "0.1.36";
53290
+ if (true) return "0.1.38";
50953
53291
  const candidates = [
50954
53292
  new URL("../package.json", import.meta.url),
50955
53293
  new URL("../../package.json", import.meta.url),
@@ -50986,6 +53324,7 @@ __export(index_exports, {
50986
53324
  async function run(argv) {
50987
53325
  const updateNotice = await getCachedUpdateNotice(argv, CLI_VERSION);
50988
53326
  setRunSuccessWarnings(updateNotice.warning && updateNotice.json ? [updateNotice.warning] : []);
53327
+ await scheduleAutoUpdateWorker(argv, CLI_VERSION);
50989
53328
  const program2 = new Command();
50990
53329
  program2.name("mano-coding").description("Mano Coding CLI - \u5DE5\u7A0B\u811A\u624B\u67B6\u4E0E AI Coding \u8D44\u4EA7\u7BA1\u7406\u5DE5\u5177").version(CLI_VERSION, "-V, --version", "\u663E\u793A CLI \u7248\u672C\u53F7").helpOption("-h, --help", "\u663E\u793A\u5E2E\u52A9\u4FE1\u606F").enablePositionalOptions().configureOutput({
50991
53330
  writeErr: (str) => process.stderr.write(str),
@@ -51019,6 +53358,7 @@ async function run(argv) {
51019
53358
  extensionCommand.addCommand(adapterCommand);
51020
53359
  program2.addCommand(extensionCommand);
51021
53360
  program2.addCommand(createLaunchCommand());
53361
+ program2.addCommand(createSelfUpdateWorkerCommand(CLI_VERSION));
51022
53362
  try {
51023
53363
  await program2.parseAsync(argv);
51024
53364
  const code = process.exitCode;
@@ -51070,6 +53410,7 @@ var init_index = __esm({
51070
53410
  init_cache();
51071
53411
  init_launch();
51072
53412
  init_self_upgrade();
53413
+ init_auto_update();
51073
53414
  init_cli_output();
51074
53415
  init_update_notice();
51075
53416
  init_cli_version();