ocx 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4507,19 +4507,11 @@ var {
4507
4507
  Help
4508
4508
  } = import__.default;
4509
4509
 
4510
- // src/commands/init.ts
4510
+ // src/commands/add.ts
4511
+ import { createHash } from "crypto";
4511
4512
  import { existsSync } from "fs";
4512
- import { writeFile } from "fs/promises";
4513
- import { join } from "path";
4514
-
4515
- // src/constants.ts
4516
- var OCX_DOMAIN = "ocx.kdco.dev";
4517
- var GITHUB_REPO = "kdcokenny/ocx";
4518
- var OCX_SCHEMA_URL = `https://${OCX_DOMAIN}/schema.json`;
4519
- var OCX_LOCK_SCHEMA_URL = `https://${OCX_DOMAIN}/lock.schema.json`;
4520
- var OCX_INSTALL_URL = `https://${OCX_DOMAIN}/install.sh`;
4521
- var GITHUB_RELEASES_URL = `https://github.com/${GITHUB_REPO}/releases`;
4522
- var GITHUB_RAW_URL = `https://raw.githubusercontent.com/${GITHUB_REPO}/main`;
4513
+ import { mkdir, readFile, writeFile } from "fs/promises";
4514
+ import { dirname, join } from "path";
4523
4515
 
4524
4516
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
4525
4517
  var exports_external = {};
@@ -8510,9 +8502,9 @@ var targetPathSchema = exports_external.string().refine((path) => path.startsWit
8510
8502
  message: 'Target path must start with ".opencode/"'
8511
8503
  }).refine((path) => {
8512
8504
  const parts = path.split("/");
8513
- if (parts.length < 2)
8514
- return false;
8515
8505
  const dir = parts[1];
8506
+ if (!dir)
8507
+ return false;
8516
8508
  return ["agent", "skill", "plugin", "command", "tool", "philosophy"].includes(dir);
8517
8509
  }, {
8518
8510
  message: 'Target must be in a valid directory: ".opencode/{agent|skill|plugin|command|tool|philosophy}/..."'
@@ -8595,83 +8587,6 @@ var registryIndexSchema = exports_external.object({
8595
8587
  }))
8596
8588
  });
8597
8589
 
8598
- // src/schemas/config.ts
8599
- var registryConfigSchema = exports_external.object({
8600
- url: exports_external.string().url("Registry URL must be a valid URL"),
8601
- version: exports_external.string().optional(),
8602
- headers: exports_external.record(exports_external.string()).optional()
8603
- });
8604
- var ocxConfigSchema = exports_external.object({
8605
- $schema: exports_external.string().optional(),
8606
- registries: exports_external.record(registryConfigSchema).default({}),
8607
- lockRegistries: exports_external.boolean().default(false)
8608
- });
8609
- var installedComponentSchema = exports_external.object({
8610
- registry: exports_external.string(),
8611
- version: exports_external.string(),
8612
- hash: exports_external.string(),
8613
- target: exports_external.string(),
8614
- installedAt: exports_external.string()
8615
- });
8616
- var ocxLockSchema = exports_external.object({
8617
- lockVersion: exports_external.literal(1),
8618
- installed: exports_external.record(installedComponentSchema).default({})
8619
- });
8620
- var opencodeMcpSchema = exports_external.record(mcpServerSchema);
8621
- var opencodeAgentSchema = exports_external.object({
8622
- disable: exports_external.boolean().optional(),
8623
- tools: exports_external.record(exports_external.boolean()).optional()
8624
- });
8625
- var opencodeConfigPatchSchema = exports_external.object({
8626
- default_agent: exports_external.string().optional(),
8627
- mcp: opencodeMcpSchema.optional(),
8628
- tools: exports_external.record(exports_external.boolean()).optional(),
8629
- agent: exports_external.record(opencodeAgentSchema).optional()
8630
- });
8631
- var CONFIG_FILE = "ocx.jsonc";
8632
- var LOCK_FILE = "ocx.lock";
8633
- function stripJsonComments(content) {
8634
- return content.replace(/("(?:[^"\\]|\\.)*")|(\/\*[\s\S]*?\*\/)|(\/\/.*)$/gm, (match, string, block, line) => {
8635
- if (string)
8636
- return string;
8637
- return "";
8638
- });
8639
- }
8640
- async function readOcxConfig(cwd) {
8641
- const configPath = `${cwd}/${CONFIG_FILE}`;
8642
- const file = Bun.file(configPath);
8643
- if (!await file.exists()) {
8644
- return null;
8645
- }
8646
- const content = await file.text();
8647
- try {
8648
- const json = JSON.parse(stripJsonComments(content));
8649
- return ocxConfigSchema.parse(json);
8650
- } catch (error) {
8651
- console.error(`Error parsing ${configPath}:`, error);
8652
- throw error;
8653
- }
8654
- }
8655
- async function writeOcxConfig(cwd, config) {
8656
- const configPath = `${cwd}/${CONFIG_FILE}`;
8657
- const content = JSON.stringify(config, null, 2);
8658
- await Bun.write(configPath, content);
8659
- }
8660
- async function readOcxLock(cwd) {
8661
- const lockPath = `${cwd}/${LOCK_FILE}`;
8662
- const file = Bun.file(lockPath);
8663
- if (!await file.exists()) {
8664
- return null;
8665
- }
8666
- const content = await file.text();
8667
- const json = JSON.parse(stripJsonComments(content));
8668
- return ocxLockSchema.parse(json);
8669
- }
8670
-
8671
- // src/utils/env.ts
8672
- var isCI = Boolean(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI || process.env.JENKINS_URL || process.env.BUILDKITE);
8673
- var isTTY = Boolean(process.stdout.isTTY && !isCI);
8674
- var supportsColor = Boolean(isTTY && process.env.FORCE_COLOR !== "0" && process.env.NO_COLOR === undefined);
8675
8590
  // src/utils/errors.ts
8676
8591
  var EXIT_CODES = {
8677
8592
  SUCCESS: 0,
@@ -8732,1791 +8647,1812 @@ class IntegrityError extends OCXError {
8732
8647
  this.name = "IntegrityError";
8733
8648
  }
8734
8649
  }
