zephex 2.0.16 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2479 -28
- package/dist/index.js +1601 -490
- package/dist/tools/architecture/index.js +398 -71
- package/dist/tools/audit_headers/index.js +118 -16
- package/dist/tools/context/index.js +399 -49
- package/dist/tools/reader/readCode.js +540 -97
- package/dist/tools/scope_task/index.js +422 -75
- package/dist/tools/search/findCode.js +486 -69
- package/dist/tools/server.js +885 -260
- package/dist/tools/thinking/index.js +118 -16
- package/package.json +3 -1
package/dist/cli.js
CHANGED
|
@@ -66,49 +66,2500 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
66
66
|
var __promiseAll = (args) => Promise.all(args);
|
|
67
67
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
68
68
|
|
|
69
|
+
// node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
70
|
+
var require_src = __commonJS((exports, module) => {
|
|
71
|
+
var ESC = "\x1B";
|
|
72
|
+
var CSI = `${ESC}[`;
|
|
73
|
+
var beep = "\x07";
|
|
74
|
+
var cursor = {
|
|
75
|
+
to(x, y) {
|
|
76
|
+
if (!y)
|
|
77
|
+
return `${CSI}${x + 1}G`;
|
|
78
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
79
|
+
},
|
|
80
|
+
move(x, y) {
|
|
81
|
+
let ret = "";
|
|
82
|
+
if (x < 0)
|
|
83
|
+
ret += `${CSI}${-x}D`;
|
|
84
|
+
else if (x > 0)
|
|
85
|
+
ret += `${CSI}${x}C`;
|
|
86
|
+
if (y < 0)
|
|
87
|
+
ret += `${CSI}${-y}A`;
|
|
88
|
+
else if (y > 0)
|
|
89
|
+
ret += `${CSI}${y}B`;
|
|
90
|
+
return ret;
|
|
91
|
+
},
|
|
92
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
93
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
94
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
95
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
96
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
97
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
98
|
+
left: `${CSI}G`,
|
|
99
|
+
hide: `${CSI}?25l`,
|
|
100
|
+
show: `${CSI}?25h`,
|
|
101
|
+
save: `${ESC}7`,
|
|
102
|
+
restore: `${ESC}8`
|
|
103
|
+
};
|
|
104
|
+
var scroll = {
|
|
105
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
106
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
107
|
+
};
|
|
108
|
+
var erase = {
|
|
109
|
+
screen: `${CSI}2J`,
|
|
110
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
111
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
112
|
+
line: `${CSI}2K`,
|
|
113
|
+
lineEnd: `${CSI}K`,
|
|
114
|
+
lineStart: `${CSI}1K`,
|
|
115
|
+
lines(count) {
|
|
116
|
+
let clear = "";
|
|
117
|
+
for (let i = 0;i < count; i++)
|
|
118
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
119
|
+
if (count)
|
|
120
|
+
clear += cursor.left;
|
|
121
|
+
return clear;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
128
|
+
var require_picocolors = __commonJS((exports, module) => {
|
|
129
|
+
var p = process || {};
|
|
130
|
+
var argv = p.argv || [];
|
|
131
|
+
var env = p.env || {};
|
|
132
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
133
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
134
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
135
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
136
|
+
};
|
|
137
|
+
var replaceClose = (string, close, replace, index) => {
|
|
138
|
+
let result = "", cursor = 0;
|
|
139
|
+
do {
|
|
140
|
+
result += string.substring(cursor, index) + replace;
|
|
141
|
+
cursor = index + close.length;
|
|
142
|
+
index = string.indexOf(close, cursor);
|
|
143
|
+
} while (~index);
|
|
144
|
+
return result + string.substring(cursor);
|
|
145
|
+
};
|
|
146
|
+
var createColors = (enabled = isColorSupported) => {
|
|
147
|
+
let f = enabled ? formatter : () => String;
|
|
148
|
+
return {
|
|
149
|
+
isColorSupported: enabled,
|
|
150
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
151
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
152
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
153
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
154
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
155
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
156
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
157
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
158
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
159
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
160
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
161
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
162
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
163
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
164
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
165
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
166
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
167
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
168
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
169
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
170
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
171
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
172
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
173
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
174
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
175
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
176
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
177
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
178
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
179
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
180
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
181
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
182
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
183
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
184
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
185
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
186
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
187
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
188
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
189
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
190
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
module.exports = createColors();
|
|
194
|
+
module.exports.createColors = createColors;
|
|
195
|
+
});
|
|
196
|
+
|
|
69
197
|
// src/cli.ts
|
|
70
|
-
import { fileURLToPath } from "url";
|
|
198
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
71
199
|
import { resolve, dirname } from "path";
|
|
72
|
-
|
|
73
|
-
|
|
200
|
+
|
|
201
|
+
// src/commands/setup.ts
|
|
202
|
+
import http from "node:http";
|
|
203
|
+
import crypto from "node:crypto";
|
|
204
|
+
import fs7 from "node:fs";
|
|
205
|
+
import path3 from "node:path";
|
|
206
|
+
import os3 from "node:os";
|
|
207
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
208
|
+
import { spawnSync } from "node:child_process";
|
|
209
|
+
|
|
210
|
+
// node_modules/.bun/@clack+prompts@0.9.1/node_modules/@clack/prompts/dist/index.mjs
|
|
211
|
+
import { stripVTControlCharacters as T2 } from "node:util";
|
|
212
|
+
|
|
213
|
+
// node_modules/.bun/@clack+core@0.4.1/node_modules/@clack/core/dist/index.mjs
|
|
214
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
215
|
+
import { stdin as $, stdout as j } from "node:process";
|
|
216
|
+
import * as f from "node:readline";
|
|
217
|
+
import M from "node:readline";
|
|
218
|
+
import { WriteStream as U } from "node:tty";
|
|
219
|
+
function J({ onlyFirst: t = false } = {}) {
|
|
220
|
+
const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
221
|
+
return new RegExp(F, t ? undefined : "g");
|
|
222
|
+
}
|
|
223
|
+
var Q = J();
|
|
224
|
+
function T(t) {
|
|
225
|
+
if (typeof t != "string")
|
|
226
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);
|
|
227
|
+
return t.replace(Q, "");
|
|
228
|
+
}
|
|
229
|
+
function O(t) {
|
|
230
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
231
|
+
}
|
|
232
|
+
var P = { exports: {} };
|
|
233
|
+
(function(t) {
|
|
234
|
+
var u = {};
|
|
235
|
+
t.exports = u, u.eastAsianWidth = function(e) {
|
|
236
|
+
var s = e.charCodeAt(0), i = e.length == 2 ? e.charCodeAt(1) : 0, D = s;
|
|
237
|
+
return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
|
|
238
|
+
}, u.characterLength = function(e) {
|
|
239
|
+
var s = this.eastAsianWidth(e);
|
|
240
|
+
return s == "F" || s == "W" || s == "A" ? 2 : 1;
|
|
241
|
+
};
|
|
242
|
+
function F(e) {
|
|
243
|
+
return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
244
|
+
}
|
|
245
|
+
u.length = function(e) {
|
|
246
|
+
for (var s = F(e), i = 0, D = 0;D < s.length; D++)
|
|
247
|
+
i = i + this.characterLength(s[D]);
|
|
248
|
+
return i;
|
|
249
|
+
}, u.slice = function(e, s, i) {
|
|
250
|
+
textLen = u.length(e), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
|
|
251
|
+
for (var D = "", C = 0, o = F(e), E = 0;E < o.length; E++) {
|
|
252
|
+
var a = o[E], n = u.length(a);
|
|
253
|
+
if (C >= s - (n == 2 ? 1 : 0))
|
|
254
|
+
if (C + n <= i)
|
|
255
|
+
D += a;
|
|
256
|
+
else
|
|
257
|
+
break;
|
|
258
|
+
C += n;
|
|
259
|
+
}
|
|
260
|
+
return D;
|
|
261
|
+
};
|
|
262
|
+
})(P);
|
|
263
|
+
var X = P.exports;
|
|
264
|
+
var DD = O(X);
|
|
265
|
+
var uD = function() {
|
|
266
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\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|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\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]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\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-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
267
|
+
};
|
|
268
|
+
var FD = O(uD);
|
|
269
|
+
function A(t, u = {}) {
|
|
270
|
+
if (typeof t != "string" || t.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, t = T(t), t.length === 0))
|
|
271
|
+
return 0;
|
|
272
|
+
t = t.replace(FD(), " ");
|
|
273
|
+
const F = u.ambiguousIsNarrow ? 1 : 2;
|
|
274
|
+
let e = 0;
|
|
275
|
+
for (const s of t) {
|
|
276
|
+
const i = s.codePointAt(0);
|
|
277
|
+
if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879)
|
|
278
|
+
continue;
|
|
279
|
+
switch (DD.eastAsianWidth(s)) {
|
|
280
|
+
case "F":
|
|
281
|
+
case "W":
|
|
282
|
+
e += 2;
|
|
283
|
+
break;
|
|
284
|
+
case "A":
|
|
285
|
+
e += F;
|
|
286
|
+
break;
|
|
287
|
+
default:
|
|
288
|
+
e += 1;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return e;
|
|
292
|
+
}
|
|
293
|
+
var m = 10;
|
|
294
|
+
var L = (t = 0) => (u) => `\x1B[${u + t}m`;
|
|
295
|
+
var N = (t = 0) => (u) => `\x1B[${38 + t};5;${u}m`;
|
|
296
|
+
var I = (t = 0) => (u, F, e) => `\x1B[${38 + t};2;${u};${F};${e}m`;
|
|
297
|
+
var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
|
|
298
|
+
Object.keys(r.modifier);
|
|
299
|
+
var tD = Object.keys(r.color);
|
|
300
|
+
var eD = Object.keys(r.bgColor);
|
|
301
|
+
[...tD, ...eD];
|
|
302
|
+
function sD() {
|
|
303
|
+
const t = new Map;
|
|
304
|
+
for (const [u, F] of Object.entries(r)) {
|
|
305
|
+
for (const [e, s] of Object.entries(F))
|
|
306
|
+
r[e] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[e] = r[e], t.set(s[0], s[1]);
|
|
307
|
+
Object.defineProperty(r, u, { value: F, enumerable: false });
|
|
308
|
+
}
|
|
309
|
+
return Object.defineProperty(r, "codes", { value: t, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = L(), r.color.ansi256 = N(), r.color.ansi16m = I(), r.bgColor.ansi = L(m), r.bgColor.ansi256 = N(m), r.bgColor.ansi16m = I(m), Object.defineProperties(r, { rgbToAnsi256: { value: (u, F, e) => u === F && F === e ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(e / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
|
|
310
|
+
const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
|
|
311
|
+
if (!F)
|
|
312
|
+
return [0, 0, 0];
|
|
313
|
+
let [e] = F;
|
|
314
|
+
e.length === 3 && (e = [...e].map((i) => i + i).join(""));
|
|
315
|
+
const s = Number.parseInt(e, 16);
|
|
316
|
+
return [s >> 16 & 255, s >> 8 & 255, s & 255];
|
|
317
|
+
}, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
|
|
318
|
+
if (u < 8)
|
|
319
|
+
return 30 + u;
|
|
320
|
+
if (u < 16)
|
|
321
|
+
return 90 + (u - 8);
|
|
322
|
+
let F, e, s;
|
|
323
|
+
if (u >= 232)
|
|
324
|
+
F = ((u - 232) * 10 + 8) / 255, e = F, s = F;
|
|
325
|
+
else {
|
|
326
|
+
u -= 16;
|
|
327
|
+
const C = u % 36;
|
|
328
|
+
F = Math.floor(u / 36) / 5, e = Math.floor(C / 6) / 5, s = C % 6 / 5;
|
|
329
|
+
}
|
|
330
|
+
const i = Math.max(F, e, s) * 2;
|
|
331
|
+
if (i === 0)
|
|
332
|
+
return 30;
|
|
333
|
+
let D = 30 + (Math.round(s) << 2 | Math.round(e) << 1 | Math.round(F));
|
|
334
|
+
return i === 2 && (D += 60), D;
|
|
335
|
+
}, enumerable: false }, rgbToAnsi: { value: (u, F, e) => r.ansi256ToAnsi(r.rgbToAnsi256(u, F, e)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
|
|
336
|
+
}
|
|
337
|
+
var iD = sD();
|
|
338
|
+
var v = new Set(["\x1B", ""]);
|
|
339
|
+
var CD = 39;
|
|
340
|
+
var w = "\x07";
|
|
341
|
+
var W = "[";
|
|
342
|
+
var rD = "]";
|
|
343
|
+
var R = "m";
|
|
344
|
+
var y = `${rD}8;;`;
|
|
345
|
+
var V = (t) => `${v.values().next().value}${W}${t}${R}`;
|
|
346
|
+
var z = (t) => `${v.values().next().value}${y}${t}${w}`;
|
|
347
|
+
var ED = (t) => t.split(" ").map((u) => A(u));
|
|
348
|
+
var _ = (t, u, F) => {
|
|
349
|
+
const e = [...u];
|
|
350
|
+
let s = false, i = false, D = A(T(t[t.length - 1]));
|
|
351
|
+
for (const [C, o] of e.entries()) {
|
|
352
|
+
const E = A(o);
|
|
353
|
+
if (D + E <= F ? t[t.length - 1] += o : (t.push(o), D = 0), v.has(o) && (s = true, i = e.slice(C + 1).join("").startsWith(y)), s) {
|
|
354
|
+
i ? o === w && (s = false, i = false) : o === R && (s = false);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
D += E, D === F && C < e.length - 1 && (t.push(""), D = 0);
|
|
358
|
+
}
|
|
359
|
+
!D && t[t.length - 1].length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
360
|
+
};
|
|
361
|
+
var nD = (t) => {
|
|
362
|
+
const u = t.split(" ");
|
|
363
|
+
let F = u.length;
|
|
364
|
+
for (;F > 0 && !(A(u[F - 1]) > 0); )
|
|
365
|
+
F--;
|
|
366
|
+
return F === u.length ? t : u.slice(0, F).join(" ") + u.slice(F).join("");
|
|
367
|
+
};
|
|
368
|
+
var oD = (t, u, F = {}) => {
|
|
369
|
+
if (F.trim !== false && t.trim() === "")
|
|
370
|
+
return "";
|
|
371
|
+
let e = "", s, i;
|
|
372
|
+
const D = ED(t);
|
|
373
|
+
let C = [""];
|
|
374
|
+
for (const [E, a] of t.split(" ").entries()) {
|
|
375
|
+
F.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
|
|
376
|
+
let n = A(C[C.length - 1]);
|
|
377
|
+
if (E !== 0 && (n >= u && (F.wordWrap === false || F.trim === false) && (C.push(""), n = 0), (n > 0 || F.trim === false) && (C[C.length - 1] += " ", n++)), F.hard && D[E] > u) {
|
|
378
|
+
const B = u - n, p = 1 + Math.floor((D[E] - B - 1) / u);
|
|
379
|
+
Math.floor((D[E] - 1) / u) < p && C.push(""), _(C, a, u);
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (n + D[E] > u && n > 0 && D[E] > 0) {
|
|
383
|
+
if (F.wordWrap === false && n < u) {
|
|
384
|
+
_(C, a, u);
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
C.push("");
|
|
388
|
+
}
|
|
389
|
+
if (n + D[E] > u && F.wordWrap === false) {
|
|
390
|
+
_(C, a, u);
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
C[C.length - 1] += a;
|
|
394
|
+
}
|
|
395
|
+
F.trim !== false && (C = C.map((E) => nD(E)));
|
|
396
|
+
const o = [...C.join(`
|
|
397
|
+
`)];
|
|
398
|
+
for (const [E, a] of o.entries()) {
|
|
399
|
+
if (e += a, v.has(a)) {
|
|
400
|
+
const { groups: B } = new RegExp(`(?:\\${W}(?<code>\\d+)m|\\${y}(?<uri>.*)${w})`).exec(o.slice(E).join("")) || { groups: {} };
|
|
401
|
+
if (B.code !== undefined) {
|
|
402
|
+
const p = Number.parseFloat(B.code);
|
|
403
|
+
s = p === CD ? undefined : p;
|
|
404
|
+
} else
|
|
405
|
+
B.uri !== undefined && (i = B.uri.length === 0 ? undefined : B.uri);
|
|
406
|
+
}
|
|
407
|
+
const n = iD.codes.get(Number(s));
|
|
408
|
+
o[E + 1] === `
|
|
409
|
+
` ? (i && (e += z("")), s && n && (e += V(n))) : a === `
|
|
410
|
+
` && (s && n && (e += V(s)), i && (e += z(i)));
|
|
411
|
+
}
|
|
412
|
+
return e;
|
|
413
|
+
};
|
|
414
|
+
function G(t, u, F) {
|
|
415
|
+
return String(t).normalize().replace(/\r\n/g, `
|
|
416
|
+
`).split(`
|
|
417
|
+
`).map((e) => oD(e, u, F)).join(`
|
|
418
|
+
`);
|
|
419
|
+
}
|
|
420
|
+
var aD = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
421
|
+
var c = { actions: new Set(aD), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]) };
|
|
422
|
+
function k(t, u) {
|
|
423
|
+
if (typeof t == "string")
|
|
424
|
+
return c.aliases.get(t) === u;
|
|
425
|
+
for (const F of t)
|
|
426
|
+
if (F !== undefined && k(F, u))
|
|
427
|
+
return true;
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
function lD(t, u) {
|
|
431
|
+
if (t === u)
|
|
432
|
+
return;
|
|
433
|
+
const F = t.split(`
|
|
434
|
+
`), e = u.split(`
|
|
435
|
+
`), s = [];
|
|
436
|
+
for (let i = 0;i < Math.max(F.length, e.length); i++)
|
|
437
|
+
F[i] !== e[i] && s.push(i);
|
|
438
|
+
return s;
|
|
439
|
+
}
|
|
440
|
+
var xD = globalThis.process.platform.startsWith("win");
|
|
441
|
+
var S = Symbol("clack:cancel");
|
|
442
|
+
function BD(t) {
|
|
443
|
+
return t === S;
|
|
444
|
+
}
|
|
445
|
+
function d(t, u) {
|
|
446
|
+
const F = t;
|
|
447
|
+
F.isTTY && F.setRawMode(u);
|
|
448
|
+
}
|
|
449
|
+
function cD({ input: t = $, output: u = j, overwrite: F = true, hideCursor: e = true } = {}) {
|
|
450
|
+
const s = f.createInterface({ input: t, output: u, prompt: "", tabSize: 1 });
|
|
451
|
+
f.emitKeypressEvents(t, s), t.isTTY && t.setRawMode(true);
|
|
452
|
+
const i = (D, { name: C, sequence: o }) => {
|
|
453
|
+
const E = String(D);
|
|
454
|
+
if (k([E, C, o], "cancel")) {
|
|
455
|
+
e && u.write(import_sisteransi.cursor.show), process.exit(0);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
if (!F)
|
|
459
|
+
return;
|
|
460
|
+
const a = C === "return" ? 0 : -1, n = C === "return" ? -1 : 0;
|
|
461
|
+
f.moveCursor(u, a, n, () => {
|
|
462
|
+
f.clearLine(u, 1, () => {
|
|
463
|
+
t.once("keypress", i);
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
return e && u.write(import_sisteransi.cursor.hide), t.once("keypress", i), () => {
|
|
468
|
+
t.off("keypress", i), e && u.write(import_sisteransi.cursor.show), t.isTTY && !xD && t.setRawMode(false), s.terminal = false, s.close();
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
var AD = Object.defineProperty;
|
|
472
|
+
var pD = (t, u, F) => (u in t) ? AD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F;
|
|
473
|
+
var h = (t, u, F) => (pD(t, typeof u != "symbol" ? u + "" : u, F), F);
|
|
474
|
+
|
|
475
|
+
class x {
|
|
476
|
+
constructor(u, F = true) {
|
|
477
|
+
h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", new Map), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
|
|
478
|
+
const { input: e = $, output: s = j, render: i, signal: D, ...C } = u;
|
|
479
|
+
this.opts = C, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = F, this._abortSignal = D, this.input = e, this.output = s;
|
|
480
|
+
}
|
|
481
|
+
unsubscribe() {
|
|
482
|
+
this._subscribers.clear();
|
|
483
|
+
}
|
|
484
|
+
setSubscriber(u, F) {
|
|
485
|
+
const e = this._subscribers.get(u) ?? [];
|
|
486
|
+
e.push(F), this._subscribers.set(u, e);
|
|
487
|
+
}
|
|
488
|
+
on(u, F) {
|
|
489
|
+
this.setSubscriber(u, { cb: F });
|
|
490
|
+
}
|
|
491
|
+
once(u, F) {
|
|
492
|
+
this.setSubscriber(u, { cb: F, once: true });
|
|
493
|
+
}
|
|
494
|
+
emit(u, ...F) {
|
|
495
|
+
const e = this._subscribers.get(u) ?? [], s = [];
|
|
496
|
+
for (const i of e)
|
|
497
|
+
i.cb(...F), i.once && s.push(() => e.splice(e.indexOf(i), 1));
|
|
498
|
+
for (const i of s)
|
|
499
|
+
i();
|
|
500
|
+
}
|
|
501
|
+
prompt() {
|
|
502
|
+
return new Promise((u, F) => {
|
|
503
|
+
if (this._abortSignal) {
|
|
504
|
+
if (this._abortSignal.aborted)
|
|
505
|
+
return this.state = "cancel", this.close(), u(S);
|
|
506
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
507
|
+
this.state = "cancel", this.close();
|
|
508
|
+
}, { once: true });
|
|
509
|
+
}
|
|
510
|
+
const e = new U(0);
|
|
511
|
+
e._write = (s, i, D) => {
|
|
512
|
+
this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
|
|
513
|
+
}, this.input.pipe(e), this.rl = M.createInterface({ input: this.input, output: e, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), M.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== undefined && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), d(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
514
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), d(this.input, false), u(this.value);
|
|
515
|
+
}), this.once("cancel", () => {
|
|
516
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), d(this.input, false), u(S);
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
onKeypress(u, F) {
|
|
521
|
+
if (this.state === "error" && (this.state = "active"), F?.name && (!this._track && c.aliases.has(F.name) && this.emit("cursor", c.aliases.get(F.name)), c.actions.has(F.name) && this.emit("cursor", F.name)), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === "\t" && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), F?.name === "return") {
|
|
522
|
+
if (this.opts.validate) {
|
|
523
|
+
const e = this.opts.validate(this.value);
|
|
524
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.value));
|
|
525
|
+
}
|
|
526
|
+
this.state !== "error" && (this.state = "submit");
|
|
527
|
+
}
|
|
528
|
+
k([u, F?.name, F?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
529
|
+
}
|
|
530
|
+
close() {
|
|
531
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
532
|
+
`), d(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
533
|
+
}
|
|
534
|
+
restoreCursor() {
|
|
535
|
+
const u = G(this._prevFrame, process.stdout.columns, { hard: true }).split(`
|
|
536
|
+
`).length - 1;
|
|
537
|
+
this.output.write(import_sisteransi.cursor.move(-999, u * -1));
|
|
538
|
+
}
|
|
539
|
+
render() {
|
|
540
|
+
const u = G(this._render(this) ?? "", process.stdout.columns, { hard: true });
|
|
541
|
+
if (u !== this._prevFrame) {
|
|
542
|
+
if (this.state === "initial")
|
|
543
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
544
|
+
else {
|
|
545
|
+
const F = lD(this._prevFrame, u);
|
|
546
|
+
if (this.restoreCursor(), F && F?.length === 1) {
|
|
547
|
+
const e = F[0];
|
|
548
|
+
this.output.write(import_sisteransi.cursor.move(0, e)), this.output.write(import_sisteransi.erase.lines(1));
|
|
549
|
+
const s = u.split(`
|
|
550
|
+
`);
|
|
551
|
+
this.output.write(s[e]), this._prevFrame = u, this.output.write(import_sisteransi.cursor.move(0, s.length - e - 1));
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (F && F?.length > 1) {
|
|
555
|
+
const e = F[0];
|
|
556
|
+
this.output.write(import_sisteransi.cursor.move(0, e)), this.output.write(import_sisteransi.erase.down());
|
|
557
|
+
const s = u.split(`
|
|
558
|
+
`).slice(e);
|
|
559
|
+
this.output.write(s.join(`
|
|
560
|
+
`)), this._prevFrame = u;
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
this.output.write(import_sisteransi.erase.down());
|
|
564
|
+
}
|
|
565
|
+
this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
var SD = Object.defineProperty;
|
|
570
|
+
var $D = (t, u, F) => (u in t) ? SD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F;
|
|
571
|
+
var q = (t, u, F) => ($D(t, typeof u != "symbol" ? u + "" : u, F), F);
|
|
572
|
+
|
|
573
|
+
class jD extends x {
|
|
574
|
+
constructor(u) {
|
|
575
|
+
super(u, false), q(this, "options"), q(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: F }) => F === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
|
|
576
|
+
switch (F) {
|
|
577
|
+
case "left":
|
|
578
|
+
case "up":
|
|
579
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
580
|
+
break;
|
|
581
|
+
case "down":
|
|
582
|
+
case "right":
|
|
583
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
this.changeValue();
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
get _value() {
|
|
590
|
+
return this.options[this.cursor];
|
|
591
|
+
}
|
|
592
|
+
changeValue() {
|
|
593
|
+
this.value = this._value.value;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// node_modules/.bun/@clack+prompts@0.9.1/node_modules/@clack/prompts/dist/index.mjs
|
|
598
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
599
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
600
|
+
import p from "node:process";
|
|
601
|
+
function X2() {
|
|
602
|
+
return p.platform !== "win32" ? p.env.TERM !== "linux" : !!p.env.CI || !!p.env.WT_SESSION || !!p.env.TERMINUS_SUBLIME || p.env.ConEmuTask === "{cmd::Cmder}" || p.env.TERM_PROGRAM === "Terminus-Sublime" || p.env.TERM_PROGRAM === "vscode" || p.env.TERM === "xterm-256color" || p.env.TERM === "alacritty" || p.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
603
|
+
}
|
|
604
|
+
var E = X2();
|
|
605
|
+
var u = (s, n) => E ? s : n;
|
|
606
|
+
var ee = u("◆", "*");
|
|
607
|
+
var A2 = u("■", "x");
|
|
608
|
+
var B = u("▲", "x");
|
|
609
|
+
var S2 = u("◇", "o");
|
|
610
|
+
var te = u("┌", "T");
|
|
611
|
+
var a = u("│", "|");
|
|
612
|
+
var m2 = u("└", "—");
|
|
613
|
+
var j2 = u("●", ">");
|
|
614
|
+
var R2 = u("○", " ");
|
|
615
|
+
var V2 = u("◻", "[•]");
|
|
616
|
+
var M2 = u("◼", "[+]");
|
|
617
|
+
var G2 = u("◻", "[ ]");
|
|
618
|
+
var se = u("▪", "•");
|
|
619
|
+
var N2 = u("─", "-");
|
|
620
|
+
var re = u("╮", "+");
|
|
621
|
+
var ie = u("├", "+");
|
|
622
|
+
var ne = u("╯", "+");
|
|
623
|
+
var ae = u("●", "•");
|
|
624
|
+
var oe = u("◆", "*");
|
|
625
|
+
var ce = u("▲", "!");
|
|
626
|
+
var le = u("■", "x");
|
|
627
|
+
var y2 = (s) => {
|
|
628
|
+
switch (s) {
|
|
629
|
+
case "initial":
|
|
630
|
+
case "active":
|
|
631
|
+
return import_picocolors.default.cyan(ee);
|
|
632
|
+
case "cancel":
|
|
633
|
+
return import_picocolors.default.red(A2);
|
|
634
|
+
case "error":
|
|
635
|
+
return import_picocolors.default.yellow(B);
|
|
636
|
+
case "submit":
|
|
637
|
+
return import_picocolors.default.green(S2);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
var k2 = (s) => {
|
|
641
|
+
const { cursor: n, options: t, style: i } = s, r2 = s.maxItems ?? Number.POSITIVE_INFINITY, c2 = Math.max(process.stdout.rows - 4, 0), o = Math.min(c2, Math.max(r2, 5));
|
|
642
|
+
let l2 = 0;
|
|
643
|
+
n >= l2 + o - 3 ? l2 = Math.max(Math.min(n - o + 3, t.length - o), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
644
|
+
const $2 = o < t.length && l2 > 0, d2 = o < t.length && l2 + o < t.length;
|
|
645
|
+
return t.slice(l2, l2 + o).map((w2, b2, C) => {
|
|
646
|
+
const I2 = b2 === 0 && $2, x2 = b2 === C.length - 1 && d2;
|
|
647
|
+
return I2 || x2 ? import_picocolors.default.dim("...") : i(w2, b2 + l2 === n);
|
|
648
|
+
});
|
|
649
|
+
};
|
|
650
|
+
var de = (s) => {
|
|
651
|
+
const n = (t, i) => {
|
|
652
|
+
const r2 = t.label ?? String(t.value);
|
|
653
|
+
switch (i) {
|
|
654
|
+
case "selected":
|
|
655
|
+
return `${import_picocolors.default.dim(r2)}`;
|
|
656
|
+
case "active":
|
|
657
|
+
return `${import_picocolors.default.green(j2)} ${r2} ${t.hint ? import_picocolors.default.dim(`(${t.hint})`) : ""}`;
|
|
658
|
+
case "cancelled":
|
|
659
|
+
return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(r2))}`;
|
|
660
|
+
default:
|
|
661
|
+
return `${import_picocolors.default.dim(R2)} ${import_picocolors.default.dim(r2)}`;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
return new jD({ options: s.options, initialValue: s.initialValue, render() {
|
|
665
|
+
const t = `${import_picocolors.default.gray(a)}
|
|
666
|
+
${y2(this.state)} ${s.message}
|
|
667
|
+
`;
|
|
668
|
+
switch (this.state) {
|
|
669
|
+
case "submit":
|
|
670
|
+
return `${t}${import_picocolors.default.gray(a)} ${n(this.options[this.cursor], "selected")}`;
|
|
671
|
+
case "cancel":
|
|
672
|
+
return `${t}${import_picocolors.default.gray(a)} ${n(this.options[this.cursor], "cancelled")}
|
|
673
|
+
${import_picocolors.default.gray(a)}`;
|
|
674
|
+
default:
|
|
675
|
+
return `${t}${import_picocolors.default.cyan(a)} ${k2({ cursor: this.cursor, options: this.options, maxItems: s.maxItems, style: (i, r2) => n(i, r2 ? "active" : "inactive") }).join(`
|
|
676
|
+
${import_picocolors.default.cyan(a)} `)}
|
|
677
|
+
${import_picocolors.default.cyan(m2)}
|
|
678
|
+
`;
|
|
679
|
+
}
|
|
680
|
+
} }).prompt();
|
|
681
|
+
};
|
|
682
|
+
var ye = (s = "", n = "") => {
|
|
683
|
+
const t = `
|
|
684
|
+
${s}
|
|
685
|
+
`.split(`
|
|
686
|
+
`), i = T2(n).length, r2 = Math.max(t.reduce((o, l2) => {
|
|
687
|
+
const $2 = T2(l2);
|
|
688
|
+
return $2.length > o ? $2.length : o;
|
|
689
|
+
}, 0), i) + 2, c2 = t.map((o) => `${import_picocolors.default.gray(a)} ${import_picocolors.default.dim(o)}${" ".repeat(r2 - T2(o).length)}${import_picocolors.default.gray(a)}`).join(`
|
|
690
|
+
`);
|
|
691
|
+
process.stdout.write(`${import_picocolors.default.gray(a)}
|
|
692
|
+
${import_picocolors.default.green(S2)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(N2.repeat(Math.max(r2 - i - 1, 1)) + re)}
|
|
693
|
+
${c2}
|
|
694
|
+
${import_picocolors.default.gray(ie + N2.repeat(r2 + 2) + ne)}
|
|
695
|
+
`);
|
|
696
|
+
};
|
|
697
|
+
var ve = (s = "") => {
|
|
698
|
+
process.stdout.write(`${import_picocolors.default.gray(m2)} ${import_picocolors.default.red(s)}
|
|
699
|
+
|
|
700
|
+
`);
|
|
701
|
+
};
|
|
702
|
+
var we = (s = "") => {
|
|
703
|
+
process.stdout.write(`${import_picocolors.default.gray(te)} ${s}
|
|
704
|
+
`);
|
|
705
|
+
};
|
|
706
|
+
var fe = (s = "") => {
|
|
707
|
+
process.stdout.write(`${import_picocolors.default.gray(a)}
|
|
708
|
+
${import_picocolors.default.gray(m2)} ${s}
|
|
709
|
+
|
|
710
|
+
`);
|
|
711
|
+
};
|
|
712
|
+
var v2 = { message: (s = "", { symbol: n = import_picocolors.default.gray(a) } = {}) => {
|
|
713
|
+
const t = [`${import_picocolors.default.gray(a)}`];
|
|
714
|
+
if (s) {
|
|
715
|
+
const [i, ...r2] = s.split(`
|
|
716
|
+
`);
|
|
717
|
+
t.push(`${n} ${i}`, ...r2.map((c2) => `${import_picocolors.default.gray(a)} ${c2}`));
|
|
718
|
+
}
|
|
719
|
+
process.stdout.write(`${t.join(`
|
|
720
|
+
`)}
|
|
721
|
+
`);
|
|
722
|
+
}, info: (s) => {
|
|
723
|
+
v2.message(s, { symbol: import_picocolors.default.blue(ae) });
|
|
724
|
+
}, success: (s) => {
|
|
725
|
+
v2.message(s, { symbol: import_picocolors.default.green(oe) });
|
|
726
|
+
}, step: (s) => {
|
|
727
|
+
v2.message(s, { symbol: import_picocolors.default.green(S2) });
|
|
728
|
+
}, warn: (s) => {
|
|
729
|
+
v2.message(s, { symbol: import_picocolors.default.yellow(ce) });
|
|
730
|
+
}, warning: (s) => {
|
|
731
|
+
v2.warn(s);
|
|
732
|
+
}, error: (s) => {
|
|
733
|
+
v2.message(s, { symbol: import_picocolors.default.red(le) });
|
|
734
|
+
} };
|
|
735
|
+
var L2 = () => {
|
|
736
|
+
const s = E ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], n = E ? 80 : 120, t = process.env.CI === "true";
|
|
737
|
+
let i, r2, c2 = false, o = "", l2;
|
|
738
|
+
const $2 = (h2) => {
|
|
739
|
+
const g = h2 > 1 ? "Something went wrong" : "Canceled";
|
|
740
|
+
c2 && P2(g, h2);
|
|
741
|
+
}, d2 = () => $2(2), w2 = () => $2(1), b2 = () => {
|
|
742
|
+
process.on("uncaughtExceptionMonitor", d2), process.on("unhandledRejection", d2), process.on("SIGINT", w2), process.on("SIGTERM", w2), process.on("exit", $2);
|
|
743
|
+
}, C = () => {
|
|
744
|
+
process.removeListener("uncaughtExceptionMonitor", d2), process.removeListener("unhandledRejection", d2), process.removeListener("SIGINT", w2), process.removeListener("SIGTERM", w2), process.removeListener("exit", $2);
|
|
745
|
+
}, I2 = () => {
|
|
746
|
+
if (l2 === undefined)
|
|
747
|
+
return;
|
|
748
|
+
t && process.stdout.write(`
|
|
749
|
+
`);
|
|
750
|
+
const h2 = l2.split(`
|
|
751
|
+
`);
|
|
752
|
+
process.stdout.write(import_sisteransi2.cursor.move(-999, h2.length - 1)), process.stdout.write(import_sisteransi2.erase.down(h2.length));
|
|
753
|
+
}, x2 = (h2) => h2.replace(/\.+$/, ""), O2 = (h2 = "") => {
|
|
754
|
+
c2 = true, i = cD(), o = x2(h2), process.stdout.write(`${import_picocolors.default.gray(a)}
|
|
755
|
+
`);
|
|
756
|
+
let g = 0, f2 = 0;
|
|
757
|
+
b2(), r2 = setInterval(() => {
|
|
758
|
+
if (t && o === l2)
|
|
759
|
+
return;
|
|
760
|
+
I2(), l2 = o;
|
|
761
|
+
const W2 = import_picocolors.default.magenta(s[g]), _2 = t ? "..." : ".".repeat(Math.floor(f2)).slice(0, 3);
|
|
762
|
+
process.stdout.write(`${W2} ${o}${_2}`), g = g + 1 < s.length ? g + 1 : 0, f2 = f2 < s.length ? f2 + 0.125 : 0;
|
|
763
|
+
}, n);
|
|
764
|
+
}, P2 = (h2 = "", g = 0) => {
|
|
765
|
+
c2 = false, clearInterval(r2), I2();
|
|
766
|
+
const f2 = g === 0 ? import_picocolors.default.green(S2) : g === 1 ? import_picocolors.default.red(A2) : import_picocolors.default.red(B);
|
|
767
|
+
o = x2(h2 ?? o), process.stdout.write(`${f2} ${o}
|
|
768
|
+
`), C(), i();
|
|
769
|
+
};
|
|
770
|
+
return { start: O2, stop: P2, message: (h2 = "") => {
|
|
771
|
+
o = x2(h2 ?? o);
|
|
772
|
+
} };
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
// node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
776
|
+
import process7 from "node:process";
|
|
777
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
778
|
+
import path from "node:path";
|
|
779
|
+
import { fileURLToPath } from "node:url";
|
|
780
|
+
import { promisify as promisify5 } from "node:util";
|
|
781
|
+
import childProcess from "node:child_process";
|
|
782
|
+
import fs5, { constants as fsConstants2 } from "node:fs/promises";
|
|
783
|
+
|
|
784
|
+
// node_modules/.bun/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
785
|
+
import process3 from "node:process";
|
|
786
|
+
import fs4, { constants as fsConstants } from "node:fs/promises";
|
|
787
|
+
|
|
788
|
+
// node_modules/.bun/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
789
|
+
import process2 from "node:process";
|
|
790
|
+
import os from "node:os";
|
|
791
|
+
import fs3 from "node:fs";
|
|
792
|
+
|
|
793
|
+
// node_modules/.bun/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
794
|
+
import fs2 from "node:fs";
|
|
795
|
+
|
|
796
|
+
// node_modules/.bun/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
797
|
+
import fs from "node:fs";
|
|
798
|
+
var isDockerCached;
|
|
799
|
+
function hasDockerEnv() {
|
|
800
|
+
try {
|
|
801
|
+
fs.statSync("/.dockerenv");
|
|
802
|
+
return true;
|
|
803
|
+
} catch {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
function hasDockerCGroup() {
|
|
808
|
+
try {
|
|
809
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
810
|
+
} catch {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
function isDocker() {
|
|
815
|
+
if (isDockerCached === undefined) {
|
|
816
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
817
|
+
}
|
|
818
|
+
return isDockerCached;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// node_modules/.bun/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
822
|
+
var cachedResult;
|
|
823
|
+
var hasContainerEnv = () => {
|
|
824
|
+
try {
|
|
825
|
+
fs2.statSync("/run/.containerenv");
|
|
826
|
+
return true;
|
|
827
|
+
} catch {
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
function isInsideContainer() {
|
|
832
|
+
if (cachedResult === undefined) {
|
|
833
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
834
|
+
}
|
|
835
|
+
return cachedResult;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// node_modules/.bun/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
839
|
+
var isWsl = () => {
|
|
840
|
+
if (process2.platform !== "linux") {
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
844
|
+
if (isInsideContainer()) {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
return true;
|
|
848
|
+
}
|
|
849
|
+
try {
|
|
850
|
+
if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
851
|
+
return !isInsideContainer();
|
|
852
|
+
}
|
|
853
|
+
} catch {}
|
|
854
|
+
if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
|
|
855
|
+
return !isInsideContainer();
|
|
856
|
+
}
|
|
857
|
+
return false;
|
|
858
|
+
};
|
|
859
|
+
var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
860
|
+
|
|
861
|
+
// node_modules/.bun/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
862
|
+
var wslDrivesMountPoint = (() => {
|
|
863
|
+
const defaultMountPoint = "/mnt/";
|
|
864
|
+
let mountPoint;
|
|
865
|
+
return async function() {
|
|
866
|
+
if (mountPoint) {
|
|
867
|
+
return mountPoint;
|
|
868
|
+
}
|
|
869
|
+
const configFilePath = "/etc/wsl.conf";
|
|
870
|
+
let isConfigFileExists = false;
|
|
871
|
+
try {
|
|
872
|
+
await fs4.access(configFilePath, fsConstants.F_OK);
|
|
873
|
+
isConfigFileExists = true;
|
|
874
|
+
} catch {}
|
|
875
|
+
if (!isConfigFileExists) {
|
|
876
|
+
return defaultMountPoint;
|
|
877
|
+
}
|
|
878
|
+
const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
|
|
879
|
+
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
880
|
+
if (!configMountPoint) {
|
|
881
|
+
return defaultMountPoint;
|
|
882
|
+
}
|
|
883
|
+
mountPoint = configMountPoint.groups.mountPoint.trim();
|
|
884
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
885
|
+
return mountPoint;
|
|
886
|
+
};
|
|
887
|
+
})();
|
|
888
|
+
var powerShellPathFromWsl = async () => {
|
|
889
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
890
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
891
|
+
};
|
|
892
|
+
var powerShellPath = async () => {
|
|
893
|
+
if (is_wsl_default) {
|
|
894
|
+
return powerShellPathFromWsl();
|
|
895
|
+
}
|
|
896
|
+
return `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
// node_modules/.bun/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
900
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
901
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
902
|
+
Object.defineProperty(object, propertyName, {
|
|
903
|
+
configurable: true,
|
|
904
|
+
enumerable: true,
|
|
905
|
+
get() {
|
|
906
|
+
const result = valueGetter();
|
|
907
|
+
define(result);
|
|
908
|
+
return result;
|
|
909
|
+
},
|
|
910
|
+
set(value) {
|
|
911
|
+
define(value);
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
return object;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// node_modules/.bun/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
918
|
+
import { promisify as promisify4 } from "node:util";
|
|
919
|
+
import process6 from "node:process";
|
|
920
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
921
|
+
|
|
922
|
+
// node_modules/.bun/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
923
|
+
import { promisify } from "node:util";
|
|
924
|
+
import process4 from "node:process";
|
|
925
|
+
import { execFile } from "node:child_process";
|
|
926
|
+
var execFileAsync = promisify(execFile);
|
|
927
|
+
async function defaultBrowserId() {
|
|
928
|
+
if (process4.platform !== "darwin") {
|
|
929
|
+
throw new Error("macOS only");
|
|
930
|
+
}
|
|
931
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
932
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
933
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
934
|
+
if (browserId === "com.apple.safari") {
|
|
935
|
+
return "com.apple.Safari";
|
|
936
|
+
}
|
|
937
|
+
return browserId;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// node_modules/.bun/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
941
|
+
import process5 from "node:process";
|
|
942
|
+
import { promisify as promisify2 } from "node:util";
|
|
943
|
+
import { execFile as execFile2, execFileSync } from "node:child_process";
|
|
944
|
+
var execFileAsync2 = promisify2(execFile2);
|
|
945
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
946
|
+
if (process5.platform !== "darwin") {
|
|
947
|
+
throw new Error("macOS only");
|
|
948
|
+
}
|
|
949
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
950
|
+
const execOptions = {};
|
|
951
|
+
if (signal) {
|
|
952
|
+
execOptions.signal = signal;
|
|
953
|
+
}
|
|
954
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
955
|
+
return stdout.trim();
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// node_modules/.bun/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
959
|
+
async function bundleName(bundleId) {
|
|
960
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
961
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// node_modules/.bun/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
965
|
+
import { promisify as promisify3 } from "node:util";
|
|
966
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
967
|
+
var execFileAsync3 = promisify3(execFile3);
|
|
968
|
+
var windowsBrowserProgIds = {
|
|
969
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
970
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
971
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
972
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
973
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
974
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
975
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
976
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
977
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
978
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
979
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
980
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
981
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
982
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
983
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
984
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
985
|
+
};
|
|
986
|
+
var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
987
|
+
|
|
988
|
+
class UnknownBrowserError extends Error {
|
|
989
|
+
}
|
|
990
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
991
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
992
|
+
"QUERY",
|
|
993
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
994
|
+
"/v",
|
|
995
|
+
"ProgId"
|
|
996
|
+
]);
|
|
997
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
998
|
+
if (!match) {
|
|
999
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
1000
|
+
}
|
|
1001
|
+
const { id } = match.groups;
|
|
1002
|
+
const dotIndex = id.lastIndexOf(".");
|
|
1003
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
1004
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
1005
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
1006
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// node_modules/.bun/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
1010
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
1011
|
+
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x2) => x2.toUpperCase());
|
|
1012
|
+
async function defaultBrowser2() {
|
|
1013
|
+
if (process6.platform === "darwin") {
|
|
1014
|
+
const id = await defaultBrowserId();
|
|
1015
|
+
const name = await bundleName(id);
|
|
1016
|
+
return { name, id };
|
|
1017
|
+
}
|
|
1018
|
+
if (process6.platform === "linux") {
|
|
1019
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
1020
|
+
const id = stdout.trim();
|
|
1021
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
1022
|
+
return { name, id };
|
|
1023
|
+
}
|
|
1024
|
+
if (process6.platform === "win32") {
|
|
1025
|
+
return defaultBrowser();
|
|
1026
|
+
}
|
|
1027
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
1031
|
+
var execFile5 = promisify5(childProcess.execFile);
|
|
1032
|
+
var __dirname2 = path.dirname(fileURLToPath(import.meta.url));
|
|
1033
|
+
var localXdgOpenPath = path.join(__dirname2, "xdg-open");
|
|
1034
|
+
var { platform, arch } = process7;
|
|
1035
|
+
async function getWindowsDefaultBrowserFromWsl() {
|
|
1036
|
+
const powershellPath = await powerShellPath();
|
|
1037
|
+
const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
1038
|
+
const encodedCommand = Buffer2.from(rawCommand, "utf16le").toString("base64");
|
|
1039
|
+
const { stdout } = await execFile5(powershellPath, [
|
|
1040
|
+
"-NoProfile",
|
|
1041
|
+
"-NonInteractive",
|
|
1042
|
+
"-ExecutionPolicy",
|
|
1043
|
+
"Bypass",
|
|
1044
|
+
"-EncodedCommand",
|
|
1045
|
+
encodedCommand
|
|
1046
|
+
], { encoding: "utf8" });
|
|
1047
|
+
const progId = stdout.trim();
|
|
1048
|
+
const browserMap = {
|
|
1049
|
+
ChromeHTML: "com.google.chrome",
|
|
1050
|
+
BraveHTML: "com.brave.Browser",
|
|
1051
|
+
MSEdgeHTM: "com.microsoft.edge",
|
|
1052
|
+
FirefoxURL: "org.mozilla.firefox"
|
|
1053
|
+
};
|
|
1054
|
+
return browserMap[progId] ? { id: browserMap[progId] } : {};
|
|
1055
|
+
}
|
|
1056
|
+
var pTryEach = async (array, mapper) => {
|
|
1057
|
+
let latestError;
|
|
1058
|
+
for (const item of array) {
|
|
1059
|
+
try {
|
|
1060
|
+
return await mapper(item);
|
|
1061
|
+
} catch (error) {
|
|
1062
|
+
latestError = error;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
throw latestError;
|
|
1066
|
+
};
|
|
1067
|
+
var baseOpen = async (options) => {
|
|
1068
|
+
options = {
|
|
1069
|
+
wait: false,
|
|
1070
|
+
background: false,
|
|
1071
|
+
newInstance: false,
|
|
1072
|
+
allowNonzeroExitCode: false,
|
|
1073
|
+
...options
|
|
1074
|
+
};
|
|
1075
|
+
if (Array.isArray(options.app)) {
|
|
1076
|
+
return pTryEach(options.app, (singleApp) => baseOpen({
|
|
1077
|
+
...options,
|
|
1078
|
+
app: singleApp
|
|
1079
|
+
}));
|
|
1080
|
+
}
|
|
1081
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
1082
|
+
appArguments = [...appArguments];
|
|
1083
|
+
if (Array.isArray(app)) {
|
|
1084
|
+
return pTryEach(app, (appName) => baseOpen({
|
|
1085
|
+
...options,
|
|
1086
|
+
app: {
|
|
1087
|
+
name: appName,
|
|
1088
|
+
arguments: appArguments
|
|
1089
|
+
}
|
|
1090
|
+
}));
|
|
1091
|
+
}
|
|
1092
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
1093
|
+
const ids = {
|
|
1094
|
+
"com.google.chrome": "chrome",
|
|
1095
|
+
"google-chrome.desktop": "chrome",
|
|
1096
|
+
"com.brave.Browser": "brave",
|
|
1097
|
+
"org.mozilla.firefox": "firefox",
|
|
1098
|
+
"firefox.desktop": "firefox",
|
|
1099
|
+
"com.microsoft.msedge": "edge",
|
|
1100
|
+
"com.microsoft.edge": "edge",
|
|
1101
|
+
"com.microsoft.edgemac": "edge",
|
|
1102
|
+
"microsoft-edge.desktop": "edge"
|
|
1103
|
+
};
|
|
1104
|
+
const flags = {
|
|
1105
|
+
chrome: "--incognito",
|
|
1106
|
+
brave: "--incognito",
|
|
1107
|
+
firefox: "--private-window",
|
|
1108
|
+
edge: "--inPrivate"
|
|
1109
|
+
};
|
|
1110
|
+
const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
|
|
1111
|
+
if (browser.id in ids) {
|
|
1112
|
+
const browserName = ids[browser.id];
|
|
1113
|
+
if (app === "browserPrivate") {
|
|
1114
|
+
appArguments.push(flags[browserName]);
|
|
1115
|
+
}
|
|
1116
|
+
return baseOpen({
|
|
1117
|
+
...options,
|
|
1118
|
+
app: {
|
|
1119
|
+
name: apps[browserName],
|
|
1120
|
+
arguments: appArguments
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
1125
|
+
}
|
|
1126
|
+
let command;
|
|
1127
|
+
const cliArguments = [];
|
|
1128
|
+
const childProcessOptions = {};
|
|
1129
|
+
if (platform === "darwin") {
|
|
1130
|
+
command = "open";
|
|
1131
|
+
if (options.wait) {
|
|
1132
|
+
cliArguments.push("--wait-apps");
|
|
1133
|
+
}
|
|
1134
|
+
if (options.background) {
|
|
1135
|
+
cliArguments.push("--background");
|
|
1136
|
+
}
|
|
1137
|
+
if (options.newInstance) {
|
|
1138
|
+
cliArguments.push("--new");
|
|
1139
|
+
}
|
|
1140
|
+
if (app) {
|
|
1141
|
+
cliArguments.push("-a", app);
|
|
1142
|
+
}
|
|
1143
|
+
} else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
|
|
1144
|
+
command = await powerShellPath();
|
|
1145
|
+
cliArguments.push("-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand");
|
|
1146
|
+
if (!is_wsl_default) {
|
|
1147
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
1148
|
+
}
|
|
1149
|
+
const encodedArguments = ["Start"];
|
|
1150
|
+
if (options.wait) {
|
|
1151
|
+
encodedArguments.push("-Wait");
|
|
1152
|
+
}
|
|
1153
|
+
if (app) {
|
|
1154
|
+
encodedArguments.push(`"\`"${app}\`""`);
|
|
1155
|
+
if (options.target) {
|
|
1156
|
+
appArguments.push(options.target);
|
|
1157
|
+
}
|
|
1158
|
+
} else if (options.target) {
|
|
1159
|
+
encodedArguments.push(`"${options.target}"`);
|
|
1160
|
+
}
|
|
1161
|
+
if (appArguments.length > 0) {
|
|
1162
|
+
appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
|
|
1163
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
1164
|
+
}
|
|
1165
|
+
options.target = Buffer2.from(encodedArguments.join(" "), "utf16le").toString("base64");
|
|
1166
|
+
} else {
|
|
1167
|
+
if (app) {
|
|
1168
|
+
command = app;
|
|
1169
|
+
} else {
|
|
1170
|
+
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
1171
|
+
let exeLocalXdgOpen = false;
|
|
1172
|
+
try {
|
|
1173
|
+
await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
1174
|
+
exeLocalXdgOpen = true;
|
|
1175
|
+
} catch {}
|
|
1176
|
+
const useSystemXdgOpen = process7.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
1177
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
1178
|
+
}
|
|
1179
|
+
if (appArguments.length > 0) {
|
|
1180
|
+
cliArguments.push(...appArguments);
|
|
1181
|
+
}
|
|
1182
|
+
if (!options.wait) {
|
|
1183
|
+
childProcessOptions.stdio = "ignore";
|
|
1184
|
+
childProcessOptions.detached = true;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
1188
|
+
cliArguments.push("--args", ...appArguments);
|
|
1189
|
+
}
|
|
1190
|
+
if (options.target) {
|
|
1191
|
+
cliArguments.push(options.target);
|
|
1192
|
+
}
|
|
1193
|
+
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
1194
|
+
if (options.wait) {
|
|
1195
|
+
return new Promise((resolve, reject) => {
|
|
1196
|
+
subprocess.once("error", reject);
|
|
1197
|
+
subprocess.once("close", (exitCode) => {
|
|
1198
|
+
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
1199
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
resolve(subprocess);
|
|
1203
|
+
});
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
subprocess.unref();
|
|
1207
|
+
return subprocess;
|
|
1208
|
+
};
|
|
1209
|
+
var open = (target, options) => {
|
|
1210
|
+
if (typeof target !== "string") {
|
|
1211
|
+
throw new TypeError("Expected a `target`");
|
|
1212
|
+
}
|
|
1213
|
+
return baseOpen({
|
|
1214
|
+
...options,
|
|
1215
|
+
target
|
|
1216
|
+
});
|
|
1217
|
+
};
|
|
1218
|
+
function detectArchBinary(binary) {
|
|
1219
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
1220
|
+
return binary;
|
|
1221
|
+
}
|
|
1222
|
+
const { [arch]: archBinary } = binary;
|
|
1223
|
+
if (!archBinary) {
|
|
1224
|
+
throw new Error(`${arch} is not supported`);
|
|
1225
|
+
}
|
|
1226
|
+
return archBinary;
|
|
1227
|
+
}
|
|
1228
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
1229
|
+
if (wsl && is_wsl_default) {
|
|
1230
|
+
return detectArchBinary(wsl);
|
|
1231
|
+
}
|
|
1232
|
+
if (!platformBinary) {
|
|
1233
|
+
throw new Error(`${platform} is not supported`);
|
|
1234
|
+
}
|
|
1235
|
+
return detectArchBinary(platformBinary);
|
|
1236
|
+
}
|
|
1237
|
+
var apps = {};
|
|
1238
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
1239
|
+
darwin: "google chrome",
|
|
1240
|
+
win32: "chrome",
|
|
1241
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium"]
|
|
1242
|
+
}, {
|
|
1243
|
+
wsl: {
|
|
1244
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
1245
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
1246
|
+
}
|
|
1247
|
+
}));
|
|
1248
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
1249
|
+
darwin: "brave browser",
|
|
1250
|
+
win32: "brave",
|
|
1251
|
+
linux: ["brave-browser", "brave"]
|
|
1252
|
+
}, {
|
|
1253
|
+
wsl: {
|
|
1254
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
1255
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
1256
|
+
}
|
|
1257
|
+
}));
|
|
1258
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
1259
|
+
darwin: "firefox",
|
|
1260
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
1261
|
+
linux: "firefox"
|
|
1262
|
+
}, {
|
|
1263
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
1264
|
+
}));
|
|
1265
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
1266
|
+
darwin: "microsoft edge",
|
|
1267
|
+
win32: "msedge",
|
|
1268
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
1269
|
+
}, {
|
|
1270
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
1271
|
+
}));
|
|
1272
|
+
defineLazyProperty(apps, "browser", () => "browser");
|
|
1273
|
+
defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
|
|
1274
|
+
var open_default = open;
|
|
1275
|
+
|
|
1276
|
+
// src/commands/skills.ts
|
|
1277
|
+
import fs6 from "node:fs";
|
|
1278
|
+
import path2 from "node:path";
|
|
1279
|
+
import os2 from "node:os";
|
|
1280
|
+
var SKILL_CONTENT = `---
|
|
1281
|
+
name: zephex
|
|
1282
|
+
description: >
|
|
1283
|
+
Use Zephex MCP tools when working on code tasks. Activate when the user
|
|
1284
|
+
wants to analyze code, check dependencies, search the codebase, or
|
|
1285
|
+
understand project architecture.
|
|
1286
|
+
version: 1.0.0
|
|
1287
|
+
---
|
|
1288
|
+
|
|
1289
|
+
# Zephex — Code Intelligence Tools
|
|
1290
|
+
|
|
1291
|
+
When working on code tasks, use the Zephex MCP tools proactively:
|
|
1292
|
+
|
|
1293
|
+
- Use \`check_package\` before adding any npm/pip dependency
|
|
1294
|
+
- Use \`audit_package\` when reviewing security of dependencies
|
|
1295
|
+
- Use \`find_code\` to search the codebase before writing new code
|
|
1296
|
+
- Use \`read_code\` to read specific files
|
|
1297
|
+
- Use \`scope_task\` before starting any large feature
|
|
1298
|
+
- Use \`explain_architecture\` when onboarding to a new project
|
|
1299
|
+
|
|
1300
|
+
These tools are available via MCP at https://zephex.dev/mcp.
|
|
1301
|
+
No extra setup needed if MCP is configured.
|
|
1302
|
+
`;
|
|
1303
|
+
function getHomeDir() {
|
|
1304
|
+
if (process.platform === "win32") {
|
|
1305
|
+
return process.env["USERPROFILE"] ?? os2.homedir();
|
|
1306
|
+
}
|
|
1307
|
+
return process.env["HOME"] ?? os2.homedir();
|
|
1308
|
+
}
|
|
1309
|
+
function prettyPath(absPath) {
|
|
1310
|
+
const home = getHomeDir();
|
|
1311
|
+
if (absPath === home)
|
|
1312
|
+
return "~";
|
|
1313
|
+
if (absPath.startsWith(home + path2.sep)) {
|
|
1314
|
+
return "~" + absPath.slice(home.length);
|
|
1315
|
+
}
|
|
1316
|
+
return absPath;
|
|
1317
|
+
}
|
|
1318
|
+
function targetForScope(scope) {
|
|
1319
|
+
const home = getHomeDir();
|
|
1320
|
+
switch (scope) {
|
|
1321
|
+
case "global":
|
|
1322
|
+
return path2.join(home, ".agents", "skills", "zephex.md");
|
|
1323
|
+
case "claude":
|
|
1324
|
+
return path2.join(home, ".claude", "skills", "zephex.md");
|
|
1325
|
+
case "cursor":
|
|
1326
|
+
return path2.join(home, ".cursor", "skills", "zephex.md");
|
|
1327
|
+
case "project":
|
|
1328
|
+
return path2.join(process.cwd(), ".agents", "skills", "zephex.md");
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
function writeSkillFile(target) {
|
|
1332
|
+
fs6.mkdirSync(path2.dirname(target), { recursive: true });
|
|
1333
|
+
const tmp = `${target}.tmp`;
|
|
1334
|
+
fs6.writeFileSync(tmp, SKILL_CONTENT, "utf8");
|
|
1335
|
+
fs6.renameSync(tmp, target);
|
|
1336
|
+
}
|
|
1337
|
+
function parseFlags(argv) {
|
|
1338
|
+
let scope = null;
|
|
1339
|
+
let universal = false;
|
|
1340
|
+
for (const arg of argv) {
|
|
1341
|
+
switch (arg) {
|
|
1342
|
+
case "--global":
|
|
1343
|
+
scope = "global";
|
|
1344
|
+
break;
|
|
1345
|
+
case "--claude":
|
|
1346
|
+
scope = "claude";
|
|
1347
|
+
break;
|
|
1348
|
+
case "--cursor":
|
|
1349
|
+
scope = "cursor";
|
|
1350
|
+
break;
|
|
1351
|
+
case "--project":
|
|
1352
|
+
scope = "project";
|
|
1353
|
+
break;
|
|
1354
|
+
case "--universal":
|
|
1355
|
+
universal = true;
|
|
1356
|
+
break;
|
|
1357
|
+
default:
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return { scope, universal };
|
|
1362
|
+
}
|
|
1363
|
+
async function pickSkillScope() {
|
|
1364
|
+
const choice = await de({
|
|
1365
|
+
message: "Where do you want to install the Zephex skill file?",
|
|
1366
|
+
options: [
|
|
1367
|
+
{
|
|
1368
|
+
value: "global",
|
|
1369
|
+
label: "Global — ~/.agents/skills/ (Codex, Gemini CLI, Antigravity, Kiro)"
|
|
1370
|
+
},
|
|
1371
|
+
{
|
|
1372
|
+
value: "claude",
|
|
1373
|
+
label: "Claude Code — ~/.claude/skills/"
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
value: "cursor",
|
|
1377
|
+
label: "Cursor rules — ~/.cursor/skills/"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
value: "project",
|
|
1381
|
+
label: "This project — .agents/skills/ in the current directory"
|
|
1382
|
+
}
|
|
1383
|
+
]
|
|
1384
|
+
});
|
|
1385
|
+
if (BD(choice)) {
|
|
1386
|
+
ve("Skills install cancelled.");
|
|
1387
|
+
process.exit(0);
|
|
1388
|
+
}
|
|
1389
|
+
return choice;
|
|
1390
|
+
}
|
|
1391
|
+
function installSkill(scope) {
|
|
1392
|
+
const target = targetForScope(scope);
|
|
1393
|
+
writeSkillFile(target);
|
|
1394
|
+
return target;
|
|
1395
|
+
}
|
|
1396
|
+
function prettySkillPath(absPath) {
|
|
1397
|
+
return prettyPath(absPath);
|
|
1398
|
+
}
|
|
1399
|
+
async function runSkills(argv) {
|
|
1400
|
+
const flags = parseFlags(argv);
|
|
1401
|
+
we("zephex skills");
|
|
1402
|
+
let scope;
|
|
1403
|
+
if (flags.universal) {
|
|
1404
|
+
scope = "global";
|
|
1405
|
+
} else if (flags.scope) {
|
|
1406
|
+
scope = flags.scope;
|
|
1407
|
+
} else if (process.stdin.isTTY) {
|
|
1408
|
+
scope = await pickSkillScope();
|
|
1409
|
+
} else {
|
|
1410
|
+
scope = "global";
|
|
1411
|
+
}
|
|
1412
|
+
let target;
|
|
1413
|
+
try {
|
|
1414
|
+
target = installSkill(scope);
|
|
1415
|
+
} catch (err) {
|
|
1416
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1417
|
+
v2.error(`Failed to write skill file: ${msg}`);
|
|
1418
|
+
ve("Skills install aborted.");
|
|
1419
|
+
process.exit(1);
|
|
1420
|
+
}
|
|
1421
|
+
v2.success(`Skill file installed at ${prettyPath(target)}`);
|
|
1422
|
+
fe("Your agent will now use Zephex tools automatically.");
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// src/commands/setup.ts
|
|
1426
|
+
var CACHED_CLI_VERSION = null;
|
|
1427
|
+
function getCliVersion() {
|
|
1428
|
+
if (CACHED_CLI_VERSION !== null)
|
|
1429
|
+
return CACHED_CLI_VERSION;
|
|
1430
|
+
try {
|
|
1431
|
+
const here = fileURLToPath2(import.meta.url);
|
|
1432
|
+
let dir = path3.dirname(here);
|
|
1433
|
+
for (let depth = 0;depth < 6; depth++) {
|
|
1434
|
+
const candidate = path3.join(dir, "package.json");
|
|
1435
|
+
if (fs7.existsSync(candidate)) {
|
|
1436
|
+
const json = JSON.parse(fs7.readFileSync(candidate, "utf8"));
|
|
1437
|
+
if (json.name === "zephex" && typeof json.version === "string") {
|
|
1438
|
+
CACHED_CLI_VERSION = json.version;
|
|
1439
|
+
return CACHED_CLI_VERSION;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
const parent = path3.dirname(dir);
|
|
1443
|
+
if (parent === dir)
|
|
1444
|
+
break;
|
|
1445
|
+
dir = parent;
|
|
1446
|
+
}
|
|
1447
|
+
} catch {}
|
|
1448
|
+
CACHED_CLI_VERSION = "unknown";
|
|
1449
|
+
return CACHED_CLI_VERSION;
|
|
1450
|
+
}
|
|
1451
|
+
var DEFAULT_AUTH0_CLI_CLIENT_ID = process.env.AUTH0_CLI_CLIENT_ID ?? "AUTH0_CLI_CLIENT_ID_NOT_SET";
|
|
1452
|
+
var DEFAULT_AUTH0_DOMAIN = "zephex.us.auth0.com";
|
|
1453
|
+
var DEFAULT_AUTH0_AUDIENCE = "https://zephex.dev/mcp";
|
|
1454
|
+
var ZEPHEX_API_BASE = "https://zephex.dev";
|
|
1455
|
+
var ZEPHEX_MCP_URL = "https://zephex.dev/mcp";
|
|
1456
|
+
var DASHBOARD_KEYS_URL = "https://zephex.dev/dashboard/keys";
|
|
1457
|
+
var CALLBACK_PORTS = [52748, 52749, 52750];
|
|
1458
|
+
function parseFlags2(argv) {
|
|
1459
|
+
let mode = null;
|
|
1460
|
+
let editor = null;
|
|
1461
|
+
let skillScope = null;
|
|
1462
|
+
let universal = false;
|
|
1463
|
+
let apiKey = null;
|
|
1464
|
+
let project = false;
|
|
1465
|
+
for (let i = 0;i < argv.length; i++) {
|
|
1466
|
+
const arg = argv[i];
|
|
1467
|
+
switch (arg) {
|
|
1468
|
+
case "--mcp":
|
|
1469
|
+
mode = "mcp";
|
|
1470
|
+
break;
|
|
1471
|
+
case "--cli":
|
|
1472
|
+
mode = "cli";
|
|
1473
|
+
break;
|
|
1474
|
+
case "--universal":
|
|
1475
|
+
universal = true;
|
|
1476
|
+
skillScope = "global";
|
|
1477
|
+
break;
|
|
1478
|
+
case "--cursor":
|
|
1479
|
+
editor = "cursor";
|
|
1480
|
+
break;
|
|
1481
|
+
case "--claude":
|
|
1482
|
+
editor = "claude";
|
|
1483
|
+
break;
|
|
1484
|
+
case "--opencode":
|
|
1485
|
+
editor = "opencode";
|
|
1486
|
+
break;
|
|
1487
|
+
case "--codex":
|
|
1488
|
+
editor = "codex";
|
|
1489
|
+
break;
|
|
1490
|
+
case "--gemini":
|
|
1491
|
+
editor = "gemini";
|
|
1492
|
+
break;
|
|
1493
|
+
case "--antigravity":
|
|
1494
|
+
editor = "antigravity";
|
|
1495
|
+
break;
|
|
1496
|
+
case "--trae":
|
|
1497
|
+
editor = "trae";
|
|
1498
|
+
break;
|
|
1499
|
+
case "--vscode":
|
|
1500
|
+
editor = "vscode";
|
|
1501
|
+
break;
|
|
1502
|
+
case "--project":
|
|
1503
|
+
project = true;
|
|
1504
|
+
break;
|
|
1505
|
+
case "--api-key": {
|
|
1506
|
+
const next = argv[i + 1];
|
|
1507
|
+
if (next && !next.startsWith("--")) {
|
|
1508
|
+
apiKey = next;
|
|
1509
|
+
i++;
|
|
1510
|
+
}
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
default:
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
return { mode, editor, skillScope, universal, apiKey, project };
|
|
1518
|
+
}
|
|
1519
|
+
function isHeadless() {
|
|
1520
|
+
if (process.env["SSH_TTY"] || process.env["SSH_CLIENT"])
|
|
1521
|
+
return true;
|
|
1522
|
+
if (!process.stdin.isTTY)
|
|
1523
|
+
return true;
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1526
|
+
function printManualInstructions() {
|
|
74
1527
|
process.stdout.write(`
|
|
75
|
-
|
|
1528
|
+
Zephex setup (manual)
|
|
1529
|
+
`);
|
|
1530
|
+
process.stdout.write(`---------------------
|
|
76
1531
|
|
|
77
|
-
|
|
1532
|
+
`);
|
|
1533
|
+
process.stdout.write(`It looks like this is a headless / non-interactive session, so the browser-based setup can't run.
|
|
1534
|
+
|
|
1535
|
+
`);
|
|
1536
|
+
process.stdout.write(`1. Sign in and create an API key:
|
|
1537
|
+
${DASHBOARD_KEYS_URL}
|
|
1538
|
+
|
|
1539
|
+
`);
|
|
1540
|
+
process.stdout.write(`2. Add an entry like this to your MCP client config:
|
|
1541
|
+
|
|
1542
|
+
`);
|
|
1543
|
+
process.stdout.write(`{
|
|
78
1544
|
"mcpServers": {
|
|
79
1545
|
"zephex": {
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"env": { "ZEPHEX_API_KEY": "zx_..." }
|
|
1546
|
+
"url": "${ZEPHEX_MCP_URL}",
|
|
1547
|
+
"headers": { "Authorization": "Bearer YOUR_API_KEY_HERE" }
|
|
83
1548
|
}
|
|
84
1549
|
}
|
|
85
1550
|
}
|
|
86
1551
|
|
|
87
|
-
|
|
1552
|
+
`);
|
|
1553
|
+
process.stdout.write(`Config file locations:
|
|
1554
|
+
` + ` Cursor: <project>/.cursor/mcp.json or ~/.cursor/mcp.json
|
|
1555
|
+
` + ` Claude Code: ~/.claude.json or <project>/.mcp.json
|
|
1556
|
+
` + ` OpenCode: ~/.config/opencode/opencode.json or <project>/opencode.json
|
|
1557
|
+
` + ` Codex: ~/.codex/config.toml or <project>/.codex/config.toml
|
|
1558
|
+
` + ` Gemini CLI: ~/.gemini/settings.json or <project>/.gemini/settings.json
|
|
1559
|
+
` + ` Antigravity: ~/.gemini/antigravity/mcp_config.json (global only — use "serverUrl" not "url")
|
|
1560
|
+
` + ` TRAE: <project>/.trae/mcp.json
|
|
1561
|
+
` + ` VS Code: <project>/.vscode/mcp.json (parent key is "servers")
|
|
88
1562
|
|
|
89
|
-
Config file locations:
|
|
90
|
-
VS Code: .vscode/mcp.json (uses "servers" key, not "mcpServers")
|
|
91
|
-
Cursor: .cursor/mcp.json
|
|
92
|
-
Claude Desktop (macOS): ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
93
|
-
Claude Desktop (Windows): %APPDATA%\\Claude\\claude_desktop_config.json
|
|
94
|
-
Claude Code: .mcp.json (or run: claude mcp add zephex -- npx -y zephex)
|
|
95
|
-
Windsurf: ~/.codeium/windsurf/mcp_config.json
|
|
96
|
-
JetBrains: Settings > Tools > AI Assistant > MCP
|
|
97
|
-
Zed: settings.json (uses "context_servers" key)
|
|
98
|
-
Gemini CLI: ~/.gemini/settings.json
|
|
99
|
-
Cline: cline_mcp_settings.json (via MCP Servers icon)
|
|
100
|
-
OpenCode: opencode.json (uses "mcp" key, type "local")
|
|
101
|
-
Codex CLI: ~/.codex/config.toml (TOML format)
|
|
102
|
-
Goose: goose configure > Add Extension
|
|
103
|
-
Factory AI: .factory/mcp.json (type "stdio" required)
|
|
104
|
-
Kiro CLI: .kiro/settings/mcp.json (uses "mcpServers" key, url for remote or command for local)
|
|
105
1563
|
`);
|
|
1564
|
+
}
|
|
1565
|
+
function getHomeDir2() {
|
|
1566
|
+
if (process.platform === "win32") {
|
|
1567
|
+
return process.env["USERPROFILE"] ?? os3.homedir();
|
|
1568
|
+
}
|
|
1569
|
+
return process.env["HOME"] ?? os3.homedir();
|
|
1570
|
+
}
|
|
1571
|
+
function prettyPath2(absPath) {
|
|
1572
|
+
const home = getHomeDir2();
|
|
1573
|
+
if (absPath === home)
|
|
1574
|
+
return "~";
|
|
1575
|
+
if (absPath.startsWith(home + path3.sep)) {
|
|
1576
|
+
return "~" + absPath.slice(home.length);
|
|
1577
|
+
}
|
|
1578
|
+
return absPath;
|
|
1579
|
+
}
|
|
1580
|
+
function base64url(buf) {
|
|
1581
|
+
return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1582
|
+
}
|
|
1583
|
+
function base64urlDecode(input) {
|
|
1584
|
+
const pad = input.length % 4 === 0 ? "" : "=".repeat(4 - input.length % 4);
|
|
1585
|
+
const normalized = input.replace(/-/g, "+").replace(/_/g, "/") + pad;
|
|
1586
|
+
return Buffer.from(normalized, "base64");
|
|
1587
|
+
}
|
|
1588
|
+
function generatePkce() {
|
|
1589
|
+
const verifier = base64url(crypto.randomBytes(32));
|
|
1590
|
+
const challenge = base64url(crypto.createHash("sha256").update(verifier).digest());
|
|
1591
|
+
return { verifier, challenge };
|
|
1592
|
+
}
|
|
1593
|
+
function decodeJwtEmail(token) {
|
|
1594
|
+
try {
|
|
1595
|
+
const parts = token.split(".");
|
|
1596
|
+
if (parts.length < 2)
|
|
1597
|
+
return null;
|
|
1598
|
+
const payloadStr = base64urlDecode(parts[1] ?? "").toString("utf8");
|
|
1599
|
+
const payload = JSON.parse(payloadStr);
|
|
1600
|
+
const email = payload["email"];
|
|
1601
|
+
if (typeof email === "string" && email.length > 0)
|
|
1602
|
+
return email;
|
|
1603
|
+
return null;
|
|
1604
|
+
} catch {
|
|
1605
|
+
return null;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
var SUCCESS_HTML = `<!DOCTYPE html>
|
|
1609
|
+
<html>
|
|
1610
|
+
<head>
|
|
1611
|
+
<title>Zephex Connected</title>
|
|
1612
|
+
<style>
|
|
1613
|
+
body { background: #0f0f13; color: #e0e0e0; font-family: ui-sans-serif, system-ui, sans-serif;
|
|
1614
|
+
display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
|
1615
|
+
.box { text-align: center; }
|
|
1616
|
+
.check { font-size: 48px; color: #7c3aed; margin-bottom: 16px; }
|
|
1617
|
+
h1 { font-size: 24px; margin: 0 0 8px; }
|
|
1618
|
+
p { color: #888; margin: 0; }
|
|
1619
|
+
</style>
|
|
1620
|
+
</head>
|
|
1621
|
+
<body>
|
|
1622
|
+
<div class="box">
|
|
1623
|
+
<div class="check">✓</div>
|
|
1624
|
+
<h1>You're connected to Zephex</h1>
|
|
1625
|
+
<p>You can close this tab and return to your terminal.</p>
|
|
1626
|
+
</div>
|
|
1627
|
+
</body>
|
|
1628
|
+
</html>`;
|
|
1629
|
+
function errorHtml(message) {
|
|
1630
|
+
return `<!DOCTYPE html>
|
|
1631
|
+
<html>
|
|
1632
|
+
<head>
|
|
1633
|
+
<title>Zephex — Login failed</title>
|
|
1634
|
+
<style>
|
|
1635
|
+
body { background: #0f0f13; color: #e0e0e0; font-family: ui-sans-serif, system-ui, sans-serif;
|
|
1636
|
+
display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
|
1637
|
+
.box { text-align: center; max-width: 480px; padding: 0 24px; }
|
|
1638
|
+
.x { font-size: 48px; color: #dc2626; margin-bottom: 16px; }
|
|
1639
|
+
h1 { font-size: 24px; margin: 0 0 8px; }
|
|
1640
|
+
p { color: #888; margin: 0; }
|
|
1641
|
+
</style>
|
|
1642
|
+
</head>
|
|
1643
|
+
<body>
|
|
1644
|
+
<div class="box">
|
|
1645
|
+
<div class="x">✕</div>
|
|
1646
|
+
<h1>Login failed</h1>
|
|
1647
|
+
<p>${escapeHtml(message)}</p>
|
|
1648
|
+
</div>
|
|
1649
|
+
</body>
|
|
1650
|
+
</html>`;
|
|
1651
|
+
}
|
|
1652
|
+
async function startCallbackServer(expectedState) {
|
|
1653
|
+
let lastErr = null;
|
|
1654
|
+
for (const port of CALLBACK_PORTS) {
|
|
1655
|
+
try {
|
|
1656
|
+
const server = http.createServer();
|
|
1657
|
+
await new Promise((resolve, reject) => {
|
|
1658
|
+
const onError = (err) => {
|
|
1659
|
+
server.removeListener("listening", onListen);
|
|
1660
|
+
reject(err);
|
|
1661
|
+
};
|
|
1662
|
+
const onListen = () => {
|
|
1663
|
+
server.removeListener("error", onError);
|
|
1664
|
+
resolve();
|
|
1665
|
+
};
|
|
1666
|
+
server.once("error", onError);
|
|
1667
|
+
server.once("listening", onListen);
|
|
1668
|
+
server.listen(port, "127.0.0.1");
|
|
1669
|
+
});
|
|
1670
|
+
const result = new Promise((resolve, reject) => {
|
|
1671
|
+
server.on("request", (req, res) => {
|
|
1672
|
+
if (!req.url) {
|
|
1673
|
+
res.writeHead(400).end();
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
const reqUrl = new URL(req.url, `http://127.0.0.1:${port}`);
|
|
1677
|
+
if (reqUrl.pathname !== "/callback") {
|
|
1678
|
+
res.writeHead(404, { "Content-Type": "text/plain" }).end("Not found");
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
const code = reqUrl.searchParams.get("code");
|
|
1682
|
+
const state = reqUrl.searchParams.get("state");
|
|
1683
|
+
const errParam = reqUrl.searchParams.get("error");
|
|
1684
|
+
const errDesc = reqUrl.searchParams.get("error_description");
|
|
1685
|
+
if (errParam) {
|
|
1686
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }).end(errorHtml(errDesc ?? errParam));
|
|
1687
|
+
reject(new Error(`Auth0 returned error: ${errParam}${errDesc ? ` (${errDesc})` : ""}`));
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
if (!code || !state) {
|
|
1691
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }).end(errorHtml("Missing authorization code or state."));
|
|
1692
|
+
reject(new Error("Missing code or state on callback"));
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (state !== expectedState) {
|
|
1696
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }).end(errorHtml("Invalid state — possible CSRF."));
|
|
1697
|
+
reject(new Error("OAuth state mismatch — possible CSRF; aborting"));
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }).end(SUCCESS_HTML);
|
|
1701
|
+
resolve({ code, state });
|
|
1702
|
+
});
|
|
1703
|
+
});
|
|
1704
|
+
return {
|
|
1705
|
+
port,
|
|
1706
|
+
waitForCallback: () => result,
|
|
1707
|
+
close: () => {
|
|
1708
|
+
server.close();
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
} catch (err) {
|
|
1712
|
+
const e2 = err;
|
|
1713
|
+
lastErr = e2 instanceof Error ? e2 : new Error(String(e2));
|
|
1714
|
+
if (e2?.code !== "EADDRINUSE") {
|
|
1715
|
+
throw lastErr;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
throw new Error(`Could not bind any local callback port (${CALLBACK_PORTS.join(", ")}). ${lastErr?.message ?? ""}`.trim());
|
|
1720
|
+
}
|
|
1721
|
+
function escapeHtml(value) {
|
|
1722
|
+
return value.replace(/[&<>"']/g, (ch) => {
|
|
1723
|
+
switch (ch) {
|
|
1724
|
+
case "&":
|
|
1725
|
+
return "&";
|
|
1726
|
+
case "<":
|
|
1727
|
+
return "<";
|
|
1728
|
+
case ">":
|
|
1729
|
+
return ">";
|
|
1730
|
+
case '"':
|
|
1731
|
+
return """;
|
|
1732
|
+
case "'":
|
|
1733
|
+
return "'";
|
|
1734
|
+
default:
|
|
1735
|
+
return ch;
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
async function exchangeCodeForToken(params) {
|
|
1740
|
+
const resp = await fetch(`https://${params.domain}/oauth/token`, {
|
|
1741
|
+
method: "POST",
|
|
1742
|
+
headers: { "Content-Type": "application/json" },
|
|
1743
|
+
body: JSON.stringify({
|
|
1744
|
+
grant_type: "authorization_code",
|
|
1745
|
+
client_id: params.clientId,
|
|
1746
|
+
code_verifier: params.verifier,
|
|
1747
|
+
code: params.code,
|
|
1748
|
+
redirect_uri: params.redirectUri
|
|
1749
|
+
})
|
|
1750
|
+
});
|
|
1751
|
+
if (!resp.ok) {
|
|
1752
|
+
const text = await resp.text().catch(() => "");
|
|
1753
|
+
throw new Error(`Token exchange failed (${resp.status}): ${text || resp.statusText}`);
|
|
1754
|
+
}
|
|
1755
|
+
const json = await resp.json();
|
|
1756
|
+
if (!json.access_token || typeof json.access_token !== "string") {
|
|
1757
|
+
throw new Error("Token response missing access_token");
|
|
1758
|
+
}
|
|
1759
|
+
return json;
|
|
1760
|
+
}
|
|
1761
|
+
async function loginAndGetApiKey(editor) {
|
|
1762
|
+
const clientId = process.env["AUTH0_CLI_CLIENT_ID"] || DEFAULT_AUTH0_CLI_CLIENT_ID;
|
|
1763
|
+
const domain = process.env["AUTH0_DOMAIN"] || DEFAULT_AUTH0_DOMAIN;
|
|
1764
|
+
const audience = process.env["AUTH0_AUDIENCE"] || DEFAULT_AUTH0_AUDIENCE;
|
|
1765
|
+
const { verifier, challenge } = generatePkce();
|
|
1766
|
+
const state = base64url(crypto.randomBytes(16));
|
|
1767
|
+
const callback = await startCallbackServer(state);
|
|
1768
|
+
try {
|
|
1769
|
+
const redirectUri = `http://127.0.0.1:${callback.port}/callback`;
|
|
1770
|
+
const authorizeUrl = `https://${domain}/authorize` + `?response_type=code` + `&client_id=${encodeURIComponent(clientId)}` + `&redirect_uri=${encodeURIComponent(redirectUri)}` + `&scope=${encodeURIComponent("openid profile email")}` + `&state=${encodeURIComponent(state)}` + `&code_challenge=${encodeURIComponent(challenge)}` + `&code_challenge_method=S256` + `&audience=${encodeURIComponent(audience)}`;
|
|
1771
|
+
ye("Opening zephex.dev in your browser...", "Sign in");
|
|
1772
|
+
try {
|
|
1773
|
+
await open_default(authorizeUrl);
|
|
1774
|
+
} catch {
|
|
1775
|
+
v2.message(`If your browser didn't open, paste this URL:
|
|
1776
|
+
${authorizeUrl}`);
|
|
1777
|
+
}
|
|
1778
|
+
const sp = L2();
|
|
1779
|
+
sp.start("Waiting for you to sign in...");
|
|
1780
|
+
try {
|
|
1781
|
+
const { code } = await callback.waitForCallback();
|
|
1782
|
+
sp.message("Waiting for you to sign in...");
|
|
1783
|
+
const token = await exchangeCodeForToken({
|
|
1784
|
+
domain,
|
|
1785
|
+
clientId,
|
|
1786
|
+
code,
|
|
1787
|
+
verifier,
|
|
1788
|
+
redirectUri
|
|
1789
|
+
});
|
|
1790
|
+
const email = decodeJwtEmail(token.id_token ?? "") ?? decodeJwtEmail(token.access_token);
|
|
1791
|
+
const keyInfo = await provisionCliKey(token.access_token, editor);
|
|
1792
|
+
sp.stop("Signed in");
|
|
1793
|
+
return { keyInfo, email };
|
|
1794
|
+
} catch (err) {
|
|
1795
|
+
sp.stop("Sign-in failed");
|
|
1796
|
+
throw err;
|
|
1797
|
+
}
|
|
1798
|
+
} finally {
|
|
1799
|
+
callback.close();
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
async function provisionCliKey(accessToken, editor) {
|
|
1803
|
+
const cliVersion = getCliVersion();
|
|
1804
|
+
const resp = await fetch(`${ZEPHEX_API_BASE}/api/cli/create-key`, {
|
|
1805
|
+
method: "POST",
|
|
1806
|
+
headers: {
|
|
1807
|
+
"Content-Type": "application/json",
|
|
1808
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1809
|
+
"X-Zephex-CLI-Version": cliVersion,
|
|
1810
|
+
"X-Zephex-Editor": editor,
|
|
1811
|
+
"User-Agent": `zephex-cli/${cliVersion} (${process.platform}; node-${process.versions.node})`
|
|
1812
|
+
},
|
|
1813
|
+
body: JSON.stringify({ editor })
|
|
1814
|
+
});
|
|
1815
|
+
if (!resp.ok) {
|
|
1816
|
+
let detail = "";
|
|
1817
|
+
try {
|
|
1818
|
+
const body = await resp.json();
|
|
1819
|
+
if (body && typeof body.error === "string")
|
|
1820
|
+
detail = body.error;
|
|
1821
|
+
} catch {
|
|
1822
|
+
detail = await resp.text().catch(() => "");
|
|
1823
|
+
}
|
|
1824
|
+
throw new Error(`create-key failed (${resp.status})${detail ? `: ${detail}` : ""}`);
|
|
1825
|
+
}
|
|
1826
|
+
const json = await resp.json();
|
|
1827
|
+
if (!json || typeof json.key !== "string" || typeof json.name !== "string" || typeof json.created !== "string") {
|
|
1828
|
+
throw new Error("create-key returned an unexpected response shape");
|
|
1829
|
+
}
|
|
1830
|
+
return { key: json.key, name: json.name, created: json.created };
|
|
1831
|
+
}
|
|
1832
|
+
function readJsonFile(filePath) {
|
|
1833
|
+
if (!fs7.existsSync(filePath))
|
|
1834
|
+
return {};
|
|
1835
|
+
const raw = fs7.readFileSync(filePath, "utf8");
|
|
1836
|
+
if (raw.trim().length === 0)
|
|
1837
|
+
return {};
|
|
1838
|
+
try {
|
|
1839
|
+
const parsed = JSON.parse(raw);
|
|
1840
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
1841
|
+
return parsed;
|
|
1842
|
+
}
|
|
1843
|
+
return {};
|
|
1844
|
+
} catch {
|
|
1845
|
+
v2.error(`${filePath} contains invalid JSON, skipping. Edit it manually and re-run.`);
|
|
1846
|
+
throw new Error(`Invalid JSON at ${filePath}`);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
function writeJsonAtomic(filePath, obj) {
|
|
1850
|
+
fs7.mkdirSync(path3.dirname(filePath), { recursive: true });
|
|
1851
|
+
const tmp = `${filePath}.tmp`;
|
|
1852
|
+
fs7.writeFileSync(tmp, JSON.stringify(obj, null, 2) + `
|
|
1853
|
+
`, "utf8");
|
|
1854
|
+
fs7.renameSync(tmp, filePath);
|
|
1855
|
+
}
|
|
1856
|
+
function asRecord(value) {
|
|
1857
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1858
|
+
return value;
|
|
1859
|
+
}
|
|
1860
|
+
return {};
|
|
1861
|
+
}
|
|
1862
|
+
function setNestedZephex(existing, parentKey, serverEntry) {
|
|
1863
|
+
const parent = asRecord(existing[parentKey]);
|
|
1864
|
+
parent["zephex"] = serverEntry;
|
|
1865
|
+
existing[parentKey] = parent;
|
|
1866
|
+
return existing;
|
|
1867
|
+
}
|
|
1868
|
+
async function writeCursorConfig(key, useProject) {
|
|
1869
|
+
const target = useProject ? path3.join(process.cwd(), ".cursor", "mcp.json") : path3.join(getHomeDir2(), ".cursor", "mcp.json");
|
|
1870
|
+
const existing = readJsonFile(target);
|
|
1871
|
+
const merged = setNestedZephex(existing, "mcpServers", {
|
|
1872
|
+
url: ZEPHEX_MCP_URL,
|
|
1873
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
1874
|
+
});
|
|
1875
|
+
writeJsonAtomic(target, merged);
|
|
1876
|
+
return target;
|
|
1877
|
+
}
|
|
1878
|
+
async function writeClaudeConfig(key, useProject) {
|
|
1879
|
+
const forceJson = process.env["ZEPHEX_SETUP_FORCE_JSON"] === "1";
|
|
1880
|
+
const isWindows = process.platform === "win32";
|
|
1881
|
+
const candidates = isWindows ? ["claude.cmd", "claude"] : ["claude"];
|
|
1882
|
+
let cliBin = null;
|
|
1883
|
+
if (!forceJson) {
|
|
1884
|
+
for (const bin of candidates) {
|
|
1885
|
+
const probe = spawnSync(bin, ["--version"], { stdio: "ignore" });
|
|
1886
|
+
if (probe.status === 0) {
|
|
1887
|
+
cliBin = bin;
|
|
1888
|
+
break;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
if (cliBin) {
|
|
1893
|
+
const r2 = spawnSync(cliBin, [
|
|
1894
|
+
"mcp",
|
|
1895
|
+
"add",
|
|
1896
|
+
"--scope",
|
|
1897
|
+
"user",
|
|
1898
|
+
"--transport",
|
|
1899
|
+
"http",
|
|
1900
|
+
"--header",
|
|
1901
|
+
`Authorization: Bearer ${key}`,
|
|
1902
|
+
"zephex",
|
|
1903
|
+
ZEPHEX_MCP_URL
|
|
1904
|
+
], { stdio: "inherit" });
|
|
1905
|
+
if (r2.status === 0) {
|
|
1906
|
+
return `${cliBin} mcp add (user scope)`;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
const target = useProject ? path3.join(process.cwd(), ".mcp.json") : path3.join(getHomeDir2(), ".claude.json");
|
|
1910
|
+
const existing = readJsonFile(target);
|
|
1911
|
+
const merged = setNestedZephex(existing, "mcpServers", {
|
|
1912
|
+
type: "http",
|
|
1913
|
+
url: ZEPHEX_MCP_URL,
|
|
1914
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
1915
|
+
});
|
|
1916
|
+
writeJsonAtomic(target, merged);
|
|
1917
|
+
return target;
|
|
1918
|
+
}
|
|
1919
|
+
async function writeVscodeConfig(key) {
|
|
1920
|
+
const target = path3.join(process.cwd(), ".vscode", "mcp.json");
|
|
1921
|
+
const existing = readJsonFile(target);
|
|
1922
|
+
const merged = setNestedZephex(existing, "servers", {
|
|
1923
|
+
type: "http",
|
|
1924
|
+
url: ZEPHEX_MCP_URL,
|
|
1925
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
1926
|
+
});
|
|
1927
|
+
writeJsonAtomic(target, merged);
|
|
1928
|
+
return target;
|
|
1929
|
+
}
|
|
1930
|
+
function opencodeGlobalPath() {
|
|
1931
|
+
if (process.platform === "win32") {
|
|
1932
|
+
const appdata = process.env["APPDATA"] ?? path3.join(getHomeDir2(), "AppData", "Roaming");
|
|
1933
|
+
return path3.join(appdata, "opencode", "opencode.json");
|
|
1934
|
+
}
|
|
1935
|
+
return path3.join(getHomeDir2(), ".config", "opencode", "opencode.json");
|
|
1936
|
+
}
|
|
1937
|
+
async function writeOpenCodeConfig(key, useProject) {
|
|
1938
|
+
const target = useProject ? path3.join(process.cwd(), "opencode.json") : opencodeGlobalPath();
|
|
1939
|
+
const existing = readJsonFile(target);
|
|
1940
|
+
const merged = setNestedZephex(existing, "mcp", {
|
|
1941
|
+
type: "remote",
|
|
1942
|
+
url: ZEPHEX_MCP_URL,
|
|
1943
|
+
enabled: true,
|
|
1944
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
1945
|
+
});
|
|
1946
|
+
writeJsonAtomic(target, merged);
|
|
1947
|
+
return target;
|
|
1948
|
+
}
|
|
1949
|
+
function codexTomlValue(value) {
|
|
1950
|
+
return JSON.stringify(value);
|
|
1951
|
+
}
|
|
1952
|
+
function rewriteCodexToml(existingText, key) {
|
|
1953
|
+
const lines = existingText.split(`
|
|
1954
|
+
`);
|
|
1955
|
+
const out = [];
|
|
1956
|
+
let skipping = false;
|
|
1957
|
+
for (const line of lines) {
|
|
1958
|
+
const headerMatch = /^\s*\[([^\]]+)\]\s*$/.exec(line);
|
|
1959
|
+
if (headerMatch) {
|
|
1960
|
+
const header = (headerMatch[1] ?? "").trim();
|
|
1961
|
+
if (header === "mcp_servers.zephex" || header.startsWith("mcp_servers.zephex.")) {
|
|
1962
|
+
skipping = true;
|
|
1963
|
+
continue;
|
|
1964
|
+
}
|
|
1965
|
+
skipping = false;
|
|
1966
|
+
}
|
|
1967
|
+
if (!skipping)
|
|
1968
|
+
out.push(line);
|
|
1969
|
+
}
|
|
1970
|
+
while (out.length > 0 && (out[out.length - 1] ?? "").trim() === "")
|
|
1971
|
+
out.pop();
|
|
1972
|
+
const newBlock = `[mcp_servers.zephex]
|
|
1973
|
+
` + `url = ${codexTomlValue(ZEPHEX_MCP_URL)}
|
|
1974
|
+
` + `
|
|
1975
|
+
` + `[mcp_servers.zephex.http_headers]
|
|
1976
|
+
` + `Authorization = ${codexTomlValue("Bearer " + key)}
|
|
1977
|
+
`;
|
|
1978
|
+
if (out.length === 0)
|
|
1979
|
+
return newBlock;
|
|
1980
|
+
return out.join(`
|
|
1981
|
+
`) + `
|
|
1982
|
+
|
|
1983
|
+
` + newBlock;
|
|
1984
|
+
}
|
|
1985
|
+
async function writeCodexConfig(key, useProject) {
|
|
1986
|
+
const target = useProject ? path3.join(process.cwd(), ".codex", "config.toml") : path3.join(getHomeDir2(), ".codex", "config.toml");
|
|
1987
|
+
let existingText = "";
|
|
1988
|
+
if (fs7.existsSync(target)) {
|
|
1989
|
+
try {
|
|
1990
|
+
existingText = fs7.readFileSync(target, "utf8");
|
|
1991
|
+
} catch (err) {
|
|
1992
|
+
v2.error(`${target} could not be read, skipping. Edit it manually and re-run.`);
|
|
1993
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
const next = rewriteCodexToml(existingText, key);
|
|
1997
|
+
fs7.mkdirSync(path3.dirname(target), { recursive: true });
|
|
1998
|
+
const tmp = `${target}.tmp`;
|
|
1999
|
+
const finalText = next.endsWith(`
|
|
2000
|
+
`) ? next : next + `
|
|
2001
|
+
`;
|
|
2002
|
+
fs7.writeFileSync(tmp, finalText, "utf8");
|
|
2003
|
+
fs7.renameSync(tmp, target);
|
|
2004
|
+
return target;
|
|
2005
|
+
}
|
|
2006
|
+
async function writeGeminiConfig(key, useProject) {
|
|
2007
|
+
const target = useProject ? path3.join(process.cwd(), ".gemini", "settings.json") : path3.join(getHomeDir2(), ".gemini", "settings.json");
|
|
2008
|
+
const existing = readJsonFile(target);
|
|
2009
|
+
const merged = setNestedZephex(existing, "mcpServers", {
|
|
2010
|
+
httpUrl: ZEPHEX_MCP_URL,
|
|
2011
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
2012
|
+
});
|
|
2013
|
+
writeJsonAtomic(target, merged);
|
|
2014
|
+
return target;
|
|
2015
|
+
}
|
|
2016
|
+
async function writeAntigravityConfig(key) {
|
|
2017
|
+
const target = path3.join(getHomeDir2(), ".gemini", "antigravity", "mcp_config.json");
|
|
2018
|
+
const existing = readJsonFile(target);
|
|
2019
|
+
const merged = setNestedZephex(existing, "mcpServers", {
|
|
2020
|
+
serverUrl: ZEPHEX_MCP_URL,
|
|
2021
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
2022
|
+
});
|
|
2023
|
+
writeJsonAtomic(target, merged);
|
|
2024
|
+
return target;
|
|
2025
|
+
}
|
|
2026
|
+
async function writeTraeConfig(key) {
|
|
2027
|
+
const target = path3.join(process.cwd(), ".trae", "mcp.json");
|
|
2028
|
+
const existing = readJsonFile(target);
|
|
2029
|
+
const merged = setNestedZephex(existing, "mcpServers", {
|
|
2030
|
+
url: ZEPHEX_MCP_URL,
|
|
2031
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
2032
|
+
});
|
|
2033
|
+
writeJsonAtomic(target, merged);
|
|
2034
|
+
return target;
|
|
2035
|
+
}
|
|
2036
|
+
async function pickEditor() {
|
|
2037
|
+
const choice = await de({
|
|
2038
|
+
message: "Which editor do you want to connect?",
|
|
2039
|
+
options: [
|
|
2040
|
+
{ value: "cursor", label: "Cursor — AI-first code editor" },
|
|
2041
|
+
{ value: "claude", label: "Claude Code — Anthropic's coding agent" },
|
|
2042
|
+
{ value: "opencode", label: "OpenCode — open-source AI coding agent" },
|
|
2043
|
+
{ value: "codex", label: "Codex — OpenAI's coding agent" },
|
|
2044
|
+
{ value: "gemini", label: "Gemini CLI — Google's coding agent" },
|
|
2045
|
+
{ value: "antigravity", label: "Antigravity — Google's agent-first IDE" },
|
|
2046
|
+
{ value: "trae", label: "TRAE — ByteDance's adaptive AI IDE" },
|
|
2047
|
+
{ value: "vscode", label: "VS Code — Microsoft's editor" }
|
|
2048
|
+
]
|
|
2049
|
+
});
|
|
2050
|
+
if (BD(choice)) {
|
|
2051
|
+
ve("Setup cancelled.");
|
|
2052
|
+
process.exit(0);
|
|
2053
|
+
}
|
|
2054
|
+
return choice;
|
|
2055
|
+
}
|
|
2056
|
+
async function pickInstallScope(labels) {
|
|
2057
|
+
const choice = await de({
|
|
2058
|
+
message: "Install for which scope?",
|
|
2059
|
+
options: [
|
|
2060
|
+
{ value: "global", label: labels.global },
|
|
2061
|
+
{ value: "project", label: labels.project }
|
|
2062
|
+
]
|
|
2063
|
+
});
|
|
2064
|
+
if (BD(choice)) {
|
|
2065
|
+
ve("Setup cancelled.");
|
|
2066
|
+
process.exit(0);
|
|
2067
|
+
}
|
|
2068
|
+
return choice === "project";
|
|
2069
|
+
}
|
|
2070
|
+
function scopeLabelsFor(editor) {
|
|
2071
|
+
switch (editor) {
|
|
2072
|
+
case "cursor":
|
|
2073
|
+
return {
|
|
2074
|
+
global: "Global (~/.cursor/mcp.json)",
|
|
2075
|
+
project: "This project (.cursor/mcp.json)"
|
|
2076
|
+
};
|
|
2077
|
+
case "claude":
|
|
2078
|
+
return {
|
|
2079
|
+
global: "Global (~/.claude.json)",
|
|
2080
|
+
project: "This project (.mcp.json)"
|
|
2081
|
+
};
|
|
2082
|
+
case "opencode":
|
|
2083
|
+
return {
|
|
2084
|
+
global: "Global (~/.config/opencode/opencode.json)",
|
|
2085
|
+
project: "This project (opencode.json)"
|
|
2086
|
+
};
|
|
2087
|
+
case "codex":
|
|
2088
|
+
return {
|
|
2089
|
+
global: "Global (~/.codex/config.toml)",
|
|
2090
|
+
project: "This project (.codex/config.toml)"
|
|
2091
|
+
};
|
|
2092
|
+
case "gemini":
|
|
2093
|
+
return {
|
|
2094
|
+
global: "Global (~/.gemini/settings.json)",
|
|
2095
|
+
project: "This project (.gemini/settings.json)"
|
|
2096
|
+
};
|
|
2097
|
+
case "antigravity":
|
|
2098
|
+
case "trae":
|
|
2099
|
+
case "vscode":
|
|
2100
|
+
return null;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
function editorOutroMessage(editor) {
|
|
2104
|
+
switch (editor) {
|
|
2105
|
+
case "cursor":
|
|
2106
|
+
return "You're connected. Open a new chat in Cursor to start using Zephex.";
|
|
2107
|
+
case "claude":
|
|
2108
|
+
return "You're connected. Run `claude` to start using Zephex.";
|
|
2109
|
+
case "opencode":
|
|
2110
|
+
return "You're connected. Restart OpenCode to start using Zephex.";
|
|
2111
|
+
case "codex":
|
|
2112
|
+
return "You're connected. Restart Codex to start using Zephex.";
|
|
2113
|
+
case "gemini":
|
|
2114
|
+
return "You're connected. Restart Gemini CLI to start using Zephex.";
|
|
2115
|
+
case "antigravity":
|
|
2116
|
+
return "You're connected. Restart Antigravity to start using Zephex.";
|
|
2117
|
+
case "trae":
|
|
2118
|
+
return "You're connected. Restart Trae to activate Zephex.";
|
|
2119
|
+
case "vscode":
|
|
2120
|
+
return "You're connected. Reload VS Code to start using Zephex.";
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
async function runCliSkillsMode(flags) {
|
|
2124
|
+
let scope;
|
|
2125
|
+
if (flags.universal) {
|
|
2126
|
+
scope = "global";
|
|
2127
|
+
} else if (flags.skillScope) {
|
|
2128
|
+
scope = flags.skillScope;
|
|
2129
|
+
} else {
|
|
2130
|
+
scope = await pickSkillScope();
|
|
2131
|
+
}
|
|
2132
|
+
let target;
|
|
2133
|
+
try {
|
|
2134
|
+
target = installSkill(scope);
|
|
2135
|
+
} catch (err) {
|
|
2136
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2137
|
+
v2.error(`Failed to write skill file: ${msg}`);
|
|
2138
|
+
ve("Setup aborted.");
|
|
2139
|
+
process.exit(1);
|
|
2140
|
+
}
|
|
2141
|
+
v2.success(`Skill installed to ${prettySkillPath(target)}`);
|
|
2142
|
+
fe("Your agent will now use Zephex tools automatically.");
|
|
2143
|
+
}
|
|
2144
|
+
async function runSetup(argv) {
|
|
2145
|
+
if (isHeadless()) {
|
|
2146
|
+
printManualInstructions();
|
|
2147
|
+
process.exit(0);
|
|
2148
|
+
}
|
|
2149
|
+
const flags = parseFlags2(argv);
|
|
2150
|
+
we("zephex setup");
|
|
2151
|
+
let mode;
|
|
2152
|
+
if (flags.mode) {
|
|
2153
|
+
mode = flags.mode;
|
|
2154
|
+
} else if (flags.universal) {
|
|
2155
|
+
mode = "cli";
|
|
2156
|
+
} else {
|
|
2157
|
+
mode = "mcp";
|
|
2158
|
+
}
|
|
2159
|
+
if (mode === "cli") {
|
|
2160
|
+
await runCliSkillsMode(flags);
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
const resolvedClientId = process.env["AUTH0_CLI_CLIENT_ID"] || DEFAULT_AUTH0_CLI_CLIENT_ID;
|
|
2164
|
+
if (!resolvedClientId || resolvedClientId === "AUTH0_CLI_CLIENT_ID_NOT_SET") {
|
|
2165
|
+
process.stderr.write(`
|
|
2166
|
+
Error: AUTH0_CLI_CLIENT_ID is not configured.
|
|
2167
|
+
` + "Run `node scripts/create-cli-auth0-app.mjs` to create the Auth0 Native\n" + `application, then set AUTH0_CLI_CLIENT_ID in your environment.
|
|
2168
|
+
` + `Alternatively create the app manually in the Auth0 dashboard:
|
|
2169
|
+
` + ` • Application type: Native
|
|
2170
|
+
` + ` • Allowed Callback URLs: http://localhost:52748/callback, http://localhost:52749/callback, http://localhost:52750/callback
|
|
2171
|
+
` + ` • Token Endpoint Auth Method: None
|
|
2172
|
+
|
|
2173
|
+
`);
|
|
2174
|
+
process.exit(1);
|
|
2175
|
+
}
|
|
2176
|
+
const editor = flags.editor ?? await pickEditor();
|
|
2177
|
+
let useProject = false;
|
|
2178
|
+
const scopeLabels = scopeLabelsFor(editor);
|
|
2179
|
+
if (scopeLabels) {
|
|
2180
|
+
useProject = flags.project ? true : await pickInstallScope(scopeLabels);
|
|
2181
|
+
}
|
|
2182
|
+
let keyInfo;
|
|
2183
|
+
let email = null;
|
|
2184
|
+
if (flags.apiKey) {
|
|
2185
|
+
keyInfo = {
|
|
2186
|
+
key: flags.apiKey,
|
|
2187
|
+
name: "provided-by-user",
|
|
2188
|
+
created: new Date().toISOString()
|
|
2189
|
+
};
|
|
2190
|
+
} else {
|
|
2191
|
+
try {
|
|
2192
|
+
const result = await loginAndGetApiKey(editor);
|
|
2193
|
+
keyInfo = result.keyInfo;
|
|
2194
|
+
email = result.email;
|
|
2195
|
+
} catch (err) {
|
|
2196
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2197
|
+
v2.error(`Login failed: ${msg}`);
|
|
2198
|
+
ve("Setup aborted.");
|
|
2199
|
+
process.exit(1);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
if (email) {
|
|
2203
|
+
v2.success(`Signed in as ${email}`);
|
|
2204
|
+
} else if (!flags.apiKey) {
|
|
2205
|
+
v2.success("Signed in");
|
|
2206
|
+
}
|
|
2207
|
+
v2.success(`API key created: ${keyInfo.name}`);
|
|
2208
|
+
let target;
|
|
2209
|
+
try {
|
|
2210
|
+
switch (editor) {
|
|
2211
|
+
case "cursor":
|
|
2212
|
+
target = await writeCursorConfig(keyInfo.key, useProject);
|
|
2213
|
+
break;
|
|
2214
|
+
case "claude":
|
|
2215
|
+
target = await writeClaudeConfig(keyInfo.key, useProject);
|
|
2216
|
+
break;
|
|
2217
|
+
case "opencode":
|
|
2218
|
+
target = await writeOpenCodeConfig(keyInfo.key, useProject);
|
|
2219
|
+
break;
|
|
2220
|
+
case "codex":
|
|
2221
|
+
target = await writeCodexConfig(keyInfo.key, useProject);
|
|
2222
|
+
break;
|
|
2223
|
+
case "gemini":
|
|
2224
|
+
target = await writeGeminiConfig(keyInfo.key, useProject);
|
|
2225
|
+
break;
|
|
2226
|
+
case "antigravity":
|
|
2227
|
+
target = await writeAntigravityConfig(keyInfo.key);
|
|
2228
|
+
break;
|
|
2229
|
+
case "trae":
|
|
2230
|
+
target = await writeTraeConfig(keyInfo.key);
|
|
2231
|
+
break;
|
|
2232
|
+
case "vscode":
|
|
2233
|
+
target = await writeVscodeConfig(keyInfo.key);
|
|
2234
|
+
break;
|
|
2235
|
+
}
|
|
2236
|
+
} catch (err) {
|
|
2237
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2238
|
+
v2.error(`Failed to write config: ${msg}`);
|
|
2239
|
+
ve("Setup aborted.");
|
|
2240
|
+
process.exit(1);
|
|
2241
|
+
}
|
|
2242
|
+
v2.success(`Config written to ${prettyPath2(target)}`);
|
|
2243
|
+
if (editor === "antigravity") {
|
|
2244
|
+
v2.info("Restart Antigravity, then verify zephex appears under '...' menu → Manage MCP Servers. If you don't see it, open the same menu → 'View raw config' to confirm ~/.gemini/antigravity/mcp_config.json contains the zephex entry.");
|
|
2245
|
+
}
|
|
2246
|
+
fe(editorOutroMessage(editor));
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
// src/commands/status.ts
|
|
2250
|
+
import fs8 from "node:fs";
|
|
2251
|
+
import path4 from "node:path";
|
|
2252
|
+
import os4 from "node:os";
|
|
2253
|
+
var ZEPHEX_MCP_URL2 = "https://zephex.dev/mcp";
|
|
2254
|
+
function getHomeDir3() {
|
|
2255
|
+
if (process.platform === "win32") {
|
|
2256
|
+
return process.env["USERPROFILE"] ?? os4.homedir();
|
|
2257
|
+
}
|
|
2258
|
+
return process.env["HOME"] ?? os4.homedir();
|
|
2259
|
+
}
|
|
2260
|
+
function opencodeGlobalPath2(home) {
|
|
2261
|
+
if (process.platform === "win32") {
|
|
2262
|
+
const appdata = process.env["APPDATA"] ?? path4.join(home, "AppData", "Roaming");
|
|
2263
|
+
return path4.join(appdata, "opencode", "opencode.json");
|
|
2264
|
+
}
|
|
2265
|
+
return path4.join(home, ".config", "opencode", "opencode.json");
|
|
2266
|
+
}
|
|
2267
|
+
function configCandidates() {
|
|
2268
|
+
const cwd = process.cwd();
|
|
2269
|
+
const home = getHomeDir3();
|
|
2270
|
+
return [
|
|
2271
|
+
{
|
|
2272
|
+
editor: "Cursor (project)",
|
|
2273
|
+
filePath: path4.join(cwd, ".cursor", "mcp.json"),
|
|
2274
|
+
parentKey: "mcpServers",
|
|
2275
|
+
format: "json"
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
editor: "Cursor (global)",
|
|
2279
|
+
filePath: path4.join(home, ".cursor", "mcp.json"),
|
|
2280
|
+
parentKey: "mcpServers",
|
|
2281
|
+
format: "json"
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
editor: "Claude (global)",
|
|
2285
|
+
filePath: path4.join(home, ".claude.json"),
|
|
2286
|
+
parentKey: "mcpServers",
|
|
2287
|
+
format: "json"
|
|
2288
|
+
},
|
|
2289
|
+
{
|
|
2290
|
+
editor: "Claude (project)",
|
|
2291
|
+
filePath: path4.join(cwd, ".mcp.json"),
|
|
2292
|
+
parentKey: "mcpServers",
|
|
2293
|
+
format: "json"
|
|
2294
|
+
},
|
|
2295
|
+
{
|
|
2296
|
+
editor: "OpenCode (global)",
|
|
2297
|
+
filePath: opencodeGlobalPath2(home),
|
|
2298
|
+
parentKey: "mcp",
|
|
2299
|
+
format: "json"
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
editor: "OpenCode (project)",
|
|
2303
|
+
filePath: path4.join(cwd, "opencode.json"),
|
|
2304
|
+
parentKey: "mcp",
|
|
2305
|
+
format: "json"
|
|
2306
|
+
},
|
|
2307
|
+
{
|
|
2308
|
+
editor: "Codex (global)",
|
|
2309
|
+
filePath: path4.join(home, ".codex", "config.toml"),
|
|
2310
|
+
parentKey: "",
|
|
2311
|
+
format: "toml"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
editor: "Codex (project)",
|
|
2315
|
+
filePath: path4.join(cwd, ".codex", "config.toml"),
|
|
2316
|
+
parentKey: "",
|
|
2317
|
+
format: "toml"
|
|
2318
|
+
},
|
|
2319
|
+
{
|
|
2320
|
+
editor: "Gemini (global)",
|
|
2321
|
+
filePath: path4.join(home, ".gemini", "settings.json"),
|
|
2322
|
+
parentKey: "mcpServers",
|
|
2323
|
+
format: "json"
|
|
2324
|
+
},
|
|
2325
|
+
{
|
|
2326
|
+
editor: "Gemini (project)",
|
|
2327
|
+
filePath: path4.join(cwd, ".gemini", "settings.json"),
|
|
2328
|
+
parentKey: "mcpServers",
|
|
2329
|
+
format: "json"
|
|
2330
|
+
},
|
|
2331
|
+
{
|
|
2332
|
+
editor: "Antigravity (global)",
|
|
2333
|
+
filePath: path4.join(home, ".gemini", "antigravity", "mcp_config.json"),
|
|
2334
|
+
parentKey: "mcpServers",
|
|
2335
|
+
format: "json"
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
editor: "TRAE (project)",
|
|
2339
|
+
filePath: path4.join(cwd, ".trae", "mcp.json"),
|
|
2340
|
+
parentKey: "mcpServers",
|
|
2341
|
+
format: "json"
|
|
2342
|
+
},
|
|
2343
|
+
{
|
|
2344
|
+
editor: "VS Code (project)",
|
|
2345
|
+
filePath: path4.join(cwd, ".vscode", "mcp.json"),
|
|
2346
|
+
parentKey: "servers",
|
|
2347
|
+
format: "json"
|
|
2348
|
+
}
|
|
2349
|
+
];
|
|
2350
|
+
}
|
|
2351
|
+
function asRecord2(value) {
|
|
2352
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2353
|
+
return value;
|
|
2354
|
+
}
|
|
2355
|
+
return null;
|
|
2356
|
+
}
|
|
2357
|
+
function readKeyFromJsonConfig(filePath, parentKey) {
|
|
2358
|
+
if (!fs8.existsSync(filePath))
|
|
2359
|
+
return null;
|
|
2360
|
+
let raw;
|
|
2361
|
+
try {
|
|
2362
|
+
raw = fs8.readFileSync(filePath, "utf8");
|
|
2363
|
+
} catch {
|
|
2364
|
+
return null;
|
|
2365
|
+
}
|
|
2366
|
+
let parsed;
|
|
2367
|
+
try {
|
|
2368
|
+
parsed = JSON.parse(raw);
|
|
2369
|
+
} catch {
|
|
2370
|
+
return null;
|
|
2371
|
+
}
|
|
2372
|
+
const root = asRecord2(parsed);
|
|
2373
|
+
if (!root)
|
|
2374
|
+
return null;
|
|
2375
|
+
const parent = asRecord2(root[parentKey]);
|
|
2376
|
+
if (!parent)
|
|
2377
|
+
return null;
|
|
2378
|
+
const zephex = asRecord2(parent["zephex"]);
|
|
2379
|
+
if (!zephex)
|
|
2380
|
+
return null;
|
|
2381
|
+
const headers = asRecord2(zephex["headers"]);
|
|
2382
|
+
if (!headers)
|
|
2383
|
+
return null;
|
|
2384
|
+
const auth = headers["Authorization"];
|
|
2385
|
+
if (typeof auth !== "string")
|
|
2386
|
+
return null;
|
|
2387
|
+
const m3 = /^bearer\s+(.+)$/i.exec(auth.trim());
|
|
2388
|
+
if (!m3 || !m3[1])
|
|
2389
|
+
return null;
|
|
2390
|
+
return m3[1].trim();
|
|
2391
|
+
}
|
|
2392
|
+
function readKeyFromCodexToml(filePath) {
|
|
2393
|
+
if (!fs8.existsSync(filePath))
|
|
2394
|
+
return null;
|
|
2395
|
+
let raw;
|
|
2396
|
+
try {
|
|
2397
|
+
raw = fs8.readFileSync(filePath, "utf8");
|
|
2398
|
+
} catch {
|
|
2399
|
+
return null;
|
|
2400
|
+
}
|
|
2401
|
+
const lines = raw.split(`
|
|
2402
|
+
`);
|
|
2403
|
+
let inHeadersSection = false;
|
|
2404
|
+
for (const rawLine of lines) {
|
|
2405
|
+
const line = rawLine.trim();
|
|
2406
|
+
const headerMatch = /^\[([^\]]+)\]$/.exec(line);
|
|
2407
|
+
if (headerMatch) {
|
|
2408
|
+
inHeadersSection = (headerMatch[1] ?? "").trim() === "mcp_servers.zephex.http_headers";
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
if (!inHeadersSection)
|
|
2412
|
+
continue;
|
|
2413
|
+
const kv = /^Authorization\s*=\s*(["'])(.+?)\1\s*$/.exec(line);
|
|
2414
|
+
if (!kv)
|
|
2415
|
+
continue;
|
|
2416
|
+
const value = kv[2] ?? "";
|
|
2417
|
+
const bearer = /^bearer\s+(.+)$/i.exec(value.trim());
|
|
2418
|
+
if (!bearer || !bearer[1])
|
|
2419
|
+
return null;
|
|
2420
|
+
return bearer[1].trim();
|
|
2421
|
+
}
|
|
2422
|
+
return null;
|
|
2423
|
+
}
|
|
2424
|
+
function readKeyFromConfig(c2) {
|
|
2425
|
+
if (c2.format === "toml")
|
|
2426
|
+
return readKeyFromCodexToml(c2.filePath);
|
|
2427
|
+
return readKeyFromJsonConfig(c2.filePath, c2.parentKey);
|
|
2428
|
+
}
|
|
2429
|
+
function previewKey(key) {
|
|
2430
|
+
if (key.length <= 12)
|
|
2431
|
+
return `${key}...`;
|
|
2432
|
+
return `${key.slice(0, 12)}...`;
|
|
2433
|
+
}
|
|
2434
|
+
async function probeKey(key) {
|
|
2435
|
+
try {
|
|
2436
|
+
const resp = await fetch(ZEPHEX_MCP_URL2, {
|
|
2437
|
+
method: "POST",
|
|
2438
|
+
headers: {
|
|
2439
|
+
"Content-Type": "application/json",
|
|
2440
|
+
Accept: "application/json, text/event-stream",
|
|
2441
|
+
Authorization: `Bearer ${key}`
|
|
2442
|
+
},
|
|
2443
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" })
|
|
2444
|
+
});
|
|
2445
|
+
if (!resp.ok) {
|
|
2446
|
+
return { ok: false, toolCount: 0, detail: `HTTP ${resp.status}` };
|
|
2447
|
+
}
|
|
2448
|
+
const contentType = (resp.headers.get("content-type") ?? "").toLowerCase();
|
|
2449
|
+
let parsed = null;
|
|
2450
|
+
if (contentType.includes("text/event-stream")) {
|
|
2451
|
+
const text = await resp.text();
|
|
2452
|
+
const dataLine = text.split(/\r?\n/).find((l2) => l2.startsWith("data:"));
|
|
2453
|
+
if (!dataLine)
|
|
2454
|
+
return { ok: false, toolCount: 0, detail: "empty SSE" };
|
|
2455
|
+
try {
|
|
2456
|
+
parsed = JSON.parse(dataLine.slice(5).trim());
|
|
2457
|
+
} catch {
|
|
2458
|
+
return { ok: false, toolCount: 0, detail: "invalid SSE JSON" };
|
|
2459
|
+
}
|
|
2460
|
+
} else {
|
|
2461
|
+
try {
|
|
2462
|
+
parsed = await resp.json();
|
|
2463
|
+
} catch {
|
|
2464
|
+
return { ok: false, toolCount: 0, detail: "invalid JSON response" };
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
if (parsed.error) {
|
|
2468
|
+
return { ok: false, toolCount: 0, detail: parsed.error.message ?? "JSON-RPC error" };
|
|
2469
|
+
}
|
|
2470
|
+
const tools = parsed.result?.tools;
|
|
2471
|
+
const count = Array.isArray(tools) ? tools.length : 0;
|
|
2472
|
+
return { ok: count > 0, toolCount: count, detail: count > 0 ? "ok" : "no tools returned" };
|
|
2473
|
+
} catch (err) {
|
|
2474
|
+
return {
|
|
2475
|
+
ok: false,
|
|
2476
|
+
toolCount: 0,
|
|
2477
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
function pad(value, width) {
|
|
2482
|
+
if (value.length >= width)
|
|
2483
|
+
return value;
|
|
2484
|
+
return value + " ".repeat(width - value.length);
|
|
2485
|
+
}
|
|
2486
|
+
function truncate(value, max) {
|
|
2487
|
+
if (value.length <= max)
|
|
2488
|
+
return value;
|
|
2489
|
+
return value.slice(0, Math.max(0, max - 3)) + "...";
|
|
2490
|
+
}
|
|
2491
|
+
function writeLine(line) {
|
|
2492
|
+
process.stdout.write(line + `
|
|
2493
|
+
`);
|
|
2494
|
+
}
|
|
2495
|
+
async function runStatus(_argv) {
|
|
2496
|
+
const candidates = configCandidates();
|
|
2497
|
+
const detected = candidates.map((c2) => ({ ...c2, key: readKeyFromConfig(c2) })).filter((c2) => c2.key !== null);
|
|
2498
|
+
if (detected.length === 0) {
|
|
2499
|
+
process.stderr.write("No Zephex MCP configs found.\nRun `zephex setup` to install one.\n");
|
|
2500
|
+
process.exit(1);
|
|
2501
|
+
}
|
|
2502
|
+
const uniqueKeys = Array.from(new Set(detected.map((d2) => d2.key)));
|
|
2503
|
+
const probeMap = new Map;
|
|
2504
|
+
await Promise.all(uniqueKeys.map(async (k3) => {
|
|
2505
|
+
probeMap.set(k3, await probeKey(k3));
|
|
2506
|
+
}));
|
|
2507
|
+
const rows = detected.map((d2) => {
|
|
2508
|
+
const probe = probeMap.get(d2.key) ?? { ok: false, toolCount: 0, detail: "unknown" };
|
|
2509
|
+
return {
|
|
2510
|
+
editor: d2.editor,
|
|
2511
|
+
filePath: d2.filePath,
|
|
2512
|
+
keyPreview: previewKey(d2.key),
|
|
2513
|
+
status: probe.ok ? "PASS" : "FAIL",
|
|
2514
|
+
toolCount: probe.toolCount,
|
|
2515
|
+
detail: probe.detail
|
|
2516
|
+
};
|
|
2517
|
+
});
|
|
2518
|
+
const headers = ["EDITOR", "CONFIG", "KEY", "STATUS", "TOOLS", "DETAIL"];
|
|
2519
|
+
const widths = [
|
|
2520
|
+
Math.max(headers[0].length, ...rows.map((r2) => r2.editor.length)),
|
|
2521
|
+
Math.min(50, Math.max(headers[1].length, ...rows.map((r2) => r2.filePath.length))),
|
|
2522
|
+
Math.max(headers[2].length, ...rows.map((r2) => r2.keyPreview.length)),
|
|
2523
|
+
Math.max(headers[3].length, ...rows.map((r2) => r2.status.length)),
|
|
2524
|
+
Math.max(headers[4].length, ...rows.map((r2) => String(r2.toolCount).length)),
|
|
2525
|
+
Math.min(40, Math.max(headers[5].length, ...rows.map((r2) => r2.detail.length)))
|
|
2526
|
+
];
|
|
2527
|
+
writeLine(headers.map((h2, i) => pad(h2, widths[i] ?? h2.length)).join(" "));
|
|
2528
|
+
writeLine(widths.map((w2) => "-".repeat(w2)).join(" "));
|
|
2529
|
+
for (const r2 of rows) {
|
|
2530
|
+
writeLine([
|
|
2531
|
+
pad(r2.editor, widths[0] ?? 0),
|
|
2532
|
+
pad(truncate(r2.filePath, widths[1] ?? r2.filePath.length), widths[1] ?? 0),
|
|
2533
|
+
pad(r2.keyPreview, widths[2] ?? 0),
|
|
2534
|
+
pad(r2.status, widths[3] ?? 0),
|
|
2535
|
+
pad(String(r2.toolCount), widths[4] ?? 0),
|
|
2536
|
+
pad(truncate(r2.detail, widths[5] ?? r2.detail.length), widths[5] ?? 0)
|
|
2537
|
+
].join(" "));
|
|
2538
|
+
}
|
|
2539
|
+
const anyPass = rows.some((r2) => r2.status === "PASS");
|
|
2540
|
+
process.exit(anyPass ? 0 : 1);
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
// src/cli.ts
|
|
2544
|
+
var args = process.argv.slice(2);
|
|
2545
|
+
var subcommand = args[0];
|
|
2546
|
+
if (subcommand === "setup" || args.includes("--setup")) {
|
|
2547
|
+
const forwarded = subcommand === "setup" ? args.slice(1) : args.filter((a2) => a2 !== "--setup");
|
|
2548
|
+
await runSetup(forwarded);
|
|
2549
|
+
process.exit(0);
|
|
2550
|
+
}
|
|
2551
|
+
if (subcommand === "status") {
|
|
2552
|
+
await runStatus(args.slice(1));
|
|
2553
|
+
process.exit(0);
|
|
2554
|
+
}
|
|
2555
|
+
if (subcommand === "skills") {
|
|
2556
|
+
await runSkills(args.slice(1));
|
|
106
2557
|
process.exit(0);
|
|
107
2558
|
}
|
|
108
2559
|
var { spawn } = await import("node:child_process");
|
|
109
|
-
var __filename2 =
|
|
110
|
-
var
|
|
111
|
-
var serverPath = resolve(
|
|
2560
|
+
var __filename2 = fileURLToPath3(import.meta.url);
|
|
2561
|
+
var __dirname3 = dirname(__filename2);
|
|
2562
|
+
var serverPath = resolve(__dirname3, "tools/server.js");
|
|
112
2563
|
var child = spawn(process.execPath, [serverPath], {
|
|
113
2564
|
stdio: "inherit",
|
|
114
2565
|
env: { ...process.env, __ZEPHEX_MAIN__: "1" }
|