8735
- // ../../node_modules/.bun/kleur@4.1.5/node_modules/kleur/index.mjs
8736
- var FORCE_COLOR;
8737
- var NODE_DISABLE_COLORS;
8738
- var NO_COLOR;
8739
- var TERM;
8740
- var isTTY2 = true;
8741
- if (typeof process !== "undefined") {
8742
- ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
8743
- isTTY2 = process.stdout && process.stdout.isTTY;
8744
- }
8745
- var $ = {
8746
- enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY2),
8747
- reset: init(0, 0),
8748
- bold: init(1, 22),
8749
- dim: init(2, 22),
8750
- italic: init(3, 23),
8751
- underline: init(4, 24),
8752
- inverse: init(7, 27),
8753
- hidden: init(8, 28),
8754
- strikethrough: init(9, 29),
8755
- black: init(30, 39),
8756
- red: init(31, 39),
8757
- green: init(32, 39),
8758
- yellow: init(33, 39),
8759
- blue: init(34, 39),
8760
- magenta: init(35, 39),
8761
- cyan: init(36, 39),
8762
- white: init(37, 39),
8763
- gray: init(90, 39),
8764
- grey: init(90, 39),
8765
- bgBlack: init(40, 49),
8766
- bgRed: init(41, 49),
8767
- bgGreen: init(42, 49),
8768
- bgYellow: init(43, 49),
8769
- bgBlue: init(44, 49),
8770
- bgMagenta: init(45, 49),
8771
- bgCyan: init(46, 49),
8772
- bgWhite: init(47, 49)
8773
- };
8774
- function run(arr, str) {
8775
- let i = 0, tmp, beg = "", end = "";
8776
- for (;i < arr.length; i++) {
8777
- tmp = arr[i];
8778
- beg += tmp.open;
8779
- end += tmp.close;
8780
- if (!!~str.indexOf(tmp.close)) {
8781
- str = str.replace(tmp.rgx, tmp.close + tmp.open);
8782
- }
8650
+
8651
+ // src/registry/fetcher.ts
8652
+ var cache = new Map;
8653
+ async function fetchWithCache(url, parse) {
8654
+ const cached = cache.get(url);
8655
+ if (cached) {
8656
+ return cached;
8783
8657
  }
8784
- return beg + str + end;
8658
+ const promise = (async () => {
8659
+ const response = await fetch(url);
8660
+ if (!response.ok) {
8661
+ if (response.status === 404) {
8662
+ throw new NotFoundError(`Not found: ${url}`);
8663
+ }
8664
+ throw new NetworkError(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
8665
+ }
8666
+ const data = await response.json();
8667
+ return parse(data);
8668
+ })();
8669
+ cache.set(url, promise);
8670
+ promise.catch(() => cache.delete(url));
8671
+ return promise;
8785
8672
  }
8786
- function chain(has, keys) {
8787
- let ctx = { has, keys };
8788
- ctx.reset = $.reset.bind(ctx);
8789
- ctx.bold = $.bold.bind(ctx);
8790
- ctx.dim = $.dim.bind(ctx);
8791
- ctx.italic = $.italic.bind(ctx);
8792
- ctx.underline = $.underline.bind(ctx);
8793
- ctx.inverse = $.inverse.bind(ctx);
8794
- ctx.hidden = $.hidden.bind(ctx);
8795
- ctx.strikethrough = $.strikethrough.bind(ctx);
8796
- ctx.black = $.black.bind(ctx);
8797
- ctx.red = $.red.bind(ctx);
8798
- ctx.green = $.green.bind(ctx);
8799
- ctx.yellow = $.yellow.bind(ctx);
8800
- ctx.blue = $.blue.bind(ctx);
8801
- ctx.magenta = $.magenta.bind(ctx);
8802
- ctx.cyan = $.cyan.bind(ctx);
8803
- ctx.white = $.white.bind(ctx);
8804
- ctx.gray = $.gray.bind(ctx);
8805
- ctx.grey = $.grey.bind(ctx);
8806
- ctx.bgBlack = $.bgBlack.bind(ctx);
8807
- ctx.bgRed = $.bgRed.bind(ctx);
8808
- ctx.bgGreen = $.bgGreen.bind(ctx);
8809
- ctx.bgYellow = $.bgYellow.bind(ctx);
8810
- ctx.bgBlue = $.bgBlue.bind(ctx);
8811
- ctx.bgMagenta = $.bgMagenta.bind(ctx);
8812
- ctx.bgCyan = $.bgCyan.bind(ctx);
8813
- ctx.bgWhite = $.bgWhite.bind(ctx);
8814
- return ctx;
8673
+ async function fetchRegistryIndex(baseUrl) {
8674
+ const url = `${baseUrl.replace(/\/$/, "")}/index.json`;
8675
+ return fetchWithCache(url, (data) => {
8676
+ const result = registryIndexSchema.safeParse(data);
8677
+ if (!result.success) {
8678
+ throw new ValidationError(`Invalid registry format at ${url}: ${result.error.message}`);
8679
+ }
8680
+ return result.data;
8681
+ });
8815
8682
  }
8816
- function init(open, close) {
8817
- let blk = {
8818
- open: `\x1B[${open}m`,
8819
- close: `\x1B[${close}m`,
8820
- rgx: new RegExp(`\\x1b\\[${close}m`, "g")
8821
- };
8822
- return function(txt) {
8823
- if (this !== undefined && this.has !== undefined) {
8824
- !!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
8825
- return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
8683
+ async function fetchComponent(baseUrl, name) {
8684
+ const url = `${baseUrl.replace(/\/$/, "")}/components/${name}.json`;
8685
+ return fetchWithCache(url, (data) => {
8686
+ const packumentResult = packumentSchema.safeParse(data);
8687
+ if (!packumentResult.success) {
8688
+ throw new ValidationError(`Invalid packument format for "${name}": ${packumentResult.error.message}`);
8826
8689
  }
8827
- return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
8828
- };
8690
+ const packument = packumentResult.data;
8691
+ const latestVersion = packument["dist-tags"].latest;
8692
+ const manifest = packument.versions[latestVersion];
8693
+ if (!manifest) {
8694
+ throw new ValidationError(`Component "${name}" has no manifest for latest version ${latestVersion}`);
8695
+ }
8696
+ const manifestResult = componentManifestSchema.safeParse(manifest);
8697
+ if (!manifestResult.success) {
8698
+ throw new ValidationError(`Invalid component manifest for "${name}@${latestVersion}": ${manifestResult.error.message}`);
8699
+ }
8700
+ return manifestResult.data;
8701
+ });
8702
+ }
8703
+ async function fetchFileContent(baseUrl, componentName, filePath) {
8704
+ const url = `${baseUrl.replace(/\/$/, "")}/components/${componentName}/${filePath}`;
8705
+ const response = await fetch(url);
8706
+ if (!response.ok) {
8707
+ throw new NetworkError(`Failed to fetch file ${filePath} for ${componentName}: ${response.status} ${response.statusText}`);
8708
+ }
8709
+ return response.text();
8829
8710
  }
8830
- var kleur_default = $;
8831
8711
 
8832
- // src/utils/logger.ts
8833
- if (!supportsColor) {
8834
- kleur_default.enabled = false;
8712
+ // src/registry/opencode-config.ts
8713
+ async function readOpencodeConfig(cwd) {
8714
+ const jsonPath = `${cwd}/opencode.json`;
8715
+ const jsoncPath = `${cwd}/opencode.jsonc`;
8716
+ for (const configPath of [jsoncPath, jsonPath]) {
8717
+ const file = Bun.file(configPath);
8718
+ if (await file.exists()) {
8719
+ const content = await file.text();
8720
+ const stripped = configPath.endsWith(".jsonc") ? stripJsonComments(content) : content;
8721
+ return {
8722
+ config: JSON.parse(stripped),
8723
+ path: configPath
8724
+ };
8725
+ }
8726
+ }
8727
+ return null;
8835
8728
  }
8836
- var options = {};
8837
- var logger = {
8838
- info(...args) {
8839
- if (options.quiet)
8840
- return;
8841
- console.log(kleur_default.blue("info"), ...args);
8842
- },
8843
- success(...args) {
8844
- if (options.quiet)
8845
- return;
8846
- console.log(kleur_default.green("\u2713"), ...args);
8847
- },
8848
- warn(...args) {
8849
- if (options.quiet)
8850
- return;
8851
- console.warn(kleur_default.yellow("warn"), ...args);
8852
- },
8853
- error(...args) {
8854
- console.error(kleur_default.red("error"), ...args);
8855
- },
8856
- debug(...args) {
8857
- if (!options.verbose)
8858
- return;
8859
- console.log(kleur_default.gray("debug"), ...args);
8860
- },
8861
- log(...args) {
8862
- if (options.quiet)
8863
- return;
8864
- console.log(...args);
8865
- },
8866
- break() {
8867
- if (options.quiet)
8868
- return;
8869
- console.log("");
8870
- }
8871
- };
8872
- // ../../node_modules/.bun/ora@8.2.0/node_modules/ora/index.js
8873
- import process9 from "process";
8874
-
8875
- // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
8876
- var ANSI_BACKGROUND_OFFSET = 10;
8877
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
8878
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
8879
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
8880
- var styles = {
8881
- modifier: {
8882
- reset: [0, 0],
8883
- bold: [1, 22],
8884
- dim: [2, 22],
8885
- italic: [3, 23],
8886
- underline: [4, 24],
8887
- overline: [53, 55],
8888
- inverse: [7, 27],
8889
- hidden: [8, 28],
8890
- strikethrough: [9, 29]
8891
- },
8892
- color: {
8893
- black: [30, 39],
8894
- red: [31, 39],
8895
- green: [32, 39],
8896
- yellow: [33, 39],
8897
- blue: [34, 39],
8898
- magenta: [35, 39],
8899
- cyan: [36, 39],
8900
- white: [37, 39],
8901
- blackBright: [90, 39],
8902
- gray: [90, 39],
8903
- grey: [90, 39],
8904
- redBright: [91, 39],
8905
- greenBright: [92, 39],
8906
- yellowBright: [93, 39],
8907
- blueBright: [94, 39],
8908
- magentaBright: [95, 39],
8909
- cyanBright: [96, 39],
8910
- whiteBright: [97, 39]
8911
- },
8912
- bgColor: {
8913
- bgBlack: [40, 49],
8914
- bgRed: [41, 49],
8915
- bgGreen: [42, 49],
8916
- bgYellow: [43, 49],
8917
- bgBlue: [44, 49],
8918
- bgMagenta: [45, 49],
8919
- bgCyan: [46, 49],
8920
- bgWhite: [47, 49],
8921
- bgBlackBright: [100, 49],
8922
- bgGray: [100, 49],
8923
- bgGrey: [100, 49],
8924
- bgRedBright: [101, 49],
8925
- bgGreenBright: [102, 49],
8926
- bgYellowBright: [103, 49],
8927
- bgBlueBright: [104, 49],
8928
- bgMagentaBright: [105, 49],
8929
- bgCyanBright: [106, 49],
8930
- bgWhiteBright: [107, 49]
8729
+ async function writeOpencodeConfig(path, config) {
8730
+ const content = JSON.stringify(config, null, 2);
8731
+ await Bun.write(path, content);
8732
+ }
8733
+ function applyMcpServers(config, mcpServers) {
8734
+ const added = [];
8735
+ const skipped = [];
8736
+ if (!config.mcp) {
8737
+ config.mcp = {};
8931
8738
  }
8932
- };
8933
- var modifierNames = Object.keys(styles.modifier);
8934
- var foregroundColorNames = Object.keys(styles.color);
8935
- var backgroundColorNames = Object.keys(styles.bgColor);
8936
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
8937
- function assembleStyles() {
8938
- const codes = new Map;
8939
- for (const [groupName, group] of Object.entries(styles)) {
8940
- for (const [styleName, style] of Object.entries(group)) {
8941
- styles[styleName] = {
8942
- open: `\x1B[${style[0]}m`,
8943
- close: `\x1B[${style[1]}m`
8739
+ for (const [name, server] of Object.entries(mcpServers)) {
8740
+ if (config.mcp[name]) {
8741
+ skipped.push(name);
8742
+ } else {
8743
+ const serverConfig = {
8744
+ type: server.type,
8745
+ enabled: server.enabled
8944
8746
  };
8945
- group[styleName] = styles[styleName];
8946
- codes.set(style[0], style[1]);
8747
+ if (server.type === "remote" && server.url) {
8748
+ serverConfig.url = server.url;
8749
+ }
8750
+ if (server.type === "local" && server.command) {
8751
+ serverConfig.command = server.command;
8752
+ }
8753
+ if (server.headers) {
8754
+ serverConfig.headers = server.headers;
8755
+ }
8756
+ config.mcp[name] = serverConfig;
8757
+ added.push(name);
8947
8758
  }
8948
- Object.defineProperty(styles, groupName, {
8949
- value: group,
8950
- enumerable: false
8951
- });
8952
8759
  }
8953
- Object.defineProperty(styles, "codes", {
8954
- value: codes,
8955
- enumerable: false
8956
- });
8957
- styles.color.close = "\x1B[39m";
8958
- styles.bgColor.close = "\x1B[49m";
8959
- styles.color.ansi = wrapAnsi16();
8960
- styles.color.ansi256 = wrapAnsi256();
8961
- styles.color.ansi16m = wrapAnsi16m();
8962
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
8963
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
8964
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
8965
- Object.defineProperties(styles, {
8966
- rgbToAnsi256: {
8967
- value(red, green, blue) {
8968
- if (red === green && green === blue) {
8969
- if (red < 8) {
8970
- return 16;
8971
- }
8972
- if (red > 248) {
8973
- return 231;
8974
- }
8975
- return Math.round((red - 8) / 247 * 24) + 232;
8976
- }
8977
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
8978
- },
8979
- enumerable: false
8980
- },
8981
- hexToRgb: {
8982
- value(hex) {
8983
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
8984
- if (!matches) {
8985
- return [0, 0, 0];
8986
- }
8987
- let [colorString] = matches;
8988
- if (colorString.length === 3) {
8989
- colorString = [...colorString].map((character) => character + character).join("");
8990
- }
8991
- const integer = Number.parseInt(colorString, 16);
8992
- return [
8993
- integer >> 16 & 255,
8994
- integer >> 8 & 255,
8995
- integer & 255
8996
- ];
8997
- },
8998
- enumerable: false
8999
- },
9000
- hexToAnsi256: {
9001
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
9002
- enumerable: false
9003
- },
9004
- ansi256ToAnsi: {
9005
- value(code) {
9006
- if (code < 8) {
9007
- return 30 + code;
9008
- }
9009
- if (code < 16) {
9010
- return 90 + (code - 8);
9011
- }
9012
- let red;
9013
- let green;
9014
- let blue;
9015
- if (code >= 232) {
9016
- red = ((code - 232) * 10 + 8) / 255;
9017
- green = red;
9018
- blue = red;
9019
- } else {
9020
- code -= 16;
9021
- const remainder = code % 36;
9022
- red = Math.floor(code / 36) / 5;
9023
- green = Math.floor(remainder / 6) / 5;
9024
- blue = remainder % 6 / 5;
9025
- }
9026
- const value = Math.max(red, green, blue) * 2;
9027
- if (value === 0) {
9028
- return 30;
9029
- }
9030
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
9031
- if (value === 2) {
9032
- result += 60;
9033
- }
9034
- return result;
9035
- },
9036
- enumerable: false
9037
- },
9038
- rgbToAnsi: {
9039
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
9040
- enumerable: false
9041
- },
9042
- hexToAnsi: {
9043
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
9044
- enumerable: false
9045
- }
9046
- });
9047
- return styles;
9048
- }
9049
- var ansiStyles = assembleStyles();
9050
- var ansi_styles_default = ansiStyles;
9051
-
9052
- // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
9053
- import process2 from "process";
9054
- import os from "os";
9055
- import tty from "tty";
9056
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
9057
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
9058
- const position = argv.indexOf(prefix + flag);
9059
- const terminatorPosition = argv.indexOf("--");
9060
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
8760
+ return { config, added, skipped };
9061
8761
  }
9062
- var { env } = process2;
9063
- var flagForceColor;
9064
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
9065
- flagForceColor = 0;
9066
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
9067
- flagForceColor = 1;
8762
+ function stripJsonComments(content) {
8763
+ let result = content.replace(/\/\/.*$/gm, "");
8764
+ result = result.replace(/\/\*[\s\S]*?\*\//g, "");
8765
+ return result;
9068
8766
  }
9069
- function envForceColor() {
9070
- if ("FORCE_COLOR" in env) {
9071
- if (env.FORCE_COLOR === "true") {
9072
- return 1;
9073
- }
9074
- if (env.FORCE_COLOR === "false") {
9075
- return 0;
9076
- }
9077
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
8767
+ async function updateOpencodeConfig(cwd, options) {
8768
+ const existing = await readOpencodeConfig(cwd);
8769
+ let config;
8770
+ let configPath;
8771
+ let created = false;
8772
+ if (existing) {
8773
+ config = existing.config;
8774
+ configPath = existing.path;
8775
+ } else {
8776
+ config = {
8777
+ $schema: "https://opencode.ai/config.json"
8778
+ };
8779
+ configPath = `${cwd}/opencode.json`;
8780
+ created = true;
9078
8781
  }
9079
- }
9080
- function translateLevel(level) {
9081
- if (level === 0) {
9082
- return false;
8782
+ let mcpAdded = [];
8783
+ let mcpSkipped = [];
8784
+ if (options.mcpServers && Object.keys(options.mcpServers).length > 0) {
8785
+ const result = applyMcpServers(config, options.mcpServers);
8786
+ config = result.config;
8787
+ mcpAdded = result.added;
8788
+ mcpSkipped = result.skipped;
9083
8789
  }
8790
+ if (options.defaultAgent && !config.default_agent) {
8791
+ config.default_agent = options.defaultAgent;
8792
+ }
8793
+ await writeOpencodeConfig(configPath, config);
9084
8794
  return {
9085
- level,
9086
- hasBasic: true,
9087
- has256: level >= 2,
9088
- has16m: level >= 3
8795
+ path: configPath,
8796
+ created,
8797
+ mcpAdded,
8798
+ mcpSkipped
9089
8799
  };
9090
8800
  }
9091
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
9092
- const noFlagForceColor = envForceColor();
9093
- if (noFlagForceColor !== undefined) {
9094
- flagForceColor = noFlagForceColor;
9095
- }
9096
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
9097
- if (forceColor === 0) {
9098
- return 0;
9099
- }
9100
- if (sniffFlags) {
9101
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
9102
- return 3;
9103
- }
9104
- if (hasFlag("color=256")) {
9105
- return 2;
8801
+
8802
+ // src/registry/resolver.ts
8803
+ async function resolveDependencies(registries, componentNames) {
8804
+ const resolved = new Map;
8805
+ const visiting = new Set;
8806
+ const mcpServers = {};
8807
+ async function resolve(name, path = []) {
8808
+ if (resolved.has(name)) {
8809
+ return;
9106
8810
  }
9107
- }
9108
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
9109
- return 1;
9110
- }
9111
- if (haveStream && !streamIsTTY && forceColor === undefined) {
9112
- return 0;
9113
- }
9114
- const min = forceColor || 0;
9115
- if (env.TERM === "dumb") {
9116
- return min;
9117
- }
9118
- if (process2.platform === "win32") {
9119
- const osRelease = os.release().split(".");
9120
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
9121
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
8811
+ if (visiting.has(name)) {
8812
+ const cycle = [...path, name].join(" \u2192 ");
8813
+ throw new ValidationError(`Circular dependency detected: ${cycle}`);
9122
8814
  }
9123
- return 1;
9124
- }
9125
- if ("CI" in env) {
9126
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env))) {
9127
- return 3;
8815
+ visiting.add(name);
8816
+ let component = null;
8817
+ let foundRegistry = null;
8818
+ const registryEntries = Object.entries(registries);
8819
+ for (const [regName, regConfig] of registryEntries) {
8820
+ try {
8821
+ const manifest = await fetchComponent(regConfig.url, name);
8822
+ component = manifest;
8823
+ foundRegistry = { name: regName, url: regConfig.url };
8824
+ break;
8825
+ } catch (_err) {}
9128
8826
  }
9129
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
9130
- return 1;
8827
+ if (!component || !foundRegistry) {
8828
+ throw new OCXError(`Component '${name}' not found in any configured registry.`, "NOT_FOUND");
9131
8829
  }
9132
- return min;
9133
- }
9134
- if ("TEAMCITY_VERSION" in env) {
9135
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
9136
- }
9137
- if (env.COLORTERM === "truecolor") {
9138
- return 3;
9139
- }
9140
- if (env.TERM === "xterm-kitty") {
9141
- return 3;
9142
- }
9143
- if (env.TERM === "xterm-ghostty") {
9144
- return 3;
9145
- }
9146
- if (env.TERM === "wezterm") {
9147
- return 3;
9148
- }
9149
- if ("TERM_PROGRAM" in env) {
9150
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
9151
- switch (env.TERM_PROGRAM) {
9152
- case "iTerm.app": {
9153
- return version >= 3 ? 3 : 2;
9154
- }
9155
- case "Apple_Terminal": {
9156
- return 2;
9157
- }
8830
+ for (const dep of component.dependencies) {
8831
+ await resolve(dep, [...path, name]);
8832
+ }
8833
+ resolved.set(name, {
8834
+ ...component,
8835
+ registryName: foundRegistry.name,
8836
+ baseUrl: foundRegistry.url
8837
+ });
8838
+ visiting.delete(name);
8839
+ if (component.mcpServers) {
8840
+ for (const [serverName, config] of Object.entries(component.mcpServers)) {
8841
+ mcpServers[serverName] = config;
8842
+ }
9158
8843
  }
9159
8844
  }
9160
- if (/-256(color)?$/i.test(env.TERM)) {
9161
- return 2;
9162
- }
9163
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
9164
- return 1;
9165
- }
9166
- if ("COLORTERM" in env) {
9167
- return 1;
8845
+ for (const name of componentNames) {
8846
+ await resolve(name);
9168
8847
  }
9169
- return min;
8848
+ const components = Array.from(resolved.values());
8849
+ const installOrder = Array.from(resolved.keys());
8850
+ return {
8851
+ components,
8852
+ installOrder,
8853
+ mcpServers
8854
+ };
9170
8855
  }
9171
- function createSupportsColor(stream, options2 = {}) {
9172
- const level = _supportsColor(stream, {
9173
- streamIsTTY: stream && stream.isTTY,
9174
- ...options2
8856
+
8857
+ // src/schemas/config.ts
8858
+ var registryConfigSchema = exports_external.object({
8859
+ url: exports_external.string().url("Registry URL must be a valid URL"),
8860
+ version: exports_external.string().optional(),
8861
+ headers: exports_external.record(exports_external.string()).optional()
8862
+ });
8863
+ var ocxConfigSchema = exports_external.object({
8864
+ $schema: exports_external.string().optional(),
8865
+ registries: exports_external.record(registryConfigSchema).default({}),
8866
+ lockRegistries: exports_external.boolean().default(false)
8867
+ });
8868
+ var installedComponentSchema = exports_external.object({
8869
+ registry: exports_external.string(),
8870
+ version: exports_external.string(),
8871
+ hash: exports_external.string(),
8872
+ target: exports_external.string(),
8873
+ installedAt: exports_external.string()
8874
+ });
8875
+ var ocxLockSchema = exports_external.object({
8876
+ lockVersion: exports_external.literal(1),
8877
+ installed: exports_external.record(installedComponentSchema).default({})
8878
+ });
8879
+ var opencodeMcpSchema = exports_external.record(mcpServerSchema);
8880
+ var opencodeAgentSchema = exports_external.object({
8881
+ disable: exports_external.boolean().optional(),
8882
+ tools: exports_external.record(exports_external.boolean()).optional()
8883
+ });
8884
+ var opencodeConfigPatchSchema = exports_external.object({
8885
+ default_agent: exports_external.string().optional(),
8886
+ mcp: opencodeMcpSchema.optional(),
8887
+ tools: exports_external.record(exports_external.boolean()).optional(),
8888
+ agent: exports_external.record(opencodeAgentSchema).optional()
8889
+ });
8890
+ var CONFIG_FILE = "ocx.jsonc";
8891
+ var LOCK_FILE = "ocx.lock";
8892
+ function stripJsonComments2(content) {
8893
+ return content.replace(/("(?:[^"\\]|\\.)*")|(\/\*[\s\S]*?\*\/)|(\/\/.*)$/gm, (_match, string, _block, _line) => {
8894
+ if (string)
8895
+ return string;
8896
+ return "";
9175
8897
  });
9176
- return translateLevel(level);
9177
8898
  }
9178
- var supportsColor2 = {
9179
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
9180
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
9181
- };
9182
- var supports_color_default = supportsColor2;
9183
-
9184
- // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/utilities.js
9185
- function stringReplaceAll(string, substring, replacer) {
9186
- let index = string.indexOf(substring);
9187
- if (index === -1) {
9188
- return string;
8899
+ async function readOcxConfig(cwd) {
8900
+ const configPath = `${cwd}/${CONFIG_FILE}`;
8901
+ const file = Bun.file(configPath);
8902
+ if (!await file.exists()) {
8903
+ return null;
8904
+ }
8905
+ const content = await file.text();
8906
+ try {
8907
+ const json = JSON.parse(stripJsonComments2(content));
8908
+ return ocxConfigSchema.parse(json);
8909
+ } catch (error) {
8910
+ console.error(`Error parsing ${configPath}:`, error);
8911
+ throw error;
9189
8912
  }
9190
- const substringLength = substring.length;
9191
- let endIndex = 0;
9192
- let returnValue = "";
9193
- do {
9194
- returnValue += string.slice(endIndex, index) + substring + replacer;
9195
- endIndex = index + substringLength;
9196
- index = string.indexOf(substring, endIndex);
9197
- } while (index !== -1);
9198
- returnValue += string.slice(endIndex);
9199
- return returnValue;
9200
8913
  }
9201
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
9202
- let endIndex = 0;
9203
- let returnValue = "";
9204
- do {
9205
- const gotCR = string[index - 1] === "\r";
9206
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
9207
- ` : `
9208
- `) + postfix;
9209
- endIndex = index + 1;
9210
- index = string.indexOf(`
9211
- `, endIndex);
9212
- } while (index !== -1);
9213
- returnValue += string.slice(endIndex);
9214
- return returnValue;
8914
+ async function writeOcxConfig(cwd, config) {
8915
+ const configPath = `${cwd}/${CONFIG_FILE}`;
8916
+ const content = JSON.stringify(config, null, 2);
8917
+ await Bun.write(configPath, content);
9215
8918
  }
9216
-
9217
- // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/index.js
9218
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
9219
- var GENERATOR = Symbol("GENERATOR");
9220
- var STYLER = Symbol("STYLER");
9221
- var IS_EMPTY = Symbol("IS_EMPTY");
9222
- var levelMapping = [
9223
- "ansi",
9224
- "ansi",
9225
- "ansi256",
9226
- "ansi16m"
9227
- ];
9228
- var styles2 = Object.create(null);
9229
- var applyOptions = (object, options2 = {}) => {
9230
- if (options2.level && !(Number.isInteger(options2.level) && options2.level >= 0 && options2.level <= 3)) {
9231
- throw new Error("The `level` option should be an integer from 0 to 3");
8919
+ async function readOcxLock(cwd) {
8920
+ const lockPath = `${cwd}/${LOCK_FILE}`;
8921
+ const file = Bun.file(lockPath);
8922
+ if (!await file.exists()) {
8923
+ return null;
9232
8924
  }
9233
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
9234
- object.level = options2.level === undefined ? colorLevel : options2.level;
9235
- };
9236
- var chalkFactory = (options2) => {
9237
- const chalk = (...strings) => strings.join(" ");
9238
- applyOptions(chalk, options2);
9239
- Object.setPrototypeOf(chalk, createChalk.prototype);
9240
- return chalk;
9241
- };
9242
- function createChalk(options2) {
9243
- return chalkFactory(options2);
8925
+ const content = await file.text();
8926
+ const json = JSON.parse(stripJsonComments2(content));
8927
+ return ocxLockSchema.parse(json);
9244
8928
  }
9245
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
9246
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
9247
- styles2[styleName] = {
9248
- get() {
9249
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
9250
- Object.defineProperty(this, styleName, { value: builder });
9251
- return builder;
9252
- }
9253
- };
8929
+
8930
+ // src/utils/env.ts
8931
+ var isCI = Boolean(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI || process.env.JENKINS_URL || process.env.BUILDKITE);
8932
+ var isTTY = Boolean(process.stdout.isTTY && !isCI);
8933
+ var supportsColor = Boolean(isTTY && process.env.FORCE_COLOR !== "0" && process.env.NO_COLOR === undefined);
8934
+ // ../../node_modules/.bun/kleur@4.1.5/node_modules/kleur/index.mjs
8935
+ var FORCE_COLOR;
8936
+ var NODE_DISABLE_COLORS;
8937
+ var NO_COLOR;
8938
+ var TERM;
8939
+ var isTTY2 = true;
8940
+ if (typeof process !== "undefined") {
8941
+ ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
8942
+ isTTY2 = process.stdout && process.stdout.isTTY;
9254
8943
  }
9255
- styles2.visible = {
9256
- get() {
9257
- const builder = createBuilder(this, this[STYLER], true);
9258
- Object.defineProperty(this, "visible", { value: builder });
9259
- return builder;
9260
- }
8944
+ var $ = {
8945
+ enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY2),
8946
+ reset: init(0, 0),
8947
+ bold: init(1, 22),
8948
+ dim: init(2, 22),
8949
+ italic: init(3, 23),
8950
+ underline: init(4, 24),
8951
+ inverse: init(7, 27),
8952
+ hidden: init(8, 28),
8953
+ strikethrough: init(9, 29),
8954
+ black: init(30, 39),
8955
+ red: init(31, 39),
8956
+ green: init(32, 39),
8957
+ yellow: init(33, 39),
8958
+ blue: init(34, 39),
8959
+ magenta: init(35, 39),
8960
+ cyan: init(36, 39),
8961
+ white: init(37, 39),
8962
+ gray: init(90, 39),
8963
+ grey: init(90, 39),
8964
+ bgBlack: init(40, 49),
8965
+ bgRed: init(41, 49),
8966
+ bgGreen: init(42, 49),
8967
+ bgYellow: init(43, 49),
8968
+ bgBlue: init(44, 49),
8969
+ bgMagenta: init(45, 49),
8970
+ bgCyan: init(46, 49),
8971
+ bgWhite: init(47, 49)
9261
8972
  };
9262
- var getModelAnsi = (model, level, type, ...arguments_) => {
9263
- if (model === "rgb") {
9264
- if (level === "ansi16m") {
9265
- return ansi_styles_default[type].ansi16m(...arguments_);
9266
- }
9267
- if (level === "ansi256") {
9268
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
8973
+ function run(arr, str) {
8974
+ let i = 0, tmp, beg = "", end = "";
8975
+ for (;i < arr.length; i++) {
8976
+ tmp = arr[i];
8977
+ beg += tmp.open;
8978
+ end += tmp.close;
8979
+ if (!!~str.indexOf(tmp.close)) {
8980
+ str = str.replace(tmp.rgx, tmp.close + tmp.open);
9269
8981
  }
9270
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
9271
8982
  }
9272
- if (model === "hex") {
9273
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
9274
- }
9275
- return ansi_styles_default[type][model](...arguments_);
9276
- };
9277
- var usedModels = ["rgb", "hex", "ansi256"];
9278
- for (const model of usedModels) {
9279
- styles2[model] = {
9280
- get() {
9281
- const { level } = this;
9282
- return function(...arguments_) {
9283
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
9284
- return createBuilder(this, styler, this[IS_EMPTY]);
9285
- };
9286
- }
8983
+ return beg + str + end;
8984
+ }
8985
+ function chain(has, keys) {
8986
+ let ctx = { has, keys };
8987
+ ctx.reset = $.reset.bind(ctx);
8988
+ ctx.bold = $.bold.bind(ctx);
8989
+ ctx.dim = $.dim.bind(ctx);
8990
+ ctx.italic = $.italic.bind(ctx);
8991
+ ctx.underline = $.underline.bind(ctx);
8992
+ ctx.inverse = $.inverse.bind(ctx);
8993
+ ctx.hidden = $.hidden.bind(ctx);
8994
+ ctx.strikethrough = $.strikethrough.bind(ctx);
8995
+ ctx.black = $.black.bind(ctx);
8996
+ ctx.red = $.red.bind(ctx);
8997
+ ctx.green = $.green.bind(ctx);
8998
+ ctx.yellow = $.yellow.bind(ctx);
8999
+ ctx.blue = $.blue.bind(ctx);
9000
+ ctx.magenta = $.magenta.bind(ctx);
9001
+ ctx.cyan = $.cyan.bind(ctx);
9002
+ ctx.white = $.white.bind(ctx);
9003
+ ctx.gray = $.gray.bind(ctx);
9004
+ ctx.grey = $.grey.bind(ctx);
9005
+ ctx.bgBlack = $.bgBlack.bind(ctx);
9006
+ ctx.bgRed = $.bgRed.bind(ctx);
9007
+ ctx.bgGreen = $.bgGreen.bind(ctx);
9008
+ ctx.bgYellow = $.bgYellow.bind(ctx);
9009
+ ctx.bgBlue = $.bgBlue.bind(ctx);
9010
+ ctx.bgMagenta = $.bgMagenta.bind(ctx);
9011
+ ctx.bgCyan = $.bgCyan.bind(ctx);
9012
+ ctx.bgWhite = $.bgWhite.bind(ctx);
9013
+ return ctx;
9014
+ }
9015
+ function init(open, close) {
9016
+ let blk = {
9017
+ open: `\x1B[${open}m`,
9018
+ close: `\x1B[${close}m`,
9019
+ rgx: new RegExp(`\\x1b\\[${close}m`, "g")
9287
9020
  };
9288
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
9289
- styles2[bgModel] = {
9290
- get() {
9291
- const { level } = this;
9292
- return function(...arguments_) {
9293
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
9294
- return createBuilder(this, styler, this[IS_EMPTY]);
9295
- };
9021
+ return function(txt) {
9022
+ if (this !== undefined && this.has !== undefined) {
9023
+ !!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
9024
+ return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
9296
9025
  }
9026
+ return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
9297
9027
  };
9298
9028
  }
9299
- var proto = Object.defineProperties(() => {}, {
9300
- ...styles2,
9301
- level: {
9302
- enumerable: true,
9303
- get() {
9304
- return this[GENERATOR].level;
9305
- },
9306
- set(level) {
9307
- this[GENERATOR].level = level;
9308
- }
9309
- }
9310
- });
9311
- var createStyler = (open, close, parent) => {
9312
- let openAll;
9313
- let closeAll;
9314
- if (parent === undefined) {
9315
- openAll = open;
9316
- closeAll = close;
9317
- } else {
9318
- openAll = parent.openAll + open;
9319
- closeAll = close + parent.closeAll;
9029
+ var kleur_default = $;
9030
+
9031
+ // src/utils/logger.ts
9032
+ if (!supportsColor) {
9033
+ kleur_default.enabled = false;
9034
+ }
9035
+ var options = {};
9036
+ var logger = {
9037
+ info(...args) {
9038
+ if (options.quiet)
9039
+ return;
9040
+ console.log(kleur_default.blue("info"), ...args);
9041
+ },
9042
+ success(...args) {
9043
+ if (options.quiet)
9044
+ return;
9045
+ console.log(kleur_default.green("\u2713"), ...args);
9046
+ },
9047
+ warn(...args) {
9048
+ if (options.quiet)
9049
+ return;
9050
+ console.warn(kleur_default.yellow("warn"), ...args);
9051
+ },
9052
+ error(...args) {
9053
+ console.error(kleur_default.red("error"), ...args);
9054
+ },
9055
+ debug(...args) {
9056
+ if (!options.verbose)
9057
+ return;
9058
+ console.log(kleur_default.gray("debug"), ...args);
9059
+ },
9060
+ log(...args) {
9061
+ if (options.quiet)
9062
+ return;
9063
+ console.log(...args);
9064
+ },
9065
+ break() {
9066
+ if (options.quiet)
9067
+ return;
9068
+ console.log("");
9320
9069
  }
9321
- return {
9322
- open,
9323
- close,
9324
- openAll,
9325
- closeAll,
9326
- parent
9327
- };
9328
- };
9329
- var createBuilder = (self, _styler, _isEmpty) => {
9330
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
9331
- Object.setPrototypeOf(builder, proto);
9332
- builder[GENERATOR] = self;
9333
- builder[STYLER] = _styler;
9334
- builder[IS_EMPTY] = _isEmpty;
9335
- return builder;
9336
9070
  };
9337
- var applyStyle = (self, string) => {
9338
- if (self.level <= 0 || !string) {
9339
- return self[IS_EMPTY] ? "" : string;
9071
+
9072
+ // src/utils/handle-error.ts
9073
+ function handleError(error, options2 = {}) {
9074
+ if (options2.json) {
9075
+ const output = formatErrorAsJson(error);
9076
+ console.log(JSON.stringify(output, null, 2));
9077
+ process.exit(output.exitCode);
9340
9078
  }
9341
- let styler = self[STYLER];
9342
- if (styler === undefined) {
9343
- return string;
9079
+ if (error instanceof OCXError) {
9080
+ logger.error(error.message);
9081
+ process.exit(error.exitCode);
9344
9082
  }
9345
- const { openAll, closeAll } = styler;
9346
- if (string.includes("\x1B")) {
9347
- while (styler !== undefined) {
9348
- string = stringReplaceAll(string, styler.close, styler.open);
9349
- styler = styler.parent;
9083
+ if (error instanceof ZodError) {
9084
+ logger.error("Validation failed:");
9085
+ for (const issue of error.issues) {
9086
+ const path = issue.path.join(".");
9087
+ logger.error(` ${path}: ${issue.message}`);
9350
9088
  }
9089
+ process.exit(EXIT_CODES.CONFIG);
9351
9090
  }
9352
- const lfIndex = string.indexOf(`
9353
- `);
9354
- if (lfIndex !== -1) {
9355
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
9356
- }
9357
- return openAll + string + closeAll;
9358
- };
9359
- Object.defineProperties(createChalk.prototype, styles2);
9360
- var chalk = createChalk();
9361
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
9362
- var source_default = chalk;
9363
-
9364
- // ../../node_modules/.bun/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
9365
- import process5 from "process";
9366
-
9367
- // ../../node_modules/.bun/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
9368
- import process4 from "process";
9369
-
9370
- // ../../node_modules/.bun/mimic-function@5.0.1/node_modules/mimic-function/index.js
9371
- var copyProperty = (to, from, property, ignoreNonConfigurable) => {
9372
- if (property === "length" || property === "prototype") {
9373
- return;
9091
+ if (error instanceof Error) {
9092
+ logger.error(error.message);
9093
+ if (process.env.DEBUG) {
9094
+ console.error(error.stack);
9095
+ }
9096
+ } else {
9097
+ logger.error("An unknown error occurred");
9374
9098
  }
9375
- if (property === "arguments" || property === "caller") {
9376
- return;
9099
+ process.exit(EXIT_CODES.GENERAL);
9100
+ }
9101
+ function formatErrorAsJson(error) {
9102
+ if (error instanceof OCXError) {
9103
+ return {
9104
+ success: false,
9105
+ error: {
9106
+ code: error.code,
9107
+ message: error.message
9108
+ },
9109
+ exitCode: error.exitCode,
9110
+ meta: {
9111
+ timestamp: new Date().toISOString()
9112
+ }
9113
+ };
9377
9114
  }
9378
- const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
9379
- const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
9380
- if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
9381
- return;
9115
+ if (error instanceof ZodError) {
9116
+ return {
9117
+ success: false,
9118
+ error: {
9119
+ code: "VALIDATION_ERROR",
9120
+ message: error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")
9121
+ },
9122
+ exitCode: EXIT_CODES.CONFIG,
9123
+ meta: {
9124
+ timestamp: new Date().toISOString()
9125
+ }
9126
+ };
9382
9127
  }
9383
- Object.defineProperty(to, property, fromDescriptor);
9384
- };
9385
- var canCopyProperty = function(toDescriptor, fromDescriptor) {
9386
- return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
9387
- };
9388
- var changePrototype = (to, from) => {
9389
- const fromPrototype = Object.getPrototypeOf(from);
9390
- if (fromPrototype === Object.getPrototypeOf(to)) {
9391
- return;
9128
+ return {
9129
+ success: false,
9130
+ error: {
9131
+ code: "UNKNOWN_ERROR",
9132
+ message: error instanceof Error ? error.message : "An unknown error occurred"
9133
+ },
9134
+ exitCode: EXIT_CODES.GENERAL,
9135
+ meta: {
9136
+ timestamp: new Date().toISOString()
9137
+ }
9138
+ };
9139
+ }
9140
+ // src/utils/json-output.ts
9141
+ function outputJson(data) {
9142
+ console.log(JSON.stringify(data, null, 2));
9143
+ }
9144
+ // ../../node_modules/.bun/ora@8.2.0/node_modules/ora/index.js
9145
+ import process9 from "process";
9146
+
9147
+ // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
9148
+ var ANSI_BACKGROUND_OFFSET = 10;
9149
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
9150
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
9151
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
9152
+ var styles = {
9153
+ modifier: {
9154
+ reset: [0, 0],
9155
+ bold: [1, 22],
9156
+ dim: [2, 22],
9157
+ italic: [3, 23],
9158
+ underline: [4, 24],
9159
+ overline: [53, 55],
9160
+ inverse: [7, 27],
9161
+ hidden: [8, 28],
9162
+ strikethrough: [9, 29]
9163
+ },
9164
+ color: {
9165
+ black: [30, 39],
9166
+ red: [31, 39],
9167
+ green: [32, 39],
9168
+ yellow: [33, 39],
9169
+ blue: [34, 39],
9170
+ magenta: [35, 39],
9171
+ cyan: [36, 39],
9172
+ white: [37, 39],
9173
+ blackBright: [90, 39],
9174
+ gray: [90, 39],
9175
+ grey: [90, 39],
9176
+ redBright: [91, 39],
9177
+ greenBright: [92, 39],
9178
+ yellowBright: [93, 39],
9179
+ blueBright: [94, 39],
9180
+ magentaBright: [95, 39],
9181
+ cyanBright: [96, 39],
9182
+ whiteBright: [97, 39]
9183
+ },
9184
+ bgColor: {
9185
+ bgBlack: [40, 49],
9186
+ bgRed: [41, 49],
9187
+ bgGreen: [42, 49],
9188
+ bgYellow: [43, 49],
9189
+ bgBlue: [44, 49],
9190
+ bgMagenta: [45, 49],
9191
+ bgCyan: [46, 49],
9192
+ bgWhite: [47, 49],
9193
+ bgBlackBright: [100, 49],
9194
+ bgGray: [100, 49],
9195
+ bgGrey: [100, 49],
9196
+ bgRedBright: [101, 49],
9197
+ bgGreenBright: [102, 49],
9198
+ bgYellowBright: [103, 49],
9199
+ bgBlueBright: [104, 49],
9200
+ bgMagentaBright: [105, 49],
9201
+ bgCyanBright: [106, 49],
9202
+ bgWhiteBright: [107, 49]
9392
9203
  }
9393
- Object.setPrototypeOf(to, fromPrototype);
9394
- };
9395
- var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
9396
- ${fromBody}`;
9397
- var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
9398
- var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
9399
- var changeToString = (to, from, name) => {
9400
- const withName = name === "" ? "" : `with ${name.trim()}() `;
9401
- const newToString = wrappedToString.bind(null, withName, from.toString());
9402
- Object.defineProperty(newToString, "name", toStringName);
9403
- const { writable, enumerable, configurable } = toStringDescriptor;
9404
- Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable });
9405
9204
  };
9406
- function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
9407
- const { name } = to;
9408
- for (const property of Reflect.ownKeys(from)) {
9409
- copyProperty(to, from, property, ignoreNonConfigurable);
9410
- }
9411
- changePrototype(to, from);
9412
- changeToString(to, from, name);
9413
- return to;
9414
- }
9415
-
9416
- // ../../node_modules/.bun/onetime@7.0.0/node_modules/onetime/index.js
9417
- var calledFunctions = new WeakMap;
9418
- var onetime = (function_, options2 = {}) => {
9419
- if (typeof function_ !== "function") {
9420
- throw new TypeError("Expected a function");
9421
- }
9422
- let returnValue;
9423
- let callCount = 0;
9424
- const functionName = function_.displayName || function_.name || "<anonymous>";
9425
- const onetime2 = function(...arguments_) {
9426
- calledFunctions.set(onetime2, ++callCount);
9427
- if (callCount === 1) {
9428
- returnValue = function_.apply(this, arguments_);
9429
- function_ = undefined;
9430
- } else if (options2.throw === true) {
9431
- throw new Error(`Function \`${functionName}\` can only be called once`);
9205
+ var modifierNames = Object.keys(styles.modifier);
9206
+ var foregroundColorNames = Object.keys(styles.color);
9207
+ var backgroundColorNames = Object.keys(styles.bgColor);
9208
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
9209
+ function assembleStyles() {
9210
+ const codes = new Map;
9211
+ for (const [groupName, group] of Object.entries(styles)) {
9212
+ for (const [styleName, style] of Object.entries(group)) {
9213
+ styles[styleName] = {
9214
+ open: `\x1B[${style[0]}m`,
9215
+ close: `\x1B[${style[1]}m`
9216
+ };
9217
+ group[styleName] = styles[styleName];
9218
+ codes.set(style[0], style[1]);
9432
9219
  }
9433
- return returnValue;
9434
- };
9435
- mimicFunction(onetime2, function_);
9436
- calledFunctions.set(onetime2, callCount);
9437
- return onetime2;
9438
- };
9439
- onetime.callCount = (function_) => {
9440
- if (!calledFunctions.has(function_)) {
9441
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
9220
+ Object.defineProperty(styles, groupName, {
9221
+ value: group,
9222
+ enumerable: false
9223
+ });
9442
9224
  }
9443
- return calledFunctions.get(function_);
9444
- };
9445
- var onetime_default = onetime;
9225
+ Object.defineProperty(styles, "codes", {
9226
+ value: codes,
9227
+ enumerable: false
9228
+ });
9229
+ styles.color.close = "\x1B[39m";
9230
+ styles.bgColor.close = "\x1B[49m";
9231
+ styles.color.ansi = wrapAnsi16();
9232
+ styles.color.ansi256 = wrapAnsi256();
9233
+ styles.color.ansi16m = wrapAnsi16m();
9234
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
9235
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
9236
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
9237
+ Object.defineProperties(styles, {
9238
+ rgbToAnsi256: {
9239
+ value(red, green, blue) {
9240
+ if (red === green && green === blue) {
9241
+ if (red < 8) {
9242
+ return 16;
9243
+ }
9244
+ if (red > 248) {
9245
+ return 231;
9246
+ }
9247
+ return Math.round((red - 8) / 247 * 24) + 232;
9248
+ }
9249
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
9250
+ },
9251
+ enumerable: false
9252
+ },
9253
+ hexToRgb: {
9254
+ value(hex) {
9255
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
9256
+ if (!matches) {
9257
+ return [0, 0, 0];
9258
+ }
9259
+ let [colorString] = matches;
9260
+ if (colorString.length === 3) {
9261
+ colorString = [...colorString].map((character) => character + character).join("");
9262
+ }
9263
+ const integer = Number.parseInt(colorString, 16);
9264
+ return [
9265
+ integer >> 16 & 255,
9266
+ integer >> 8 & 255,
9267
+ integer & 255
9268
+ ];
9269
+ },
9270
+ enumerable: false
9271
+ },
9272
+ hexToAnsi256: {
9273
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
9274
+ enumerable: false
9275
+ },
9276
+ ansi256ToAnsi: {
9277
+ value(code) {
9278
+ if (code < 8) {
9279
+ return 30 + code;
9280
+ }
9281
+ if (code < 16) {
9282
+ return 90 + (code - 8);
9283
+ }
9284
+ let red;
9285
+ let green;
9286
+ let blue;
9287
+ if (code >= 232) {
9288
+ red = ((code - 232) * 10 + 8) / 255;
9289
+ green = red;
9290
+ blue = red;
9291
+ } else {
9292
+ code -= 16;
9293
+ const remainder = code % 36;
9294
+ red = Math.floor(code / 36) / 5;
9295
+ green = Math.floor(remainder / 6) / 5;
9296
+ blue = remainder % 6 / 5;
9297
+ }
9298
+ const value = Math.max(red, green, blue) * 2;
9299
+ if (value === 0) {
9300
+ return 30;
9301
+ }
9302
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
9303
+ if (value === 2) {
9304
+ result += 60;
9305
+ }
9306
+ return result;
9307
+ },
9308
+ enumerable: false
9309
+ },
9310
+ rgbToAnsi: {
9311
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
9312
+ enumerable: false
9313
+ },
9314
+ hexToAnsi: {
9315
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
9316
+ enumerable: false
9317
+ }
9318
+ });
9319
+ return styles;
9320
+ }
9321
+ var ansiStyles = assembleStyles();
9322
+ var ansi_styles_default = ansiStyles;
9446
9323
 
9447
- // ../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
9448
- var signals = [];
9449
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
9450
- if (process.platform !== "win32") {
9451
- signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
9324
+ // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
9325
+ import process2 from "process";
9326
+ import os from "os";
9327
+ import tty from "tty";
9328
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
9329
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
9330
+ const position = argv.indexOf(prefix + flag);
9331
+ const terminatorPosition = argv.indexOf("--");
9332
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
9452
9333
  }
9453
- if (process.platform === "linux") {
9454
- signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
9334
+ var { env } = process2;
9335
+ var flagForceColor;
9336
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
9337
+ flagForceColor = 0;
9338
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
9339
+ flagForceColor = 1;
9455
9340
  }
9456
-
9457
- // ../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
9458
- var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
9459
- var kExitEmitter = Symbol.for("signal-exit emitter");
9460
- var global = globalThis;
9461
- var ObjectDefineProperty = Object.defineProperty.bind(Object);
9462
-
9463
- class Emitter {
9464
- emitted = {
9465
- afterExit: false,
9466
- exit: false
9467
- };
9468
- listeners = {
9469
- afterExit: [],
9470
- exit: []
9471
- };
9472
- count = 0;
9473
- id = Math.random();
9474
- constructor() {
9475
- if (global[kExitEmitter]) {
9476
- return global[kExitEmitter];
9341
+ function envForceColor() {
9342
+ if ("FORCE_COLOR" in env) {
9343
+ if (env.FORCE_COLOR === "true") {
9344
+ return 1;
9477
9345
  }
9478
- ObjectDefineProperty(global, kExitEmitter, {
9479
- value: this,
9480
- writable: false,
9481
- enumerable: false,
9482
- configurable: false
9483
- });
9346
+ if (env.FORCE_COLOR === "false") {
9347
+ return 0;
9348
+ }
9349
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
9350
+ }
9351
+ }
9352
+ function translateLevel(level) {
9353
+ if (level === 0) {
9354
+ return false;
9355
+ }
9356
+ return {
9357
+ level,
9358
+ hasBasic: true,
9359
+ has256: level >= 2,
9360
+ has16m: level >= 3
9361
+ };
9362
+ }
9363
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
9364
+ const noFlagForceColor = envForceColor();
9365
+ if (noFlagForceColor !== undefined) {
9366
+ flagForceColor = noFlagForceColor;
9484
9367
  }
9485
- on(ev, fn) {
9486
- this.listeners[ev].push(fn);
9368
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
9369
+ if (forceColor === 0) {
9370
+ return 0;
9487
9371
  }
9488
- removeListener(ev, fn) {
9489
- const list = this.listeners[ev];
9490
- const i = list.indexOf(fn);
9491
- if (i === -1) {
9492
- return;
9372
+ if (sniffFlags) {
9373
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
9374
+ return 3;
9493
9375
  }
9494
- if (i === 0 && list.length === 1) {
9495
- list.length = 0;
9496
- } else {
9497
- list.splice(i, 1);
9376
+ if (hasFlag("color=256")) {
9377
+ return 2;
9498
9378
  }
9499
9379
  }
9500
- emit(ev, code, signal) {
9501
- if (this.emitted[ev]) {
9502
- return false;
9380
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
9381
+ return 1;
9382
+ }
9383
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
9384
+ return 0;
9385
+ }
9386
+ const min = forceColor || 0;
9387
+ if (env.TERM === "dumb") {
9388
+ return min;
9389
+ }
9390
+ if (process2.platform === "win32") {
9391
+ const osRelease = os.release().split(".");
9392
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
9393
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
9503
9394
  }
9504
- this.emitted[ev] = true;
9505
- let ret = false;
9506
- for (const fn of this.listeners[ev]) {
9507
- ret = fn(code, signal) === true || ret;
9395
+ return 1;
9396
+ }
9397
+ if ("CI" in env) {
9398
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env))) {
9399
+ return 3;
9508
9400
  }
9509
- if (ev === "exit") {
9510
- ret = this.emit("afterExit", code, signal) || ret;
9401
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
9402
+ return 1;
9511
9403
  }
9512
- return ret;
9404
+ return min;
9405
+ }
9406
+ if ("TEAMCITY_VERSION" in env) {
9407
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
9408
+ }
9409
+ if (env.COLORTERM === "truecolor") {
9410
+ return 3;
9411
+ }
9412
+ if (env.TERM === "xterm-kitty") {
9413
+ return 3;
9414
+ }
9415
+ if (env.TERM === "xterm-ghostty") {
9416
+ return 3;
9417
+ }
9418
+ if (env.TERM === "wezterm") {
9419
+ return 3;
9420
+ }
9421
+ if ("TERM_PROGRAM" in env) {
9422
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
9423
+ switch (env.TERM_PROGRAM) {
9424
+ case "iTerm.app": {
9425
+ return version >= 3 ? 3 : 2;
9426
+ }
9427
+ case "Apple_Terminal": {
9428
+ return 2;
9429
+ }
9430
+ }
9431
+ }
9432
+ if (/-256(color)?$/i.test(env.TERM)) {
9433
+ return 2;
9434
+ }
9435
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
9436
+ return 1;
9437
+ }
9438
+ if ("COLORTERM" in env) {
9439
+ return 1;
9513
9440
  }
9441
+ return min;
9514
9442
  }
9515
-
9516
- class SignalExitBase {
9443
+ function createSupportsColor(stream, options2 = {}) {
9444
+ const level = _supportsColor(stream, {
9445
+ streamIsTTY: stream && stream.isTTY,
9446
+ ...options2
9447
+ });
9448
+ return translateLevel(level);
9517
9449
  }
9518
- var signalExitWrap = (handler) => {
9519
- return {
9520
- onExit(cb, opts) {
9521
- return handler.onExit(cb, opts);
9522
- },
9523
- load() {
9524
- return handler.load();
9525
- },
9526
- unload() {
9527
- return handler.unload();
9528
- }
9529
- };
9450
+ var supportsColor2 = {
9451
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
9452
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
9530
9453
  };
9454
+ var supports_color_default = supportsColor2;
9531
9455
 
9532
- class SignalExitFallback extends SignalExitBase {
9533
- onExit() {
9534
- return () => {};
9456
+ // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/utilities.js
9457
+ function stringReplaceAll(string, substring, replacer) {
9458
+ let index = string.indexOf(substring);
9459
+ if (index === -1) {
9460
+ return string;
9535
9461
  }
9536
- load() {}
9537
- unload() {}
9462
+ const substringLength = substring.length;
9463
+ let endIndex = 0;
9464
+ let returnValue = "";
9465
+ do {
9466
+ returnValue += string.slice(endIndex, index) + substring + replacer;
9467
+ endIndex = index + substringLength;
9468
+ index = string.indexOf(substring, endIndex);
9469
+ } while (index !== -1);
9470
+ returnValue += string.slice(endIndex);
9471
+ return returnValue;
9472
+ }
9473
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
9474
+ let endIndex = 0;
9475
+ let returnValue = "";
9476
+ do {
9477
+ const gotCR = string[index - 1] === "\r";
9478
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
9479
+ ` : `
9480
+ `) + postfix;
9481
+ endIndex = index + 1;
9482
+ index = string.indexOf(`
9483
+ `, endIndex);
9484
+ } while (index !== -1);
9485
+ returnValue += string.slice(endIndex);
9486
+ return returnValue;
9538
9487
  }
9539
9488
 
9540
- class SignalExit extends SignalExitBase {
9541
- #hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
9542
- #emitter = new Emitter;
9543
- #process;
9544
- #originalProcessEmit;
9545
- #originalProcessReallyExit;
9546
- #sigListeners = {};
9547
- #loaded = false;
9548
- constructor(process3) {
9549
- super();
9550
- this.#process = process3;
9551
- this.#sigListeners = {};
9552
- for (const sig of signals) {
9553
- this.#sigListeners[sig] = () => {
9554
- const listeners = this.#process.listeners(sig);
9555
- let { count } = this.#emitter;
9556
- const p = process3;
9557
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
9558
- count += p.__signal_exit_emitter__.count;
9559
- }
9560
- if (listeners.length === count) {
9561
- this.unload();
9562
- const ret = this.#emitter.emit("exit", null, sig);
9563
- const s = sig === "SIGHUP" ? this.#hupSig : sig;
9564
- if (!ret)
9565
- process3.kill(process3.pid, s);
9566
- }
9489
+ // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/index.js
9490
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
9491
+ var GENERATOR = Symbol("GENERATOR");
9492
+ var STYLER = Symbol("STYLER");
9493
+ var IS_EMPTY = Symbol("IS_EMPTY");
9494
+ var levelMapping = [
9495
+ "ansi",
9496
+ "ansi",
9497
+ "ansi256",
9498
+ "ansi16m"
9499
+ ];
9500
+ var styles2 = Object.create(null);
9501
+ var applyOptions = (object, options2 = {}) => {
9502
+ if (options2.level && !(Number.isInteger(options2.level) && options2.level >= 0 && options2.level <= 3)) {
9503
+ throw new Error("The `level` option should be an integer from 0 to 3");
9504
+ }
9505
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
9506
+ object.level = options2.level === undefined ? colorLevel : options2.level;
9507
+ };
9508
+ var chalkFactory = (options2) => {
9509
+ const chalk = (...strings) => strings.join(" ");
9510
+ applyOptions(chalk, options2);
9511
+ Object.setPrototypeOf(chalk, createChalk.prototype);
9512
+ return chalk;
9513
+ };
9514
+ function createChalk(options2) {
9515
+ return chalkFactory(options2);
9516
+ }
9517
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
9518
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
9519
+ styles2[styleName] = {
9520
+ get() {
9521
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
9522
+ Object.defineProperty(this, styleName, { value: builder });
9523
+ return builder;
9524
+ }
9525
+ };
9526
+ }
9527
+ styles2.visible = {
9528
+ get() {
9529
+ const builder = createBuilder(this, this[STYLER], true);
9530
+ Object.defineProperty(this, "visible", { value: builder });
9531
+ return builder;
9532
+ }
9533
+ };
9534
+ var getModelAnsi = (model, level, type, ...arguments_) => {
9535
+ if (model === "rgb") {
9536
+ if (level === "ansi16m") {
9537
+ return ansi_styles_default[type].ansi16m(...arguments_);
9538
+ }
9539
+ if (level === "ansi256") {
9540
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
9541
+ }
9542
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
9543
+ }
9544
+ if (model === "hex") {
9545
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
9546
+ }
9547
+ return ansi_styles_default[type][model](...arguments_);
9548
+ };
9549
+ var usedModels = ["rgb", "hex", "ansi256"];
9550
+ for (const model of usedModels) {
9551
+ styles2[model] = {
9552
+ get() {
9553
+ const { level } = this;
9554
+ return function(...arguments_) {
9555
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
9556
+ return createBuilder(this, styler, this[IS_EMPTY]);
9557
+ };
9558
+ }
9559
+ };
9560
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
9561
+ styles2[bgModel] = {
9562
+ get() {
9563
+ const { level } = this;
9564
+ return function(...arguments_) {
9565
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
9566
+ return createBuilder(this, styler, this[IS_EMPTY]);
9567
9567
  };
9568
9568
  }
9569
- this.#originalProcessReallyExit = process3.reallyExit;
9570
- this.#originalProcessEmit = process3.emit;
9571
- }
9572
- onExit(cb, opts) {
9573
- if (!processOk(this.#process)) {
9574
- return () => {};
9575
- }
9576
- if (this.#loaded === false) {
9577
- this.load();
9569
+ };
9570
+ }
9571
+ var proto = Object.defineProperties(() => {}, {
9572
+ ...styles2,
9573
+ level: {
9574
+ enumerable: true,
9575
+ get() {
9576
+ return this[GENERATOR].level;
9577
+ },
9578
+ set(level) {
9579
+ this[GENERATOR].level = level;
9578
9580
  }
9579
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
9580
- this.#emitter.on(ev, cb);
9581
- return () => {
9582
- this.#emitter.removeListener(ev, cb);
9583
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
9584
- this.unload();
9585
- }
9586
- };
9587
9581
  }
9588
- load() {
9589
- if (this.#loaded) {
9590
- return;
9591
- }
9592
- this.#loaded = true;
9593
- this.#emitter.count += 1;
9594
- for (const sig of signals) {
9595
- try {
9596
- const fn = this.#sigListeners[sig];
9597
- if (fn)
9598
- this.#process.on(sig, fn);
9599
- } catch (_) {}
9600
- }
9601
- this.#process.emit = (ev, ...a) => {
9602
- return this.#processEmit(ev, ...a);
9603
- };
9604
- this.#process.reallyExit = (code) => {
9605
- return this.#processReallyExit(code);
9606
- };
9582
+ });
9583
+ var createStyler = (open, close, parent) => {
9584
+ let openAll;
9585
+ let closeAll;
9586
+ if (parent === undefined) {
9587
+ openAll = open;
9588
+ closeAll = close;
9589
+ } else {
9590
+ openAll = parent.openAll + open;
9591
+ closeAll = close + parent.closeAll;
9607
9592
  }
9608
- unload() {
9609
- if (!this.#loaded) {
9610
- return;
9611
- }
9612
- this.#loaded = false;
9613
- signals.forEach((sig) => {
9614
- const listener = this.#sigListeners[sig];
9615
- if (!listener) {
9616
- throw new Error("Listener not defined for signal: " + sig);
9617
- }
9618
- try {
9619
- this.#process.removeListener(sig, listener);
9620
- } catch (_) {}
9621
- });
9622
- this.#process.emit = this.#originalProcessEmit;
9623
- this.#process.reallyExit = this.#originalProcessReallyExit;
9624
- this.#emitter.count -= 1;
9593
+ return {
9594
+ open,
9595
+ close,
9596
+ openAll,
9597
+ closeAll,
9598
+ parent
9599
+ };
9600
+ };
9601
+ var createBuilder = (self, _styler, _isEmpty) => {
9602
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
9603
+ Object.setPrototypeOf(builder, proto);
9604
+ builder[GENERATOR] = self;
9605
+ builder[STYLER] = _styler;
9606
+ builder[IS_EMPTY] = _isEmpty;
9607
+ return builder;
9608
+ };
9609
+ var applyStyle = (self, string) => {
9610
+ if (self.level <= 0 || !string) {
9611
+ return self[IS_EMPTY] ? "" : string;
9625
9612
  }
9626
- #processReallyExit(code) {
9627
- if (!processOk(this.#process)) {
9628
- return 0;
9629
- }
9630
- this.#process.exitCode = code || 0;
9631
- this.#emitter.emit("exit", this.#process.exitCode, null);
9632
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
9613
+ let styler = self[STYLER];
9614
+ if (styler === undefined) {
9615
+ return string;
9633
9616
  }
9634
- #processEmit(ev, ...args) {
9635
- const og = this.#originalProcessEmit;
9636
- if (ev === "exit" && processOk(this.#process)) {
9637
- if (typeof args[0] === "number") {
9638
- this.#process.exitCode = args[0];
9639
- }
9640
- const ret = og.call(this.#process, ev, ...args);
9641
- this.#emitter.emit("exit", this.#process.exitCode, null);
9642
- return ret;
9643
- } else {
9644
- return og.call(this.#process, ev, ...args);
9617
+ const { openAll, closeAll } = styler;
9618
+ if (string.includes("\x1B")) {
9619
+ while (styler !== undefined) {
9620
+ string = stringReplaceAll(string, styler.close, styler.open);
9621
+ styler = styler.parent;
9645
9622
  }
9646
9623
  }
9647
- }
9648
- var process3 = globalThis.process;
9649
- var {
9650
- onExit,
9651
- load,
9652
- unload
9653
- } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
9624
+ const lfIndex = string.indexOf(`
9625
+ `);
9626
+ if (lfIndex !== -1) {
9627
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
9628
+ }
9629
+ return openAll + string + closeAll;
9630
+ };
9631
+ Object.defineProperties(createChalk.prototype, styles2);
9632
+ var chalk = createChalk();
9633
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
9634
+ var source_default = chalk;
9635
+
9636
+ // ../../node_modules/.bun/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
9637
+ import process5 from "process";
9654
9638
 
9655
9639
  // ../../node_modules/.bun/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
9656
- var terminal = process4.stderr.isTTY ? process4.stderr : process4.stdout.isTTY ? process4.stdout : undefined;
9657
- var restoreCursor = terminal ? onetime_default(() => {
9658
- onExit(() => {
9659
- terminal.write("\x1B[?25h");
9660
- }, { alwaysLast: true });
9661
- }) : () => {};
9662
- var restore_cursor_default = restoreCursor;
9640
+ import process4 from "process";
9663
9641
 
9664
- // ../../node_modules/.bun/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
9665
- var isHidden = false;
9666
- var cliCursor = {};
9667
- cliCursor.show = (writableStream = process5.stderr) => {
9668
- if (!writableStream.isTTY) {
9642
+ // ../../node_modules/.bun/mimic-function@5.0.1/node_modules/mimic-function/index.js
9643
+ var copyProperty = (to, from, property, ignoreNonConfigurable) => {
9644
+ if (property === "length" || property === "prototype") {
9669
9645
  return;
9670
9646
  }
9671
- isHidden = false;
9672
- writableStream.write("\x1B[?25h");
9673
- };
9674
- cliCursor.hide = (writableStream = process5.stderr) => {
9675
- if (!writableStream.isTTY) {
9647
+ if (property === "arguments" || property === "caller") {
9676
9648
  return;
9677
9649
  }
9678
- restore_cursor_default();
9679
- isHidden = true;
9680
- writableStream.write("\x1B[?25l");
9681
- };
9682
- cliCursor.toggle = (force, writableStream) => {
9683
- if (force !== undefined) {
9684
- isHidden = force;
9685
- }
9686
- if (isHidden) {
9687
- cliCursor.show(writableStream);
9688
- } else {
9689
- cliCursor.hide(writableStream);
9690
- }
9691
- };
9692
- var cli_cursor_default = cliCursor;
9693
-
9694
- // ../../node_modules/.bun/ora@8.2.0/node_modules/ora/index.js
9695
- var import_cli_spinners = __toESM(require_cli_spinners(), 1);
9696
-
9697
- // ../../node_modules/.bun/is-unicode-supported@1.3.0/node_modules/is-unicode-supported/index.js
9698
- import process6 from "process";
9699
- function isUnicodeSupported() {
9700
- if (process6.platform !== "win32") {
9701
- return process6.env.TERM !== "linux";
9650
+ const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
9651
+ const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
9652
+ if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
9653
+ return;
9702
9654
  }
9703
- return Boolean(process6.env.CI) || Boolean(process6.env.WT_SESSION) || Boolean(process6.env.TERMINUS_SUBLIME) || process6.env.ConEmuTask === "{cmd::Cmder}" || process6.env.TERM_PROGRAM === "Terminus-Sublime" || process6.env.TERM_PROGRAM === "vscode" || process6.env.TERM === "xterm-256color" || process6.env.TERM === "alacritty" || process6.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
9704
- }
9705
-
9706
- // ../../node_modules/.bun/log-symbols@6.0.0/node_modules/log-symbols/index.js
9707
- var main = {
9708
- info: source_default.blue("\u2139"),
9709
- success: source_default.green("\u2714"),
9710
- warning: source_default.yellow("\u26A0"),
9711
- error: source_default.red("\u2716")
9655
+ Object.defineProperty(to, property, fromDescriptor);
9712
9656
  };
9713
- var fallback = {
9714
- info: source_default.blue("i"),
9715
- success: source_default.green("\u221A"),
9716
- warning: source_default.yellow("\u203C"),
9717
- error: source_default.red("\xD7")
9657
+ var canCopyProperty = function(toDescriptor, fromDescriptor) {
9658
+ return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
9718
9659
  };
9719
- var logSymbols = isUnicodeSupported() ? main : fallback;
9720
- var log_symbols_default = logSymbols;
9721
-
9722
- // ../../node_modules/.bun/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
9723
- function ansiRegex({ onlyFirst = false } = {}) {
9724
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
9725
- const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
9726
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
9727
- const pattern = `${osc}|${csi}`;
9728
- return new RegExp(pattern, onlyFirst ? undefined : "g");
9729
- }
9730
-
9731
- // ../../node_modules/.bun/strip-ansi@7.1.2/node_modules/strip-ansi/index.js
9732
- var regex = ansiRegex();
9733
- function stripAnsi(string) {
9734
- if (typeof string !== "string") {
9735
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
9736
- }
9737
- return string.replace(regex, "");
9738
- }
9739
-
9740
- // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js
9741
- function isAmbiguous(x) {
9742
- return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
9743
- }
9744
- function isFullWidth(x) {
9745
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
9746
- }
9747
- function isWide(x) {
9748
- return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
9749
- }
9750
-
9751
- // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js
9752
- function validate(codePoint) {
9753
- if (!Number.isSafeInteger(codePoint)) {
9754
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
9660
+ var changePrototype = (to, from) => {
9661
+ const fromPrototype = Object.getPrototypeOf(from);
9662
+ if (fromPrototype === Object.getPrototypeOf(to)) {
9663
+ return;
9755
9664
  }
9756
- }
9757
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
9758
- validate(codePoint);
9759
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
9760
- return 2;
9665
+ Object.setPrototypeOf(to, fromPrototype);
9666
+ };
9667
+ var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
9668
+ ${fromBody}`;
9669
+ var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
9670
+ var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
9671
+ var changeToString = (to, from, name) => {
9672
+ const withName = name === "" ? "" : `with ${name.trim()}() `;
9673
+ const newToString = wrappedToString.bind(null, withName, from.toString());
9674
+ Object.defineProperty(newToString, "name", toStringName);
9675
+ const { writable, enumerable, configurable } = toStringDescriptor;
9676
+ Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable });
9677
+ };
9678
+ function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
9679
+ const { name } = to;
9680
+ for (const property of Reflect.ownKeys(from)) {
9681
+ copyProperty(to, from, property, ignoreNonConfigurable);
9761
9682
  }
9762
- return 1;
9683
+ changePrototype(to, from);
9684
+ changeToString(to, from, name);
9685
+ return to;
9763
9686
  }
9764
9687
 
9765
- // ../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex/index.mjs
9766
- var emoji_regex_default = () => {
9767
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
9768
- };
9769
-
9770
- // ../../node_modules/.bun/string-width@7.2.0/node_modules/string-width/index.js
9771
- var segmenter = new Intl.Segmenter;
9772
- var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
9773
- function stringWidth(string, options2 = {}) {
9774
- if (typeof string !== "string" || string.length === 0) {
9775
- return 0;
9776
- }
9777
- const {
9778
- ambiguousIsNarrow = true,
9779
- countAnsiEscapeCodes = false
9780
- } = options2;
9781
- if (!countAnsiEscapeCodes) {
9782
- string = stripAnsi(string);
9783
- }
9784
- if (string.length === 0) {
9785
- return 0;
9688
+ // ../../node_modules/.bun/onetime@7.0.0/node_modules/onetime/index.js
9689
+ var calledFunctions = new WeakMap;
9690
+ var onetime = (function_, options2 = {}) => {
9691
+ if (typeof function_ !== "function") {
9692
+ throw new TypeError("Expected a function");
9786
9693
  }
9787
- let width = 0;
9788
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
9789
- for (const { segment: character } of segmenter.segment(string)) {
9790
- const codePoint = character.codePointAt(0);
9791
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
9792
- continue;
9793
- }
9794
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
9795
- continue;
9796
- }
9797
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
9798
- continue;
9799
- }
9800
- if (codePoint >= 55296 && codePoint <= 57343) {
9801
- continue;
9802
- }
9803
- if (codePoint >= 65024 && codePoint <= 65039) {
9804
- continue;
9805
- }
9806
- if (defaultIgnorableCodePointRegex.test(character)) {
9807
- continue;
9808
- }
9809
- if (emoji_regex_default().test(character)) {
9810
- width += 2;
9811
- continue;
9694
+ let returnValue;
9695
+ let callCount = 0;
9696
+ const functionName = function_.displayName || function_.name || "<anonymous>";
9697
+ const onetime2 = function(...arguments_) {
9698
+ calledFunctions.set(onetime2, ++callCount);
9699
+ if (callCount === 1) {
9700
+ returnValue = function_.apply(this, arguments_);
9701
+ function_ = undefined;
9702
+ } else if (options2.throw === true) {
9703
+ throw new Error(`Function \`${functionName}\` can only be called once`);
9812
9704
  }
9813
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
9705
+ return returnValue;
9706
+ };
9707
+ mimicFunction(onetime2, function_);
9708
+ calledFunctions.set(onetime2, callCount);
9709
+ return onetime2;
9710
+ };
9711
+ onetime.callCount = (function_) => {
9712
+ if (!calledFunctions.has(function_)) {
9713
+ throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
9814
9714
  }
9815
- return width;
9816
- }
9715
+ return calledFunctions.get(function_);
9716
+ };
9717
+ var onetime_default = onetime;
9817
9718
 
9818
- // ../../node_modules/.bun/is-interactive@2.0.0/node_modules/is-interactive/index.js
9819
- function isInteractive({ stream = process.stdout } = {}) {
9820
- return Boolean(stream && stream.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env));
9719
+ // ../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
9720
+ var signals = [];
9721
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
9722
+ if (process.platform !== "win32") {
9723
+ signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
9821
9724
  }
9822
-
9823
- // ../../node_modules/.bun/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
9824
- import process7 from "process";
9825
- function isUnicodeSupported2() {
9826
- const { env: env2 } = process7;
9827
- const { TERM: TERM2, TERM_PROGRAM } = env2;
9828
- if (process7.platform !== "win32") {
9829
- return TERM2 !== "linux";
9830
- }
9831
- return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM2 === "xterm-256color" || TERM2 === "alacritty" || TERM2 === "rxvt-unicode" || TERM2 === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
9725
+ if (process.platform === "linux") {
9726
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
9832
9727
  }
9833
9728
 
9834
- // ../../node_modules/.bun/stdin-discarder@0.2.2/node_modules/stdin-discarder/index.js
9835
- import process8 from "process";
9836
- var ASCII_ETX_CODE = 3;
9729
+ // ../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
9730
+ var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
9731
+ var kExitEmitter = Symbol.for("signal-exit emitter");
9732
+ var global = globalThis;
9733
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
9837
9734
 
9838
- class StdinDiscarder {
9839
- #activeCount = 0;
9840
- start() {
9841
- this.#activeCount++;
9842
- if (this.#activeCount === 1) {
9843
- this.#realStart();
9735
+ class Emitter {
9736
+ emitted = {
9737
+ afterExit: false,
9738
+ exit: false
9739
+ };
9740
+ listeners = {
9741
+ afterExit: [],
9742
+ exit: []
9743
+ };
9744
+ count = 0;
9745
+ id = Math.random();
9746
+ constructor() {
9747
+ if (global[kExitEmitter]) {
9748
+ return global[kExitEmitter];
9844
9749
  }
9750
+ ObjectDefineProperty(global, kExitEmitter, {
9751
+ value: this,
9752
+ writable: false,
9753
+ enumerable: false,
9754
+ configurable: false
9755
+ });
9845
9756
  }
9846
- stop() {
9847
- if (this.#activeCount <= 0) {
9848
- throw new Error("`stop` called more times than `start`");
9849
- }
9850
- this.#activeCount--;
9851
- if (this.#activeCount === 0) {
9852
- this.#realStop();
9853
- }
9757
+ on(ev, fn) {
9758
+ this.listeners[ev].push(fn);
9854
9759
  }
9855
- #realStart() {
9856
- if (process8.platform === "win32" || !process8.stdin.isTTY) {
9760
+ removeListener(ev, fn) {
9761
+ const list = this.listeners[ev];
9762
+ const i = list.indexOf(fn);
9763
+ if (i === -1) {
9857
9764
  return;
9858
9765
  }
9859
- process8.stdin.setRawMode(true);
9860
- process8.stdin.on("data", this.#handleInput);
9861
- process8.stdin.resume();
9862
- }
9863
- #realStop() {
9864
- if (!process8.stdin.isTTY) {
9865
- return;
9766
+ if (i === 0 && list.length === 1) {
9767
+ list.length = 0;
9768
+ } else {
9769
+ list.splice(i, 1);
9866
9770
  }
9867
- process8.stdin.off("data", this.#handleInput);
9868
- process8.stdin.pause();
9869
- process8.stdin.setRawMode(false);
9870
9771
  }
9871
- #handleInput(chunk) {
9872
- if (chunk[0] === ASCII_ETX_CODE) {
9873
- process8.emit("SIGINT");
9772
+ emit(ev, code, signal) {
9773
+ if (this.emitted[ev]) {
9774
+ return false;
9775
+ }
9776
+ this.emitted[ev] = true;
9777
+ let ret = false;
9778
+ for (const fn of this.listeners[ev]) {
9779
+ ret = fn(code, signal) === true || ret;
9780
+ }
9781
+ if (ev === "exit") {
9782
+ ret = this.emit("afterExit", code, signal) || ret;
9874
9783
  }
9784
+ return ret;
9875
9785
  }
9876
9786
  }
9877
- var stdinDiscarder = new StdinDiscarder;
9878
- var stdin_discarder_default = stdinDiscarder;
9879
-
9880
- // ../../node_modules/.bun/ora@8.2.0/node_modules/ora/index.js
9881
- var import_cli_spinners2 = __toESM(require_cli_spinners(), 1);
9882
9787
 
9883
- class Ora {
9884
- #linesToClear = 0;
9885
- #isDiscardingStdin = false;
9886
- #lineCount = 0;
9887
- #frameIndex = -1;
9888
- #lastSpinnerFrameTime = 0;
9889
- #options;
9890
- #spinner;
9891
- #stream;
9892
- #id;
9893
- #initialInterval;
9894
- #isEnabled;
9895
- #isSilent;
9896
- #indent;
9897
- #text;
9898
- #prefixText;
9899
- #suffixText;
9900
- color;
9901
- constructor(options2) {
9902
- if (typeof options2 === "string") {
9903
- options2 = {
9904
- text: options2
9905
- };
9906
- }
9907
- this.#options = {
9908
- color: "cyan",
9909
- stream: process9.stderr,
9910
- discardStdin: true,
9911
- hideCursor: true,
9912
- ...options2
9913
- };
9914
- this.color = this.#options.color;
9915
- this.spinner = this.#options.spinner;
9916
- this.#initialInterval = this.#options.interval;
9917
- this.#stream = this.#options.stream;
9918
- this.#isEnabled = typeof this.#options.isEnabled === "boolean" ? this.#options.isEnabled : isInteractive({ stream: this.#stream });
9919
- this.#isSilent = typeof this.#options.isSilent === "boolean" ? this.#options.isSilent : false;
9920
- this.text = this.#options.text;
9921
- this.prefixText = this.#options.prefixText;
9922
- this.suffixText = this.#options.suffixText;
9923
- this.indent = this.#options.indent;
9924
- if (process9.env.NODE_ENV === "test") {
9925
- this._stream = this.#stream;
9926
- this._isEnabled = this.#isEnabled;
9927
- Object.defineProperty(this, "_linesToClear", {
9928
- get() {
9929
- return this.#linesToClear;
9930
- },
9931
- set(newValue) {
9932
- this.#linesToClear = newValue;
9933
- }
9934
- });
9935
- Object.defineProperty(this, "_frameIndex", {
9936
- get() {
9937
- return this.#frameIndex;
9788
+ class SignalExitBase {
9789
+ }
9790
+ var signalExitWrap = (handler) => {
9791
+ return {
9792
+ onExit(cb, opts) {
9793
+ return handler.onExit(cb, opts);
9794
+ },
9795
+ load() {
9796
+ return handler.load();
9797
+ },
9798
+ unload() {
9799
+ return handler.unload();
9800
+ }
9801
+ };
9802
+ };
9803
+
9804
+ class SignalExitFallback extends SignalExitBase {
9805
+ onExit() {
9806
+ return () => {};
9807
+ }
9808
+ load() {}
9809
+ unload() {}
9810
+ }
9811
+
9812
+ class SignalExit extends SignalExitBase {
9813
+ #hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
9814
+ #emitter = new Emitter;
9815
+ #process;
9816
+ #originalProcessEmit;
9817
+ #originalProcessReallyExit;
9818
+ #sigListeners = {};
9819
+ #loaded = false;
9820
+ constructor(process3) {
9821
+ super();
9822
+ this.#process = process3;
9823
+ this.#sigListeners = {};
9824
+ for (const sig of signals) {
9825
+ this.#sigListeners[sig] = () => {
9826
+ const listeners = this.#process.listeners(sig);
9827
+ let { count } = this.#emitter;
9828
+ const p = process3;
9829
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
9830
+ count += p.__signal_exit_emitter__.count;
9938
9831
  }
9939
- });
9940
- Object.defineProperty(this, "_lineCount", {
9941
- get() {
9942
- return this.#lineCount;
9832
+ if (listeners.length === count) {
9833
+ this.unload();
9834
+ const ret = this.#emitter.emit("exit", null, sig);
9835
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
9836
+ if (!ret)
9837
+ process3.kill(process3.pid, s);
9943
9838
  }
9944
- });
9839
+ };
9945
9840
  }
9841
+ this.#originalProcessReallyExit = process3.reallyExit;
9842
+ this.#originalProcessEmit = process3.emit;
9946
9843
  }
9947
- get indent() {
9948
- return this.#indent;
9844
+ onExit(cb, opts) {
9845
+ if (!processOk(this.#process)) {
9846
+ return () => {};
9847
+ }
9848
+ if (this.#loaded === false) {
9849
+ this.load();
9850
+ }
9851
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
9852
+ this.#emitter.on(ev, cb);
9853
+ return () => {
9854
+ this.#emitter.removeListener(ev, cb);
9855
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
9856
+ this.unload();
9857
+ }
9858
+ };
9949
9859
  }
9950
- set indent(indent = 0) {
9951
- if (!(indent >= 0 && Number.isInteger(indent))) {
9952
- throw new Error("The `indent` option must be an integer from 0 and up");
9860
+ load() {
9861
+ if (this.#loaded) {
9862
+ return;
9953
9863
  }
9954
- this.#indent = indent;
9955
- this.#updateLineCount();
9864
+ this.#loaded = true;
9865
+ this.#emitter.count += 1;
9866
+ for (const sig of signals) {
9867
+ try {
9868
+ const fn = this.#sigListeners[sig];
9869
+ if (fn)
9870
+ this.#process.on(sig, fn);
9871
+ } catch (_) {}
9872
+ }
9873
+ this.#process.emit = (ev, ...a) => {
9874
+ return this.#processEmit(ev, ...a);
9875
+ };
9876
+ this.#process.reallyExit = (code) => {
9877
+ return this.#processReallyExit(code);
9878
+ };
9956
9879
  }
9957
- get interval() {
9958
- return this.#initialInterval ?? this.#spinner.interval ?? 100;
9880
+ unload() {
9881
+ if (!this.#loaded) {
9882
+ return;
9883
+ }
9884
+ this.#loaded = false;
9885
+ signals.forEach((sig) => {
9886
+ const listener = this.#sigListeners[sig];
9887
+ if (!listener) {
9888
+ throw new Error("Listener not defined for signal: " + sig);
9889
+ }
9890
+ try {
9891
+ this.#process.removeListener(sig, listener);
9892
+ } catch (_) {}
9893
+ });
9894
+ this.#process.emit = this.#originalProcessEmit;
9895
+ this.#process.reallyExit = this.#originalProcessReallyExit;
9896
+ this.#emitter.count -= 1;
9959
9897
  }
9960
- get spinner() {
9961
- return this.#spinner;
9898
+ #processReallyExit(code) {
9899
+ if (!processOk(this.#process)) {
9900
+ return 0;
9901
+ }
9902
+ this.#process.exitCode = code || 0;
9903
+ this.#emitter.emit("exit", this.#process.exitCode, null);
9904
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
9962
9905
  }
9963
- set spinner(spinner) {
9964
- this.#frameIndex = -1;
9965
- this.#initialInterval = undefined;
9966
- if (typeof spinner === "object") {
9967
- if (spinner.frames === undefined) {
9968
- throw new Error("The given spinner must have a `frames` property");
9906
+ #processEmit(ev, ...args) {
9907
+ const og = this.#originalProcessEmit;
9908
+ if (ev === "exit" && processOk(this.#process)) {
9909
+ if (typeof args[0] === "number") {
9910
+ this.#process.exitCode = args[0];
9969
9911
  }
9970
- this.#spinner = spinner;
9971
- } else if (!isUnicodeSupported2()) {
9972
- this.#spinner = import_cli_spinners.default.line;
9973
- } else if (spinner === undefined) {
9974
- this.#spinner = import_cli_spinners.default.dots;
9975
- } else if (spinner !== "default" && import_cli_spinners.default[spinner]) {
9976
- this.#spinner = import_cli_spinners.default[spinner];
9912
+ const ret = og.call(this.#process, ev, ...args);
9913
+ this.#emitter.emit("exit", this.#process.exitCode, null);
9914
+ return ret;
9977
9915
  } else {
9978
- throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);
9916
+ return og.call(this.#process, ev, ...args);
9979
9917
  }
9980
9918
  }
9981
- get text() {
9982
- return this.#text;
9983
- }
9984
- set text(value = "") {
9985
- this.#text = value;
9986
- this.#updateLineCount();
9987
- }
9988
- get prefixText() {
9989
- return this.#prefixText;
9990
- }
9991
- set prefixText(value = "") {
9992
- this.#prefixText = value;
9993
- this.#updateLineCount();
9994
- }
9995
- get suffixText() {
9996
- return this.#suffixText;
9997
- }
9998
- set suffixText(value = "") {
9999
- this.#suffixText = value;
10000
- this.#updateLineCount();
10001
- }
10002
- get isSpinning() {
10003
- return this.#id !== undefined;
9919
+ }
9920
+ var process3 = globalThis.process;
9921
+ var {
9922
+ onExit,
9923
+ load,
9924
+ unload
9925
+ } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
9926
+
9927
+ // ../../node_modules/.bun/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
9928
+ var terminal = process4.stderr.isTTY ? process4.stderr : process4.stdout.isTTY ? process4.stdout : undefined;
9929
+ var restoreCursor = terminal ? onetime_default(() => {
9930
+ onExit(() => {
9931
+ terminal.write("\x1B[?25h");
9932
+ }, { alwaysLast: true });
9933
+ }) : () => {};
9934
+ var restore_cursor_default = restoreCursor;
9935
+
9936
+ // ../../node_modules/.bun/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
9937
+ var isHidden = false;
9938
+ var cliCursor = {};
9939
+ cliCursor.show = (writableStream = process5.stderr) => {
9940
+ if (!writableStream.isTTY) {
9941
+ return;
10004
9942
  }
10005
- #getFullPrefixText(prefixText = this.#prefixText, postfix = " ") {
10006
- if (typeof prefixText === "string" && prefixText !== "") {
10007
- return prefixText + postfix;
10008
- }
10009
- if (typeof prefixText === "function") {
10010
- return prefixText() + postfix;
10011
- }
10012
- return "";
9943
+ isHidden = false;
9944
+ writableStream.write("\x1B[?25h");
9945
+ };
9946
+ cliCursor.hide = (writableStream = process5.stderr) => {
9947
+ if (!writableStream.isTTY) {
9948
+ return;
10013
9949
  }
10014
- #getFullSuffixText(suffixText = this.#suffixText, prefix = " ") {
10015
- if (typeof suffixText === "string" && suffixText !== "") {
10016
- return prefix + suffixText;
10017
- }
10018
- if (typeof suffixText === "function") {
10019
- return prefix + suffixText();
10020
- }
10021
- return "";
9950
+ restore_cursor_default();
9951
+ isHidden = true;
9952
+ writableStream.write("\x1B[?25l");
9953
+ };
9954
+ cliCursor.toggle = (force, writableStream) => {
9955
+ if (force !== undefined) {
9956
+ isHidden = force;
10022
9957
  }
10023
- #updateLineCount() {
10024
- const columns = this.#stream.columns ?? 80;
10025
- const fullPrefixText = this.#getFullPrefixText(this.#prefixText, "-");
10026
- const fullSuffixText = this.#getFullSuffixText(this.#suffixText, "-");
10027
- const fullText = " ".repeat(this.#indent) + fullPrefixText + "--" + this.#text + "--" + fullSuffixText;
10028
- this.#lineCount = 0;
10029
- for (const line of stripAnsi(fullText).split(`
10030
- `)) {
10031
- this.#lineCount += Math.max(1, Math.ceil(stringWidth(line, { countAnsiEscapeCodes: true }) / columns));
10032
- }
9958
+ if (isHidden) {
9959
+ cliCursor.show(writableStream);
9960
+ } else {
9961
+ cliCursor.hide(writableStream);
10033
9962
  }
10034
- get isEnabled() {
10035
- return this.#isEnabled && !this.#isSilent;
9963
+ };
9964
+ var cli_cursor_default = cliCursor;
9965
+
9966
+ // ../../node_modules/.bun/ora@8.2.0/node_modules/ora/index.js
9967
+ var import_cli_spinners = __toESM(require_cli_spinners(), 1);
9968
+
9969
+ // ../../node_modules/.bun/is-unicode-supported@1.3.0/node_modules/is-unicode-supported/index.js
9970
+ import process6 from "process";
9971
+ function isUnicodeSupported() {
9972
+ if (process6.platform !== "win32") {
9973
+ return process6.env.TERM !== "linux";
10036
9974
  }
10037
- set isEnabled(value) {
10038
- if (typeof value !== "boolean") {
10039
- throw new TypeError("The `isEnabled` option must be a boolean");
10040
- }
10041
- this.#isEnabled = value;
9975
+ return Boolean(process6.env.CI) || Boolean(process6.env.WT_SESSION) || Boolean(process6.env.TERMINUS_SUBLIME) || process6.env.ConEmuTask === "{cmd::Cmder}" || process6.env.TERM_PROGRAM === "Terminus-Sublime" || process6.env.TERM_PROGRAM === "vscode" || process6.env.TERM === "xterm-256color" || process6.env.TERM === "alacritty" || process6.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
9976
+ }
9977
+
9978
+ // ../../node_modules/.bun/log-symbols@6.0.0/node_modules/log-symbols/index.js
9979
+ var main = {
9980
+ info: source_default.blue("\u2139"),
9981
+ success: source_default.green("\u2714"),
9982
+ warning: source_default.yellow("\u26A0"),
9983
+ error: source_default.red("\u2716")
9984
+ };
9985
+ var fallback = {
9986
+ info: source_default.blue("i"),
9987
+ success: source_default.green("\u221A"),
9988
+ warning: source_default.yellow("\u203C"),
9989
+ error: source_default.red("\xD7")
9990
+ };
9991
+ var logSymbols = isUnicodeSupported() ? main : fallback;
9992
+ var log_symbols_default = logSymbols;
9993
+
9994
+ // ../../node_modules/.bun/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
9995
+ function ansiRegex({ onlyFirst = false } = {}) {
9996
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
9997
+ const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
9998
+ const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
9999
+ const pattern = `${osc}|${csi}`;
10000
+ return new RegExp(pattern, onlyFirst ? undefined : "g");
10001
+ }
10002
+
10003
+ // ../../node_modules/.bun/strip-ansi@7.1.2/node_modules/strip-ansi/index.js
10004
+ var regex = ansiRegex();
10005
+ function stripAnsi(string) {
10006
+ if (typeof string !== "string") {
10007
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
10042
10008
  }
10043
- get isSilent() {
10044
- return this.#isSilent;
10009
+ return string.replace(regex, "");
10010
+ }
10011
+
10012
+ // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js
10013
+ function isAmbiguous(x) {
10014
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
10015
+ }
10016
+ function isFullWidth(x) {
10017
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
10018
+ }
10019
+ function isWide(x) {
10020
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
10021
+ }
10022
+
10023
+ // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js
10024
+ function validate(codePoint) {
10025
+ if (!Number.isSafeInteger(codePoint)) {
10026
+ throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
10045
10027
  }
10046
- set isSilent(value) {
10047
- if (typeof value !== "boolean") {
10048
- throw new TypeError("The `isSilent` option must be a boolean");
10049
- }
10050
- this.#isSilent = value;
10028
+ }
10029
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
10030
+ validate(codePoint);
10031
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
10032
+ return 2;
10051
10033
  }
10052
- frame() {
10053
- const now = Date.now();
10054
- if (this.#frameIndex === -1 || now - this.#lastSpinnerFrameTime >= this.interval) {
10055
- this.#frameIndex = ++this.#frameIndex % this.#spinner.frames.length;
10056
- this.#lastSpinnerFrameTime = now;
10057
- }
10058
- const { frames } = this.#spinner;
10059
- let frame = frames[this.#frameIndex];
10060
- if (this.color) {
10061
- frame = source_default[this.color](frame);
10062
- }
10063
- const fullPrefixText = typeof this.#prefixText === "string" && this.#prefixText !== "" ? this.#prefixText + " " : "";
10064
- const fullText = typeof this.text === "string" ? " " + this.text : "";
10065
- const fullSuffixText = typeof this.#suffixText === "string" && this.#suffixText !== "" ? " " + this.#suffixText : "";
10066
- return fullPrefixText + frame + fullText + fullSuffixText;
10034
+ return 1;
10035
+ }
10036
+
10037
+ // ../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex/index.mjs
10038
+ var emoji_regex_default = () => {
10039
+ return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
10040
+ };
10041
+
10042
+ // ../../node_modules/.bun/string-width@7.2.0/node_modules/string-width/index.js
10043
+ var segmenter = new Intl.Segmenter;
10044
+ var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
10045
+ function stringWidth(string, options2 = {}) {
10046
+ if (typeof string !== "string" || string.length === 0) {
10047
+ return 0;
10067
10048
  }
10068
- clear() {
10069
- if (!this.#isEnabled || !this.#stream.isTTY) {
10070
- return this;
10071
- }
10072
- this.#stream.cursorTo(0);
10073
- for (let index = 0;index < this.#linesToClear; index++) {
10074
- if (index > 0) {
10075
- this.#stream.moveCursor(0, -1);
10076
- }
10077
- this.#stream.clearLine(1);
10078
- }
10079
- if (this.#indent || this.lastIndent !== this.#indent) {
10080
- this.#stream.cursorTo(this.#indent);
10081
- }
10082
- this.lastIndent = this.#indent;
10083
- this.#linesToClear = 0;
10084
- return this;
10049
+ const {
10050
+ ambiguousIsNarrow = true,
10051
+ countAnsiEscapeCodes = false
10052
+ } = options2;
10053
+ if (!countAnsiEscapeCodes) {
10054
+ string = stripAnsi(string);
10085
10055
  }
10086
- render() {
10087
- if (this.#isSilent) {
10088
- return this;
10089
- }
10090
- this.clear();
10091
- this.#stream.write(this.frame());
10092
- this.#linesToClear = this.#lineCount;
10093
- return this;
10056
+ if (string.length === 0) {
10057
+ return 0;
10094
10058
  }
10095
- start(text) {
10096
- if (text) {
10097
- this.text = text;
10098
- }
10099
- if (this.#isSilent) {
10100
- return this;
10101
- }
10102
- if (!this.#isEnabled) {
10103
- if (this.text) {
10104
- this.#stream.write(`- ${this.text}
10105
- `);
10106
- }
10107
- return this;
10108
- }
10109
- if (this.isSpinning) {
10110
- return this;
10059
+ let width = 0;
10060
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
10061
+ for (const { segment: character } of segmenter.segment(string)) {
10062
+ const codePoint = character.codePointAt(0);
10063
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
10064
+ continue;
10111
10065
  }
10112
- if (this.#options.hideCursor) {
10113
- cli_cursor_default.hide(this.#stream);
10066
+ if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
10067
+ continue;
10114
10068
  }
10115
- if (this.#options.discardStdin && process9.stdin.isTTY) {
10116
- this.#isDiscardingStdin = true;
10117
- stdin_discarder_default.start();
10069
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
10070
+ continue;
10118
10071
  }
10119
- this.render();
10120
- this.#id = setInterval(this.render.bind(this), this.interval);
10121
- return this;
10122
- }
10123
- stop() {
10124
- if (!this.#isEnabled) {
10125
- return this;
10072
+ if (codePoint >= 55296 && codePoint <= 57343) {
10073
+ continue;
10126
10074
  }
10127
- clearInterval(this.#id);
10128
- this.#id = undefined;
10129
- this.#frameIndex = 0;
10130
- this.clear();
10131
- if (this.#options.hideCursor) {
10132
- cli_cursor_default.show(this.#stream);
10075
+ if (codePoint >= 65024 && codePoint <= 65039) {
10076
+ continue;
10133
10077
  }
10134
- if (this.#options.discardStdin && process9.stdin.isTTY && this.#isDiscardingStdin) {
10135
- stdin_discarder_default.stop();
10136
- this.#isDiscardingStdin = false;
10078
+ if (defaultIgnorableCodePointRegex.test(character)) {
10079
+ continue;
10137
10080
  }
10138
- return this;
10139
- }
10140
- succeed(text) {
10141
- return this.stopAndPersist({ symbol: log_symbols_default.success, text });
10142
- }
10143
- fail(text) {
10144
- return this.stopAndPersist({ symbol: log_symbols_default.error, text });
10145
- }
10146
- warn(text) {
10147
- return this.stopAndPersist({ symbol: log_symbols_default.warning, text });
10148
- }
10149
- info(text) {
10150
- return this.stopAndPersist({ symbol: log_symbols_default.info, text });
10151
- }
10152
- stopAndPersist(options2 = {}) {
10153
- if (this.#isSilent) {
10154
- return this;
10081
+ if (emoji_regex_default().test(character)) {
10082
+ width += 2;
10083
+ continue;
10155
10084
  }
10156
- const prefixText = options2.prefixText ?? this.#prefixText;
10157
- const fullPrefixText = this.#getFullPrefixText(prefixText, " ");
10158
- const symbolText = options2.symbol ?? " ";
10159
- const text = options2.text ?? this.text;
10160
- const separatorText = symbolText ? " " : "";
10161
- const fullText = typeof text === "string" ? separatorText + text : "";
10162
- const suffixText = options2.suffixText ?? this.#suffixText;
10163
- const fullSuffixText = this.#getFullSuffixText(suffixText, " ");
10164
- const textToWrite = fullPrefixText + symbolText + fullText + fullSuffixText + `
10165
- `;
10166
- this.stop();
10167
- this.#stream.write(textToWrite);
10168
- return this;
10085
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
10169
10086
  }
10170
- }
10171
- function ora(options2) {
10172
- return new Ora(options2);
10087
+ return width;
10173
10088
  }
10174
10089
 
10175
- // src/utils/spinner.ts
10176
- function createSpinner(options2) {
10177
- const shouldSpin = isTTY && !options2.quiet;
10178
- const spinner = ora({
10179
- text: options2.text,
10180
- isSilent: !shouldSpin
10181
- });
10182
- return spinner;
10090
+ // ../../node_modules/.bun/is-interactive@2.0.0/node_modules/is-interactive/index.js
10091
+ function isInteractive({ stream = process.stdout } = {}) {
10092
+ return Boolean(stream && stream.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env));
10183
10093
  }
10184
- // src/utils/handle-error.ts
10185
- function handleError(error, options2 = {}) {
10186
- if (options2.json) {
10187
- const output = formatErrorAsJson(error);
10188
- console.log(JSON.stringify(output, null, 2));
10189
- process.exit(output.exitCode);
10190
- }
10191
- if (error instanceof OCXError) {
10192
- logger.error(error.message);
10193
- process.exit(error.exitCode);
10194
- }
10195
- if (error instanceof ZodError) {
10196
- logger.error("Validation failed:");
10197
- for (const issue of error.issues) {
10198
- const path = issue.path.join(".");
10199
- logger.error(` ${path}: ${issue.message}`);
10200
- }
10201
- process.exit(EXIT_CODES.CONFIG);
10202
- }
10203
- if (error instanceof Error) {
10204
- logger.error(error.message);
10205
- if (process.env.DEBUG) {
10206
- console.error(error.stack);
10207
- }
10208
- } else {
10209
- logger.error("An unknown error occurred");
10094
+
10095
+ // ../../node_modules/.bun/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
10096
+ import process7 from "process";
10097
+ function isUnicodeSupported2() {
10098
+ const { env: env2 } = process7;
10099
+ const { TERM: TERM2, TERM_PROGRAM } = env2;
10100
+ if (process7.platform !== "win32") {
10101
+ return TERM2 !== "linux";
10210
10102
  }
10211
- process.exit(EXIT_CODES.GENERAL);
10103
+ return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM2 === "xterm-256color" || TERM2 === "alacritty" || TERM2 === "rxvt-unicode" || TERM2 === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
10212
10104
  }
10213
- function formatErrorAsJson(error) {
10214
- if (error instanceof OCXError) {
10215
- return {
10216
- success: false,
10217
- error: {
10218
- code: error.code,
10219
- message: error.message
10220
- },
10221
- exitCode: error.exitCode,
10222
- meta: {
10223
- timestamp: new Date().toISOString()
10224
- }
10225
- };
10226
- }
10227
- if (error instanceof ZodError) {
10228
- return {
10229
- success: false,
10230
- error: {
10231
- code: "VALIDATION_ERROR",
10232
- message: error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")
10233
- },
10234
- exitCode: EXIT_CODES.CONFIG,
10235
- meta: {
10236
- timestamp: new Date().toISOString()
10237
- }
10238
- };
10105
+
10106
+ // ../../node_modules/.bun/stdin-discarder@0.2.2/node_modules/stdin-discarder/index.js
10107
+ import process8 from "process";
10108
+ var ASCII_ETX_CODE = 3;
10109
+
10110
+ class StdinDiscarder {
10111
+ #activeCount = 0;
10112
+ start() {
10113
+ this.#activeCount++;
10114
+ if (this.#activeCount === 1) {
10115
+ this.#realStart();
10116
+ }
10239
10117
  }
10240
- return {
10241
- success: false,
10242
- error: {
10243
- code: "UNKNOWN_ERROR",
10244
- message: error instanceof Error ? error.message : "An unknown error occurred"
10245
- },
10246
- exitCode: EXIT_CODES.GENERAL,
10247
- meta: {
10248
- timestamp: new Date().toISOString()
10118
+ stop() {
10119
+ if (this.#activeCount <= 0) {
10120
+ throw new Error("`stop` called more times than `start`");
10249
10121
  }
10250
- };
10251
- }
10252
- // src/utils/json-output.ts
10253
- function outputJson(data) {
10254
- console.log(JSON.stringify(data, null, 2));
10255
- }
10256
- // src/commands/init.ts
10257
- function registerInitCommand(program2) {
10258
- program2.command("init").description("Initialize OCX configuration in your project").option("-y, --yes", "Skip prompts and use defaults").option("--cwd <path>", "Working directory", process.cwd()).option("-q, --quiet", "Suppress output").option("-v, --verbose", "Verbose output").option("--json", "Output as JSON").action(async (options2) => {
10259
- try {
10260
- await runInit(options2);
10261
- } catch (error) {
10262
- handleError(error, { json: options2.json });
10122
+ this.#activeCount--;
10123
+ if (this.#activeCount === 0) {
10124
+ this.#realStop();
10263
10125
  }
10264
- });
10265
- }
10266
- async function runInit(options2) {
10267
- const cwd = options2.cwd ?? process.cwd();
10268
- const configPath = join(cwd, "ocx.jsonc");
10269
- if (existsSync(configPath)) {
10270
- if (!options2.yes) {
10271
- logger.warn("ocx.jsonc already exists");
10272
- logger.info("Use --yes to overwrite");
10126
+ }
10127
+ #realStart() {
10128
+ if (process8.platform === "win32" || !process8.stdin.isTTY) {
10273
10129
  return;
10274
10130
  }
10275
- logger.info("Overwriting existing ocx.jsonc");
10131
+ process8.stdin.setRawMode(true);
10132
+ process8.stdin.on("data", this.#handleInput);
10133
+ process8.stdin.resume();
10276
10134
  }
10277
- const spin = options2.quiet ? null : createSpinner({ text: "Initializing OCX..." });
10278
- spin?.start();
10279
- try {
10280
- const rawConfig = {
10281
- $schema: OCX_SCHEMA_URL,
10282
- registries: {}
10283
- };
10284
- const config = ocxConfigSchema.parse(rawConfig);
10285
- const content = JSON.stringify(config, null, 2);
10286
- await writeFile(configPath, content, "utf-8");
10287
- if (!options2.quiet && !options2.json) {
10288
- logger.success("Initialized OCX configuration");
10135
+ #realStop() {
10136
+ if (!process8.stdin.isTTY) {
10137
+ return;
10289
10138
  }
10290
- spin?.succeed("Initialized OCX configuration");
10291
- if (options2.json) {
10292
- console.log(JSON.stringify({ success: true, path: configPath }));
10293
- } else if (!options2.quiet) {
10294
- logger.info(`Created ${configPath}`);
10295
- logger.info("");
10296
- logger.info("Next steps:");
10297
- logger.info(" 1. Add a registry: ocx registry add <url>");
10298
- logger.info(" 2. Install components: ocx add <component>");
10139
+ process8.stdin.off("data", this.#handleInput);
10140
+ process8.stdin.pause();
10141
+ process8.stdin.setRawMode(false);
10142
+ }
10143
+ #handleInput(chunk) {
10144
+ if (chunk[0] === ASCII_ETX_CODE) {
10145
+ process8.emit("SIGINT");
10299
10146
  }
10300
- } catch (error) {
10301
- spin?.fail("Failed to initialize");
10302
- throw error;
10303
10147
  }
10304
10148
  }
10149
+ var stdinDiscarder = new StdinDiscarder;
10150
+ var stdin_discarder_default = stdinDiscarder;
10305
10151
 
10306
- // src/commands/add.ts
10307
- import { existsSync as existsSync2 } from "fs";
10308
- import { mkdir, readFile, writeFile as writeFile2 } from "fs/promises";
10309
- import { dirname, join as join2 } from "path";
10310
- import { createHash } from "crypto";
10152
+ // ../../node_modules/.bun/ora@8.2.0/node_modules/ora/index.js
10153
+ var import_cli_spinners2 = __toESM(require_cli_spinners(), 1);
10311
10154
 
10312
- // src/registry/fetcher.ts
10313
- var cache = new Map;
10314
- async function fetchWithCache(url, parse) {
10315
- const cached = cache.get(url);
10316
- if (cached) {
10317
- return cached;
10155
+ class Ora {
10156
+ #linesToClear = 0;
10157
+ #isDiscardingStdin = false;
10158
+ #lineCount = 0;
10159
+ #frameIndex = -1;
10160
+ #lastSpinnerFrameTime = 0;
10161
+ #options;
10162
+ #spinner;
10163
+ #stream;
10164
+ #id;
10165
+ #initialInterval;
10166
+ #isEnabled;
10167
+ #isSilent;
10168
+ #indent;
10169
+ #text;
10170
+ #prefixText;
10171
+ #suffixText;
10172
+ color;
10173
+ constructor(options2) {
10174
+ if (typeof options2 === "string") {
10175
+ options2 = {
10176
+ text: options2
10177
+ };
10178
+ }
10179
+ this.#options = {
10180
+ color: "cyan",
10181
+ stream: process9.stderr,
10182
+ discardStdin: true,
10183
+ hideCursor: true,
10184
+ ...options2
10185
+ };
10186
+ this.color = this.#options.color;
10187
+ this.spinner = this.#options.spinner;
10188
+ this.#initialInterval = this.#options.interval;
10189
+ this.#stream = this.#options.stream;
10190
+ this.#isEnabled = typeof this.#options.isEnabled === "boolean" ? this.#options.isEnabled : isInteractive({ stream: this.#stream });
10191
+ this.#isSilent = typeof this.#options.isSilent === "boolean" ? this.#options.isSilent : false;
10192
+ this.text = this.#options.text;
10193
+ this.prefixText = this.#options.prefixText;
10194
+ this.suffixText = this.#options.suffixText;
10195
+ this.indent = this.#options.indent;
10196
+ if (process9.env.NODE_ENV === "test") {
10197
+ this._stream = this.#stream;
10198
+ this._isEnabled = this.#isEnabled;
10199
+ Object.defineProperty(this, "_linesToClear", {
10200
+ get() {
10201
+ return this.#linesToClear;
10202
+ },
10203
+ set(newValue) {
10204
+ this.#linesToClear = newValue;
10205
+ }
10206
+ });
10207
+ Object.defineProperty(this, "_frameIndex", {
10208
+ get() {
10209
+ return this.#frameIndex;
10210
+ }
10211
+ });
10212
+ Object.defineProperty(this, "_lineCount", {
10213
+ get() {
10214
+ return this.#lineCount;
10215
+ }
10216
+ });
10217
+ }
10318
10218
  }
10319
- const promise = (async () => {
10320
- const response = await fetch(url);
10321
- if (!response.ok) {
10322
- if (response.status === 404) {
10323
- throw new NotFoundError(`Not found: ${url}`);
10219
+ get indent() {
10220
+ return this.#indent;
10221
+ }
10222
+ set indent(indent = 0) {
10223
+ if (!(indent >= 0 && Number.isInteger(indent))) {
10224
+ throw new Error("The `indent` option must be an integer from 0 and up");
10225
+ }
10226
+ this.#indent = indent;
10227
+ this.#updateLineCount();
10228
+ }
10229
+ get interval() {
10230
+ return this.#initialInterval ?? this.#spinner.interval ?? 100;
10231
+ }
10232
+ get spinner() {
10233
+ return this.#spinner;
10234
+ }
10235
+ set spinner(spinner) {
10236
+ this.#frameIndex = -1;
10237
+ this.#initialInterval = undefined;
10238
+ if (typeof spinner === "object") {
10239
+ if (spinner.frames === undefined) {
10240
+ throw new Error("The given spinner must have a `frames` property");
10324
10241
  }
10325
- throw new NetworkError(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
10242
+ this.#spinner = spinner;
10243
+ } else if (!isUnicodeSupported2()) {
10244
+ this.#spinner = import_cli_spinners.default.line;
10245
+ } else if (spinner === undefined) {
10246
+ this.#spinner = import_cli_spinners.default.dots;
10247
+ } else if (spinner !== "default" && import_cli_spinners.default[spinner]) {
10248
+ this.#spinner = import_cli_spinners.default[spinner];
10249
+ } else {
10250
+ throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);
10251
+ }
10252
+ }
10253
+ get text() {
10254
+ return this.#text;
10255
+ }
10256
+ set text(value = "") {
10257
+ this.#text = value;
10258
+ this.#updateLineCount();
10259
+ }
10260
+ get prefixText() {
10261
+ return this.#prefixText;
10262
+ }
10263
+ set prefixText(value = "") {
10264
+ this.#prefixText = value;
10265
+ this.#updateLineCount();
10266
+ }
10267
+ get suffixText() {
10268
+ return this.#suffixText;
10269
+ }
10270
+ set suffixText(value = "") {
10271
+ this.#suffixText = value;
10272
+ this.#updateLineCount();
10273
+ }
10274
+ get isSpinning() {
10275
+ return this.#id !== undefined;
10276
+ }
10277
+ #getFullPrefixText(prefixText = this.#prefixText, postfix = " ") {
10278
+ if (typeof prefixText === "string" && prefixText !== "") {
10279
+ return prefixText + postfix;
10326
10280
  }
10327
- const data = await response.json();
10328
- return parse(data);
10329
- })();
10330
- cache.set(url, promise);
10331
- promise.catch(() => cache.delete(url));
10332
- return promise;
10333
- }
10334
- async function fetchRegistryIndex(baseUrl) {
10335
- const url = `${baseUrl.replace(/\/$/, "")}/index.json`;
10336
- return fetchWithCache(url, (data) => {
10337
- const result = registryIndexSchema.safeParse(data);
10338
- if (!result.success) {
10339
- throw new ValidationError(`Invalid registry format at ${url}: ${result.error.message}`);
10281
+ if (typeof prefixText === "function") {
10282
+ return prefixText() + postfix;
10340
10283
  }
10341
- return result.data;
10342
- });
10343
- }
10344
- async function fetchComponent(baseUrl, name) {
10345
- const url = `${baseUrl.replace(/\/$/, "")}/components/${name}.json`;
10346
- return fetchWithCache(url, (data) => {
10347
- const packumentResult = packumentSchema.safeParse(data);
10348
- if (!packumentResult.success) {
10349
- throw new ValidationError(`Invalid packument format for "${name}": ${packumentResult.error.message}`);
10284
+ return "";
10285
+ }
10286
+ #getFullSuffixText(suffixText = this.#suffixText, prefix = " ") {
10287
+ if (typeof suffixText === "string" && suffixText !== "") {
10288
+ return prefix + suffixText;
10350
10289
  }
10351
- const packument = packumentResult.data;
10352
- const latestVersion = packument["dist-tags"].latest;
10353
- const manifest = packument.versions[latestVersion];
10354
- if (!manifest) {
10355
- throw new ValidationError(`Component "${name}" has no manifest for latest version ${latestVersion}`);
10290
+ if (typeof suffixText === "function") {
10291
+ return prefix + suffixText();
10356
10292
  }
10357
- const manifestResult = componentManifestSchema.safeParse(manifest);
10358
- if (!manifestResult.success) {
10359
- throw new ValidationError(`Invalid component manifest for "${name}@${latestVersion}": ${manifestResult.error.message}`);
10293
+ return "";
10294
+ }
10295
+ #updateLineCount() {
10296
+ const columns = this.#stream.columns ?? 80;
10297
+ const fullPrefixText = this.#getFullPrefixText(this.#prefixText, "-");
10298
+ const fullSuffixText = this.#getFullSuffixText(this.#suffixText, "-");
10299
+ const fullText = " ".repeat(this.#indent) + fullPrefixText + "--" + this.#text + "--" + fullSuffixText;
10300
+ this.#lineCount = 0;
10301
+ for (const line of stripAnsi(fullText).split(`
10302
+ `)) {
10303
+ this.#lineCount += Math.max(1, Math.ceil(stringWidth(line, { countAnsiEscapeCodes: true }) / columns));
10360
10304
  }
10361
- return manifestResult.data;
10362
- });
10363
- }
10364
- async function fetchFileContent(baseUrl, componentName, filePath) {
10365
- const url = `${baseUrl.replace(/\/$/, "")}/components/${componentName}/${filePath}`;
10366
- const response = await fetch(url);
10367
- if (!response.ok) {
10368
- throw new NetworkError(`Failed to fetch file ${filePath} for ${componentName}: ${response.status} ${response.statusText}`);
10369
10305
  }
10370
- return response.text();
10371
- }
10372
-
10373
- // src/registry/resolver.ts
10374
- async function resolveDependencies(registries, componentNames) {
10375
- const resolved = new Map;
10376
- const visiting = new Set;
10377
- const mcpServers = {};
10378
- async function resolve(name, path = []) {
10379
- if (resolved.has(name)) {
10380
- return;
10306
+ get isEnabled() {
10307
+ return this.#isEnabled && !this.#isSilent;
10308
+ }
10309
+ set isEnabled(value) {
10310
+ if (typeof value !== "boolean") {
10311
+ throw new TypeError("The `isEnabled` option must be a boolean");
10381
10312
  }
10382
- if (visiting.has(name)) {
10383
- const cycle = [...path, name].join(" \u2192 ");
10384
- throw new ValidationError(`Circular dependency detected: ${cycle}`);
10313
+ this.#isEnabled = value;
10314
+ }
10315
+ get isSilent() {
10316
+ return this.#isSilent;
10317
+ }
10318
+ set isSilent(value) {
10319
+ if (typeof value !== "boolean") {
10320
+ throw new TypeError("The `isSilent` option must be a boolean");
10385
10321
  }
10386
- visiting.add(name);
10387
- let component = null;
10388
- let foundRegistry = null;
10389
- const registryEntries = Object.entries(registries);
10390
- for (const [regName, regConfig] of registryEntries) {
10391
- try {
10392
- const manifest = await fetchComponent(regConfig.url, name);
10393
- component = manifest;
10394
- foundRegistry = { name: regName, url: regConfig.url };
10395
- break;
10396
- } catch (_err) {
10397
- continue;
10398
- }
10322
+ this.#isSilent = value;
10323
+ }
10324
+ frame() {
10325
+ const now = Date.now();
10326
+ if (this.#frameIndex === -1 || now - this.#lastSpinnerFrameTime >= this.interval) {
10327
+ this.#frameIndex = ++this.#frameIndex % this.#spinner.frames.length;
10328
+ this.#lastSpinnerFrameTime = now;
10399
10329
  }
10400
- if (!component || !foundRegistry) {
10401
- throw new OCXError(`Component '${name}' not found in any configured registry.`, "NOT_FOUND");
10330
+ const { frames } = this.#spinner;
10331
+ let frame = frames[this.#frameIndex];
10332
+ if (this.color) {
10333
+ frame = source_default[this.color](frame);
10402
10334
  }
10403
- for (const dep of component.dependencies) {
10404
- await resolve(dep, [...path, name]);
10335
+ const fullPrefixText = typeof this.#prefixText === "string" && this.#prefixText !== "" ? this.#prefixText + " " : "";
10336
+ const fullText = typeof this.text === "string" ? " " + this.text : "";
10337
+ const fullSuffixText = typeof this.#suffixText === "string" && this.#suffixText !== "" ? " " + this.#suffixText : "";
10338
+ return fullPrefixText + frame + fullText + fullSuffixText;
10339
+ }
10340
+ clear() {
10341
+ if (!this.#isEnabled || !this.#stream.isTTY) {
10342
+ return this;
10405
10343
  }
10406
- resolved.set(name, {
10407
- ...component,
10408
- registryName: foundRegistry.name,
10409
- baseUrl: foundRegistry.url
10410
- });
10411
- visiting.delete(name);
10412
- if (component.mcpServers) {
10413
- for (const [serverName, config] of Object.entries(component.mcpServers)) {
10414
- mcpServers[serverName] = config;
10344
+ this.#stream.cursorTo(0);
10345
+ for (let index = 0;index < this.#linesToClear; index++) {
10346
+ if (index > 0) {
10347
+ this.#stream.moveCursor(0, -1);
10415
10348
  }
10349
+ this.#stream.clearLine(1);
10416
10350
  }
10417
- }
10418
- for (const name of componentNames) {
10419
- await resolve(name);
10420
- }
10421
- const components = Array.from(resolved.values());
10422
- const installOrder = Array.from(resolved.keys());
10423
- return {
10424
- components,
10425
- installOrder,
10426
- mcpServers
10427
- };
10428
- }
10429
-
10430
- // src/registry/opencode-config.ts
10431
- async function readOpencodeConfig(cwd) {
10432
- const jsonPath = `${cwd}/opencode.json`;
10433
- const jsoncPath = `${cwd}/opencode.jsonc`;
10434
- for (const configPath of [jsoncPath, jsonPath]) {
10435
- const file = Bun.file(configPath);
10436
- if (await file.exists()) {
10437
- const content = await file.text();
10438
- const stripped = configPath.endsWith(".jsonc") ? stripJsonComments2(content) : content;
10439
- return {
10440
- config: JSON.parse(stripped),
10441
- path: configPath
10442
- };
10351
+ if (this.#indent || this.lastIndent !== this.#indent) {
10352
+ this.#stream.cursorTo(this.#indent);
10443
10353
  }
10354
+ this.lastIndent = this.#indent;
10355
+ this.#linesToClear = 0;
10356
+ return this;
10444
10357
  }
10445
- return null;
10446
- }
10447
- async function writeOpencodeConfig(path, config) {
10448
- const content = JSON.stringify(config, null, 2);
10449
- await Bun.write(path, content);
10450
- }
10451
- function applyMcpServers(config, mcpServers) {
10452
- const added = [];
10453
- const skipped = [];
10454
- if (!config.mcp) {
10455
- config.mcp = {};
10358
+ render() {
10359
+ if (this.#isSilent) {
10360
+ return this;
10361
+ }
10362
+ this.clear();
10363
+ this.#stream.write(this.frame());
10364
+ this.#linesToClear = this.#lineCount;
10365
+ return this;
10456
10366
  }
10457
- for (const [name, server] of Object.entries(mcpServers)) {
10458
- if (config.mcp[name]) {
10459
- skipped.push(name);
10460
- } else {
10461
- const serverConfig = {
10462
- type: server.type,
10463
- enabled: server.enabled
10464
- };
10465
- if (server.type === "remote" && server.url) {
10466
- serverConfig.url = server.url;
10467
- }
10468
- if (server.type === "local" && server.command) {
10469
- serverConfig.command = server.command;
10470
- }
10471
- if (server.headers) {
10472
- serverConfig.headers = server.headers;
10367
+ start(text) {
10368
+ if (text) {
10369
+ this.text = text;
10370
+ }
10371
+ if (this.#isSilent) {
10372
+ return this;
10373
+ }
10374
+ if (!this.#isEnabled) {
10375
+ if (this.text) {
10376
+ this.#stream.write(`- ${this.text}
10377
+ `);
10473
10378
  }
10474
- config.mcp[name] = serverConfig;
10475
- added.push(name);
10379
+ return this;
10380
+ }
10381
+ if (this.isSpinning) {
10382
+ return this;
10383
+ }
10384
+ if (this.#options.hideCursor) {
10385
+ cli_cursor_default.hide(this.#stream);
10386
+ }
10387
+ if (this.#options.discardStdin && process9.stdin.isTTY) {
10388
+ this.#isDiscardingStdin = true;
10389
+ stdin_discarder_default.start();
10476
10390
  }
10391
+ this.render();
10392
+ this.#id = setInterval(this.render.bind(this), this.interval);
10393
+ return this;
10477
10394
  }
10478
- return { config, added, skipped };
10479
- }
10480
- function stripJsonComments2(content) {
10481
- let result = content.replace(/\/\/.*$/gm, "");
10482
- result = result.replace(/\/\*[\s\S]*?\*\//g, "");
10483
- return result;
10484
- }
10485
- async function updateOpencodeConfig(cwd, options2) {
10486
- let existing = await readOpencodeConfig(cwd);
10487
- let config;
10488
- let configPath;
10489
- let created = false;
10490
- if (existing) {
10491
- config = existing.config;
10492
- configPath = existing.path;
10493
- } else {
10494
- config = {
10495
- $schema: "https://opencode.ai/config.json"
10496
- };
10497
- configPath = `${cwd}/opencode.json`;
10498
- created = true;
10395
+ stop() {
10396
+ if (!this.#isEnabled) {
10397
+ return this;
10398
+ }
10399
+ clearInterval(this.#id);
10400
+ this.#id = undefined;
10401
+ this.#frameIndex = 0;
10402
+ this.clear();
10403
+ if (this.#options.hideCursor) {
10404
+ cli_cursor_default.show(this.#stream);
10405
+ }
10406
+ if (this.#options.discardStdin && process9.stdin.isTTY && this.#isDiscardingStdin) {
10407
+ stdin_discarder_default.stop();
10408
+ this.#isDiscardingStdin = false;
10409
+ }
10410
+ return this;
10499
10411
  }
10500
- let mcpAdded = [];
10501
- let mcpSkipped = [];
10502
- if (options2.mcpServers && Object.keys(options2.mcpServers).length > 0) {
10503
- const result = applyMcpServers(config, options2.mcpServers);
10504
- config = result.config;
10505
- mcpAdded = result.added;
10506
- mcpSkipped = result.skipped;
10412
+ succeed(text) {
10413
+ return this.stopAndPersist({ symbol: log_symbols_default.success, text });
10414
+ }
10415
+ fail(text) {
10416
+ return this.stopAndPersist({ symbol: log_symbols_default.error, text });
10507
10417
  }
10508
- if (options2.defaultAgent && !config.default_agent) {
10509
- config.default_agent = options2.defaultAgent;
10418
+ warn(text) {
10419
+ return this.stopAndPersist({ symbol: log_symbols_default.warning, text });
10420
+ }
10421
+ info(text) {
10422
+ return this.stopAndPersist({ symbol: log_symbols_default.info, text });
10423
+ }
10424
+ stopAndPersist(options2 = {}) {
10425
+ if (this.#isSilent) {
10426
+ return this;
10427
+ }
10428
+ const prefixText = options2.prefixText ?? this.#prefixText;
10429
+ const fullPrefixText = this.#getFullPrefixText(prefixText, " ");
10430
+ const symbolText = options2.symbol ?? " ";
10431
+ const text = options2.text ?? this.text;
10432
+ const separatorText = symbolText ? " " : "";
10433
+ const fullText = typeof text === "string" ? separatorText + text : "";
10434
+ const suffixText = options2.suffixText ?? this.#suffixText;
10435
+ const fullSuffixText = this.#getFullSuffixText(suffixText, " ");
10436
+ const textToWrite = fullPrefixText + symbolText + fullText + fullSuffixText + `
10437
+ `;
10438
+ this.stop();
10439
+ this.#stream.write(textToWrite);
10440
+ return this;
10510
10441
  }
10511
- await writeOpencodeConfig(configPath, config);
10512
- return {
10513
- path: configPath,
10514
- created,
10515
- mcpAdded,
10516
- mcpSkipped
10517
- };
10442
+ }
10443
+ function ora(options2) {
10444
+ return new Ora(options2);
10518
10445
  }
10519
10446
 
10447
+ // src/utils/spinner.ts
10448
+ function createSpinner(options2) {
10449
+ const shouldSpin = isTTY && !options2.quiet;
10450
+ const spinner = ora({
10451
+ text: options2.text,
10452
+ isSilent: !shouldSpin
10453
+ });
10454
+ return spinner;
10455
+ }
10520
10456
  // src/commands/add.ts
10521
10457
  function registerAddCommand(program2) {
10522
10458
  program2.command("add").description("Add components to your project").argument("<components...>", "Components to install").option("-y, --yes", "Skip prompts").option("--dry-run", "Show what would be installed without making changes").option("--cwd <path>", "Working directory", process.cwd()).option("-q, --quiet", "Suppress output").option("-v, --verbose", "Verbose output").option("--json", "Output as JSON").action(async (components, options2) => {
@@ -10529,15 +10465,15 @@ function registerAddCommand(program2) {
10529
10465
  }
10530
10466
  async function runAdd(componentNames, options2) {
10531
10467
  const cwd = options2.cwd ?? process.cwd();
10532
- const configPath = join2(cwd, "ocx.jsonc");
10533
- const lockPath = join2(cwd, "ocx.lock");
10534
- if (!existsSync2(configPath)) {
10468
+ const configPath = join(cwd, "ocx.jsonc");
10469
+ const lockPath = join(cwd, "ocx.lock");
10470
+ if (!existsSync(configPath)) {
10535
10471
  throw new ConfigError("No ocx.jsonc found. Run 'ocx init' first.");
10536
10472
  }
10537
10473
  const configContent = await readFile(configPath, "utf-8");
10538
10474
  const config = ocxConfigSchema.parse(JSON.parse(configContent));
10539
10475
  let lock = { lockVersion: 1, installed: {} };
10540
- if (existsSync2(lockPath)) {
10476
+ if (existsSync(lockPath)) {
10541
10477
  const lockContent = await readFile(lockPath, "utf-8");
10542
10478
  lock = ocxLockSchema.parse(JSON.parse(lockContent));
10543
10479
  }
@@ -10595,7 +10531,7 @@ async function runAdd(componentNames, options2) {
10595
10531
  logger.info(`Configured ${result.mcpAdded.length} MCP servers`);
10596
10532
  }
10597
10533
  }
10598
- await writeFile2(lockPath, JSON.stringify(lock, null, 2), "utf-8");
10534
+ await writeFile(lockPath, JSON.stringify(lock, null, 2), "utf-8");
10599
10535
  if (options2.json) {
10600
10536
  console.log(JSON.stringify({
10601
10537
  success: true,
@@ -10616,12 +10552,12 @@ async function installComponent(component, files, cwd) {
10616
10552
  const componentFile = component.files.find((f) => f.path === file.path);
10617
10553
  if (!componentFile)
10618
10554
  continue;
10619
- const targetPath = join2(cwd, componentFile.target);
10555
+ const targetPath = join(cwd, componentFile.target);
10620
10556
  const targetDir = dirname(targetPath);
10621
- if (!existsSync2(targetDir)) {
10557
+ if (!existsSync(targetDir)) {
10622
10558
  await mkdir(targetDir, { recursive: true });
10623
10559
  }
10624
- await writeFile2(targetPath, file.content);
10560
+ await writeFile(targetPath, file.content);
10625
10561
  }
10626
10562
  }
10627
10563
  function getTargetPath(component) {
@@ -10655,6 +10591,112 @@ function logResolved(resolved) {
10655
10591
  }
10656
10592
  }
10657
10593
 
10594
+ // src/commands/build.ts
10595
+ import { mkdir as mkdir2 } from "fs/promises";
10596
+ import { dirname as dirname2, join as join2, relative } from "path";
10597
+ function registerBuildCommand(program2) {
10598
+ program2.command("build").description("Build a registry from source (for registry authors)").argument("[path]", "Registry source directory", ".").option("--out <dir>", "Output directory", "./dist").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (path, options2) => {
10599
+ try {
10600
+ const sourcePath = join2(options2.cwd, path);
10601
+ const outPath = join2(options2.cwd, options2.out);
10602
+ const spinner2 = createSpinner({
10603
+ text: "Building registry...",
10604
+ quiet: options2.quiet || options2.json
10605
+ });
10606
+ if (!options2.json)
10607
+ spinner2.start();
10608
+ const registryFile = Bun.file(join2(sourcePath, "registry.json"));
10609
+ if (!await registryFile.exists()) {
10610
+ if (!options2.json)
10611
+ spinner2.fail("No registry.json found in source directory");
10612
+ process.exit(1);
10613
+ }
10614
+ const registryData = await registryFile.json();
10615
+ const parseResult = registrySchema.safeParse(registryData);
10616
+ if (!parseResult.success) {
10617
+ if (!options2.json) {
10618
+ spinner2.fail("Registry validation failed");
10619
+ const errors3 = parseResult.error.errors.map((e) => ` ${e.path.join(".")}: ${e.message}`);
10620
+ for (const err of errors3) {
10621
+ console.log(kleur_default.red(err));
10622
+ }
10623
+ }
10624
+ process.exit(1);
10625
+ }
10626
+ const registry = parseResult.data;
10627
+ const validationErrors = [];
10628
+ const componentsDir = join2(outPath, "components");
10629
+ await mkdir2(componentsDir, { recursive: true });
10630
+ for (const component of registry.components) {
10631
+ const packument = {
10632
+ name: component.name,
10633
+ versions: {
10634
+ [registry.version]: component
10635
+ },
10636
+ "dist-tags": {
10637
+ latest: registry.version
10638
+ }
10639
+ };
10640
+ const packumentPath = join2(componentsDir, `${component.name}.json`);
10641
+ await Bun.write(packumentPath, JSON.stringify(packument, null, 2));
10642
+ for (const file of component.files) {
10643
+ const sourceFilePath = join2(sourcePath, "files", file.path);
10644
+ const destFilePath = join2(componentsDir, component.name, file.path);
10645
+ const destFileDir = dirname2(destFilePath);
10646
+ if (!await Bun.file(sourceFilePath).exists()) {
10647
+ validationErrors.push(`${component.name}: Source file not found at ${sourceFilePath}`);
10648
+ continue;
10649
+ }
10650
+ await mkdir2(destFileDir, { recursive: true });
10651
+ const sourceFile = Bun.file(sourceFilePath);
10652
+ await Bun.write(destFilePath, sourceFile);
10653
+ }
10654
+ }
10655
+ if (validationErrors.length > 0) {
10656
+ if (!options2.json) {
10657
+ spinner2.fail(`Build failed with ${validationErrors.length} errors`);
10658
+ for (const err of validationErrors) {
10659
+ console.log(kleur_default.red(` ${err}`));
10660
+ }
10661
+ }
10662
+ process.exit(1);
10663
+ }
10664
+ const index = {
10665
+ name: registry.name,
10666
+ prefix: registry.prefix,
10667
+ version: registry.version,
10668
+ author: registry.author,
10669
+ components: registry.components.map((c) => ({
10670
+ name: c.name,
10671
+ type: c.type,
10672
+ description: c.description
10673
+ }))
10674
+ };
10675
+ await Bun.write(join2(outPath, "index.json"), JSON.stringify(index, null, 2));
10676
+ if (!options2.json) {
10677
+ const msg = `Built ${registry.components.length} components to ${relative(options2.cwd, outPath)}`;
10678
+ spinner2.succeed(msg);
10679
+ if (!process.stdout.isTTY) {
10680
+ logger.success(`Built ${registry.components.length} components`);
10681
+ }
10682
+ }
10683
+ if (options2.json) {
10684
+ outputJson({
10685
+ success: true,
10686
+ data: {
10687
+ name: registry.name,
10688
+ version: registry.version,
10689
+ components: registry.components.length,
10690
+ output: outPath
10691
+ }
10692
+ });
10693
+ }
10694
+ } catch (error) {
10695
+ handleError(error, { json: options2.json });
10696
+ }
10697
+ });
10698
+ }
10699
+
10658
10700
  // ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/base.js
10659
10701
  class Diff {
10660
10702
  diff(oldStr, newStr, options2 = {}) {
@@ -11506,131 +11548,29 @@ function registerDiffCommand(program2) {
11506
11548
  const upstreamFile = upstream.files[0];
11507
11549
  if (!upstreamFile) {
11508
11550
  results.push({ name, hasChanges: false });
11509
- continue;
11510
- }
11511
- const upstreamContent = await fetchFileContent(registryConfig.url, name, upstreamFile.path);
11512
- if (localContent === upstreamContent) {
11513
- results.push({ name, hasChanges: false });
11514
- } else {
11515
- const patch = createPatch(name, upstreamContent, localContent);
11516
- results.push({ name, hasChanges: true, diff: patch });
11517
- }
11518
- } catch (err) {
11519
- logger.warn(`Could not fetch upstream for ${name}: ${String(err)}`);
11520
- }
11521
- }
11522
- if (options2.json) {
11523
- outputJson({ success: true, data: { diffs: results } });
11524
- } else {
11525
- for (const res of results) {
11526
- if (res.hasChanges) {
11527
- console.log(kleur_default.yellow(`
11528
- Diff for ${res.name}:`));
11529
- console.log(res.diff || "Changes detected (no diff available)");
11530
- } else if (!options2.quiet) {
11531
- logger.success(`${res.name}: No changes`);
11532
- }
11533
- }
11534
- }
11535
- } catch (error) {
11536
- handleError(error, { json: options2.json });
11537
- }
11538
- });
11539
- }
11540
-
11541
- // src/commands/search.ts
11542
- var import_fuzzysort = __toESM(require_fuzzysort(), 1);
11543
- function registerSearchCommand(program2) {
11544
- program2.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]", "Search query").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).option("-v, --verbose", "Verbose output", false).option("-i, --installed", "List installed components only", false).option("-l, --limit <n>", "Limit results", "20").action(async (query, options2) => {
11545
- try {
11546
- const limit = parseInt(String(options2.limit), 10);
11547
- if (options2.installed) {
11548
- const lock = await readOcxLock(options2.cwd);
11549
- if (!lock) {
11550
- if (options2.json) {
11551
- outputJson({ success: true, data: { components: [] } });
11552
- } else {
11553
- logger.info("No components installed.");
11554
- }
11555
- return;
11556
- }
11557
- const installed = Object.entries(lock.installed).map(([name, info]) => ({
11558
- name,
11559
- registry: info.registry,
11560
- version: info.version,
11561
- installedAt: info.installedAt
11562
- }));
11563
- if (options2.json) {
11564
- outputJson({ success: true, data: { components: installed } });
11565
- } else {
11566
- logger.info(`Installed components (${installed.length}):`);
11567
- for (const comp of installed) {
11568
- console.log(` ${kleur_default.cyan(comp.name)} ${kleur_default.dim(`v${comp.version}`)} from ${comp.registry}`);
11569
- }
11570
- }
11571
- return;
11572
- }
11573
- const config = await readOcxConfig(options2.cwd);
11574
- if (!config) {
11575
- logger.warn("No ocx.jsonc found. Run 'ocx init' first.");
11576
- return;
11577
- }
11578
- if (options2.verbose) {
11579
- logger.info(`Searching in ${Object.keys(config.registries).length} registries...`);
11580
- }
11581
- const allComponents = [];
11582
- const spinner2 = createSpinner({
11583
- text: "Searching registries...",
11584
- quiet: options2.quiet || options2.verbose
11585
- });
11586
- if (!options2.json && !options2.verbose) {
11587
- spinner2.start();
11588
- }
11589
- for (const [registryName, registryConfig] of Object.entries(config.registries)) {
11590
- try {
11591
- if (options2.verbose) {
11592
- logger.info(`Fetching index from ${registryName} (${registryConfig.url})...`);
11593
- }
11594
- const index = await fetchRegistryIndex(registryConfig.url);
11595
- if (options2.verbose) {
11596
- logger.info(`Found ${index.components.length} components in ${registryName}`);
11597
- }
11598
- for (const comp of index.components) {
11599
- allComponents.push({
11600
- name: comp.name,
11601
- description: comp.description,
11602
- type: comp.type,
11603
- registry: registryName
11604
- });
11605
- }
11606
- } catch (error) {
11607
- if (options2.verbose) {
11608
- logger.warn(`Failed to fetch registry ${registryName}: ${error instanceof Error ? error.message : String(error)}`);
11551
+ continue;
11552
+ }
11553
+ const upstreamContent = await fetchFileContent(registryConfig.url, name, upstreamFile.path);
11554
+ if (localContent === upstreamContent) {
11555
+ results.push({ name, hasChanges: false });
11556
+ } else {
11557
+ const patch = createPatch(name, upstreamContent, localContent);
11558
+ results.push({ name, hasChanges: true, diff: patch });
11609
11559
  }
11560
+ } catch (err) {
11561
+ logger.warn(`Could not fetch upstream for ${name}: ${String(err)}`);
11610
11562
  }
11611
11563
  }
11612
- if (!options2.json && !options2.verbose) {
11613
- spinner2.stop();
11614
- }
11615
- let results = allComponents;
11616
- if (query) {
11617
- const fuzzyResults = import_fuzzysort.default.go(query, allComponents, {
11618
- keys: ["name", "description"],
11619
- limit
11620
- });
11621
- results = fuzzyResults.map((r) => r.obj);
11622
- } else {
11623
- results = results.slice(0, limit);
11624
- }
11625
11564
  if (options2.json) {
11626
- outputJson({ success: true, data: { components: results } });
11565
+ outputJson({ success: true, data: { diffs: results } });
11627
11566
  } else {
11628
- if (results.length === 0) {
11629
- logger.info("No components found.");
11630
- } else {
11631
- logger.info(`Found ${results.length} components:`);
11632
- for (const comp of results) {
11633
- console.log(` ${kleur_default.cyan(comp.name)} ${kleur_default.dim(`(${comp.type})`)} - ${comp.description}`);
11567
+ for (const res of results) {
11568
+ if (res.hasChanges) {
11569
+ console.log(kleur_default.yellow(`
11570
+ Diff for ${res.name}:`));
11571
+ console.log(res.diff || "Changes detected (no diff available)");
11572
+ } else if (!options2.quiet) {
11573
+ logger.success(`${res.name}: No changes`);
11634
11574
  }
11635
11575
  }
11636
11576
  }
@@ -11640,12 +11580,76 @@ function registerSearchCommand(program2) {
11640
11580
  });
11641
11581
  }
11642
11582
 
11583
+ // src/commands/init.ts
11584
+ import { existsSync as existsSync2 } from "fs";
11585
+ import { writeFile as writeFile2 } from "fs/promises";
11586
+ import { join as join3 } from "path";
11587
+
11588
+ // src/constants.ts
11589
+ var OCX_DOMAIN = "ocx.kdco.dev";
11590
+ var GITHUB_REPO = "kdcokenny/ocx";
11591
+ var OCX_SCHEMA_URL = `https://${OCX_DOMAIN}/schema.json`;
11592
+ var OCX_LOCK_SCHEMA_URL = `https://${OCX_DOMAIN}/lock.schema.json`;
11593
+ var OCX_INSTALL_URL = `https://${OCX_DOMAIN}/install.sh`;
11594
+ var GITHUB_RELEASES_URL = `https://github.com/${GITHUB_REPO}/releases`;
11595
+ var GITHUB_RAW_URL = `https://raw.githubusercontent.com/${GITHUB_REPO}/main`;
11596
+
11597
+ // src/commands/init.ts
11598
+ function registerInitCommand(program2) {
11599
+ program2.command("init").description("Initialize OCX configuration in your project").option("-y, --yes", "Skip prompts and use defaults").option("--cwd <path>", "Working directory", process.cwd()).option("-q, --quiet", "Suppress output").option("-v, --verbose", "Verbose output").option("--json", "Output as JSON").action(async (options2) => {
11600
+ try {
11601
+ await runInit(options2);
11602
+ } catch (error) {
11603
+ handleError(error, { json: options2.json });
11604
+ }
11605
+ });
11606
+ }
11607
+ async function runInit(options2) {
11608
+ const cwd = options2.cwd ?? process.cwd();
11609
+ const configPath = join3(cwd, "ocx.jsonc");
11610
+ if (existsSync2(configPath)) {
11611
+ if (!options2.yes) {
11612
+ logger.warn("ocx.jsonc already exists");
11613
+ logger.info("Use --yes to overwrite");
11614
+ return;
11615
+ }
11616
+ logger.info("Overwriting existing ocx.jsonc");
11617
+ }
11618
+ const spin = options2.quiet ? null : createSpinner({ text: "Initializing OCX..." });
11619
+ spin?.start();
11620
+ try {
11621
+ const rawConfig = {
11622
+ $schema: OCX_SCHEMA_URL,
11623
+ registries: {}
11624
+ };
11625
+ const config = ocxConfigSchema.parse(rawConfig);
11626
+ const content = JSON.stringify(config, null, 2);
11627
+ await writeFile2(configPath, content, "utf-8");
11628
+ if (!options2.quiet && !options2.json) {
11629
+ logger.success("Initialized OCX configuration");
11630
+ }
11631
+ spin?.succeed("Initialized OCX configuration");
11632
+ if (options2.json) {
11633
+ console.log(JSON.stringify({ success: true, path: configPath }));
11634
+ } else if (!options2.quiet) {
11635
+ logger.info(`Created ${configPath}`);
11636
+ logger.info("");
11637
+ logger.info("Next steps:");
11638
+ logger.info(" 1. Add a registry: ocx registry add <url>");
11639
+ logger.info(" 2. Install components: ocx add <component>");
11640
+ }
11641
+ } catch (error) {
11642
+ spin?.fail("Failed to initialize");
11643
+ throw error;
11644
+ }
11645
+ }
11646
+
11643
11647
  // src/commands/registry.ts
11644
11648
  function registerRegistryCommand(program2) {
11645
11649
  const registry = program2.command("registry").description("Manage registries");
11646
11650
  registry.command("add").description("Add a registry").argument("<url>", "Registry URL").option("--name <name>", "Registry alias (defaults to hostname)").option("--version <version>", "Pin to specific version").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (url, options2) => {
11647
11651
  try {
11648
- let config = await readOcxConfig(options2.cwd);
11652
+ const config = await readOcxConfig(options2.cwd);
11649
11653
  if (!config) {
11650
11654
  logger.error("No ocx.jsonc found. Run 'ocx init' first.");
11651
11655
  process.exit(1);
@@ -11675,7 +11679,7 @@ function registerRegistryCommand(program2) {
11675
11679
  });
11676
11680
  registry.command("remove").description("Remove a registry").argument("<name>", "Registry name").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (name, options2) => {
11677
11681
  try {
11678
- let config = await readOcxConfig(options2.cwd);
11682
+ const config = await readOcxConfig(options2.cwd);
11679
11683
  if (!config) {
11680
11684
  logger.error("No ocx.jsonc found. Run 'ocx init' first.");
11681
11685
  process.exit(1);
@@ -11735,102 +11739,101 @@ function registerRegistryCommand(program2) {
11735
11739
  });
11736
11740
  }
11737
11741
 
11738
- // src/commands/build.ts
11739
- import { join as join3, relative, dirname as dirname2 } from "path";
11740
- import { mkdir as mkdir2 } from "fs/promises";
11741
- function registerBuildCommand(program2) {
11742
- program2.command("build").description("Build a registry from source (for registry authors)").argument("[path]", "Registry source directory", ".").option("--out <dir>", "Output directory", "./dist").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (path, options2) => {
11742
+ // src/commands/search.ts
11743
+ var import_fuzzysort = __toESM(require_fuzzysort(), 1);
11744
+ function registerSearchCommand(program2) {
11745
+ program2.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]", "Search query").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).option("-v, --verbose", "Verbose output", false).option("-i, --installed", "List installed components only", false).option("-l, --limit <n>", "Limit results", "20").action(async (query, options2) => {
11743
11746
  try {
11744
- const sourcePath = join3(options2.cwd, path);
11745
- const outPath = join3(options2.cwd, options2.out);
11746
- const spinner2 = createSpinner({ text: "Building registry...", quiet: options2.quiet || options2.json });
11747
- if (!options2.json)
11748
- spinner2.start();
11749
- const registryFile = Bun.file(join3(sourcePath, "registry.json"));
11750
- if (!await registryFile.exists()) {
11751
- if (!options2.json)
11752
- spinner2.fail("No registry.json found in source directory");
11753
- process.exit(1);
11754
- }
11755
- const registryData = await registryFile.json();
11756
- const parseResult = registrySchema.safeParse(registryData);
11757
- if (!parseResult.success) {
11758
- if (!options2.json) {
11759
- spinner2.fail("Registry validation failed");
11760
- const errors3 = parseResult.error.errors.map((e) => ` ${e.path.join(".")}: ${e.message}`);
11761
- for (const err of errors3) {
11762
- console.log(kleur_default.red(err));
11747
+ const limit = parseInt(String(options2.limit), 10);
11748
+ if (options2.installed) {
11749
+ const lock = await readOcxLock(options2.cwd);
11750
+ if (!lock) {
11751
+ if (options2.json) {
11752
+ outputJson({ success: true, data: { components: [] } });
11753
+ } else {
11754
+ logger.info("No components installed.");
11763
11755
  }
11756
+ return;
11764
11757
  }
11765
- process.exit(1);
11766
- }
11767
- const registry = parseResult.data;
11768
- const validationErrors = [];
11769
- const componentsDir = join3(outPath, "components");
11770
- await mkdir2(componentsDir, { recursive: true });
11771
- for (const component of registry.components) {
11772
- const packument = {
11773
- name: component.name,
11774
- versions: {
11775
- [registry.version]: component
11776
- },
11777
- "dist-tags": {
11778
- latest: registry.version
11779
- }
11780
- };
11781
- const packumentPath = join3(componentsDir, `${component.name}.json`);
11782
- await Bun.write(packumentPath, JSON.stringify(packument, null, 2));
11783
- for (const file of component.files) {
11784
- const sourceFilePath = join3(sourcePath, "files", file.path);
11785
- const destFilePath = join3(componentsDir, component.name, file.path);
11786
- const destFileDir = dirname2(destFilePath);
11787
- if (!await Bun.file(sourceFilePath).exists()) {
11788
- validationErrors.push(`${component.name}: Source file not found at ${sourceFilePath}`);
11789
- continue;
11758
+ const installed = Object.entries(lock.installed).map(([name, info]) => ({
11759
+ name,
11760
+ registry: info.registry,
11761
+ version: info.version,
11762
+ installedAt: info.installedAt
11763
+ }));
11764
+ if (options2.json) {
11765
+ outputJson({ success: true, data: { components: installed } });
11766
+ } else {
11767
+ logger.info(`Installed components (${installed.length}):`);
11768
+ for (const comp of installed) {
11769
+ console.log(` ${kleur_default.cyan(comp.name)} ${kleur_default.dim(`v${comp.version}`)} from ${comp.registry}`);
11790
11770
  }
11791
- await mkdir2(destFileDir, { recursive: true });
11792
- const sourceFile = Bun.file(sourceFilePath);
11793
- await Bun.write(destFilePath, sourceFile);
11794
11771
  }
11772
+ return;
11795
11773
  }
11796
- if (validationErrors.length > 0) {
11797
- if (!options2.json) {
11798
- spinner2.fail(`Build failed with ${validationErrors.length} errors`);
11799
- for (const err of validationErrors) {
11800
- console.log(kleur_default.red(` ${err}`));
11774
+ const config = await readOcxConfig(options2.cwd);
11775
+ if (!config) {
11776
+ logger.warn("No ocx.jsonc found. Run 'ocx init' first.");
11777
+ return;
11778
+ }
11779
+ if (options2.verbose) {
11780
+ logger.info(`Searching in ${Object.keys(config.registries).length} registries...`);
11781
+ }
11782
+ const allComponents = [];
11783
+ const spinner2 = createSpinner({
11784
+ text: "Searching registries...",
11785
+ quiet: options2.quiet || options2.verbose
11786
+ });
11787
+ if (!options2.json && !options2.verbose) {
11788
+ spinner2.start();
11789
+ }
11790
+ for (const [registryName, registryConfig] of Object.entries(config.registries)) {
11791
+ try {
11792
+ if (options2.verbose) {
11793
+ logger.info(`Fetching index from ${registryName} (${registryConfig.url})...`);
11794
+ }
11795
+ const index = await fetchRegistryIndex(registryConfig.url);
11796
+ if (options2.verbose) {
11797
+ logger.info(`Found ${index.components.length} components in ${registryName}`);
11798
+ }
11799
+ for (const comp of index.components) {
11800
+ allComponents.push({
11801
+ name: comp.name,
11802
+ description: comp.description,
11803
+ type: comp.type,
11804
+ registry: registryName
11805
+ });
11806
+ }
11807
+ } catch (error) {
11808
+ if (options2.verbose) {
11809
+ logger.warn(`Failed to fetch registry ${registryName}: ${error instanceof Error ? error.message : String(error)}`);
11801
11810
  }
11802
11811
  }
11803
- process.exit(1);
11804
11812
  }
11805
- const index = {
11806
- name: registry.name,
11807
- prefix: registry.prefix,
11808
- version: registry.version,
11809
- author: registry.author,
11810
- components: registry.components.map((c) => ({
11811
- name: c.name,
11812
- type: c.type,
11813
- description: c.description
11814
- }))
11815
- };
11816
- await Bun.write(join3(outPath, "index.json"), JSON.stringify(index, null, 2));
11817
- if (!options2.json) {
11818
- const msg = `Built ${registry.components.length} components to ${relative(options2.cwd, outPath)}`;
11819
- spinner2.succeed(msg);
11820
- if (!process.stdout.isTTY) {
11821
- logger.success(`Built ${registry.components.length} components`);
11822
- }
11813
+ if (!options2.json && !options2.verbose) {
11814
+ spinner2.stop();
11815
+ }
11816
+ let results = allComponents;
11817
+ if (query) {
11818
+ const fuzzyResults = import_fuzzysort.default.go(query, allComponents, {
11819
+ keys: ["name", "description"],
11820
+ limit
11821
+ });
11822
+ results = fuzzyResults.map((r) => r.obj);
11823
+ } else {
11824
+ results = results.slice(0, limit);
11823
11825
  }
11824
11826
  if (options2.json) {
11825
- outputJson({
11826
- success: true,
11827
- data: {
11828
- name: registry.name,
11829
- version: registry.version,
11830
- components: registry.components.length,
11831
- output: outPath
11827
+ outputJson({ success: true, data: { components: results } });
11828
+ } else {
11829
+ if (results.length === 0) {
11830
+ logger.info("No components found.");
11831
+ } else {
11832
+ logger.info(`Found ${results.length} components:`);
11833
+ for (const comp of results) {
11834
+ console.log(` ${kleur_default.cyan(comp.name)} ${kleur_default.dim(`(${comp.type})`)} - ${comp.description}`);
11832
11835
  }
11833
- });
11836
+ }
11834
11837
  }
11835
11838
  } catch (error) {
11836
11839
  handleError(error, { json: options2.json });
@@ -11854,4 +11857,4 @@ main2().catch((err) => {
11854
11857
  handleError(err);
11855
11858
  });
11856
11859
 
11857
- //# debugId=70FCAFE78B94376F64756E2164756E21
11860
+ //# debugId=23985CCDFBBA246964756E2164756E21