openkitt 0.3.14 → 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +17 -9
  2. package/dist/cli.js +1791 -1363
  3. package/package.json +4 -2
package/dist/cli.js CHANGED
@@ -2192,6 +2192,100 @@ var require_picocolors = __commonJS((exports, module) => {
2192
2192
  module.exports.createColors = createColors;
2193
2193
  });
2194
2194
 
2195
+ // src/audit/logger.ts
2196
+ import {
2197
+ appendFileSync,
2198
+ existsSync,
2199
+ mkdirSync,
2200
+ renameSync,
2201
+ rmSync,
2202
+ statSync,
2203
+ writeFileSync
2204
+ } from "node:fs";
2205
+ import { join } from "node:path";
2206
+ function formatLine(type, message) {
2207
+ return `[${new Date().toISOString()}] ${type} ${message}
2208
+ `;
2209
+ }
2210
+ function ensureAuditDir(auditDir) {
2211
+ if (existsSync(auditDir)) {
2212
+ return;
2213
+ }
2214
+ mkdirSync(auditDir, { recursive: true, mode: 448 });
2215
+ }
2216
+ function rotateLogIfNeeded(logPath, log1Path, log2Path) {
2217
+ if (!existsSync(logPath)) {
2218
+ return;
2219
+ }
2220
+ const stats = statSync(logPath);
2221
+ if (stats.size < MAX_LOG_SIZE_BYTES) {
2222
+ return;
2223
+ }
2224
+ if (existsSync(log2Path)) {
2225
+ rmSync(log2Path, { force: true });
2226
+ }
2227
+ if (existsSync(log1Path)) {
2228
+ renameSync(log1Path, log2Path);
2229
+ }
2230
+ renameSync(logPath, log1Path);
2231
+ writeFileSync(logPath, "", { encoding: "utf8", mode: 384 });
2232
+ }
2233
+ function writeAuditLine(logPath, log1Path, log2Path, type, message) {
2234
+ try {
2235
+ rotateLogIfNeeded(logPath, log1Path, log2Path);
2236
+ appendFileSync(logPath, formatLine(type, message), { encoding: "utf8", mode: 384 });
2237
+ } catch {
2238
+ return;
2239
+ }
2240
+ }
2241
+ function createAuditLogger(workspaceDir) {
2242
+ const auditDir = join(workspaceDir, AUDIT_DIR_NAME);
2243
+ const logPath = join(auditDir, AUDIT_FILE_NAME);
2244
+ const log1Path = join(auditDir, ROTATED_LOG_1);
2245
+ const log2Path = join(auditDir, ROTATED_LOG_2);
2246
+ return {
2247
+ log(type, message) {
2248
+ try {
2249
+ ensureAuditDir(auditDir);
2250
+ } catch {
2251
+ return;
2252
+ }
2253
+ writeAuditLine(logPath, log1Path, log2Path, type, message);
2254
+ },
2255
+ cmd(command, status, detail) {
2256
+ const suffix = detail ? ` (${detail})` : "";
2257
+ this.log("CMD", `${command} → ${status}${suffix}`);
2258
+ },
2259
+ cmdExec(command, status) {
2260
+ this.log("CMD_EXEC", `${command} → ${status}`);
2261
+ },
2262
+ mcp(tool, params, status, detail) {
2263
+ const suffix = detail ? ` (${detail})` : "";
2264
+ this.log("MCP", `${tool} (${params}) → ${status}${suffix}`);
2265
+ },
2266
+ llmCall(provider, model, promptVersion, estimatedTokens, status) {
2267
+ this.log("LLM_CALL", `${provider}/${model} (prompt: ${promptVersion}, est. ${estimatedTokens} tokens) → ${status}`);
2268
+ },
2269
+ fileWrite(path, hash) {
2270
+ const suffix = hash ? ` (SHA-256: ${hash})` : "";
2271
+ this.log("FILE_WRITE", `${path}${suffix}`);
2272
+ },
2273
+ staged(path, detail) {
2274
+ this.log("STAGED", `${path} (${detail})`);
2275
+ },
2276
+ userConfirmed() {
2277
+ this.log("USER_CONFIRMED", "staged changes");
2278
+ },
2279
+ security(action, message) {
2280
+ this.log("SECURITY", `${action} ${message}`);
2281
+ }
2282
+ };
2283
+ }
2284
+ var AUDIT_DIR_NAME = ".kitt", AUDIT_FILE_NAME = "audit.log", ROTATED_LOG_1 = "audit.log.1", ROTATED_LOG_2 = "audit.log.2", MAX_LOG_SIZE_BYTES;
2285
+ var init_logger = __esm(() => {
2286
+ MAX_LOG_SIZE_BYTES = 10 * 1024 * 1024;
2287
+ });
2288
+
2195
2289
  // node_modules/sisteransi/src/index.js
2196
2290
  var require_src = __commonJS((exports, module) => {
2197
2291
  var ESC = "\x1B";
@@ -2250,6 +2344,869 @@ var require_src = __commonJS((exports, module) => {
2250
2344
  module.exports = { cursor, scroll, erase, beep };
2251
2345
  });
2252
2346
 
2347
+ // node_modules/@clack/core/dist/index.mjs
2348
+ import { stdin as j, stdout as M } from "node:process";
2349
+ import O from "node:readline";
2350
+ import { Writable as X } from "node:stream";
2351
+ function DD({ onlyFirst: e = false } = {}) {
2352
+ const t = ["[\\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("|");
2353
+ return new RegExp(t, e ? undefined : "g");
2354
+ }
2355
+ function P(e) {
2356
+ if (typeof e != "string")
2357
+ throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);
2358
+ return e.replace(uD, "");
2359
+ }
2360
+ function L(e) {
2361
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
2362
+ }
2363
+ function p(e, u = {}) {
2364
+ if (typeof e != "string" || e.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, e = P(e), e.length === 0))
2365
+ return 0;
2366
+ e = e.replace(sD(), " ");
2367
+ const t = u.ambiguousIsNarrow ? 1 : 2;
2368
+ let F = 0;
2369
+ for (const s of e) {
2370
+ const i = s.codePointAt(0);
2371
+ if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879)
2372
+ continue;
2373
+ switch (eD.eastAsianWidth(s)) {
2374
+ case "F":
2375
+ case "W":
2376
+ F += 2;
2377
+ break;
2378
+ case "A":
2379
+ F += t;
2380
+ break;
2381
+ default:
2382
+ F += 1;
2383
+ }
2384
+ }
2385
+ return F;
2386
+ }
2387
+ function rD() {
2388
+ const e = new Map;
2389
+ for (const [u, t] of Object.entries(r)) {
2390
+ for (const [F, s] of Object.entries(t))
2391
+ r[F] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, t[F] = r[F], e.set(s[0], s[1]);
2392
+ Object.defineProperty(r, u, { value: t, enumerable: false });
2393
+ }
2394
+ return Object.defineProperty(r, "codes", { value: e, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = N(), r.color.ansi256 = I(), r.color.ansi16m = R(), r.bgColor.ansi = N(w), r.bgColor.ansi256 = I(w), r.bgColor.ansi16m = R(w), Object.defineProperties(r, { rgbToAnsi256: { value: (u, t, F) => u === t && t === F ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
2395
+ const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
2396
+ if (!t)
2397
+ return [0, 0, 0];
2398
+ let [F] = t;
2399
+ F.length === 3 && (F = [...F].map((i) => i + i).join(""));
2400
+ const s = Number.parseInt(F, 16);
2401
+ return [s >> 16 & 255, s >> 8 & 255, s & 255];
2402
+ }, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
2403
+ if (u < 8)
2404
+ return 30 + u;
2405
+ if (u < 16)
2406
+ return 90 + (u - 8);
2407
+ let t, F, s;
2408
+ if (u >= 232)
2409
+ t = ((u - 232) * 10 + 8) / 255, F = t, s = t;
2410
+ else {
2411
+ u -= 16;
2412
+ const C = u % 36;
2413
+ t = Math.floor(u / 36) / 5, F = Math.floor(C / 6) / 5, s = C % 6 / 5;
2414
+ }
2415
+ const i = Math.max(t, F, s) * 2;
2416
+ if (i === 0)
2417
+ return 30;
2418
+ let D = 30 + (Math.round(s) << 2 | Math.round(F) << 1 | Math.round(t));
2419
+ return i === 2 && (D += 60), D;
2420
+ }, enumerable: false }, rgbToAnsi: { value: (u, t, F) => r.ansi256ToAnsi(r.rgbToAnsi256(u, t, F)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
2421
+ }
2422
+ function Y(e, u, t) {
2423
+ return String(e).normalize().replace(/\r\n/g, `
2424
+ `).split(`
2425
+ `).map((F) => lD(F, u, t)).join(`
2426
+ `);
2427
+ }
2428
+ function $(e, u) {
2429
+ if (typeof e == "string")
2430
+ return B.aliases.get(e) === u;
2431
+ for (const t of e)
2432
+ if (t !== undefined && $(t, u))
2433
+ return true;
2434
+ return false;
2435
+ }
2436
+ function BD(e, u) {
2437
+ if (e === u)
2438
+ return;
2439
+ const t = e.split(`
2440
+ `), F = u.split(`
2441
+ `), s = [];
2442
+ for (let i = 0;i < Math.max(t.length, F.length); i++)
2443
+ t[i] !== F[i] && s.push(i);
2444
+ return s;
2445
+ }
2446
+ function pD(e) {
2447
+ return e === S;
2448
+ }
2449
+ function m(e, u) {
2450
+ const t = e;
2451
+ t.isTTY && t.setRawMode(u);
2452
+ }
2453
+
2454
+ class x {
2455
+ constructor(u, t = true) {
2456
+ 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");
2457
+ const { input: F = j, output: s = M, render: i, signal: D, ...C } = u;
2458
+ 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 = t, this._abortSignal = D, this.input = F, this.output = s;
2459
+ }
2460
+ unsubscribe() {
2461
+ this._subscribers.clear();
2462
+ }
2463
+ setSubscriber(u, t) {
2464
+ const F = this._subscribers.get(u) ?? [];
2465
+ F.push(t), this._subscribers.set(u, F);
2466
+ }
2467
+ on(u, t) {
2468
+ this.setSubscriber(u, { cb: t });
2469
+ }
2470
+ once(u, t) {
2471
+ this.setSubscriber(u, { cb: t, once: true });
2472
+ }
2473
+ emit(u, ...t) {
2474
+ const F = this._subscribers.get(u) ?? [], s = [];
2475
+ for (const i of F)
2476
+ i.cb(...t), i.once && s.push(() => F.splice(F.indexOf(i), 1));
2477
+ for (const i of s)
2478
+ i();
2479
+ }
2480
+ prompt() {
2481
+ return new Promise((u, t) => {
2482
+ if (this._abortSignal) {
2483
+ if (this._abortSignal.aborted)
2484
+ return this.state = "cancel", this.close(), u(S);
2485
+ this._abortSignal.addEventListener("abort", () => {
2486
+ this.state = "cancel", this.close();
2487
+ }, { once: true });
2488
+ }
2489
+ const F = new X;
2490
+ F._write = (s, i, D) => {
2491
+ this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
2492
+ }, this.input.pipe(F), this.rl = O.createInterface({ input: this.input, output: F, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), O.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), m(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
2493
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u(this.value);
2494
+ }), this.once("cancel", () => {
2495
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u(S);
2496
+ });
2497
+ });
2498
+ }
2499
+ onKeypress(u, t) {
2500
+ if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.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()), t?.name === "return") {
2501
+ if (this.opts.validate) {
2502
+ const F = this.opts.validate(this.value);
2503
+ F && (this.error = F instanceof Error ? F.message : F, this.state = "error", this.rl?.write(this.value));
2504
+ }
2505
+ this.state !== "error" && (this.state = "submit");
2506
+ }
2507
+ $([u, t?.name, t?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
2508
+ }
2509
+ close() {
2510
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
2511
+ `), m(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
2512
+ }
2513
+ restoreCursor() {
2514
+ const u = Y(this._prevFrame, process.stdout.columns, { hard: true }).split(`
2515
+ `).length - 1;
2516
+ this.output.write(import_sisteransi.cursor.move(-999, u * -1));
2517
+ }
2518
+ render() {
2519
+ const u = Y(this._render(this) ?? "", process.stdout.columns, { hard: true });
2520
+ if (u !== this._prevFrame) {
2521
+ if (this.state === "initial")
2522
+ this.output.write(import_sisteransi.cursor.hide);
2523
+ else {
2524
+ const t = BD(this._prevFrame, u);
2525
+ if (this.restoreCursor(), t && t?.length === 1) {
2526
+ const F = t[0];
2527
+ this.output.write(import_sisteransi.cursor.move(0, F)), this.output.write(import_sisteransi.erase.lines(1));
2528
+ const s = u.split(`
2529
+ `);
2530
+ this.output.write(s[F]), this._prevFrame = u, this.output.write(import_sisteransi.cursor.move(0, s.length - F - 1));
2531
+ return;
2532
+ }
2533
+ if (t && t?.length > 1) {
2534
+ const F = t[0];
2535
+ this.output.write(import_sisteransi.cursor.move(0, F)), this.output.write(import_sisteransi.erase.down());
2536
+ const s = u.split(`
2537
+ `).slice(F);
2538
+ this.output.write(s.join(`
2539
+ `)), this._prevFrame = u;
2540
+ return;
2541
+ }
2542
+ this.output.write(import_sisteransi.erase.down());
2543
+ }
2544
+ this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
2545
+ }
2546
+ }
2547
+ }
2548
+ var import_sisteransi, import_picocolors, uD, W, tD, eD, FD = function() {
2549
+ 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;
2550
+ }, sD, w = 10, N = (e = 0) => (u) => `\x1B[${u + e}m`, I = (e = 0) => (u) => `\x1B[${38 + e};5;${u}m`, R = (e = 0) => (u, t, F) => `\x1B[${38 + e};2;${u};${t};${F}m`, r, iD, CD, ED, d, oD = 39, y = "\x07", V = "[", nD = "]", G = "m", _, z = (e) => `${d.values().next().value}${V}${e}${G}`, K = (e) => `${d.values().next().value}${_}${e}${y}`, aD = (e) => e.split(" ").map((u) => p(u)), k = (e, u, t) => {
2551
+ const F = [...u];
2552
+ let s = false, i = false, D = p(P(e[e.length - 1]));
2553
+ for (const [C, n] of F.entries()) {
2554
+ const E = p(n);
2555
+ if (D + E <= t ? e[e.length - 1] += n : (e.push(n), D = 0), d.has(n) && (s = true, i = F.slice(C + 1).join("").startsWith(_)), s) {
2556
+ i ? n === y && (s = false, i = false) : n === G && (s = false);
2557
+ continue;
2558
+ }
2559
+ D += E, D === t && C < F.length - 1 && (e.push(""), D = 0);
2560
+ }
2561
+ !D && e[e.length - 1].length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
2562
+ }, hD = (e) => {
2563
+ const u = e.split(" ");
2564
+ let t = u.length;
2565
+ for (;t > 0 && !(p(u[t - 1]) > 0); )
2566
+ t--;
2567
+ return t === u.length ? e : u.slice(0, t).join(" ") + u.slice(t).join("");
2568
+ }, lD = (e, u, t = {}) => {
2569
+ if (t.trim !== false && e.trim() === "")
2570
+ return "";
2571
+ let F = "", s, i;
2572
+ const D = aD(e);
2573
+ let C = [""];
2574
+ for (const [E, a] of e.split(" ").entries()) {
2575
+ t.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
2576
+ let o = p(C[C.length - 1]);
2577
+ if (E !== 0 && (o >= u && (t.wordWrap === false || t.trim === false) && (C.push(""), o = 0), (o > 0 || t.trim === false) && (C[C.length - 1] += " ", o++)), t.hard && D[E] > u) {
2578
+ const c = u - o, f = 1 + Math.floor((D[E] - c - 1) / u);
2579
+ Math.floor((D[E] - 1) / u) < f && C.push(""), k(C, a, u);
2580
+ continue;
2581
+ }
2582
+ if (o + D[E] > u && o > 0 && D[E] > 0) {
2583
+ if (t.wordWrap === false && o < u) {
2584
+ k(C, a, u);
2585
+ continue;
2586
+ }
2587
+ C.push("");
2588
+ }
2589
+ if (o + D[E] > u && t.wordWrap === false) {
2590
+ k(C, a, u);
2591
+ continue;
2592
+ }
2593
+ C[C.length - 1] += a;
2594
+ }
2595
+ t.trim !== false && (C = C.map((E) => hD(E)));
2596
+ const n = [...C.join(`
2597
+ `)];
2598
+ for (const [E, a] of n.entries()) {
2599
+ if (F += a, d.has(a)) {
2600
+ const { groups: c } = new RegExp(`(?:\\${V}(?<code>\\d+)m|\\${_}(?<uri>.*)${y})`).exec(n.slice(E).join("")) || { groups: {} };
2601
+ if (c.code !== undefined) {
2602
+ const f = Number.parseFloat(c.code);
2603
+ s = f === oD ? undefined : f;
2604
+ } else
2605
+ c.uri !== undefined && (i = c.uri.length === 0 ? undefined : c.uri);
2606
+ }
2607
+ const o = ED.codes.get(Number(s));
2608
+ n[E + 1] === `
2609
+ ` ? (i && (F += K("")), s && o && (F += z(o))) : a === `
2610
+ ` && (s && o && (F += z(s)), i && (F += K(i)));
2611
+ }
2612
+ return F;
2613
+ }, xD, B, AD, S, gD, vD = (e, u, t) => (u in e) ? gD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t, h = (e, u, t) => (vD(e, typeof u != "symbol" ? u + "" : u, t), t), dD, A, kD, $D = (e, u, t) => (u in e) ? kD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t, H = (e, u, t) => ($D(e, typeof u != "symbol" ? u + "" : u, t), t), SD, TD, jD = (e, u, t) => (u in e) ? TD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t, U = (e, u, t) => (jD(e, typeof u != "symbol" ? u + "" : u, t), t), MD, OD, PD = (e, u, t) => (u in e) ? OD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t, J = (e, u, t) => (PD(e, typeof u != "symbol" ? u + "" : u, t), t), LD, RD;
2614
+ var init_dist = __esm(() => {
2615
+ import_sisteransi = __toESM(require_src(), 1);
2616
+ import_picocolors = __toESM(require_picocolors(), 1);
2617
+ uD = DD();
2618
+ W = { exports: {} };
2619
+ (function(e) {
2620
+ var u = {};
2621
+ e.exports = u, u.eastAsianWidth = function(F) {
2622
+ var s = F.charCodeAt(0), i = F.length == 2 ? F.charCodeAt(1) : 0, D = s;
2623
+ 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";
2624
+ }, u.characterLength = function(F) {
2625
+ var s = this.eastAsianWidth(F);
2626
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
2627
+ };
2628
+ function t(F) {
2629
+ return F.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
2630
+ }
2631
+ u.length = function(F) {
2632
+ for (var s = t(F), i = 0, D = 0;D < s.length; D++)
2633
+ i = i + this.characterLength(s[D]);
2634
+ return i;
2635
+ }, u.slice = function(F, s, i) {
2636
+ textLen = u.length(F), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
2637
+ for (var D = "", C = 0, n = t(F), E = 0;E < n.length; E++) {
2638
+ var a = n[E], o = u.length(a);
2639
+ if (C >= s - (o == 2 ? 1 : 0))
2640
+ if (C + o <= i)
2641
+ D += a;
2642
+ else
2643
+ break;
2644
+ C += o;
2645
+ }
2646
+ return D;
2647
+ };
2648
+ })(W);
2649
+ tD = W.exports;
2650
+ eD = L(tD);
2651
+ sD = L(FD);
2652
+ 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] } };
2653
+ Object.keys(r.modifier);
2654
+ iD = Object.keys(r.color);
2655
+ CD = Object.keys(r.bgColor);
2656
+ [...iD, ...CD];
2657
+ ED = rD();
2658
+ d = new Set(["\x1B", "›"]);
2659
+ _ = `${nD}8;;`;
2660
+ xD = ["up", "down", "left", "right", "space", "enter", "cancel"];
2661
+ B = { actions: new Set(xD), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]) };
2662
+ AD = globalThis.process.platform.startsWith("win");
2663
+ S = Symbol("clack:cancel");
2664
+ gD = Object.defineProperty;
2665
+ dD = class dD extends x {
2666
+ get cursor() {
2667
+ return this.value ? 0 : 1;
2668
+ }
2669
+ get _value() {
2670
+ return this.cursor === 0;
2671
+ }
2672
+ constructor(u) {
2673
+ super(u, false), this.value = !!u.initialValue, this.on("value", () => {
2674
+ this.value = this._value;
2675
+ }), this.on("confirm", (t) => {
2676
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
2677
+ }), this.on("cursor", () => {
2678
+ this.value = !this.value;
2679
+ });
2680
+ }
2681
+ };
2682
+ A = new WeakMap;
2683
+ kD = Object.defineProperty;
2684
+ SD = class extends x {
2685
+ constructor(u) {
2686
+ super(u, false), H(this, "options"), H(this, "cursor", 0), this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u.cursorAt), 0), this.on("key", (t) => {
2687
+ t === "a" && this.toggleAll();
2688
+ }), this.on("cursor", (t) => {
2689
+ switch (t) {
2690
+ case "left":
2691
+ case "up":
2692
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
2693
+ break;
2694
+ case "down":
2695
+ case "right":
2696
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
2697
+ break;
2698
+ case "space":
2699
+ this.toggleValue();
2700
+ break;
2701
+ }
2702
+ });
2703
+ }
2704
+ get _value() {
2705
+ return this.options[this.cursor].value;
2706
+ }
2707
+ toggleAll() {
2708
+ const u = this.value.length === this.options.length;
2709
+ this.value = u ? [] : this.options.map((t) => t.value);
2710
+ }
2711
+ toggleValue() {
2712
+ const u = this.value.includes(this._value);
2713
+ this.value = u ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
2714
+ }
2715
+ };
2716
+ TD = Object.defineProperty;
2717
+ MD = class MD extends x {
2718
+ constructor({ mask: u, ...t }) {
2719
+ super(t), U(this, "valueWithCursor", ""), U(this, "_mask", "•"), this._mask = u ?? "•", this.on("finalize", () => {
2720
+ this.valueWithCursor = this.masked;
2721
+ }), this.on("value", () => {
2722
+ if (this.cursor >= this.value.length)
2723
+ this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
2724
+ else {
2725
+ const F = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
2726
+ this.valueWithCursor = `${F}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
2727
+ }
2728
+ });
2729
+ }
2730
+ get cursor() {
2731
+ return this._cursor;
2732
+ }
2733
+ get masked() {
2734
+ return this.value.replaceAll(/./g, this._mask);
2735
+ }
2736
+ };
2737
+ OD = Object.defineProperty;
2738
+ LD = class LD extends x {
2739
+ constructor(u) {
2740
+ super(u, false), J(this, "options"), J(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: t }) => t === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
2741
+ switch (t) {
2742
+ case "left":
2743
+ case "up":
2744
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
2745
+ break;
2746
+ case "down":
2747
+ case "right":
2748
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
2749
+ break;
2750
+ }
2751
+ this.changeValue();
2752
+ });
2753
+ }
2754
+ get _value() {
2755
+ return this.options[this.cursor];
2756
+ }
2757
+ changeValue() {
2758
+ this.value = this._value.value;
2759
+ }
2760
+ };
2761
+ RD = class RD extends x {
2762
+ get valueWithCursor() {
2763
+ if (this.state === "submit")
2764
+ return this.value;
2765
+ if (this.cursor >= this.value.length)
2766
+ return `${this.value}█`;
2767
+ const u = this.value.slice(0, this.cursor), [t, ...F] = this.value.slice(this.cursor);
2768
+ return `${u}${import_picocolors.default.inverse(t)}${F.join("")}`;
2769
+ }
2770
+ get cursor() {
2771
+ return this._cursor;
2772
+ }
2773
+ constructor(u) {
2774
+ super(u), this.on("finalize", () => {
2775
+ this.value || (this.value = u.defaultValue);
2776
+ });
2777
+ }
2778
+ };
2779
+ });
2780
+
2781
+ // node_modules/@clack/prompts/dist/index.mjs
2782
+ import y2 from "node:process";
2783
+ function ce() {
2784
+ return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2785
+ }
2786
+ var import_picocolors2, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2, W2, C, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U2, K2, b2 = (t) => {
2787
+ switch (t) {
2788
+ case "initial":
2789
+ case "active":
2790
+ return import_picocolors2.default.cyan(le);
2791
+ case "cancel":
2792
+ return import_picocolors2.default.red(L2);
2793
+ case "error":
2794
+ return import_picocolors2.default.yellow(W2);
2795
+ case "submit":
2796
+ return import_picocolors2.default.green(C);
2797
+ }
2798
+ }, G2 = (t) => {
2799
+ const { cursor: n, options: r2, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
2800
+ let l2 = 0;
2801
+ n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
2802
+ const $2 = a < r2.length && l2 > 0, g = a < r2.length && l2 + a < r2.length;
2803
+ return r2.slice(l2, l2 + a).map((p2, v2, f) => {
2804
+ const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g;
2805
+ return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v2 + l2 === n);
2806
+ });
2807
+ }, he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
2808
+ const n = `${import_picocolors2.default.gray(o)}
2809
+ ${b2(this.state)} ${t.message}
2810
+ `, r2 = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : r2;
2811
+ switch (this.state) {
2812
+ case "error":
2813
+ return `${n.trim()}
2814
+ ${import_picocolors2.default.yellow(o)} ${i}
2815
+ ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
2816
+ `;
2817
+ case "submit":
2818
+ return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(this.value || t.placeholder)}`;
2819
+ case "cancel":
2820
+ return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
2821
+ ${import_picocolors2.default.gray(o)}` : ""}`;
2822
+ default:
2823
+ return `${n}${import_picocolors2.default.cyan(o)} ${i}
2824
+ ${import_picocolors2.default.cyan(d2)}
2825
+ `;
2826
+ }
2827
+ } }).prompt(), ge = (t) => new MD({ validate: t.validate, mask: t.mask ?? $e, render() {
2828
+ const n = `${import_picocolors2.default.gray(o)}
2829
+ ${b2(this.state)} ${t.message}
2830
+ `, r2 = this.valueWithCursor, i = this.masked;
2831
+ switch (this.state) {
2832
+ case "error":
2833
+ return `${n.trim()}
2834
+ ${import_picocolors2.default.yellow(o)} ${i}
2835
+ ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
2836
+ `;
2837
+ case "submit":
2838
+ return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(i)}`;
2839
+ case "cancel":
2840
+ return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(i ?? ""))}${i ? `
2841
+ ${import_picocolors2.default.gray(o)}` : ""}`;
2842
+ default:
2843
+ return `${n}${import_picocolors2.default.cyan(o)} ${r2}
2844
+ ${import_picocolors2.default.cyan(d2)}
2845
+ `;
2846
+ }
2847
+ } }).prompt(), ye = (t) => {
2848
+ const n = t.active ?? "Yes", r2 = t.inactive ?? "No";
2849
+ return new dD({ active: n, inactive: r2, initialValue: t.initialValue ?? true, render() {
2850
+ const i = `${import_picocolors2.default.gray(o)}
2851
+ ${b2(this.state)} ${t.message}
2852
+ `, s = this.value ? n : r2;
2853
+ switch (this.state) {
2854
+ case "submit":
2855
+ return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
2856
+ case "cancel":
2857
+ return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
2858
+ ${import_picocolors2.default.gray(o)}`;
2859
+ default:
2860
+ return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r2)}` : `${import_picocolors2.default.green(k2)} ${r2}`}
2861
+ ${import_picocolors2.default.cyan(d2)}
2862
+ `;
2863
+ }
2864
+ } }).prompt();
2865
+ }, ve = (t) => {
2866
+ const n = (r2, i) => {
2867
+ const s = r2.label ?? String(r2.value);
2868
+ switch (i) {
2869
+ case "selected":
2870
+ return `${import_picocolors2.default.dim(s)}`;
2871
+ case "active":
2872
+ return `${import_picocolors2.default.green(k2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
2873
+ case "cancelled":
2874
+ return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
2875
+ default:
2876
+ return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
2877
+ }
2878
+ };
2879
+ return new LD({ options: t.options, initialValue: t.initialValue, render() {
2880
+ const r2 = `${import_picocolors2.default.gray(o)}
2881
+ ${b2(this.state)} ${t.message}
2882
+ `;
2883
+ switch (this.state) {
2884
+ case "submit":
2885
+ return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
2886
+ case "cancel":
2887
+ return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
2888
+ ${import_picocolors2.default.gray(o)}`;
2889
+ default:
2890
+ return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
2891
+ ${import_picocolors2.default.cyan(o)} `)}
2892
+ ${import_picocolors2.default.cyan(d2)}
2893
+ `;
2894
+ }
2895
+ } }).prompt();
2896
+ }, fe = (t) => {
2897
+ const n = (r2, i) => {
2898
+ const s = r2.label ?? String(r2.value);
2899
+ return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(T)} ${import_picocolors2.default.dim(s)} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active-selected" ? `${import_picocolors2.default.green(T)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(F)} ${import_picocolors2.default.dim(s)}`;
2900
+ };
2901
+ return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r2) {
2902
+ if (this.required && r2.length === 0)
2903
+ return `Please select at least one option.
2904
+ ${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
2905
+ }, render() {
2906
+ const r2 = `${import_picocolors2.default.gray(o)}
2907
+ ${b2(this.state)} ${t.message}
2908
+ `, i = (s, c) => {
2909
+ const a = this.value.includes(s.value);
2910
+ return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
2911
+ };
2912
+ switch (this.state) {
2913
+ case "submit":
2914
+ return `${r2}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
2915
+ case "cancel": {
2916
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors2.default.dim(", "));
2917
+ return `${r2}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
2918
+ ${import_picocolors2.default.gray(o)}` : ""}`;
2919
+ }
2920
+ case "error": {
2921
+ const s = this.error.split(`
2922
+ `).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
2923
+ `);
2924
+ return `${r2 + import_picocolors2.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
2925
+ ${import_picocolors2.default.yellow(o)} `)}
2926
+ ${s}
2927
+ `;
2928
+ }
2929
+ default:
2930
+ return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
2931
+ ${import_picocolors2.default.cyan(o)} `)}
2932
+ ${import_picocolors2.default.cyan(d2)}
2933
+ `;
2934
+ }
2935
+ } }).prompt();
2936
+ }, J2;
2937
+ var init_dist2 = __esm(() => {
2938
+ init_dist();
2939
+ init_dist();
2940
+ import_picocolors2 = __toESM(require_picocolors(), 1);
2941
+ import_sisteransi2 = __toESM(require_src(), 1);
2942
+ V2 = ce();
2943
+ le = u("◆", "*");
2944
+ L2 = u("■", "x");
2945
+ W2 = u("▲", "x");
2946
+ C = u("◇", "o");
2947
+ ue = u("┌", "T");
2948
+ o = u("│", "|");
2949
+ d2 = u("└", "—");
2950
+ k2 = u("●", ">");
2951
+ P2 = u("○", " ");
2952
+ A2 = u("◻", "[•]");
2953
+ T = u("◼", "[+]");
2954
+ F = u("◻", "[ ]");
2955
+ $e = u("▪", "•");
2956
+ _2 = u("─", "-");
2957
+ me = u("╮", "+");
2958
+ de = u("├", "+");
2959
+ pe = u("╯", "+");
2960
+ q = u("●", "•");
2961
+ D = u("◆", "*");
2962
+ U2 = u("▲", "!");
2963
+ K2 = u("■", "x");
2964
+ J2 = `${import_picocolors2.default.gray(o)} `;
2965
+ });
2966
+
2967
+ // src/utils/display.ts
2968
+ function success(message) {
2969
+ console.log(`${import_picocolors3.default.green("✓")} ${message}`);
2970
+ }
2971
+ function error(message) {
2972
+ console.log(`${import_picocolors3.default.red("✗")} ${message}`);
2973
+ }
2974
+ function warn(message) {
2975
+ console.log(`${import_picocolors3.default.yellow("⚠")} ${message}`);
2976
+ }
2977
+ function info(message) {
2978
+ console.log(`${import_picocolors3.default.blue("ℹ")} ${message}`);
2979
+ }
2980
+ function resolvePrice(model) {
2981
+ if (model in MODEL_PRICING)
2982
+ return MODEL_PRICING[model];
2983
+ const key = Object.keys(MODEL_PRICING).find((k3) => model.startsWith(k3));
2984
+ return key ? MODEL_PRICING[key] : null;
2985
+ }
2986
+ function formatCost(usd) {
2987
+ if (usd === 0)
2988
+ return "$0.00";
2989
+ if (usd < 0.001)
2990
+ return `$${usd.toFixed(6)}`;
2991
+ if (usd < 0.01)
2992
+ return `$${usd.toFixed(4)}`;
2993
+ return `$${usd.toFixed(2)}`;
2994
+ }
2995
+ function renderContextBanner(params) {
2996
+ const { inputTokens, outputTokens, provider, model } = params;
2997
+ const totalTokens = inputTokens + outputTokens;
2998
+ const contextWindow = /opus/.test(model) ? 200000 : 200000;
2999
+ const pctUsed = contextWindow > 0 ? Math.min(100, Math.round(inputTokens / contextWindow * 100)) : 0;
3000
+ const pricing = resolvePrice(model);
3001
+ const costUsd = pricing ? inputTokens / 1e6 * pricing[0] + outputTokens / 1e6 * pricing[1] : null;
3002
+ const providerLabel = provider.charAt(0).toUpperCase() + provider.slice(1);
3003
+ const width = 36;
3004
+ const border = import_picocolors3.default.dim("─".repeat(width));
3005
+ console.log("");
3006
+ console.log(` ${import_picocolors3.default.dim(border)}`);
3007
+ console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.bold("Context")}${" ".repeat(width - 9)}${import_picocolors3.default.dim("│")}`);
3008
+ console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.cyan(totalTokens.toLocaleString())} ${import_picocolors3.default.dim("tokens")}${" ".repeat(Math.max(0, width - 2 - totalTokens.toLocaleString().length - 7))}${import_picocolors3.default.dim("│")}`);
3009
+ console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.yellow(`${pctUsed}%`)} ${import_picocolors3.default.dim("of context window used")}${" ".repeat(Math.max(0, width - 2 - String(pctUsed).length - 1 - 22))}${import_picocolors3.default.dim("│")}`);
3010
+ if (costUsd !== null) {
3011
+ const costStr = formatCost(costUsd);
3012
+ console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.green(costStr)} ${import_picocolors3.default.dim("spent")}${" ".repeat(Math.max(0, width - 2 - costStr.length - 6))}${import_picocolors3.default.dim("│")}`);
3013
+ }
3014
+ console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.dim(`${providerLabel} · ${model}`)}${" ".repeat(Math.max(0, width - 2 - providerLabel.length - 3 - model.length))}${import_picocolors3.default.dim("│")}`);
3015
+ console.log(` ${import_picocolors3.default.dim(border)}`);
3016
+ console.log("");
3017
+ }
3018
+ function isModelNotSupportedError(err) {
3019
+ const msg = err instanceof Error ? err.message : String(err);
3020
+ return msg.includes("model is not supported") || msg.includes("model_not_found") || msg.includes("invalid model") || /4\d\d.*model/i.test(msg);
3021
+ }
3022
+ var import_picocolors3, MODEL_PRICING;
3023
+ var init_display = __esm(() => {
3024
+ init_dist2();
3025
+ import_picocolors3 = __toESM(require_picocolors(), 1);
3026
+ MODEL_PRICING = {
3027
+ "claude-opus-4-5": [15, 75],
3028
+ "claude-opus-4": [15, 75],
3029
+ "claude-sonnet-4-5": [3, 15],
3030
+ "claude-sonnet-4": [3, 15],
3031
+ "claude-sonnet-4-20250514": [3, 15],
3032
+ "claude-3-7-sonnet-20250219": [3, 15],
3033
+ "claude-3-5-sonnet-20241022": [3, 15],
3034
+ "claude-3-5-haiku-20241022": [0.8, 4],
3035
+ "claude-haiku-4-5": [0.8, 4],
3036
+ "gpt-4o": [2.5, 10],
3037
+ "gpt-4o-mini": [0.15, 0.6],
3038
+ o3: [10, 40],
3039
+ "o4-mini": [1.1, 4.4],
3040
+ "gpt-4.1": [2, 8],
3041
+ "gemini-2.0-flash": [0.1, 0.4],
3042
+ "gemini-2.5-pro-preview-05-06": [1.25, 10]
3043
+ };
3044
+ });
3045
+
3046
+ // src/mcp/lifecycle.ts
3047
+ var exports_lifecycle = {};
3048
+ __export(exports_lifecycle, {
3049
+ spawnMcpServer: () => spawnMcpServer,
3050
+ shutdownMcpServer: () => shutdownMcpServer,
3051
+ isMcpServerRunning: () => isMcpServerRunning,
3052
+ getMcpServerProcess: () => getMcpServerProcess,
3053
+ findMcpEntryPoint: () => findMcpEntryPoint
3054
+ });
3055
+ import { spawn, execSync } from "node:child_process";
3056
+ import { existsSync as existsSync2 } from "node:fs";
3057
+ import { join as join2 } from "node:path";
3058
+ function findMcpEntryPoint() {
3059
+ try {
3060
+ const globalRoot = execSync("npm root -g", { encoding: "utf-8", stdio: "pipe" }).trim();
3061
+ const candidate = join2(globalRoot, "@railway", "mcp-server", "dist", "index.js");
3062
+ if (existsSync2(candidate))
3063
+ return candidate;
3064
+ } catch {}
3065
+ return null;
3066
+ }
3067
+ function formatExitDetail(code, signal) {
3068
+ const codeLabel = code === null ? "null" : String(code);
3069
+ const signalLabel = signal ?? "null";
3070
+ return `code=${codeLabel}, signal=${signalLabel}`;
3071
+ }
3072
+ function isChildRunning(child) {
3073
+ return child.exitCode === null && !child.killed;
3074
+ }
3075
+ function buildServerProcess(child) {
3076
+ if (!child.stdin || !child.stdout) {
3077
+ throw new Error("MCP server stdio was not created");
3078
+ }
3079
+ return {
3080
+ process: child,
3081
+ stdin: child.stdin,
3082
+ stdout: child.stdout,
3083
+ pid: child.pid ?? -1
3084
+ };
3085
+ }
3086
+ function attachLifecycleListeners(child) {
3087
+ child.stderr?.on("data", (chunk) => {
3088
+ const message = String(chunk).trim();
3089
+ if (!message) {
3090
+ return;
3091
+ }
3092
+ auditLogger.mcp("server-lifecycle", "stderr", "FAILED", message);
3093
+ });
3094
+ child.on("exit", (code, signal) => {
3095
+ const detail = formatExitDetail(code, signal);
3096
+ if (activeServer?.process === child) {
3097
+ activeServer = null;
3098
+ }
3099
+ if (intentionallyShuttingDown.has(child)) {
3100
+ return;
3101
+ }
3102
+ shouldLogRespawn = true;
3103
+ auditLogger.mcp("server-lifecycle", "crash", "FAILED", detail);
3104
+ });
3105
+ }
3106
+ function displaySpawnFailure(reason) {
3107
+ error(MCP_START_FAILURE_MESSAGE);
3108
+ auditLogger.mcp("server-lifecycle", "spawn", "FAILED", reason);
3109
+ }
3110
+ async function spawnMcpServer() {
3111
+ if (activeServer && isChildRunning(activeServer.process)) {
3112
+ return activeServer;
3113
+ }
3114
+ if (pendingSpawn) {
3115
+ return pendingSpawn;
3116
+ }
3117
+ const entryPoint = findMcpEntryPoint();
3118
+ if (!entryPoint) {
3119
+ throw new Error(MCP_START_FAILURE_MESSAGE);
3120
+ }
3121
+ const respawn = shouldLogRespawn;
3122
+ const child = spawn("node", [entryPoint], {
3123
+ stdio: ["pipe", "pipe", "pipe"]
3124
+ });
3125
+ attachLifecycleListeners(child);
3126
+ pendingSpawn = new Promise((resolve, reject) => {
3127
+ const handleError = (spawnError) => {
3128
+ child.off("spawn", handleSpawn);
3129
+ if (activeServer?.process === child) {
3130
+ activeServer = null;
3131
+ }
3132
+ displaySpawnFailure(spawnError.message);
3133
+ reject(spawnError);
3134
+ };
3135
+ const handleSpawn = () => {
3136
+ child.off("error", handleError);
3137
+ let serverProcess;
3138
+ try {
3139
+ serverProcess = buildServerProcess(child);
3140
+ } catch (buildError) {
3141
+ const err = buildError instanceof Error ? buildError : new Error(String(buildError));
3142
+ displaySpawnFailure(err.message);
3143
+ reject(err);
3144
+ return;
3145
+ }
3146
+ activeServer = serverProcess;
3147
+ shouldLogRespawn = false;
3148
+ if (respawn) {
3149
+ auditLogger.mcp("server-lifecycle", "respawn", "SUCCESS", `pid=${serverProcess.pid}`);
3150
+ } else {
3151
+ auditLogger.mcp("server-lifecycle", "spawn", "SUCCESS", `pid=${serverProcess.pid}`);
3152
+ }
3153
+ resolve(serverProcess);
3154
+ };
3155
+ child.once("error", handleError);
3156
+ child.once("spawn", handleSpawn);
3157
+ }).finally(() => {
3158
+ pendingSpawn = null;
3159
+ });
3160
+ return pendingSpawn;
3161
+ }
3162
+ function getMcpServerProcess() {
3163
+ if (!activeServer) {
3164
+ return null;
3165
+ }
3166
+ if (!isChildRunning(activeServer.process)) {
3167
+ activeServer = null;
3168
+ return null;
3169
+ }
3170
+ return activeServer;
3171
+ }
3172
+ function isMcpServerRunning() {
3173
+ return getMcpServerProcess() !== null;
3174
+ }
3175
+ async function shutdownMcpServer() {
3176
+ if (!activeServer) {
3177
+ return;
3178
+ }
3179
+ const child = activeServer.process;
3180
+ intentionallyShuttingDown.add(child);
3181
+ if (!isChildRunning(child)) {
3182
+ activeServer = null;
3183
+ return;
3184
+ }
3185
+ const exitPromise = new Promise((resolve) => {
3186
+ child.once("exit", (code, signal) => {
3187
+ resolve({ code, signal });
3188
+ });
3189
+ });
3190
+ child.kill("SIGTERM");
3191
+ let forcedKill = false;
3192
+ const timeoutHandle = setTimeout(() => {
3193
+ forcedKill = true;
3194
+ child.kill("SIGKILL");
3195
+ }, SHUTDOWN_TIMEOUT_MS);
3196
+ const exitResult = await exitPromise;
3197
+ clearTimeout(timeoutHandle);
3198
+ activeServer = null;
3199
+ const detail = forcedKill ? `forced after timeout (${formatExitDetail(exitResult.code, exitResult.signal)})` : formatExitDetail(exitResult.code, exitResult.signal);
3200
+ auditLogger.mcp("server-lifecycle", "shutdown", "SUCCESS", detail);
3201
+ }
3202
+ var MCP_START_FAILURE_MESSAGE = "Railway MCP Server not found. Install it: npm install -g @railway/mcp-server", SHUTDOWN_TIMEOUT_MS = 5000, auditLogger, activeServer = null, pendingSpawn = null, shouldLogRespawn = false, intentionallyShuttingDown;
3203
+ var init_lifecycle = __esm(() => {
3204
+ init_logger();
3205
+ init_display();
3206
+ auditLogger = createAuditLogger(".");
3207
+ intentionallyShuttingDown = new WeakSet;
3208
+ });
3209
+
2253
3210
  // src/credentials/encryption.ts
2254
3211
  import { execSync as execSync2 } from "node:child_process";
2255
3212
  import {
@@ -2631,11 +3588,15 @@ function readConfig() {
2631
3588
  if (raw.length === 0) {
2632
3589
  return {};
2633
3590
  }
2634
- const parsed = JSON.parse(raw);
2635
- if (!parsed || typeof parsed !== "object") {
3591
+ try {
3592
+ const parsed = JSON.parse(raw);
3593
+ if (!parsed || typeof parsed !== "object") {
3594
+ return {};
3595
+ }
3596
+ return parsed;
3597
+ } catch {
2636
3598
  return {};
2637
3599
  }
2638
- return parsed;
2639
3600
  }
2640
3601
  function writeConfig(config) {
2641
3602
  ensureConfigDir();
@@ -2814,8 +3775,7 @@ async function refreshCopilotToken(githubToken) {
2814
3775
  throw new Error(`Copilot token exchange failed: network error — ${err instanceof Error ? err.message : String(err)}`);
2815
3776
  }
2816
3777
  if (!res.ok) {
2817
- const body = await res.text().catch(() => "");
2818
- throw new Error(`Copilot token exchange failed (HTTP ${res.status}): ${body.slice(0, 300)}`);
3778
+ throw new Error(`Copilot token exchange failed (HTTP ${res.status})`);
2819
3779
  }
2820
3780
  const data = await res.json();
2821
3781
  if (typeof data.token !== "string" || typeof data.expires_at !== "number") {
@@ -2824,6 +3784,9 @@ async function refreshCopilotToken(githubToken) {
2824
3784
  return { token: data.token, expiresAt: data.expires_at * 1000 };
2825
3785
  }
2826
3786
  async function getCopilotToken() {
3787
+ if (pendingCopilotRefresh) {
3788
+ return pendingCopilotRefresh;
3789
+ }
2827
3790
  const config = readConfig();
2828
3791
  const llm = getStoredLlm(config);
2829
3792
  if (!llm || llm.authType !== "github-copilot") {
@@ -2836,24 +3799,29 @@ async function getCopilotToken() {
2836
3799
  if (Date.now() < stored.copilotTokenExpiresAt - 60000) {
2837
3800
  return decrypted.copilotToken;
2838
3801
  }
2839
- let refreshed;
2840
- try {
2841
- refreshed = await refreshCopilotToken(decrypted.githubToken);
2842
- } catch {
2843
- return null;
2844
- }
2845
- const encCopilot = await encrypt(refreshed.token);
2846
- writeConfig({
2847
- llm: {
2848
- ...stored,
2849
- copilotToken: encCopilot.encrypted,
2850
- copilotIv: encCopilot.iv,
2851
- copilotSalt: encCopilot.salt,
2852
- copilotAuthTag: encCopilot.authTag,
2853
- copilotTokenExpiresAt: refreshed.expiresAt
3802
+ pendingCopilotRefresh = (async () => {
3803
+ let refreshed;
3804
+ try {
3805
+ refreshed = await refreshCopilotToken(decrypted.githubToken);
3806
+ } catch {
3807
+ return null;
2854
3808
  }
3809
+ const encCopilot = await encrypt(refreshed.token);
3810
+ writeConfig({
3811
+ llm: {
3812
+ ...stored,
3813
+ copilotToken: encCopilot.encrypted,
3814
+ copilotIv: encCopilot.iv,
3815
+ copilotSalt: encCopilot.salt,
3816
+ copilotAuthTag: encCopilot.authTag,
3817
+ copilotTokenExpiresAt: refreshed.expiresAt
3818
+ }
3819
+ });
3820
+ return refreshed.token;
3821
+ })().finally(() => {
3822
+ pendingCopilotRefresh = null;
2855
3823
  });
2856
- return refreshed.token;
3824
+ return pendingCopilotRefresh;
2857
3825
  }
2858
3826
  async function exchangeCopilotToken(githubToken) {
2859
3827
  return refreshCopilotToken(githubToken);
@@ -2910,7 +3878,7 @@ async function isLlmConfigured() {
2910
3878
  const apiKey = await getLlmApiKey();
2911
3879
  return apiKey !== null;
2912
3880
  }
2913
- var CONFIG_DIR, CONFIG_FILE, KEYCHAIN_API_KEY = "llm-api-key", DIR_MODE = 448, FILE_MODE = 384, SHARED_MODEL_MIGRATIONS, COPILOT_MODEL_MIGRATIONS, COPILOT_TOKEN_URL = "https://api.github.com/copilot_internal/v2/token";
3881
+ var CONFIG_DIR, CONFIG_FILE, KEYCHAIN_API_KEY = "llm-api-key", DIR_MODE = 448, FILE_MODE = 384, SHARED_MODEL_MIGRATIONS, COPILOT_MODEL_MIGRATIONS, COPILOT_TOKEN_URL = "https://api.github.com/copilot_internal/v2/token", pendingCopilotRefresh = null;
2914
3882
  var init_config = __esm(() => {
2915
3883
  init_encryption();
2916
3884
  init_keychain();
@@ -2924,12 +3892,12 @@ var init_config = __esm(() => {
2924
3892
  "o4-mini": "gpt-4.1"
2925
3893
  };
2926
3894
  COPILOT_MODEL_MIGRATIONS = {
2927
- "claude-sonnet-4-5": "claude-sonnet-4.6",
3895
+ "claude-sonnet-4-5": "claude-haiku-4.5",
2928
3896
  "claude-haiku-4-5": "claude-haiku-4.5",
2929
- "claude-opus-4-5": "claude-opus-4.6",
2930
- "claude-sonnet-4": "claude-sonnet-4.6",
2931
- "claude-sonnet-4.5": "claude-sonnet-4.6",
2932
- "claude-opus-4.5": "claude-opus-4.6",
3897
+ "claude-opus-4-5": "claude-haiku-4.5",
3898
+ "claude-sonnet-4": "claude-haiku-4.5",
3899
+ "claude-sonnet-4.5": "claude-haiku-4.5",
3900
+ "claude-opus-4.5": "claude-haiku-4.5",
2933
3901
  "gemini-2.5-pro": "gpt-4.1"
2934
3902
  };
2935
3903
  });
@@ -3126,7 +4094,7 @@ var init_values = __esm(() => {
3126
4094
  });
3127
4095
 
3128
4096
  // node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs
3129
- var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
4097
+ var sleep = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
3130
4098
 
3131
4099
  // node_modules/@anthropic-ai/sdk/version.mjs
3132
4100
  var VERSION = "0.66.0";
@@ -3820,8 +4788,8 @@ var init_api_promise = __esm(() => {
3820
4788
  init_parse();
3821
4789
  APIPromise = class APIPromise extends Promise {
3822
4790
  constructor(client, responsePromise, parseResponse = defaultParseResponse) {
3823
- super((resolve2) => {
3824
- resolve2(null);
4791
+ super((resolve3) => {
4792
+ resolve3(null);
3825
4793
  });
3826
4794
  this.responsePromise = responsePromise;
3827
4795
  this.parseResponse = parseResponse;
@@ -4724,12 +5692,12 @@ var init_BetaMessageStream = __esm(() => {
4724
5692
  }
4725
5693
  return this._emit("error", new AnthropicError(String(error3)));
4726
5694
  });
4727
- __classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve2, reject) => {
4728
- __classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve2, "f");
5695
+ __classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve3, reject) => {
5696
+ __classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve3, "f");
4729
5697
  __classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
4730
5698
  }), "f");
4731
- __classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve2, reject) => {
4732
- __classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve2, "f");
5699
+ __classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve3, reject) => {
5700
+ __classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve3, "f");
4733
5701
  __classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
4734
5702
  }), "f");
4735
5703
  __classPrivateFieldGet(this, _BetaMessageStream_connectedPromise, "f").catch(() => {});
@@ -4846,11 +5814,11 @@ var init_BetaMessageStream = __esm(() => {
4846
5814
  return this;
4847
5815
  }
4848
5816
  emitted(event) {
4849
- return new Promise((resolve2, reject) => {
5817
+ return new Promise((resolve3, reject) => {
4850
5818
  __classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
4851
5819
  if (event !== "error")
4852
5820
  this.once("error", reject);
4853
- this.once(event, resolve2);
5821
+ this.once(event, resolve3);
4854
5822
  });
4855
5823
  }
4856
5824
  async done() {
@@ -5165,7 +6133,7 @@ var init_BetaMessageStream = __esm(() => {
5165
6133
  if (done) {
5166
6134
  return { value: undefined, done: true };
5167
6135
  }
5168
- return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
6136
+ return new Promise((resolve3, reject) => readQueue.push({ resolve: resolve3, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
5169
6137
  }
5170
6138
  const chunk = pushQueue.shift();
5171
6139
  return { value: chunk, done: false };
@@ -5200,13 +6168,13 @@ var init_constants = __esm(() => {
5200
6168
 
5201
6169
  // node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs
5202
6170
  function promiseWithResolvers() {
5203
- let resolve2;
6171
+ let resolve3;
5204
6172
  let reject;
5205
6173
  const promise = new Promise((res, rej) => {
5206
- resolve2 = res;
6174
+ resolve3 = res;
5207
6175
  reject = rej;
5208
6176
  });
5209
- return { promise, resolve: resolve2, reject };
6177
+ return { promise, resolve: resolve3, reject };
5210
6178
  }
5211
6179
  async function generateToolResponse(params, lastMessage = params.messages.at(-1)) {
5212
6180
  if (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content || typeof lastMessage.content === "string") {
@@ -5550,12 +6518,12 @@ var init_MessageStream = __esm(() => {
5550
6518
  }
5551
6519
  return this._emit("error", new AnthropicError(String(error3)));
5552
6520
  });
5553
- __classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve2, reject) => {
5554
- __classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve2, "f");
6521
+ __classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve3, reject) => {
6522
+ __classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve3, "f");
5555
6523
  __classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
5556
6524
  }), "f");
5557
- __classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve2, reject) => {
5558
- __classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve2, "f");
6525
+ __classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve3, reject) => {
6526
+ __classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve3, "f");
5559
6527
  __classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
5560
6528
  }), "f");
5561
6529
  __classPrivateFieldGet(this, _MessageStream_connectedPromise, "f").catch(() => {});
@@ -5672,11 +6640,11 @@ var init_MessageStream = __esm(() => {
5672
6640
  return this;
5673
6641
  }
5674
6642
  emitted(event) {
5675
- return new Promise((resolve2, reject) => {
6643
+ return new Promise((resolve3, reject) => {
5676
6644
  __classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true, "f");
5677
6645
  if (event !== "error")
5678
6646
  this.once("error", reject);
5679
- this.once(event, resolve2);
6647
+ this.once(event, resolve3);
5680
6648
  });
5681
6649
  }
5682
6650
  async done() {
@@ -5984,7 +6952,7 @@ var init_MessageStream = __esm(() => {
5984
6952
  if (done) {
5985
6953
  return { value: undefined, done: true };
5986
6954
  }
5987
- return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
6955
+ return new Promise((resolve3, reject) => readQueue.push({ resolve: resolve3, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
5988
6956
  }
5989
6957
  const chunk = pushQueue.shift();
5990
6958
  return { value: chunk, done: false };
@@ -6839,7 +7807,7 @@ var init_values2 = __esm(() => {
6839
7807
  });
6840
7808
 
6841
7809
  // node_modules/openai/internal/utils/sleep.mjs
6842
- var sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
7810
+ var sleep2 = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
6843
7811
 
6844
7812
  // node_modules/openai/version.mjs
6845
7813
  var VERSION2 = "6.22.0";
@@ -7866,8 +8834,8 @@ var init_api_promise2 = __esm(() => {
7866
8834
  init_parse2();
7867
8835
  APIPromise2 = class APIPromise2 extends Promise {
7868
8836
  constructor(client, responsePromise, parseResponse = defaultParseResponse2) {
7869
- super((resolve2) => {
7870
- resolve2(null);
8837
+ super((resolve3) => {
8838
+ resolve3(null);
7871
8839
  });
7872
8840
  this.responsePromise = responsePromise;
7873
8841
  this.parseResponse = parseResponse;
@@ -8392,12 +9360,12 @@ class EventStream {
8392
9360
  _EventStream_errored.set(this, false);
8393
9361
  _EventStream_aborted.set(this, false);
8394
9362
  _EventStream_catchingPromiseCreated.set(this, false);
8395
- __classPrivateFieldSet2(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
8396
- __classPrivateFieldSet2(this, _EventStream_resolveConnectedPromise, resolve2, "f");
9363
+ __classPrivateFieldSet2(this, _EventStream_connectedPromise, new Promise((resolve3, reject) => {
9364
+ __classPrivateFieldSet2(this, _EventStream_resolveConnectedPromise, resolve3, "f");
8397
9365
  __classPrivateFieldSet2(this, _EventStream_rejectConnectedPromise, reject, "f");
8398
9366
  }), "f");
8399
- __classPrivateFieldSet2(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
8400
- __classPrivateFieldSet2(this, _EventStream_resolveEndPromise, resolve2, "f");
9367
+ __classPrivateFieldSet2(this, _EventStream_endPromise, new Promise((resolve3, reject) => {
9368
+ __classPrivateFieldSet2(this, _EventStream_resolveEndPromise, resolve3, "f");
8401
9369
  __classPrivateFieldSet2(this, _EventStream_rejectEndPromise, reject, "f");
8402
9370
  }), "f");
8403
9371
  __classPrivateFieldGet2(this, _EventStream_connectedPromise, "f").catch(() => {});
@@ -8449,11 +9417,11 @@ class EventStream {
8449
9417
  return this;
8450
9418
  }
8451
9419
  emitted(event) {
8452
- return new Promise((resolve2, reject) => {
9420
+ return new Promise((resolve3, reject) => {
8453
9421
  __classPrivateFieldSet2(this, _EventStream_catchingPromiseCreated, true, "f");
8454
9422
  if (event !== "error")
8455
9423
  this.once("error", reject);
8456
- this.once(event, resolve2);
9424
+ this.once(event, resolve3);
8457
9425
  });
8458
9426
  }
8459
9427
  async done() {
@@ -9460,7 +10428,7 @@ var init_ChatCompletionStream = __esm(() => {
9460
10428
  if (done) {
9461
10429
  return { value: undefined, done: true };
9462
10430
  }
9463
- return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
10431
+ return new Promise((resolve3, reject) => readQueue.push({ resolve: resolve3, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
9464
10432
  }
9465
10433
  const chunk = pushQueue.shift();
9466
10434
  return { value: chunk, done: false };
@@ -10076,7 +11044,7 @@ var init_AssistantStream = __esm(() => {
10076
11044
  if (done) {
10077
11045
  return { value: undefined, done: true };
10078
11046
  }
10079
- return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
11047
+ return new Promise((resolve3, reject) => readQueue.push({ resolve: resolve3, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
10080
11048
  }
10081
11049
  const chunk = pushQueue.shift();
10082
11050
  return { value: chunk, done: false };
@@ -11700,7 +12668,7 @@ var init_ResponseStream = __esm(() => {
11700
12668
  if (done) {
11701
12669
  return { value: undefined, done: true };
11702
12670
  }
11703
- return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: undefined, done: true });
12671
+ return new Promise((resolve3, reject) => readQueue.push({ resolve: resolve3, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: undefined, done: true });
11704
12672
  }
11705
12673
  const event = pushQueue.shift();
11706
12674
  return { value: event, done: false };
@@ -13754,7 +14722,7 @@ class GoogleGenerativeAI {
13754
14722
  }
13755
14723
  }
13756
14724
  var SchemaType, ExecutableCodeLanguage, Outcome, POSSIBLE_ROLES, HarmCategory, HarmBlockThreshold, HarmProbability, BlockReason, FinishReason, TaskType, FunctionCallingMode, DynamicRetrievalMode, GoogleGenerativeAIError, GoogleGenerativeAIResponseError, GoogleGenerativeAIFetchError, GoogleGenerativeAIRequestInputError, GoogleGenerativeAIAbortError, DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com", DEFAULT_API_VERSION = "v1beta", PACKAGE_VERSION = "0.24.1", PACKAGE_LOG_HEADER = "genai-js", Task, badFinishReasons, responseLineRE, VALID_PART_FIELDS, VALID_PARTS_PER_ROLE, SILENT_ERROR = "SILENT_ERROR";
13757
- var init_dist = __esm(() => {
14725
+ var init_dist3 = __esm(() => {
13758
14726
  (function(SchemaType2) {
13759
14727
  SchemaType2["STRING"] = "string";
13760
14728
  SchemaType2["NUMBER"] = "number";
@@ -113927,14 +114895,14 @@ ${lanes.join(`
113927
114895
  }
113928
114896
  }
113929
114897
  function createImportCallExpressionAMD(arg, containsLexicalThis) {
113930
- const resolve4 = factory2.createUniqueName("resolve");
114898
+ const resolve5 = factory2.createUniqueName("resolve");
113931
114899
  const reject = factory2.createUniqueName("reject");
113932
114900
  const parameters = [
113933
- factory2.createParameterDeclaration(undefined, undefined, resolve4),
114901
+ factory2.createParameterDeclaration(undefined, undefined, resolve5),
113934
114902
  factory2.createParameterDeclaration(undefined, undefined, reject)
113935
114903
  ];
113936
114904
  const body = factory2.createBlock([
113937
- factory2.createExpressionStatement(factory2.createCallExpression(factory2.createIdentifier("require"), undefined, [factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve4, reject]))
114905
+ factory2.createExpressionStatement(factory2.createCallExpression(factory2.createIdentifier("require"), undefined, [factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve5, reject]))
113938
114906
  ]);
113939
114907
  let func;
113940
114908
  if (languageVersion >= 2) {
@@ -184114,8 +185082,8 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
184114
185082
  installPackage(options) {
184115
185083
  this.packageInstallId++;
184116
185084
  const request = { kind: "installPackage", ...options, id: this.packageInstallId };
184117
- const promise = new Promise((resolve4, reject) => {
184118
- (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map)).set(this.packageInstallId, { resolve: resolve4, reject });
185085
+ const promise = new Promise((resolve5, reject) => {
185086
+ (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map)).set(this.packageInstallId, { resolve: resolve5, reject });
184119
185087
  });
184120
185088
  this.installer.send(request);
184121
185089
  return promise;
@@ -185971,7 +186939,7 @@ var require_path_browserify = __commonJS((exports, module) => {
185971
186939
  return dir + sep + base;
185972
186940
  }
185973
186941
  var posix = {
185974
- resolve: function resolve4() {
186942
+ resolve: function resolve5() {
185975
186943
  var resolvedPath = "";
185976
186944
  var resolvedAbsolute = false;
185977
186945
  var cwd;
@@ -231627,12 +232595,12 @@ interface CSSNumericArray{[Symbol.iterator]():ArrayIterator<CSSNumericValue>;ent
231627
232595
 
231628
232596
  class NodeRuntimeFileSystem {
231629
232597
  delete(path4) {
231630
- return new Promise((resolve4, reject) => {
232598
+ return new Promise((resolve5, reject) => {
231631
232599
  fs__namespace.rm(path4, { recursive: true }, (err) => {
231632
232600
  if (err)
231633
232601
  reject(err);
231634
232602
  else
231635
- resolve4();
232603
+ resolve5();
231636
232604
  });
231637
232605
  });
231638
232606
  }
@@ -231651,12 +232619,12 @@ interface CSSNumericArray{[Symbol.iterator]():ArrayIterator<CSSNumericValue>;ent
231651
232619
  }));
231652
232620
  }
231653
232621
  readFile(filePath, encoding = "utf-8") {
231654
- return new Promise((resolve4, reject) => {
232622
+ return new Promise((resolve5, reject) => {
231655
232623
  fs__namespace.readFile(filePath, encoding, (err, data) => {
231656
232624
  if (err)
231657
232625
  reject(err);
231658
232626
  else
231659
- resolve4(data);
232627
+ resolve5(data);
231660
232628
  });
231661
232629
  });
231662
232630
  }
@@ -231664,12 +232632,12 @@ interface CSSNumericArray{[Symbol.iterator]():ArrayIterator<CSSNumericValue>;ent
231664
232632
  return fs__namespace.readFileSync(filePath, encoding);
231665
232633
  }
231666
232634
  async writeFile(filePath, fileText) {
231667
- await new Promise((resolve4, reject) => {
232635
+ await new Promise((resolve5, reject) => {
231668
232636
  fs__namespace.writeFile(filePath, fileText, (err) => {
231669
232637
  if (err)
231670
232638
  reject(err);
231671
232639
  else
231672
- resolve4();
232640
+ resolve5();
231673
232641
  });
231674
232642
  });
231675
232643
  }
@@ -231683,12 +232651,12 @@ interface CSSNumericArray{[Symbol.iterator]():ArrayIterator<CSSNumericValue>;ent
231683
232651
  fs__namespace.mkdirSync(dirPath, { recursive: true });
231684
232652
  }
231685
232653
  move(srcPath, destPath) {
231686
- return new Promise((resolve4, reject) => {
232654
+ return new Promise((resolve5, reject) => {
231687
232655
  fs__namespace.rename(srcPath, destPath, (err) => {
231688
232656
  if (err)
231689
232657
  reject(err);
231690
232658
  else
231691
- resolve4();
232659
+ resolve5();
231692
232660
  });
231693
232661
  });
231694
232662
  }
@@ -231696,12 +232664,12 @@ interface CSSNumericArray{[Symbol.iterator]():ArrayIterator<CSSNumericValue>;ent
231696
232664
  fs__namespace.renameSync(srcPath, destPath);
231697
232665
  }
231698
232666
  copy(srcPath, destPath) {
231699
- return new Promise((resolve4, reject) => {
232667
+ return new Promise((resolve5, reject) => {
231700
232668
  fs__namespace.copyFile(srcPath, destPath, (err) => {
231701
232669
  if (err)
231702
232670
  reject(err);
231703
232671
  else
231704
- resolve4();
232672
+ resolve5();
231705
232673
  });
231706
232674
  });
231707
232675
  }
@@ -231709,15 +232677,15 @@ interface CSSNumericArray{[Symbol.iterator]():ArrayIterator<CSSNumericValue>;ent
231709
232677
  fs__namespace.copyFileSync(srcPath, destPath);
231710
232678
  }
231711
232679
  stat(path4) {
231712
- return new Promise((resolve4, reject) => {
232680
+ return new Promise((resolve5, reject) => {
231713
232681
  fs__namespace.stat(path4, (err, stat) => {
231714
232682
  if (err) {
231715
232683
  if (err.code === "ENOENT" || err.code === "ENOTDIR")
231716
- resolve4(undefined);
232684
+ resolve5(undefined);
231717
232685
  else
231718
232686
  reject(err);
231719
232687
  } else {
231720
- resolve4(stat);
232688
+ resolve5(stat);
231721
232689
  }
231722
232690
  });
231723
232691
  });
@@ -255746,982 +256714,18 @@ var {
255746
256714
  } = import__.default;
255747
256715
 
255748
256716
  // src/cli.ts
255749
- var import_picocolors12 = __toESM(require_picocolors(), 1);
256717
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
255750
256718
  import { createInterface, emitKeypressEvents } from "node:readline";
255751
256719
  import { stdin as input, stdout as output } from "node:process";
255752
- import { existsSync as existsSync21, mkdirSync as mkdirSync11, readFileSync as readFileSync15, writeFileSync as writeFileSync15, realpathSync } from "node:fs";
256720
+ import { existsSync as existsSync21, mkdirSync as mkdirSync11, readFileSync as readFileSync15, writeFileSync as writeFileSync15, realpathSync as realpathSync2 } from "node:fs";
255753
256721
  import { homedir as homedir6 } from "node:os";
255754
- import { join as join24, resolve as resolve6, dirname as dirname5 } from "node:path";
256722
+ import { join as join24, resolve as resolve7, dirname as dirname5 } from "node:path";
255755
256723
  import { pathToFileURL } from "node:url";
255756
256724
 
255757
256725
  // src/utils/prerequisites.ts
255758
- import { execSync as execSync3 } from "node:child_process";
255759
-
255760
- // src/mcp/lifecycle.ts
255761
- import { spawn, execSync } from "node:child_process";
255762
- import { existsSync as existsSync2 } from "node:fs";
255763
- import { join as join2 } from "node:path";
255764
-
255765
- // src/audit/logger.ts
255766
- import {
255767
- appendFileSync,
255768
- existsSync,
255769
- mkdirSync,
255770
- renameSync,
255771
- rmSync,
255772
- statSync,
255773
- writeFileSync
255774
- } from "node:fs";
255775
- import { join } from "node:path";
255776
- var AUDIT_DIR_NAME = ".kitt";
255777
- var AUDIT_FILE_NAME = "audit.log";
255778
- var ROTATED_LOG_1 = "audit.log.1";
255779
- var ROTATED_LOG_2 = "audit.log.2";
255780
- var MAX_LOG_SIZE_BYTES = 10 * 1024 * 1024;
255781
- function formatLine(type, message) {
255782
- return `[${new Date().toISOString()}] ${type} ${message}
255783
- `;
255784
- }
255785
- function ensureAuditDir(auditDir) {
255786
- if (existsSync(auditDir)) {
255787
- return;
255788
- }
255789
- mkdirSync(auditDir, { recursive: true, mode: 448 });
255790
- }
255791
- function rotateLogIfNeeded(logPath, log1Path, log2Path) {
255792
- if (!existsSync(logPath)) {
255793
- return;
255794
- }
255795
- const stats = statSync(logPath);
255796
- if (stats.size < MAX_LOG_SIZE_BYTES) {
255797
- return;
255798
- }
255799
- if (existsSync(log2Path)) {
255800
- rmSync(log2Path, { force: true });
255801
- }
255802
- if (existsSync(log1Path)) {
255803
- renameSync(log1Path, log2Path);
255804
- }
255805
- renameSync(logPath, log1Path);
255806
- writeFileSync(logPath, "", { encoding: "utf8", mode: 384 });
255807
- }
255808
- function writeAuditLine(logPath, log1Path, log2Path, type, message) {
255809
- try {
255810
- rotateLogIfNeeded(logPath, log1Path, log2Path);
255811
- appendFileSync(logPath, formatLine(type, message), { encoding: "utf8", mode: 384 });
255812
- } catch {
255813
- return;
255814
- }
255815
- }
255816
- function createAuditLogger(workspaceDir) {
255817
- const auditDir = join(workspaceDir, AUDIT_DIR_NAME);
255818
- const logPath = join(auditDir, AUDIT_FILE_NAME);
255819
- const log1Path = join(auditDir, ROTATED_LOG_1);
255820
- const log2Path = join(auditDir, ROTATED_LOG_2);
255821
- return {
255822
- log(type, message) {
255823
- try {
255824
- ensureAuditDir(auditDir);
255825
- } catch {
255826
- return;
255827
- }
255828
- writeAuditLine(logPath, log1Path, log2Path, type, message);
255829
- },
255830
- cmd(command, status, detail) {
255831
- const suffix = detail ? ` (${detail})` : "";
255832
- this.log("CMD", `${command} → ${status}${suffix}`);
255833
- },
255834
- cmdExec(command, status) {
255835
- this.log("CMD_EXEC", `${command} → ${status}`);
255836
- },
255837
- mcp(tool, params, status, detail) {
255838
- const suffix = detail ? ` (${detail})` : "";
255839
- this.log("MCP", `${tool} (${params}) → ${status}${suffix}`);
255840
- },
255841
- llmCall(provider, model, promptVersion, estimatedTokens, status) {
255842
- this.log("LLM_CALL", `${provider}/${model} (prompt: ${promptVersion}, est. ${estimatedTokens} tokens) → ${status}`);
255843
- },
255844
- fileWrite(path, hash) {
255845
- const suffix = hash ? ` (SHA-256: ${hash})` : "";
255846
- this.log("FILE_WRITE", `${path}${suffix}`);
255847
- },
255848
- staged(path, detail) {
255849
- this.log("STAGED", `${path} (${detail})`);
255850
- },
255851
- userConfirmed() {
255852
- this.log("USER_CONFIRMED", "staged changes");
255853
- },
255854
- security(action, message) {
255855
- this.log("SECURITY", `${action} ${message}`);
255856
- }
255857
- };
255858
- }
255859
-
255860
- // node_modules/@clack/core/dist/index.mjs
255861
- var import_sisteransi = __toESM(require_src(), 1);
255862
- import { stdin as j, stdout as M } from "node:process";
255863
- var import_picocolors = __toESM(require_picocolors(), 1);
255864
- import O from "node:readline";
255865
- import { Writable as X } from "node:stream";
255866
- function DD({ onlyFirst: e = false } = {}) {
255867
- const t = ["[\\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("|");
255868
- return new RegExp(t, e ? undefined : "g");
255869
- }
255870
- var uD = DD();
255871
- function P(e) {
255872
- if (typeof e != "string")
255873
- throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);
255874
- return e.replace(uD, "");
255875
- }
255876
- function L(e) {
255877
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
255878
- }
255879
- var W = { exports: {} };
255880
- (function(e) {
255881
- var u = {};
255882
- e.exports = u, u.eastAsianWidth = function(F) {
255883
- var s = F.charCodeAt(0), i = F.length == 2 ? F.charCodeAt(1) : 0, D = s;
255884
- 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";
255885
- }, u.characterLength = function(F) {
255886
- var s = this.eastAsianWidth(F);
255887
- return s == "F" || s == "W" || s == "A" ? 2 : 1;
255888
- };
255889
- function t(F) {
255890
- return F.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
255891
- }
255892
- u.length = function(F) {
255893
- for (var s = t(F), i = 0, D = 0;D < s.length; D++)
255894
- i = i + this.characterLength(s[D]);
255895
- return i;
255896
- }, u.slice = function(F, s, i) {
255897
- textLen = u.length(F), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
255898
- for (var D = "", C = 0, n = t(F), E = 0;E < n.length; E++) {
255899
- var a = n[E], o = u.length(a);
255900
- if (C >= s - (o == 2 ? 1 : 0))
255901
- if (C + o <= i)
255902
- D += a;
255903
- else
255904
- break;
255905
- C += o;
255906
- }
255907
- return D;
255908
- };
255909
- })(W);
255910
- var tD = W.exports;
255911
- var eD = L(tD);
255912
- var FD = function() {
255913
- 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;
255914
- };
255915
- var sD = L(FD);
255916
- function p(e, u = {}) {
255917
- if (typeof e != "string" || e.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, e = P(e), e.length === 0))
255918
- return 0;
255919
- e = e.replace(sD(), " ");
255920
- const t = u.ambiguousIsNarrow ? 1 : 2;
255921
- let F = 0;
255922
- for (const s of e) {
255923
- const i = s.codePointAt(0);
255924
- if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879)
255925
- continue;
255926
- switch (eD.eastAsianWidth(s)) {
255927
- case "F":
255928
- case "W":
255929
- F += 2;
255930
- break;
255931
- case "A":
255932
- F += t;
255933
- break;
255934
- default:
255935
- F += 1;
255936
- }
255937
- }
255938
- return F;
255939
- }
255940
- var w = 10;
255941
- var N = (e = 0) => (u) => `\x1B[${u + e}m`;
255942
- var I = (e = 0) => (u) => `\x1B[${38 + e};5;${u}m`;
255943
- var R = (e = 0) => (u, t, F) => `\x1B[${38 + e};2;${u};${t};${F}m`;
255944
- 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] } };
255945
- Object.keys(r.modifier);
255946
- var iD = Object.keys(r.color);
255947
- var CD = Object.keys(r.bgColor);
255948
- [...iD, ...CD];
255949
- function rD() {
255950
- const e = new Map;
255951
- for (const [u, t] of Object.entries(r)) {
255952
- for (const [F, s] of Object.entries(t))
255953
- r[F] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, t[F] = r[F], e.set(s[0], s[1]);
255954
- Object.defineProperty(r, u, { value: t, enumerable: false });
255955
- }
255956
- return Object.defineProperty(r, "codes", { value: e, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = N(), r.color.ansi256 = I(), r.color.ansi16m = R(), r.bgColor.ansi = N(w), r.bgColor.ansi256 = I(w), r.bgColor.ansi16m = R(w), Object.defineProperties(r, { rgbToAnsi256: { value: (u, t, F) => u === t && t === F ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
255957
- const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
255958
- if (!t)
255959
- return [0, 0, 0];
255960
- let [F] = t;
255961
- F.length === 3 && (F = [...F].map((i) => i + i).join(""));
255962
- const s = Number.parseInt(F, 16);
255963
- return [s >> 16 & 255, s >> 8 & 255, s & 255];
255964
- }, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
255965
- if (u < 8)
255966
- return 30 + u;
255967
- if (u < 16)
255968
- return 90 + (u - 8);
255969
- let t, F, s;
255970
- if (u >= 232)
255971
- t = ((u - 232) * 10 + 8) / 255, F = t, s = t;
255972
- else {
255973
- u -= 16;
255974
- const C = u % 36;
255975
- t = Math.floor(u / 36) / 5, F = Math.floor(C / 6) / 5, s = C % 6 / 5;
255976
- }
255977
- const i = Math.max(t, F, s) * 2;
255978
- if (i === 0)
255979
- return 30;
255980
- let D = 30 + (Math.round(s) << 2 | Math.round(F) << 1 | Math.round(t));
255981
- return i === 2 && (D += 60), D;
255982
- }, enumerable: false }, rgbToAnsi: { value: (u, t, F) => r.ansi256ToAnsi(r.rgbToAnsi256(u, t, F)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
255983
- }
255984
- var ED = rD();
255985
- var d = new Set(["\x1B", "›"]);
255986
- var oD = 39;
255987
- var y = "\x07";
255988
- var V = "[";
255989
- var nD = "]";
255990
- var G = "m";
255991
- var _ = `${nD}8;;`;
255992
- var z = (e) => `${d.values().next().value}${V}${e}${G}`;
255993
- var K = (e) => `${d.values().next().value}${_}${e}${y}`;
255994
- var aD = (e) => e.split(" ").map((u) => p(u));
255995
- var k = (e, u, t) => {
255996
- const F = [...u];
255997
- let s = false, i = false, D = p(P(e[e.length - 1]));
255998
- for (const [C, n] of F.entries()) {
255999
- const E = p(n);
256000
- if (D + E <= t ? e[e.length - 1] += n : (e.push(n), D = 0), d.has(n) && (s = true, i = F.slice(C + 1).join("").startsWith(_)), s) {
256001
- i ? n === y && (s = false, i = false) : n === G && (s = false);
256002
- continue;
256003
- }
256004
- D += E, D === t && C < F.length - 1 && (e.push(""), D = 0);
256005
- }
256006
- !D && e[e.length - 1].length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
256007
- };
256008
- var hD = (e) => {
256009
- const u = e.split(" ");
256010
- let t = u.length;
256011
- for (;t > 0 && !(p(u[t - 1]) > 0); )
256012
- t--;
256013
- return t === u.length ? e : u.slice(0, t).join(" ") + u.slice(t).join("");
256014
- };
256015
- var lD = (e, u, t = {}) => {
256016
- if (t.trim !== false && e.trim() === "")
256017
- return "";
256018
- let F = "", s, i;
256019
- const D = aD(e);
256020
- let C = [""];
256021
- for (const [E, a] of e.split(" ").entries()) {
256022
- t.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
256023
- let o = p(C[C.length - 1]);
256024
- if (E !== 0 && (o >= u && (t.wordWrap === false || t.trim === false) && (C.push(""), o = 0), (o > 0 || t.trim === false) && (C[C.length - 1] += " ", o++)), t.hard && D[E] > u) {
256025
- const c = u - o, f = 1 + Math.floor((D[E] - c - 1) / u);
256026
- Math.floor((D[E] - 1) / u) < f && C.push(""), k(C, a, u);
256027
- continue;
256028
- }
256029
- if (o + D[E] > u && o > 0 && D[E] > 0) {
256030
- if (t.wordWrap === false && o < u) {
256031
- k(C, a, u);
256032
- continue;
256033
- }
256034
- C.push("");
256035
- }
256036
- if (o + D[E] > u && t.wordWrap === false) {
256037
- k(C, a, u);
256038
- continue;
256039
- }
256040
- C[C.length - 1] += a;
256041
- }
256042
- t.trim !== false && (C = C.map((E) => hD(E)));
256043
- const n = [...C.join(`
256044
- `)];
256045
- for (const [E, a] of n.entries()) {
256046
- if (F += a, d.has(a)) {
256047
- const { groups: c } = new RegExp(`(?:\\${V}(?<code>\\d+)m|\\${_}(?<uri>.*)${y})`).exec(n.slice(E).join("")) || { groups: {} };
256048
- if (c.code !== undefined) {
256049
- const f = Number.parseFloat(c.code);
256050
- s = f === oD ? undefined : f;
256051
- } else
256052
- c.uri !== undefined && (i = c.uri.length === 0 ? undefined : c.uri);
256053
- }
256054
- const o = ED.codes.get(Number(s));
256055
- n[E + 1] === `
256056
- ` ? (i && (F += K("")), s && o && (F += z(o))) : a === `
256057
- ` && (s && o && (F += z(s)), i && (F += K(i)));
256058
- }
256059
- return F;
256060
- };
256061
- function Y(e, u, t) {
256062
- return String(e).normalize().replace(/\r\n/g, `
256063
- `).split(`
256064
- `).map((F) => lD(F, u, t)).join(`
256065
- `);
256066
- }
256067
- var xD = ["up", "down", "left", "right", "space", "enter", "cancel"];
256068
- var B = { actions: new Set(xD), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]) };
256069
- function $(e, u) {
256070
- if (typeof e == "string")
256071
- return B.aliases.get(e) === u;
256072
- for (const t of e)
256073
- if (t !== undefined && $(t, u))
256074
- return true;
256075
- return false;
256076
- }
256077
- function BD(e, u) {
256078
- if (e === u)
256079
- return;
256080
- const t = e.split(`
256081
- `), F = u.split(`
256082
- `), s = [];
256083
- for (let i = 0;i < Math.max(t.length, F.length); i++)
256084
- t[i] !== F[i] && s.push(i);
256085
- return s;
256086
- }
256087
- var AD = globalThis.process.platform.startsWith("win");
256088
- var S = Symbol("clack:cancel");
256089
- function pD(e) {
256090
- return e === S;
256091
- }
256092
- function m(e, u) {
256093
- const t = e;
256094
- t.isTTY && t.setRawMode(u);
256095
- }
256096
- var gD = Object.defineProperty;
256097
- var vD = (e, u, t) => (u in e) ? gD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t;
256098
- var h = (e, u, t) => (vD(e, typeof u != "symbol" ? u + "" : u, t), t);
256099
-
256100
- class x {
256101
- constructor(u, t = true) {
256102
- 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");
256103
- const { input: F = j, output: s = M, render: i, signal: D, ...C } = u;
256104
- 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 = t, this._abortSignal = D, this.input = F, this.output = s;
256105
- }
256106
- unsubscribe() {
256107
- this._subscribers.clear();
256108
- }
256109
- setSubscriber(u, t) {
256110
- const F = this._subscribers.get(u) ?? [];
256111
- F.push(t), this._subscribers.set(u, F);
256112
- }
256113
- on(u, t) {
256114
- this.setSubscriber(u, { cb: t });
256115
- }
256116
- once(u, t) {
256117
- this.setSubscriber(u, { cb: t, once: true });
256118
- }
256119
- emit(u, ...t) {
256120
- const F = this._subscribers.get(u) ?? [], s = [];
256121
- for (const i of F)
256122
- i.cb(...t), i.once && s.push(() => F.splice(F.indexOf(i), 1));
256123
- for (const i of s)
256124
- i();
256125
- }
256126
- prompt() {
256127
- return new Promise((u, t) => {
256128
- if (this._abortSignal) {
256129
- if (this._abortSignal.aborted)
256130
- return this.state = "cancel", this.close(), u(S);
256131
- this._abortSignal.addEventListener("abort", () => {
256132
- this.state = "cancel", this.close();
256133
- }, { once: true });
256134
- }
256135
- const F = new X;
256136
- F._write = (s, i, D) => {
256137
- this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
256138
- }, this.input.pipe(F), this.rl = O.createInterface({ input: this.input, output: F, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), O.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), m(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
256139
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u(this.value);
256140
- }), this.once("cancel", () => {
256141
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u(S);
256142
- });
256143
- });
256144
- }
256145
- onKeypress(u, t) {
256146
- if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.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()), t?.name === "return") {
256147
- if (this.opts.validate) {
256148
- const F = this.opts.validate(this.value);
256149
- F && (this.error = F instanceof Error ? F.message : F, this.state = "error", this.rl?.write(this.value));
256150
- }
256151
- this.state !== "error" && (this.state = "submit");
256152
- }
256153
- $([u, t?.name, t?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
256154
- }
256155
- close() {
256156
- this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
256157
- `), m(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
256158
- }
256159
- restoreCursor() {
256160
- const u = Y(this._prevFrame, process.stdout.columns, { hard: true }).split(`
256161
- `).length - 1;
256162
- this.output.write(import_sisteransi.cursor.move(-999, u * -1));
256163
- }
256164
- render() {
256165
- const u = Y(this._render(this) ?? "", process.stdout.columns, { hard: true });
256166
- if (u !== this._prevFrame) {
256167
- if (this.state === "initial")
256168
- this.output.write(import_sisteransi.cursor.hide);
256169
- else {
256170
- const t = BD(this._prevFrame, u);
256171
- if (this.restoreCursor(), t && t?.length === 1) {
256172
- const F = t[0];
256173
- this.output.write(import_sisteransi.cursor.move(0, F)), this.output.write(import_sisteransi.erase.lines(1));
256174
- const s = u.split(`
256175
- `);
256176
- this.output.write(s[F]), this._prevFrame = u, this.output.write(import_sisteransi.cursor.move(0, s.length - F - 1));
256177
- return;
256178
- }
256179
- if (t && t?.length > 1) {
256180
- const F = t[0];
256181
- this.output.write(import_sisteransi.cursor.move(0, F)), this.output.write(import_sisteransi.erase.down());
256182
- const s = u.split(`
256183
- `).slice(F);
256184
- this.output.write(s.join(`
256185
- `)), this._prevFrame = u;
256186
- return;
256187
- }
256188
- this.output.write(import_sisteransi.erase.down());
256189
- }
256190
- this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
256191
- }
256192
- }
256193
- }
256194
-
256195
- class dD extends x {
256196
- get cursor() {
256197
- return this.value ? 0 : 1;
256198
- }
256199
- get _value() {
256200
- return this.cursor === 0;
256201
- }
256202
- constructor(u) {
256203
- super(u, false), this.value = !!u.initialValue, this.on("value", () => {
256204
- this.value = this._value;
256205
- }), this.on("confirm", (t) => {
256206
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
256207
- }), this.on("cursor", () => {
256208
- this.value = !this.value;
256209
- });
256210
- }
256211
- }
256212
- var A;
256213
- A = new WeakMap;
256214
- var kD = Object.defineProperty;
256215
- var $D = (e, u, t) => (u in e) ? kD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t;
256216
- var H = (e, u, t) => ($D(e, typeof u != "symbol" ? u + "" : u, t), t);
256217
- var SD = class extends x {
256218
- constructor(u) {
256219
- super(u, false), H(this, "options"), H(this, "cursor", 0), this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u.cursorAt), 0), this.on("key", (t) => {
256220
- t === "a" && this.toggleAll();
256221
- }), this.on("cursor", (t) => {
256222
- switch (t) {
256223
- case "left":
256224
- case "up":
256225
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
256226
- break;
256227
- case "down":
256228
- case "right":
256229
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
256230
- break;
256231
- case "space":
256232
- this.toggleValue();
256233
- break;
256234
- }
256235
- });
256236
- }
256237
- get _value() {
256238
- return this.options[this.cursor].value;
256239
- }
256240
- toggleAll() {
256241
- const u = this.value.length === this.options.length;
256242
- this.value = u ? [] : this.options.map((t) => t.value);
256243
- }
256244
- toggleValue() {
256245
- const u = this.value.includes(this._value);
256246
- this.value = u ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
256247
- }
256248
- };
256249
- var TD = Object.defineProperty;
256250
- var jD = (e, u, t) => (u in e) ? TD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t;
256251
- var U = (e, u, t) => (jD(e, typeof u != "symbol" ? u + "" : u, t), t);
256252
-
256253
- class MD extends x {
256254
- constructor({ mask: u, ...t }) {
256255
- super(t), U(this, "valueWithCursor", ""), U(this, "_mask", "•"), this._mask = u ?? "•", this.on("finalize", () => {
256256
- this.valueWithCursor = this.masked;
256257
- }), this.on("value", () => {
256258
- if (this.cursor >= this.value.length)
256259
- this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
256260
- else {
256261
- const F = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
256262
- this.valueWithCursor = `${F}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
256263
- }
256264
- });
256265
- }
256266
- get cursor() {
256267
- return this._cursor;
256268
- }
256269
- get masked() {
256270
- return this.value.replaceAll(/./g, this._mask);
256271
- }
256272
- }
256273
- var OD = Object.defineProperty;
256274
- var PD = (e, u, t) => (u in e) ? OD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t;
256275
- var J = (e, u, t) => (PD(e, typeof u != "symbol" ? u + "" : u, t), t);
256276
-
256277
- class LD extends x {
256278
- constructor(u) {
256279
- super(u, false), J(this, "options"), J(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: t }) => t === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
256280
- switch (t) {
256281
- case "left":
256282
- case "up":
256283
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
256284
- break;
256285
- case "down":
256286
- case "right":
256287
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
256288
- break;
256289
- }
256290
- this.changeValue();
256291
- });
256292
- }
256293
- get _value() {
256294
- return this.options[this.cursor];
256295
- }
256296
- changeValue() {
256297
- this.value = this._value.value;
256298
- }
256299
- }
256300
- class RD extends x {
256301
- get valueWithCursor() {
256302
- if (this.state === "submit")
256303
- return this.value;
256304
- if (this.cursor >= this.value.length)
256305
- return `${this.value}█`;
256306
- const u = this.value.slice(0, this.cursor), [t, ...F] = this.value.slice(this.cursor);
256307
- return `${u}${import_picocolors.default.inverse(t)}${F.join("")}`;
256308
- }
256309
- get cursor() {
256310
- return this._cursor;
256311
- }
256312
- constructor(u) {
256313
- super(u), this.on("finalize", () => {
256314
- this.value || (this.value = u.defaultValue);
256315
- });
256316
- }
256317
- }
256318
-
256319
- // node_modules/@clack/prompts/dist/index.mjs
256320
- var import_picocolors2 = __toESM(require_picocolors(), 1);
256321
- var import_sisteransi2 = __toESM(require_src(), 1);
256322
- import y2 from "node:process";
256323
- function ce() {
256324
- return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
256325
- }
256326
- var V2 = ce();
256327
- var u = (t, n) => V2 ? t : n;
256328
- var le = u("◆", "*");
256329
- var L2 = u("■", "x");
256330
- var W2 = u("▲", "x");
256331
- var C = u("◇", "o");
256332
- var ue = u("┌", "T");
256333
- var o = u("│", "|");
256334
- var d2 = u("└", "—");
256335
- var k2 = u("●", ">");
256336
- var P2 = u("○", " ");
256337
- var A2 = u("◻", "[•]");
256338
- var T = u("◼", "[+]");
256339
- var F = u("◻", "[ ]");
256340
- var $e = u("▪", "•");
256341
- var _2 = u("─", "-");
256342
- var me = u("╮", "+");
256343
- var de = u("├", "+");
256344
- var pe = u("╯", "+");
256345
- var q = u("●", "•");
256346
- var D = u("◆", "*");
256347
- var U2 = u("▲", "!");
256348
- var K2 = u("■", "x");
256349
- var b2 = (t) => {
256350
- switch (t) {
256351
- case "initial":
256352
- case "active":
256353
- return import_picocolors2.default.cyan(le);
256354
- case "cancel":
256355
- return import_picocolors2.default.red(L2);
256356
- case "error":
256357
- return import_picocolors2.default.yellow(W2);
256358
- case "submit":
256359
- return import_picocolors2.default.green(C);
256360
- }
256361
- };
256362
- var G2 = (t) => {
256363
- const { cursor: n, options: r2, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
256364
- let l2 = 0;
256365
- n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
256366
- const $2 = a < r2.length && l2 > 0, g = a < r2.length && l2 + a < r2.length;
256367
- return r2.slice(l2, l2 + a).map((p2, v2, f) => {
256368
- const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g;
256369
- return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v2 + l2 === n);
256370
- });
256371
- };
256372
- var he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
256373
- const n = `${import_picocolors2.default.gray(o)}
256374
- ${b2(this.state)} ${t.message}
256375
- `, r2 = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : r2;
256376
- switch (this.state) {
256377
- case "error":
256378
- return `${n.trim()}
256379
- ${import_picocolors2.default.yellow(o)} ${i}
256380
- ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
256381
- `;
256382
- case "submit":
256383
- return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(this.value || t.placeholder)}`;
256384
- case "cancel":
256385
- return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
256386
- ${import_picocolors2.default.gray(o)}` : ""}`;
256387
- default:
256388
- return `${n}${import_picocolors2.default.cyan(o)} ${i}
256389
- ${import_picocolors2.default.cyan(d2)}
256390
- `;
256391
- }
256392
- } }).prompt();
256393
- var ge = (t) => new MD({ validate: t.validate, mask: t.mask ?? $e, render() {
256394
- const n = `${import_picocolors2.default.gray(o)}
256395
- ${b2(this.state)} ${t.message}
256396
- `, r2 = this.valueWithCursor, i = this.masked;
256397
- switch (this.state) {
256398
- case "error":
256399
- return `${n.trim()}
256400
- ${import_picocolors2.default.yellow(o)} ${i}
256401
- ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
256402
- `;
256403
- case "submit":
256404
- return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(i)}`;
256405
- case "cancel":
256406
- return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(i ?? ""))}${i ? `
256407
- ${import_picocolors2.default.gray(o)}` : ""}`;
256408
- default:
256409
- return `${n}${import_picocolors2.default.cyan(o)} ${r2}
256410
- ${import_picocolors2.default.cyan(d2)}
256411
- `;
256412
- }
256413
- } }).prompt();
256414
- var ye = (t) => {
256415
- const n = t.active ?? "Yes", r2 = t.inactive ?? "No";
256416
- return new dD({ active: n, inactive: r2, initialValue: t.initialValue ?? true, render() {
256417
- const i = `${import_picocolors2.default.gray(o)}
256418
- ${b2(this.state)} ${t.message}
256419
- `, s = this.value ? n : r2;
256420
- switch (this.state) {
256421
- case "submit":
256422
- return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
256423
- case "cancel":
256424
- return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
256425
- ${import_picocolors2.default.gray(o)}`;
256426
- default:
256427
- return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r2)}` : `${import_picocolors2.default.green(k2)} ${r2}`}
256428
- ${import_picocolors2.default.cyan(d2)}
256429
- `;
256430
- }
256431
- } }).prompt();
256432
- };
256433
- var ve = (t) => {
256434
- const n = (r2, i) => {
256435
- const s = r2.label ?? String(r2.value);
256436
- switch (i) {
256437
- case "selected":
256438
- return `${import_picocolors2.default.dim(s)}`;
256439
- case "active":
256440
- return `${import_picocolors2.default.green(k2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
256441
- case "cancelled":
256442
- return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
256443
- default:
256444
- return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
256445
- }
256446
- };
256447
- return new LD({ options: t.options, initialValue: t.initialValue, render() {
256448
- const r2 = `${import_picocolors2.default.gray(o)}
256449
- ${b2(this.state)} ${t.message}
256450
- `;
256451
- switch (this.state) {
256452
- case "submit":
256453
- return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
256454
- case "cancel":
256455
- return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
256456
- ${import_picocolors2.default.gray(o)}`;
256457
- default:
256458
- return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
256459
- ${import_picocolors2.default.cyan(o)} `)}
256460
- ${import_picocolors2.default.cyan(d2)}
256461
- `;
256462
- }
256463
- } }).prompt();
256464
- };
256465
- var fe = (t) => {
256466
- const n = (r2, i) => {
256467
- const s = r2.label ?? String(r2.value);
256468
- return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(T)} ${import_picocolors2.default.dim(s)} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active-selected" ? `${import_picocolors2.default.green(T)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(F)} ${import_picocolors2.default.dim(s)}`;
256469
- };
256470
- return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r2) {
256471
- if (this.required && r2.length === 0)
256472
- return `Please select at least one option.
256473
- ${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
256474
- }, render() {
256475
- const r2 = `${import_picocolors2.default.gray(o)}
256476
- ${b2(this.state)} ${t.message}
256477
- `, i = (s, c) => {
256478
- const a = this.value.includes(s.value);
256479
- return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
256480
- };
256481
- switch (this.state) {
256482
- case "submit":
256483
- return `${r2}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
256484
- case "cancel": {
256485
- const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors2.default.dim(", "));
256486
- return `${r2}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
256487
- ${import_picocolors2.default.gray(o)}` : ""}`;
256488
- }
256489
- case "error": {
256490
- const s = this.error.split(`
256491
- `).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
256492
- `);
256493
- return `${r2 + import_picocolors2.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
256494
- ${import_picocolors2.default.yellow(o)} `)}
256495
- ${s}
256496
- `;
256497
- }
256498
- default:
256499
- return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
256500
- ${import_picocolors2.default.cyan(o)} `)}
256501
- ${import_picocolors2.default.cyan(d2)}
256502
- `;
256503
- }
256504
- } }).prompt();
256505
- };
256506
- var J2 = `${import_picocolors2.default.gray(o)} `;
256507
-
256508
- // src/utils/display.ts
256509
- var import_picocolors3 = __toESM(require_picocolors(), 1);
256510
- function success(message) {
256511
- console.log(`${import_picocolors3.default.green("✓")} ${message}`);
256512
- }
256513
- function error(message) {
256514
- console.log(`${import_picocolors3.default.red("✗")} ${message}`);
256515
- }
256516
- function warn(message) {
256517
- console.log(`${import_picocolors3.default.yellow("⚠")} ${message}`);
256518
- }
256519
- function info(message) {
256520
- console.log(`${import_picocolors3.default.blue("ℹ")} ${message}`);
256521
- }
256522
- var MODEL_PRICING = {
256523
- "claude-opus-4-5": [15, 75],
256524
- "claude-opus-4": [15, 75],
256525
- "claude-sonnet-4-5": [3, 15],
256526
- "claude-sonnet-4": [3, 15],
256527
- "claude-sonnet-4-20250514": [3, 15],
256528
- "claude-3-7-sonnet-20250219": [3, 15],
256529
- "claude-3-5-sonnet-20241022": [3, 15],
256530
- "claude-3-5-haiku-20241022": [0.8, 4],
256531
- "claude-haiku-4-5": [0.8, 4],
256532
- "gpt-4o": [2.5, 10],
256533
- "gpt-4o-mini": [0.15, 0.6],
256534
- o3: [10, 40],
256535
- "o4-mini": [1.1, 4.4],
256536
- "gpt-4.1": [2, 8],
256537
- "gemini-2.0-flash": [0.1, 0.4],
256538
- "gemini-2.5-pro-preview-05-06": [1.25, 10]
256539
- };
256540
- function resolvePrice(model) {
256541
- if (model in MODEL_PRICING)
256542
- return MODEL_PRICING[model];
256543
- const key = Object.keys(MODEL_PRICING).find((k3) => model.startsWith(k3));
256544
- return key ? MODEL_PRICING[key] : null;
256545
- }
256546
- function formatCost(usd) {
256547
- if (usd === 0)
256548
- return "$0.00";
256549
- if (usd < 0.001)
256550
- return `$${usd.toFixed(6)}`;
256551
- if (usd < 0.01)
256552
- return `$${usd.toFixed(4)}`;
256553
- return `$${usd.toFixed(2)}`;
256554
- }
256555
- function renderContextBanner(params) {
256556
- const { inputTokens, outputTokens, provider, model } = params;
256557
- const totalTokens = inputTokens + outputTokens;
256558
- const contextWindow = /opus/.test(model) ? 200000 : 200000;
256559
- const pctUsed = contextWindow > 0 ? Math.min(100, Math.round(inputTokens / contextWindow * 100)) : 0;
256560
- const pricing = resolvePrice(model);
256561
- const costUsd = pricing ? inputTokens / 1e6 * pricing[0] + outputTokens / 1e6 * pricing[1] : null;
256562
- const providerLabel = provider.charAt(0).toUpperCase() + provider.slice(1);
256563
- const width = 36;
256564
- const border = import_picocolors3.default.dim("─".repeat(width));
256565
- console.log("");
256566
- console.log(` ${import_picocolors3.default.dim(border)}`);
256567
- console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.bold("Context")}${" ".repeat(width - 9)}${import_picocolors3.default.dim("│")}`);
256568
- console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.cyan(totalTokens.toLocaleString())} ${import_picocolors3.default.dim("tokens")}${" ".repeat(Math.max(0, width - 2 - totalTokens.toLocaleString().length - 7))}${import_picocolors3.default.dim("│")}`);
256569
- console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.yellow(`${pctUsed}%`)} ${import_picocolors3.default.dim("of context window used")}${" ".repeat(Math.max(0, width - 2 - String(pctUsed).length - 1 - 22))}${import_picocolors3.default.dim("│")}`);
256570
- if (costUsd !== null) {
256571
- const costStr = formatCost(costUsd);
256572
- console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.green(costStr)} ${import_picocolors3.default.dim("spent")}${" ".repeat(Math.max(0, width - 2 - costStr.length - 6))}${import_picocolors3.default.dim("│")}`);
256573
- }
256574
- console.log(` ${import_picocolors3.default.dim("│")} ${import_picocolors3.default.dim(`${providerLabel} · ${model}`)}${" ".repeat(Math.max(0, width - 2 - providerLabel.length - 3 - model.length))}${import_picocolors3.default.dim("│")}`);
256575
- console.log(` ${import_picocolors3.default.dim(border)}`);
256576
- console.log("");
256577
- }
256578
- function isModelNotSupportedError(err) {
256579
- const msg = err instanceof Error ? err.message : String(err);
256580
- return msg.includes("model is not supported") || msg.includes("model_not_found") || msg.includes("invalid model") || /4\d\d.*model/i.test(msg);
256581
- }
256582
-
256583
- // src/mcp/lifecycle.ts
256584
- var MCP_START_FAILURE_MESSAGE = "Railway MCP Server not found. Install it: npm install -g @railway/mcp-server";
256585
- var SHUTDOWN_TIMEOUT_MS = 5000;
256586
- var auditLogger = createAuditLogger(".");
256587
- function findMcpEntryPoint() {
256588
- try {
256589
- const globalRoot = execSync("npm root -g", { encoding: "utf-8", stdio: "pipe" }).trim();
256590
- const candidate = join2(globalRoot, "@railway", "mcp-server", "dist", "index.js");
256591
- if (existsSync2(candidate))
256592
- return candidate;
256593
- } catch {}
256594
- return null;
256595
- }
256596
- var activeServer = null;
256597
- var pendingSpawn = null;
256598
- var shouldLogRespawn = false;
256599
- var intentionallyShuttingDown = new WeakSet;
256600
- function formatExitDetail(code, signal) {
256601
- const codeLabel = code === null ? "null" : String(code);
256602
- const signalLabel = signal ?? "null";
256603
- return `code=${codeLabel}, signal=${signalLabel}`;
256604
- }
256605
- function isChildRunning(child) {
256606
- return child.exitCode === null && !child.killed;
256607
- }
256608
- function buildServerProcess(child) {
256609
- if (!child.stdin || !child.stdout) {
256610
- throw new Error("MCP server stdio was not created");
256611
- }
256612
- return {
256613
- process: child,
256614
- stdin: child.stdin,
256615
- stdout: child.stdout,
256616
- pid: child.pid ?? -1
256617
- };
256618
- }
256619
- function attachLifecycleListeners(child) {
256620
- child.stderr?.on("data", (chunk) => {
256621
- const message = String(chunk).trim();
256622
- if (!message) {
256623
- return;
256624
- }
256625
- auditLogger.mcp("server-lifecycle", "stderr", "FAILED", message);
256626
- });
256627
- child.on("exit", (code, signal) => {
256628
- const detail = formatExitDetail(code, signal);
256629
- if (activeServer?.process === child) {
256630
- activeServer = null;
256631
- }
256632
- if (intentionallyShuttingDown.has(child)) {
256633
- return;
256634
- }
256635
- shouldLogRespawn = true;
256636
- auditLogger.mcp("server-lifecycle", "crash", "FAILED", detail);
256637
- });
256638
- }
256639
- function displaySpawnFailure(reason) {
256640
- error(MCP_START_FAILURE_MESSAGE);
256641
- auditLogger.mcp("server-lifecycle", "spawn", "FAILED", reason);
256642
- }
256643
- async function spawnMcpServer() {
256644
- if (activeServer && isChildRunning(activeServer.process)) {
256645
- return activeServer;
256646
- }
256647
- if (pendingSpawn) {
256648
- return pendingSpawn;
256649
- }
256650
- const entryPoint = findMcpEntryPoint();
256651
- if (!entryPoint) {
256652
- throw new Error(MCP_START_FAILURE_MESSAGE);
256653
- }
256654
- const respawn = shouldLogRespawn;
256655
- const child = spawn("node", [entryPoint], {
256656
- stdio: ["pipe", "pipe", "pipe"]
256657
- });
256658
- attachLifecycleListeners(child);
256659
- pendingSpawn = new Promise((resolve, reject) => {
256660
- const handleError = (spawnError) => {
256661
- child.off("spawn", handleSpawn);
256662
- if (activeServer?.process === child) {
256663
- activeServer = null;
256664
- }
256665
- displaySpawnFailure(spawnError.message);
256666
- reject(spawnError);
256667
- };
256668
- const handleSpawn = () => {
256669
- child.off("error", handleError);
256670
- let serverProcess;
256671
- try {
256672
- serverProcess = buildServerProcess(child);
256673
- } catch (buildError) {
256674
- const err = buildError instanceof Error ? buildError : new Error(String(buildError));
256675
- displaySpawnFailure(err.message);
256676
- reject(err);
256677
- return;
256678
- }
256679
- activeServer = serverProcess;
256680
- shouldLogRespawn = false;
256681
- if (respawn) {
256682
- auditLogger.mcp("server-lifecycle", "respawn", "SUCCESS", `pid=${serverProcess.pid}`);
256683
- } else {
256684
- auditLogger.mcp("server-lifecycle", "spawn", "SUCCESS", `pid=${serverProcess.pid}`);
256685
- }
256686
- resolve(serverProcess);
256687
- };
256688
- child.once("error", handleError);
256689
- child.once("spawn", handleSpawn);
256690
- }).finally(() => {
256691
- pendingSpawn = null;
256692
- });
256693
- return pendingSpawn;
256694
- }
256695
- async function shutdownMcpServer() {
256696
- if (!activeServer) {
256697
- return;
256698
- }
256699
- const child = activeServer.process;
256700
- intentionallyShuttingDown.add(child);
256701
- if (!isChildRunning(child)) {
256702
- activeServer = null;
256703
- return;
256704
- }
256705
- const exitPromise = new Promise((resolve) => {
256706
- child.once("exit", (code, signal) => {
256707
- resolve({ code, signal });
256708
- });
256709
- });
256710
- child.kill("SIGTERM");
256711
- let forcedKill = false;
256712
- const timeoutHandle = setTimeout(() => {
256713
- forcedKill = true;
256714
- child.kill("SIGKILL");
256715
- }, SHUTDOWN_TIMEOUT_MS);
256716
- const exitResult = await exitPromise;
256717
- clearTimeout(timeoutHandle);
256718
- activeServer = null;
256719
- const detail = forcedKill ? `forced after timeout (${formatExitDetail(exitResult.code, exitResult.signal)})` : formatExitDetail(exitResult.code, exitResult.signal);
256720
- auditLogger.mcp("server-lifecycle", "shutdown", "SUCCESS", detail);
256721
- }
256722
-
256723
- // src/utils/prerequisites.ts
256726
+ init_lifecycle();
256724
256727
  var import_picocolors4 = __toESM(require_picocolors(), 1);
256728
+ import { execSync as execSync3 } from "node:child_process";
256725
256729
  function getNodeVersion() {
256726
256730
  try {
256727
256731
  const output = execSync3("node --version", {
@@ -256815,7 +256819,7 @@ async function displayLlmStatus() {
256815
256819
  }
256816
256820
 
256817
256821
  // src/manifest/reader.ts
256818
- import { existsSync as existsSync6, readFileSync as readFileSync4 } from "node:fs";
256822
+ import { existsSync as existsSync6, readFileSync as readFileSync4, readdirSync } from "node:fs";
256819
256823
  import { join as join6, dirname as dirname2, resolve } from "node:path";
256820
256824
 
256821
256825
  // src/utils/global-config.ts
@@ -257068,6 +257072,34 @@ function reconcileManifest(workspaceDir) {
257068
257072
  writeManifest(workspaceDir, cleaned);
257069
257073
  return cleaned;
257070
257074
  }
257075
+ var SKIP_DIRS = new Set(["node_modules", ".git", ".kitt", "dist", "build", ".next", ".cache"]);
257076
+ function findChildWorkspaces(startDir, maxDepth = 3) {
257077
+ const results = [];
257078
+ const root = resolve(startDir);
257079
+ function scan(dir, depth) {
257080
+ if (depth > maxDepth)
257081
+ return;
257082
+ let entries;
257083
+ try {
257084
+ entries = readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !SKIP_DIRS.has(e2.name) && !e2.name.startsWith(".")).map((e2) => e2.name);
257085
+ } catch {
257086
+ return;
257087
+ }
257088
+ for (const name of entries) {
257089
+ const childPath = join6(dir, name);
257090
+ if (isKittWorkspace(childPath)) {
257091
+ const manifest = readManifest(childPath);
257092
+ if (manifest) {
257093
+ results.push({ path: childPath, manifest });
257094
+ }
257095
+ continue;
257096
+ }
257097
+ scan(childPath, depth + 1);
257098
+ }
257099
+ }
257100
+ scan(root, 0);
257101
+ return results;
257102
+ }
257071
257103
 
257072
257104
  // src/utils/auth-guard.ts
257073
257105
  init_config();
@@ -257139,6 +257171,7 @@ async function railwayLogout() {
257139
257171
  }
257140
257172
 
257141
257173
  // src/utils/auth-guard.ts
257174
+ init_lifecycle();
257142
257175
  var WORKSPACE_REQUIRED = new Set([
257143
257176
  "create",
257144
257177
  "delete",
@@ -257183,6 +257216,7 @@ var COMMAND_AUTH = {
257183
257216
  settings: "none",
257184
257217
  list: "none",
257185
257218
  versions: "none",
257219
+ switch: "none",
257186
257220
  exit: "none",
257187
257221
  init: "both",
257188
257222
  create: "both",
@@ -257199,12 +257233,15 @@ async function checkAuthGuard(commandKey) {
257199
257233
  if (WORKSPACE_REQUIRED.has(commandKey)) {
257200
257234
  const workspaceRoot = findWorkspaceRootStrict(process.cwd());
257201
257235
  if (!workspaceRoot) {
257202
- return {
257203
- allowed: false,
257204
- message: "No KITT workspace found. Run /init to initialize one."
257205
- };
257236
+ const children = findChildWorkspaces(process.cwd());
257237
+ if (children.length === 0) {
257238
+ return {
257239
+ allowed: false,
257240
+ message: "No KITT workspace found. Run /init to create one, or /switch to select an existing workspace."
257241
+ };
257242
+ }
257206
257243
  }
257207
- if (APPS_REQUIRED.has(commandKey)) {
257244
+ if (workspaceRoot && APPS_REQUIRED.has(commandKey)) {
257208
257245
  const manifest = readManifest(workspaceRoot);
257209
257246
  const appCount = manifest ? Object.keys(manifest.apps).length : 0;
257210
257247
  if (appCount === 0) {
@@ -257256,19 +257293,25 @@ async function checkAuthGuard(commandKey) {
257256
257293
  return { allowed: true };
257257
257294
  }
257258
257295
 
257296
+ // src/cli.ts
257297
+ init_display();
257298
+
257259
257299
  // src/sandbox/staging.ts
257300
+ init_logger();
257260
257301
  import {
257261
257302
  copyFileSync,
257262
257303
  existsSync as existsSync7,
257304
+ lstatSync,
257263
257305
  mkdirSync as mkdirSync5,
257264
- readdirSync,
257306
+ readdirSync as readdirSync2,
257265
257307
  readFileSync as readFileSync5,
257308
+ realpathSync,
257266
257309
  rmSync as rmSync2,
257267
257310
  statSync as statSync3,
257268
257311
  writeFileSync as writeFileSync5
257269
257312
  } from "node:fs";
257270
257313
  import { createHash } from "node:crypto";
257271
- import { dirname as dirname3, join as join7, relative } from "node:path";
257314
+ import { dirname as dirname3, join as join7, relative, resolve as resolve2 } from "node:path";
257272
257315
  var KITT_DIR = ".kitt";
257273
257316
  var STAGING_DIR = "staging";
257274
257317
  function getStagingDir(workspaceDir) {
@@ -257278,7 +257321,15 @@ function hashContent(content) {
257278
257321
  return createHash("sha256").update(content).digest("hex");
257279
257322
  }
257280
257323
  function assertWithinWorkspace(workspaceDir, targetPath) {
257281
- const pathFromWorkspace = relative(workspaceDir, targetPath);
257324
+ let resolvedTarget = targetPath;
257325
+ const resolvedWorkspace = existsSync7(workspaceDir) ? realpathSync(workspaceDir) : resolve2(workspaceDir);
257326
+ if (existsSync7(targetPath)) {
257327
+ if (lstatSync(targetPath).isSymbolicLink()) {
257328
+ throw new Error(`Refusing to follow symlink: ${targetPath}`);
257329
+ }
257330
+ resolvedTarget = realpathSync(targetPath);
257331
+ }
257332
+ const pathFromWorkspace = relative(resolvedWorkspace, resolvedTarget);
257282
257333
  if (pathFromWorkspace === ".." || pathFromWorkspace.startsWith(`..${pathFromWorkspace.includes("\\") ? "\\" : "/"}`)) {
257283
257334
  throw new Error(`Refusing to write outside workspace: ${targetPath}`);
257284
257335
  }
@@ -257287,7 +257338,7 @@ function countLines(content) {
257287
257338
  return content.match(/\n/g)?.length ?? 0;
257288
257339
  }
257289
257340
  function collectStagedFilePaths(stagingDir, currentDir, output) {
257290
- const entries = readdirSync(currentDir);
257341
+ const entries = readdirSync2(currentDir);
257291
257342
  for (const entry of entries) {
257292
257343
  const absolutePath = join7(currentDir, entry);
257293
257344
  const stats = statSync3(absolutePath);
@@ -257327,7 +257378,7 @@ function listStagedFiles(workspaceDir) {
257327
257378
  }
257328
257379
  const filePaths = [];
257329
257380
  collectStagedFilePaths(stagingDir, stagingDir, filePaths);
257330
- return filePaths.sort((a, b3) => a.localeCompare(b3)).map((stagedRelativePath) => {
257381
+ return filePaths.sort((a, b3) => a.localeCompare(b3, "en")).map((stagedRelativePath) => {
257331
257382
  const workspacePath = join7(workspaceDir, stagedRelativePath);
257332
257383
  assertWithinWorkspace(workspaceDir, workspacePath);
257333
257384
  const content = readFileSync5(join7(stagingDir, stagedRelativePath), "utf-8");
@@ -257370,6 +257421,7 @@ function rejectStagedChanges(workspaceDir) {
257370
257421
  }
257371
257422
 
257372
257423
  // src/utils/cleanup.ts
257424
+ init_display();
257373
257425
  var cleanupRegistered = false;
257374
257426
  var replMode = false;
257375
257427
  function setReplMode(value) {
@@ -257395,29 +257447,33 @@ function registerCleanupHandlers() {
257395
257447
  return;
257396
257448
  }
257397
257449
  cleanupRegistered = true;
257398
- process.on("SIGINT", () => {
257450
+ process.once("SIGINT", () => {
257399
257451
  handleCleanupSignal("SIGINT");
257400
257452
  });
257401
- process.on("SIGTERM", () => {
257453
+ process.once("SIGTERM", () => {
257402
257454
  handleCleanupSignal("SIGTERM");
257403
257455
  });
257404
257456
  }
257405
257457
 
257406
257458
  // src/commands/init.ts
257407
- import { existsSync as existsSync10, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "node:fs";
257408
- import { homedir as homedir3, platform as platform5 } from "node:os";
257409
- import { basename, join as join11, resolve as resolve2 } from "node:path";
257410
- var import_picocolors5 = __toESM(require_picocolors(), 1);
257459
+ init_dist2();
257460
+ init_logger();
257411
257461
  init_config();
257462
+ var import_picocolors5 = __toESM(require_picocolors(), 1);
257463
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readdirSync as readdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "node:fs";
257464
+ import { homedir as homedir3, platform as platform5 } from "node:os";
257465
+ import { basename, join as join11, resolve as resolve3 } from "node:path";
257412
257466
 
257413
257467
  // src/llm/client.ts
257414
- import { randomUUID } from "node:crypto";
257468
+ init_logger();
257415
257469
  init_config();
257470
+ import { randomUUID } from "node:crypto";
257416
257471
 
257417
257472
  // src/prompts/version.ts
257418
257473
  var PROMPT_VERSION = "0.1.0";
257419
257474
 
257420
257475
  // src/llm/rate-limiter.ts
257476
+ init_display();
257421
257477
  var MAX_RETRIES = 3;
257422
257478
  var WARN_THRESHOLD = 50;
257423
257479
  var BLOCK_THRESHOLD = 100;
@@ -257484,7 +257540,7 @@ async function loadProvider(provider) {
257484
257540
  case "openai":
257485
257541
  return (await Promise.resolve().then(() => (init_openai(), exports_openai))).default;
257486
257542
  case "gemini":
257487
- return (await Promise.resolve().then(() => (init_dist(), exports_dist2))).GoogleGenerativeAI;
257543
+ return (await Promise.resolve().then(() => (init_dist3(), exports_dist2))).GoogleGenerativeAI;
257488
257544
  }
257489
257545
  }
257490
257546
  function normalizeToolSchema(tools) {
@@ -258302,12 +258358,14 @@ async function executeOperations(options) {
258302
258358
  }
258303
258359
 
258304
258360
  // src/mcp/client.ts
258361
+ init_logger();
258305
258362
  var JSON_RPC_VERSION = "2.0";
258306
258363
  var MCP_PROTOCOL_VERSION = "2025-11-25";
258307
258364
  var CLIENT_INFO = {
258308
258365
  name: "openkitt",
258309
258366
  version: "0.1.0"
258310
258367
  };
258368
+ var REQUEST_TIMEOUT_MS = 30000;
258311
258369
  var auditLogger3 = createAuditLogger(".");
258312
258370
  function createJsonRpcError(code, message) {
258313
258371
  const error4 = new Error(message);
@@ -258366,6 +258424,7 @@ async function createMcpClient(server2) {
258366
258424
  const pendingRequests = new Map;
258367
258425
  const rejectPending = (error4) => {
258368
258426
  for (const pending of pendingRequests.values()) {
258427
+ clearTimeout(pending.timer);
258369
258428
  pending.reject(error4);
258370
258429
  }
258371
258430
  pendingRequests.clear();
@@ -258389,6 +258448,7 @@ async function createMcpClient(server2) {
258389
258448
  if (isJsonRpcResponse(message)) {
258390
258449
  const pending = pendingRequests.get(message.id);
258391
258450
  if (pending) {
258451
+ clearTimeout(pending.timer);
258392
258452
  pendingRequests.delete(message.id);
258393
258453
  if (message.error) {
258394
258454
  pending.reject(createJsonRpcError(message.error.code, message.error.message));
@@ -258397,15 +258457,12 @@ async function createMcpClient(server2) {
258397
258457
  }
258398
258458
  }
258399
258459
  }
258400
- }
258401
- newlineIndex = stdoutBuffer.indexOf(`
258460
+ newlineIndex = stdoutBuffer.indexOf(`
258402
258461
  `);
258462
+ }
258403
258463
  }
258404
258464
  };
258405
258465
  const handleServerExit = () => {
258406
- if (closed) {
258407
- return;
258408
- }
258409
258466
  ready = false;
258410
258467
  rejectPending(new Error("MCP server connection closed"));
258411
258468
  };
@@ -258431,8 +258488,12 @@ async function createMcpClient(server2) {
258431
258488
  method,
258432
258489
  ...params ? { params } : {}
258433
258490
  };
258434
- return new Promise((resolve2, reject) => {
258435
- pendingRequests.set(id, { resolve: resolve2, reject });
258491
+ return new Promise((resolve3, reject) => {
258492
+ const timer = setTimeout(() => {
258493
+ pendingRequests.delete(id);
258494
+ reject(new Error(`MCP request '${method}' timed out after ${REQUEST_TIMEOUT_MS}ms`));
258495
+ }, REQUEST_TIMEOUT_MS);
258496
+ pendingRequests.set(id, { resolve: resolve3, reject, timer });
258436
258497
  writeMessage(message);
258437
258498
  });
258438
258499
  };
@@ -258509,6 +258570,9 @@ async function createMcpClient(server2) {
258509
258570
  };
258510
258571
  }
258511
258572
 
258573
+ // src/commands/init.ts
258574
+ init_lifecycle();
258575
+
258512
258576
  // src/scaffold/packages.ts
258513
258577
  import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
258514
258578
  import { join as join8 } from "node:path";
@@ -258654,6 +258718,9 @@ function scaffoldDefaultPackages(packagesDir) {
258654
258718
  scaffoldAnalytics(packagesDir);
258655
258719
  }
258656
258720
 
258721
+ // src/commands/init.ts
258722
+ init_display();
258723
+
258657
258724
  // src/utils/validation.ts
258658
258725
  import { existsSync as existsSync8 } from "node:fs";
258659
258726
  import { join as join9 } from "node:path";
@@ -258702,7 +258769,7 @@ function isWindows3() {
258702
258769
  return platform4() === "win32";
258703
258770
  }
258704
258771
  function normalizeEntries(entries) {
258705
- const lines = [...entries].sort((a, b3) => a.integration.localeCompare(b3.integration)).map((entry) => `${entry.integration}=${entry.version}`);
258772
+ const lines = [...entries].sort((a, b3) => a.integration.localeCompare(b3.integration, "en")).map((entry) => `${entry.integration}=${entry.version}`);
258706
258773
  if (lines.length === 0) {
258707
258774
  return "";
258708
258775
  }
@@ -258759,7 +258826,7 @@ var INTEGRATION_ALLOWLIST = [
258759
258826
  "Trigger.dev SDK",
258760
258827
  "Railway CLI"
258761
258828
  ];
258762
- var SEMVER_REGEX = /^\d+\.\d+\.\d+$/;
258829
+ var SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
258763
258830
  var TABLE_ROW_REGEX = /^\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|$/;
258764
258831
  var ALLOWLIST_SET = new Set(INTEGRATION_ALLOWLIST);
258765
258832
  function isSeparatorCell(value) {
@@ -258846,7 +258913,7 @@ function getDefaultVersions() {
258846
258913
  }
258847
258914
 
258848
258915
  // src/versions/registry.ts
258849
- var REQUEST_TIMEOUT_MS = 5000;
258916
+ var REQUEST_TIMEOUT_MS2 = 5000;
258850
258917
  var INTEGRATION_NPM_MAP = {
258851
258918
  TailwindCSS: "tailwindcss",
258852
258919
  "shadcn/ui": "shadcn",
@@ -258914,7 +258981,7 @@ async function fetchLatestVersion(npmPackage) {
258914
258981
  const controller = new AbortController;
258915
258982
  const timeoutId = setTimeout(() => {
258916
258983
  controller.abort();
258917
- }, REQUEST_TIMEOUT_MS);
258984
+ }, REQUEST_TIMEOUT_MS2);
258918
258985
  try {
258919
258986
  const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(npmPackage)}/latest`, {
258920
258987
  signal: controller.signal
@@ -258959,7 +259026,7 @@ async function versionExistsOnNpm(npmPackage, version) {
258959
259026
  const controller = new AbortController;
258960
259027
  const timeoutId = setTimeout(() => {
258961
259028
  controller.abort();
258962
- }, REQUEST_TIMEOUT_MS);
259029
+ }, REQUEST_TIMEOUT_MS2);
258963
259030
  try {
258964
259031
  const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(npmPackage)}/${encodeURIComponent(version)}`, { method: "HEAD", signal: controller.signal });
258965
259032
  return response.ok;
@@ -259038,7 +259105,7 @@ function extractRailwayProjectId(operationsResult) {
259038
259105
  try {
259039
259106
  const raw = readFileSync7(railwayConfig, "utf-8");
259040
259107
  const cfg = JSON.parse(raw);
259041
- const cwd = resolve2(".");
259108
+ const cwd = resolve3(".");
259042
259109
  const linked = cfg.projects?.[cwd];
259043
259110
  if (linked?.project)
259044
259111
  return linked.project;
@@ -259058,28 +259125,25 @@ function extractRailwayProjectId(operationsResult) {
259058
259125
  return labeledProjectId[1];
259059
259126
  return null;
259060
259127
  }
259061
- async function initCommand(context, _args) {
259062
- const workspaceDir = resolve2(".");
259063
- if (isKittWorkspace(workspaceDir)) {
259064
- error("Already a KITT workspace. Run /create to add a new app.");
259065
- return;
259066
- }
259067
- const ALLOWED_EXISTING = new Set([".git", ".gitignore", ".DS_Store", "README.md", "LICENSE", "LICENSE.md"]);
259068
- const existing = readdirSync2(workspaceDir).filter((f) => !ALLOWED_EXISTING.has(f));
259069
- if (existing.length > 0) {
259070
- error(`Directory is not empty. Remove or move these files first: ${existing.slice(0, 5).join(", ")}${existing.length > 5 ? ` (+${existing.length - 5} more)` : ""}`);
259071
- return;
259072
- }
259128
+ async function initCommand(context, args) {
259073
259129
  let workspaceName;
259074
- if (context.yes) {
259075
- workspaceName = getWorkspaceNameFromDirectory(workspaceDir);
259130
+ if (args[0]) {
259131
+ workspaceName = sanitizeInput(args[0].trim());
259132
+ const nameCheck = validateAppName(workspaceName);
259133
+ if (!nameCheck.valid) {
259134
+ error(nameCheck.error ?? "Invalid workspace name.");
259135
+ return;
259136
+ }
259137
+ } else if (context.yes) {
259138
+ workspaceName = getWorkspaceNameFromDirectory(resolve3("."));
259076
259139
  } else {
259077
259140
  const nameResult = await he({
259078
259141
  message: "Workspace name:",
259079
- placeholder: getWorkspaceNameFromDirectory(workspaceDir),
259080
- defaultValue: getWorkspaceNameFromDirectory(workspaceDir),
259142
+ placeholder: "my-project",
259081
259143
  validate: (v2) => {
259082
- const sanitized = v2.trim() || getWorkspaceNameFromDirectory(workspaceDir);
259144
+ const sanitized = v2.trim();
259145
+ if (sanitized.length === 0)
259146
+ return "Name is required";
259083
259147
  const result = validateAppName(sanitized);
259084
259148
  return result.valid ? undefined : result.error;
259085
259149
  }
@@ -259088,8 +259152,24 @@ async function initCommand(context, _args) {
259088
259152
  warn("Init cancelled.");
259089
259153
  return;
259090
259154
  }
259091
- workspaceName = sanitizeInput(nameResult.trim()) || getWorkspaceNameFromDirectory(workspaceDir);
259155
+ workspaceName = sanitizeInput(nameResult.trim());
259156
+ }
259157
+ const workspaceDir = resolve3(workspaceName);
259158
+ if (existsSync10(workspaceDir)) {
259159
+ if (isKittWorkspace(workspaceDir)) {
259160
+ error(`Directory '${workspaceName}' is already a KITT workspace. Run /create to add a new app.`);
259161
+ return;
259162
+ }
259163
+ const ALLOWED_EXISTING = new Set([".git", ".gitignore", ".DS_Store", "README.md", "LICENSE", "LICENSE.md"]);
259164
+ const existing = readdirSync3(workspaceDir).filter((f) => !ALLOWED_EXISTING.has(f));
259165
+ if (existing.length > 0) {
259166
+ error(`Directory '${workspaceName}' is not empty. Remove or move these files first: ${existing.slice(0, 5).join(", ")}${existing.length > 5 ? ` (+${existing.length - 5} more)` : ""}`);
259167
+ return;
259168
+ }
259169
+ } else {
259170
+ mkdirSync7(workspaceDir, { recursive: true });
259092
259171
  }
259172
+ process.chdir(workspaceDir);
259093
259173
  let packageManager = resolvePackageManager(workspaceDir);
259094
259174
  if (!context.yes) {
259095
259175
  const pmResult = await ve({
@@ -259206,9 +259286,31 @@ async function initCommand(context, _args) {
259206
259286
  }
259207
259287
 
259208
259288
  // src/commands/create.ts
259289
+ init_logger();
259290
+ init_config();
259291
+ import { execSync as execSync6 } from "node:child_process";
259209
259292
  import { existsSync as existsSync16, mkdirSync as mkdirSync10 } from "node:fs";
259210
259293
  import { join as join18 } from "node:path";
259211
- init_config();
259294
+ init_lifecycle();
259295
+
259296
+ // src/utils/workspace-resolver.ts
259297
+ async function resolveWorkspaceDir(startDir) {
259298
+ const upResult = findWorkspaceRoot(startDir);
259299
+ if (upResult)
259300
+ return upResult;
259301
+ const children = findChildWorkspaces(startDir);
259302
+ if (children.length === 0)
259303
+ return null;
259304
+ if (children.length === 1)
259305
+ return children[0].path;
259306
+ return null;
259307
+ }
259308
+ function getChildWorkspaces(startDir) {
259309
+ return findChildWorkspaces(startDir);
259310
+ }
259311
+
259312
+ // src/commands/create.ts
259313
+ init_display();
259212
259314
 
259213
259315
  // src/utils/constraints.ts
259214
259316
  var FRONTEND_DEFAULT_INTEGRATIONS = ["tailwindcss", "shadcn", "vitest", "posthog", "sentry"];
@@ -259372,6 +259474,8 @@ function resolveIntegrations(selections, manifest) {
259372
259474
  }
259373
259475
 
259374
259476
  // src/utils/prompts.ts
259477
+ init_dist2();
259478
+ init_display();
259375
259479
  class CancelError extends Error {
259376
259480
  constructor(message = "Creation cancelled.") {
259377
259481
  super(message);
@@ -259646,15 +259750,14 @@ All three arrays are required. Use empty arrays if a category is not needed.
259646
259750
  - Do NOT emit package installation commands (bun add, npm install, pnpm add, yarn add). All dependencies must be declared in the package.json you generate via newFiles — KITT installs them automatically after applying files.
259647
259751
  - Do NOT emit framework scaffold commands (create-next-app, create-start, @tanstack/cli create) for TanStack Start, Hono, Next.js, or Express.js — KITT generates all framework files statically.
259648
259752
  - Do NOT emit vitest init, sentry-cli, @sentry/cli, or any monitoring/observability CLI setup commands. Vitest requires no init step. Sentry is configured via environment variables only.
259649
- - You may ONLY propose commands matching these patterns (shown for bun; equivalents for npm/pnpm/yarn are also accepted):
259650
- * bunx shadcn@<semver> init --yes --base-color neutral --cwd apps/<appName> (MUST include --cwd apps/<appName>)
259651
- * bunx shadcn@<semver> add <component>
259652
- * bunx storybook@<semver> init
259653
- * bunx prisma init
259654
- * bunx prisma generate
259655
- * bunx drizzle-kit generate
259656
- * bunx playwright install
259657
- - Any command not in the list above MUST NOT appear in commands[]. If no valid commands are needed, return an empty commands array.
259753
+ - You may ONLY propose commands matching these patterns (replace <exec> with the package manager's execute command: bunx for bun, npx for npm, pnpm dlx for pnpm, yarn dlx for yarn):
259754
+ * <exec> shadcn@<semver> init --yes --base-color neutral --cwd apps/<appName> (MUST include --cwd apps/<appName>)
259755
+ * <exec> shadcn@<semver> add <component>
259756
+ * <exec> storybook@<semver> init
259757
+ * <exec> prisma init
259758
+ * <exec> prisma generate
259759
+ * <exec> drizzle-kit generate
259760
+ * <exec> playwright install
259658
259761
  - Do not propose commands that download scripts, make network requests, or execute arbitrary code.
259659
259762
  </commands_rules>
259660
259763
 
@@ -260010,8 +260113,8 @@ function createScaffoldingExecutor(client, onChunk) {
260010
260113
  break;
260011
260114
  }
260012
260115
  const delayMs = isOverloaded ? Math.min(OVERLOAD_RETRY_BASE_MS * 2 ** (attempt - 1), OVERLOAD_MAX_RETRY_MS) * (0.5 + Math.random() * 0.5) : calculateBackoff(attempt);
260013
- await new Promise((resolve3) => {
260014
- setTimeout(resolve3, delayMs);
260116
+ await new Promise((resolve4) => {
260117
+ setTimeout(resolve4, delayMs);
260015
260118
  });
260016
260119
  }
260017
260120
  }
@@ -260049,6 +260152,9 @@ async function executeScaffolding(client, context, onChunk) {
260049
260152
  return scaffoldingExecutor.execute(context);
260050
260153
  }
260051
260154
 
260155
+ // src/commands/create-scaffolding.ts
260156
+ init_display();
260157
+
260052
260158
  // src/versions/compat.ts
260053
260159
  var import_semver = __toESM(require_semver2(), 1);
260054
260160
  var DEPENDENCY_COUPLING = [
@@ -260124,7 +260230,7 @@ async function checkCompatibility(displayVersions, resolvedIntegrations, framewo
260124
260230
  if (installed === null)
260125
260231
  continue;
260126
260232
  const satisfied = checkRange(installed, range);
260127
- if (satisfied === true || satisfied === null)
260233
+ if (satisfied === true)
260128
260234
  continue;
260129
260235
  const issue = {
260130
260236
  package: `${npmName}@${version}`,
@@ -260155,7 +260261,7 @@ async function checkCompatibility(displayVersions, resolvedIntegrations, framewo
260155
260261
  if (!depInstalled)
260156
260262
  continue;
260157
260263
  const satisfied = checkRange(depInstalled, coupling.depRange);
260158
- if (satisfied === true || satisfied === null)
260264
+ if (satisfied === true)
260159
260265
  continue;
260160
260266
  errors.push({
260161
260267
  package: `${coupling.pkg}@${pkgVersion}`,
@@ -260169,6 +260275,51 @@ async function checkCompatibility(displayVersions, resolvedIntegrations, framewo
260169
260275
  return { errors, warnings };
260170
260276
  }
260171
260277
 
260278
+ // src/utils/pm.ts
260279
+ var COMMANDS = {
260280
+ bun: {
260281
+ execute: "bunx",
260282
+ add: "bun add",
260283
+ remove: "bun remove",
260284
+ run: "bun run",
260285
+ install: "bun install"
260286
+ },
260287
+ npm: {
260288
+ execute: "npx",
260289
+ add: "npm install",
260290
+ remove: "npm uninstall",
260291
+ run: "npm run",
260292
+ install: "npm install"
260293
+ },
260294
+ pnpm: {
260295
+ execute: "pnpm dlx",
260296
+ add: "pnpm add",
260297
+ remove: "pnpm remove",
260298
+ run: "pnpm run",
260299
+ install: "pnpm install"
260300
+ },
260301
+ yarn: {
260302
+ execute: "yarn dlx",
260303
+ add: "yarn add",
260304
+ remove: "yarn remove",
260305
+ run: "yarn run",
260306
+ install: "yarn install"
260307
+ }
260308
+ };
260309
+ var LOCKFILES = {
260310
+ bun: "bun.lockb",
260311
+ npm: "package-lock.json",
260312
+ pnpm: "pnpm-lock.yaml",
260313
+ yarn: "yarn.lock"
260314
+ };
260315
+ var DEFAULT_PM = "bun";
260316
+ function getCommand(pm, operation) {
260317
+ return COMMANDS[pm][operation];
260318
+ }
260319
+ function getLockfile(pm) {
260320
+ return LOCKFILES[pm];
260321
+ }
260322
+
260172
260323
  // src/scaffold/frameworks/hono.ts
260173
260324
  function buildHonoFiles(opts) {
260174
260325
  const { appName, integrations } = opts;
@@ -260252,7 +260403,7 @@ function buildIndexTs(base, appName, integrations) {
260252
260403
  `) };
260253
260404
  }
260254
260405
  function buildHomeRoute(base, appName) {
260255
- const displayName = appName.charAt(0).toUpperCase() + appName.slice(1);
260406
+ const displayName = appName.length > 0 ? appName.charAt(0).toUpperCase() + appName.slice(1) : "App";
260256
260407
  const html = [
260257
260408
  "<!DOCTYPE html>",
260258
260409
  '<html lang="en">',
@@ -260497,7 +260648,7 @@ function buildIndexTs2(base, appName, integrations) {
260497
260648
  `) };
260498
260649
  }
260499
260650
  function buildHomeRoute2(base, appName) {
260500
- const displayName = appName.charAt(0).toUpperCase() + appName.slice(1);
260651
+ const displayName = appName.length > 0 ? appName.charAt(0).toUpperCase() + appName.slice(1) : "App";
260501
260652
  const html = [
260502
260653
  "<!DOCTYPE html>",
260503
260654
  '<html lang="en">',
@@ -260756,8 +260907,8 @@ function buildNextjsPackageJson(opts) {
260756
260907
  devDependencies["storybook"] = sbVersion;
260757
260908
  devDependencies["@storybook/react"] = sbVersion;
260758
260909
  devDependencies["@storybook/react-vite"] = sbVersion;
260759
- devDependencies["@storybook/addon-essentials"] = sbVersion;
260760
- devDependencies["@storybook/addon-interactions"] = sbVersion;
260910
+ devDependencies["@storybook/addon-essentials"] = "8.6.14";
260911
+ devDependencies["@storybook/addon-interactions"] = "8.6.14";
260761
260912
  }
260762
260913
  const pkg = {
260763
260914
  name: `@${workspaceName}/${appName}`,
@@ -260925,7 +261076,7 @@ ${bodyContent}
260925
261076
  `;
260926
261077
  }
260927
261078
  function buildHomePage(appName, _workspaceName, integrations) {
260928
- const displayName = appName.charAt(0).toUpperCase() + appName.slice(1);
261079
+ const displayName = appName.length > 0 ? appName.charAt(0).toUpperCase() + appName.slice(1) : "App";
260929
261080
  const hasTailwind = integrations.includes("tailwindcss");
260930
261081
  if (hasTailwind) {
260931
261082
  return [
@@ -261116,7 +261267,7 @@ function buildTanstackStartPackageJson(opts) {
261116
261267
  const typesReactDomVersion = v3(versions, "@types/react-dom", "19.0.0");
261117
261268
  const dependencies = {
261118
261269
  "@tanstack/react-start": tanstackVersion,
261119
- "@tanstack/react-router": tanstackVersion,
261270
+ "@tanstack/react-router": v3(versions, "@tanstack/react-router", tanstackVersion),
261120
261271
  react: reactVersion,
261121
261272
  "react-dom": reactVersion
261122
261273
  };
@@ -261195,8 +261346,8 @@ function buildTanstackStartPackageJson(opts) {
261195
261346
  devDependencies["storybook"] = sbVersion;
261196
261347
  devDependencies["@storybook/react"] = sbVersion;
261197
261348
  devDependencies["@storybook/react-vite"] = sbVersion;
261198
- devDependencies["@storybook/addon-essentials"] = sbVersion;
261199
- devDependencies["@storybook/addon-interactions"] = sbVersion;
261349
+ devDependencies["@storybook/addon-essentials"] = "8.6.14";
261350
+ devDependencies["@storybook/addon-interactions"] = "8.6.14";
261200
261351
  }
261201
261352
  const pkg = {
261202
261353
  name: `@${workspaceName}/${appName}`,
@@ -261341,7 +261492,7 @@ export default { fetch: createStartHandler(defaultStreamHandler) };
261341
261492
  return { path: `${base}/src/server.ts`, content };
261342
261493
  }
261343
261494
  function buildRouter(base, appName, integrations) {
261344
- const displayName = appName.charAt(0).toUpperCase() + appName.slice(1);
261495
+ const displayName = appName.length > 0 ? appName.charAt(0).toUpperCase() + appName.slice(1) : "App";
261345
261496
  const hasSentry = integrations.includes("sentry");
261346
261497
  const sentryImport = hasSentry ? `import * as Sentry from '@sentry/tanstackstart-react';
261347
261498
  ` : "";
@@ -261389,7 +261540,7 @@ function buildRouter(base, appName, integrations) {
261389
261540
  }
261390
261541
  function buildRootRoute(base, appName, integrations) {
261391
261542
  const hasTailwind = integrations.includes("tailwindcss");
261392
- const displayName = appName.charAt(0).toUpperCase() + appName.slice(1);
261543
+ const displayName = appName.length > 0 ? appName.charAt(0).toUpperCase() + appName.slice(1) : "App";
261393
261544
  const cssImport = hasTailwind ? `import appCss from '~/styles/app.css?url';
261394
261545
  ` : "";
261395
261546
  const linksSection = hasTailwind ? ` links: [{ rel: 'stylesheet', href: appCss }],
@@ -261502,7 +261653,7 @@ function buildAppCss(base) {
261502
261653
  };
261503
261654
  }
261504
261655
  function buildIndexRoute(base, appName, welcomeContent) {
261505
- const displayName = appName.charAt(0).toUpperCase() + appName.slice(1);
261656
+ const displayName = appName.length > 0 ? appName.charAt(0).toUpperCase() + appName.slice(1) : "App";
261506
261657
  const homeBody = welcomeContent ?? [
261507
261658
  ` return (`,
261508
261659
  ` <main className="min-h-screen bg-[#050508] text-white flex items-center justify-center antialiased">`,
@@ -262291,23 +262442,24 @@ function buildIntegrationFiles(opts) {
262291
262442
  return files;
262292
262443
  }
262293
262444
  function buildIntegrationCommands(opts) {
262294
- const { integrations, versions, appName, framework } = opts;
262445
+ const { integrations, versions, appName, packageManager } = opts;
262446
+ const x2 = getCommand(packageManager, "execute");
262295
262447
  const commands = [];
262296
262448
  if (integrations.includes("shadcn")) {
262297
262449
  const shadcnVersion = versions["shadcn/ui"] ?? "3.8.5";
262298
262450
  commands.push({
262299
- command: `bunx shadcn@${shadcnVersion} init --yes --base-color neutral --cwd apps/${appName}`,
262451
+ command: `${x2} shadcn@${shadcnVersion} init --yes --base-color neutral --cwd apps/${appName}`,
262300
262452
  purpose: "Initialize shadcn/ui components"
262301
262453
  });
262302
262454
  }
262303
262455
  if (integrations.includes("drizzle")) {
262304
- commands.push({ command: "bunx drizzle-kit generate", purpose: "Generate Drizzle migrations" });
262456
+ commands.push({ command: `${x2} drizzle-kit generate`, purpose: "Generate Drizzle migrations" });
262305
262457
  }
262306
262458
  if (integrations.includes("prisma")) {
262307
- commands.push({ command: "bunx prisma generate", purpose: "Generate Prisma client" });
262459
+ commands.push({ command: `${x2} prisma generate`, purpose: "Generate Prisma client" });
262308
262460
  }
262309
262461
  if (integrations.includes("playwright")) {
262310
- commands.push({ command: "bunx playwright install", purpose: "Install Playwright browsers" });
262462
+ commands.push({ command: `${x2} playwright install`, purpose: "Install Playwright browsers" });
262311
262463
  }
262312
262464
  return commands;
262313
262465
  }
@@ -262467,7 +262619,8 @@ async function executeCreateScaffolding(options) {
262467
262619
  framework,
262468
262620
  integrations: options.resolvedIntegrations,
262469
262621
  versions: mergedVersions,
262470
- workspaceName: options.manifest.workspace.name
262622
+ workspaceName: options.manifest.workspace.name,
262623
+ packageManager: options.manifest.workspace.packageManager
262471
262624
  });
262472
262625
  return {
262473
262626
  scaffolding: {
@@ -262490,8 +262643,9 @@ async function executeCreateScaffolding(options) {
262490
262643
  }
262491
262644
 
262492
262645
  // src/sandbox/scanner.ts
262493
- import { existsSync as existsSync11, lstatSync, readFileSync as readFileSync9 } from "node:fs";
262494
- import { extname, isAbsolute, join as join13, normalize, resolve as resolve3 } from "node:path";
262646
+ init_logger();
262647
+ import { existsSync as existsSync11, lstatSync as lstatSync2, readFileSync as readFileSync9 } from "node:fs";
262648
+ import { extname, isAbsolute, join as join13, normalize, resolve as resolve4 } from "node:path";
262495
262649
  var ALLOWED_EXTENSIONS = new Set([
262496
262650
  ".ts",
262497
262651
  ".tsx",
@@ -262512,6 +262666,9 @@ var SUSPICIOUS_CONTENT_PATTERNS = [
262512
262666
  { pattern: /\bexec\s*\(/, detail: "Found 'exec(' - command execution is not allowed" },
262513
262667
  { pattern: /\bchild_process\b/, detail: "Found 'child_process' - process spawning module usage is not allowed" },
262514
262668
  { pattern: /\bspawn\s*\(/, detail: "Found 'spawn(' - process spawning is not allowed" },
262669
+ { pattern: /\bnew\s+Function\s*\(/, detail: "Found 'new Function(' - dynamic code execution is not allowed" },
262670
+ { pattern: /\bimport\s*\(/, detail: "Found dynamic 'import(' - dynamic imports are not allowed" },
262671
+ { pattern: /\(\s*0\s*,\s*eval\s*\)\s*\(/, detail: "Found indirect eval '(0, eval)(' - dynamic code execution is not allowed" },
262515
262672
  {
262516
262673
  pattern: /require\(\s*['"]http['"]\s*\)/,
262517
262674
  detail: `Found 'require("http")' - insecure HTTP imports are not allowed`
@@ -262567,7 +262724,7 @@ function validateFilePath(filePath) {
262567
262724
  });
262568
262725
  }
262569
262726
  if (existsSync11(filePath)) {
262570
- const stats = lstatSync(filePath);
262727
+ const stats = lstatSync2(filePath);
262571
262728
  if (stats.isSymbolicLink()) {
262572
262729
  warnings.push({
262573
262730
  type: "path_traversal",
@@ -262598,7 +262755,7 @@ function scanStagedFiles(workspaceDir) {
262598
262755
  const auditLogger4 = createAuditLogger(workspaceDir);
262599
262756
  const warnings = [];
262600
262757
  const stagedFiles = listStagedFiles(workspaceDir);
262601
- const stagingRoot = resolve3(workspaceDir, ".kitt/staging");
262758
+ const stagingRoot = resolve4(workspaceDir, ".kitt/staging");
262602
262759
  for (const stagedFile of stagedFiles) {
262603
262760
  const filePathWarnings = validateFilePath(stagedFile.relativePath);
262604
262761
  const fileTypeWarnings = validateFileType(stagedFile.relativePath);
@@ -262607,7 +262764,7 @@ function scanStagedFiles(workspaceDir) {
262607
262764
  if (hasPathIssues) {
262608
262765
  continue;
262609
262766
  }
262610
- const stagedAbsolutePath = resolve3(stagingRoot, normalize(stagedFile.relativePath));
262767
+ const stagedAbsolutePath = resolve4(stagingRoot, normalize(stagedFile.relativePath));
262611
262768
  const stagedContent = readFileSync9(stagedAbsolutePath, "utf-8");
262612
262769
  warnings.push(...scanFileContent(stagedFile.relativePath, stagedContent));
262613
262770
  }
@@ -262638,6 +262795,9 @@ function stageNewFiles(newFiles, workspaceDir) {
262638
262795
  }
262639
262796
 
262640
262797
  // src/commands/create-confirm.ts
262798
+ init_dist2();
262799
+ init_logger();
262800
+ init_display();
262641
262801
  function presentStagedChanges(diffSummary, scanResult) {
262642
262802
  info("Staged changes:");
262643
262803
  for (const line of diffSummary) {
@@ -262673,10 +262833,11 @@ async function confirmAndApply(options) {
262673
262833
  }
262674
262834
 
262675
262835
  // src/ast/engine.ts
262836
+ init_logger();
262676
262837
  var import_ts_morph = __toESM(require_ts_morph(), 1);
262677
262838
  import { createHash as createHash3 } from "node:crypto";
262678
262839
  import { existsSync as existsSync12, mkdirSync as mkdirSync8, writeFileSync as writeFileSync10 } from "node:fs";
262679
- import { dirname as dirname4, isAbsolute as isAbsolute2, join as join14, normalize as normalize2, relative as relative2, resolve as resolve4 } from "node:path";
262840
+ import { dirname as dirname4, isAbsolute as isAbsolute2, join as join14, normalize as normalize2, relative as relative2, resolve as resolve5 } from "node:path";
262680
262841
  var KITT_DIR2 = ".kitt";
262681
262842
  var STAGING_DIR2 = "staging";
262682
262843
  function hashContent2(content) {
@@ -262716,7 +262877,7 @@ function createAstEngine(workspaceDir) {
262716
262877
  const auditLogger4 = createAuditLogger(workspaceDir);
262717
262878
  function loadSourceFile(relativePath) {
262718
262879
  validateRelativePath(relativePath);
262719
- const fullPath = resolve4(workspaceDir, relativePath);
262880
+ const fullPath = resolve5(workspaceDir, relativePath);
262720
262881
  if (!isRelativePathInside(workspaceDir, fullPath)) {
262721
262882
  throw new Error(`Path is outside workspace: ${relativePath}`);
262722
262883
  }
@@ -262732,7 +262893,7 @@ function createAstEngine(workspaceDir) {
262732
262893
  function writeToStaging2(relativePath, sourceFile) {
262733
262894
  validateRelativePath(relativePath);
262734
262895
  const stagingPath = join14(workspaceDir, KITT_DIR2, STAGING_DIR2, relativePath);
262735
- if (!isRelativePathInside(resolve4(workspaceDir, KITT_DIR2, STAGING_DIR2), stagingPath)) {
262896
+ if (!isRelativePathInside(resolve5(workspaceDir, KITT_DIR2, STAGING_DIR2), stagingPath)) {
262736
262897
  throw new Error(`Refusing to write outside staging directory: ${relativePath}`);
262737
262898
  }
262738
262899
  mkdirSync8(dirname4(stagingPath), { recursive: true });
@@ -263109,7 +263270,7 @@ function applyOperation(sourceFile, operation) {
263109
263270
  // src/ast/validator.ts
263110
263271
  var import_ts_morph3 = __toESM(require_ts_morph(), 1);
263111
263272
  import { existsSync as existsSync13 } from "node:fs";
263112
- import { extname as extname2, isAbsolute as isAbsolute3, normalize as normalize3, relative as relative3, resolve as resolve5 } from "node:path";
263273
+ import { extname as extname2, isAbsolute as isAbsolute3, normalize as normalize3, relative as relative3, resolve as resolve6 } from "node:path";
263113
263274
  var VALID_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx"]);
263114
263275
  var TARGET_FILE_OPERATION = { op: "targetFile" };
263115
263276
  function toMessageText(messageText) {
@@ -263285,8 +263446,8 @@ function validateTargetFile(workspaceDir, filePath) {
263285
263446
  message: `Unsupported AST target extension: ${targetExt || "(none)"}`
263286
263447
  });
263287
263448
  }
263288
- const absoluteWorkspaceDir = resolve5(workspaceDir);
263289
- const absoluteTargetPath = resolve5(absoluteWorkspaceDir, filePath);
263449
+ const absoluteWorkspaceDir = resolve6(workspaceDir);
263450
+ const absoluteTargetPath = resolve6(absoluteWorkspaceDir, filePath);
263290
263451
  const pathFromWorkspace = relative3(absoluteWorkspaceDir, absoluteTargetPath);
263291
263452
  if (pathFromWorkspace !== "" && (pathFromWorkspace.startsWith("..") || isAbsolute3(pathFromWorkspace))) {
263292
263453
  errors.push({
@@ -263346,7 +263507,7 @@ function validateTransforms(workspaceDir, transforms) {
263346
263507
  if (!hasRemoveChecks) {
263347
263508
  continue;
263348
263509
  }
263349
- const absolutePath = resolve5(workspaceDir, transform.path);
263510
+ const absolutePath = resolve6(workspaceDir, transform.path);
263350
263511
  let sourceFile;
263351
263512
  try {
263352
263513
  sourceFile = project.addSourceFileAtPath(absolutePath);
@@ -263416,51 +263577,12 @@ function executeTransformPipeline(transforms, workspaceDir) {
263416
263577
  }
263417
263578
 
263418
263579
  // src/commands/create-pipeline.ts
263419
- import { execSync as execSync5 } from "node:child_process";
263580
+ init_logger();
263581
+ import { execFileSync as execFileSync2 } from "node:child_process";
263420
263582
  import { join as join15 } from "node:path";
263421
263583
 
263422
- // src/utils/pm.ts
263423
- var COMMANDS = {
263424
- bun: {
263425
- execute: "bunx",
263426
- add: "bun add",
263427
- remove: "bun remove",
263428
- run: "bun run"
263429
- },
263430
- npm: {
263431
- execute: "npx",
263432
- add: "npm install",
263433
- remove: "npm uninstall",
263434
- run: "npm run"
263435
- },
263436
- pnpm: {
263437
- execute: "pnpm dlx",
263438
- add: "pnpm add",
263439
- remove: "pnpm remove",
263440
- run: "pnpm run"
263441
- },
263442
- yarn: {
263443
- execute: "yarn dlx",
263444
- add: "yarn add",
263445
- remove: "yarn remove",
263446
- run: "yarn run"
263447
- }
263448
- };
263449
- var LOCKFILES = {
263450
- bun: "bun.lockb",
263451
- npm: "package-lock.json",
263452
- pnpm: "pnpm-lock.yaml",
263453
- yarn: "yarn.lock"
263454
- };
263455
- var DEFAULT_PM = "bun";
263456
- function getCommand(pm, operation) {
263457
- return COMMANDS[pm][operation];
263458
- }
263459
- function getLockfile(pm) {
263460
- return LOCKFILES[pm];
263461
- }
263462
-
263463
263584
  // src/sandbox/command-allowlist.ts
263585
+ init_logger();
263464
263586
  var auditLogger4 = createAuditLogger(".");
263465
263587
  var SEMVER_PATTERN = String.raw`\d+\.\d+\.\d+`;
263466
263588
  var PATH_PATTERN = String.raw`[A-Za-z0-9._/-]+`;
@@ -263531,7 +263653,15 @@ function blocked(command, reason) {
263531
263653
  reason
263532
263654
  };
263533
263655
  }
263656
+ var MAX_COMMAND_LENGTH = 512;
263534
263657
  function validateCommand(command, packageManager) {
263658
+ const normalized = command.replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "").replace(/\s+/g, " ").trim();
263659
+ if (normalized.length === 0) {
263660
+ return blocked(command, "Command is empty after normalization");
263661
+ }
263662
+ if (normalized.length > MAX_COMMAND_LENGTH) {
263663
+ return blocked(command, `Command exceeds maximum length of ${MAX_COMMAND_LENGTH} characters`);
263664
+ }
263535
263665
  const executePrefix = escapeRegex(getCommand(packageManager, "execute"));
263536
263666
  const removePrefix = escapeRegex(getCommand(packageManager, "remove"));
263537
263667
  const packageWithVersion = `(${PACKAGE_PATTERN})@(${SEMVER_PATTERN})`;
@@ -263547,8 +263677,8 @@ function validateCommand(command, packageManager) {
263547
263677
  new RegExp(`^${executePrefix} drizzle-kit generate$`),
263548
263678
  new RegExp(`^${executePrefix} playwright install$`)
263549
263679
  ];
263550
- const cdMatch = /^cd ([A-Za-z0-9._\/-]+) && (.+)$/.exec(command);
263551
- const bare = cdMatch ? cdMatch[2] : command;
263680
+ const cdMatch = /^cd ([A-Za-z0-9._\/-]+) && (.+)$/.exec(normalized);
263681
+ const bare = cdMatch ? cdMatch[2] : normalized;
263552
263682
  const addPrefix = escapeRegex(getCommand(packageManager, "add"));
263553
263683
  const devFlag = String.raw`(?:(?:-D|-d|--dev|--save-dev) )?`;
263554
263684
  const addRegex = new RegExp(`^${addPrefix} ${devFlag}${packageWithVersion}( ${packageWithVersion})*$`);
@@ -263563,6 +263693,7 @@ function validateCommand(command, packageManager) {
263563
263693
  }
263564
263694
 
263565
263695
  // src/commands/create-pipeline.ts
263696
+ init_display();
263566
263697
  function executeCommandPipeline(commands, options) {
263567
263698
  const auditLogger5 = createAuditLogger(options.workspaceDir);
263568
263699
  const results = [];
@@ -263593,7 +263724,8 @@ function executeCommandPipeline(commands, options) {
263593
263724
  continue;
263594
263725
  }
263595
263726
  try {
263596
- execSync5(bare, { cwd, stdio: "inherit" });
263727
+ const [bin, ...args] = bare.split(/\s+/);
263728
+ execFileSync2(bin, args, { cwd, stdio: "inherit" });
263597
263729
  results.push({
263598
263730
  command: cmd.command,
263599
263731
  purpose: cmd.purpose,
@@ -263615,6 +263747,7 @@ function executeCommandPipeline(commands, options) {
263615
263747
  }
263616
263748
 
263617
263749
  // src/commands/create-infra.ts
263750
+ init_display();
263618
263751
  function extractServiceId(operationsResult) {
263619
263752
  const jsonServiceId = /"serviceId"\s*:\s*"([^"]+)"/i.exec(operationsResult);
263620
263753
  if (jsonServiceId?.[1]) {
@@ -263675,16 +263808,21 @@ async function provisionInfrastructure(options) {
263675
263808
  }
263676
263809
 
263677
263810
  // src/commands/run.ts
263811
+ init_dist2();
263812
+ var import_picocolors6 = __toESM(require_picocolors(), 1);
263678
263813
  import { spawn as spawn2 } from "node:child_process";
263679
263814
  import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
263680
263815
  import { join as join17 } from "node:path";
263681
- var import_picocolors6 = __toESM(require_picocolors(), 1);
263816
+ init_display();
263682
263817
 
263683
263818
  // src/commands/settings.ts
263684
- import { execSync as execSync6 } from "node:child_process";
263819
+ init_dist2();
263820
+ init_logger();
263821
+ import { execSync as execSync5 } from "node:child_process";
263685
263822
  import { chmodSync as chmodSync4, existsSync as existsSync14, mkdirSync as mkdirSync9, readFileSync as readFileSync10, renameSync as renameSync5, rmSync as rmSync3, unlinkSync as unlinkSync4, writeFileSync as writeFileSync11 } from "node:fs";
263686
263823
  import { homedir as homedir4, platform as platform6 } from "node:os";
263687
263824
  import { join as join16 } from "node:path";
263825
+ init_display();
263688
263826
  var SUPPORTED_PACKAGE_MANAGERS = ["bun", "npm", "pnpm", "yarn"];
263689
263827
  var CONFIG_DIR2 = join16(homedir4(), ".kitt");
263690
263828
  var CONFIG_FILE2 = join16(CONFIG_DIR2, "config.json");
@@ -263789,8 +263927,13 @@ function removePackageManagerArtifacts(workspaceDir, packageManager) {
263789
263927
  }
263790
263928
  function ensureWorkspaceFieldInRootPackageJson(workspaceDir) {
263791
263929
  const packageJsonPath = join16(workspaceDir, "package.json");
263792
- const raw = readFileSync10(packageJsonPath, "utf-8");
263793
- const parsed = JSON.parse(raw);
263930
+ let parsed;
263931
+ try {
263932
+ const raw = readFileSync10(packageJsonPath, "utf-8");
263933
+ parsed = JSON.parse(raw);
263934
+ } catch {
263935
+ throw new Error("Root package.json is missing or contains invalid JSON.");
263936
+ }
263794
263937
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
263795
263938
  throw new Error("Root package.json must contain a JSON object.");
263796
263939
  }
@@ -263869,7 +264012,11 @@ async function maybeConfirmMigration(context, fromPm, toPm) {
263869
264012
  function migrateWorkspacePackageManager(workspaceDir, fromPm, toPm) {
263870
264013
  removePackageManagerArtifacts(workspaceDir, fromPm);
263871
264014
  writePackageManagerFiles(workspaceDir, toPm);
263872
- execSync6(getInstallCommand(toPm), { cwd: workspaceDir, stdio: "inherit" });
264015
+ try {
264016
+ execSync5(getInstallCommand(toPm), { cwd: workspaceDir, stdio: "inherit" });
264017
+ } catch {
264018
+ throw new Error(`Failed to install dependencies with ${toPm}. You may need to run the install command manually.`);
264019
+ }
263873
264020
  }
263874
264021
  async function runDisplayMode(workspaceDir) {
263875
264022
  const autoOpen = readAutoOpenBrowser();
@@ -263937,7 +264084,11 @@ async function runSetMode(context, workspaceDir, args) {
263937
264084
  success(`Workspace migrated to ${rawValue}`);
263938
264085
  }
263939
264086
  async function settingsCommand(context, args) {
263940
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
264087
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
264088
+ if (!workspaceDir) {
264089
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
264090
+ return;
264091
+ }
263941
264092
  if (args.length === 0) {
263942
264093
  await runDisplayMode(workspaceDir);
263943
264094
  return;
@@ -263975,7 +264126,7 @@ function resolveDevScript(appDir) {
263975
264126
  return { found: false, reason: "no-matching-script", available };
263976
264127
  }
263977
264128
  function spawnDevServer(appDir, runCmd, script, appName) {
263978
- return new Promise((resolve6, reject) => {
264129
+ return new Promise((resolve7, reject) => {
263979
264130
  const [bin, ...binArgs] = `${runCmd} ${script}`.split(" ");
263980
264131
  if (!bin) {
263981
264132
  reject(new Error("Could not resolve run command."));
@@ -263990,25 +264141,33 @@ function spawnDevServer(appDir, runCmd, script, appName) {
263990
264141
  shell: false
263991
264142
  });
263992
264143
  child.on("error", (err) => {
264144
+ cleanup();
263993
264145
  reject(new Error(`Failed to start dev server: ${err.message}`));
263994
264146
  });
263995
264147
  child.on("close", (code) => {
264148
+ cleanup();
263996
264149
  if (code !== null && code !== 0) {
263997
264150
  reject(new Error(`Dev server exited with code ${code}.`));
263998
264151
  return;
263999
264152
  }
264000
- resolve6();
264153
+ resolve7();
264001
264154
  });
264002
- process.on("SIGINT", () => {
264155
+ const onSigint = () => {
264003
264156
  child.kill("SIGINT");
264004
- });
264005
- process.on("SIGTERM", () => {
264157
+ };
264158
+ const onSigterm = () => {
264006
264159
  child.kill("SIGTERM");
264007
- });
264160
+ };
264161
+ process.on("SIGINT", onSigint);
264162
+ process.on("SIGTERM", onSigterm);
264163
+ function cleanup() {
264164
+ process.removeListener("SIGINT", onSigint);
264165
+ process.removeListener("SIGTERM", onSigterm);
264166
+ }
264008
264167
  });
264009
264168
  }
264010
264169
  function startDevServerWithUrl(appDir, runCmd, script, appName) {
264011
- return new Promise((resolve6, reject) => {
264170
+ return new Promise((resolve7, reject) => {
264012
264171
  const [bin, ...binArgs] = `${runCmd} ${script}`.split(" ");
264013
264172
  if (!bin) {
264014
264173
  reject(new Error("Could not resolve run command."));
@@ -264025,7 +264184,9 @@ function startDevServerWithUrl(appDir, runCmd, script, appName) {
264025
264184
  let detectedUrl = null;
264026
264185
  function openBrowser(url) {
264027
264186
  const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
264028
- spawn2(opener, [url], { detached: true, stdio: "ignore" }).unref();
264187
+ const proc = spawn2(opener, [url], { detached: true, stdio: "ignore" });
264188
+ proc.on("error", () => {});
264189
+ proc.unref();
264029
264190
  }
264030
264191
  function onUrlDetected(url) {
264031
264192
  if (detectedUrl !== null)
@@ -264059,25 +264220,37 @@ function startDevServerWithUrl(appDir, runCmd, script, appName) {
264059
264220
  scanForUrl(text);
264060
264221
  });
264061
264222
  child.on("error", (err) => {
264223
+ cleanup();
264062
264224
  reject(new Error(`Failed to start dev server: ${err.message}`));
264063
264225
  });
264064
264226
  child.on("close", (code) => {
264227
+ cleanup();
264065
264228
  if (code !== null && code !== 0) {
264066
264229
  reject(new Error(`Dev server exited with code ${code}.`));
264067
264230
  return;
264068
264231
  }
264069
- resolve6();
264232
+ resolve7();
264070
264233
  });
264071
- process.on("SIGINT", () => {
264234
+ const onSigint = () => {
264072
264235
  child.kill("SIGINT");
264073
- });
264074
- process.on("SIGTERM", () => {
264236
+ };
264237
+ const onSigterm = () => {
264075
264238
  child.kill("SIGTERM");
264076
- });
264239
+ };
264240
+ process.on("SIGINT", onSigint);
264241
+ process.on("SIGTERM", onSigterm);
264242
+ function cleanup() {
264243
+ process.removeListener("SIGINT", onSigint);
264244
+ process.removeListener("SIGTERM", onSigterm);
264245
+ }
264077
264246
  });
264078
264247
  }
264079
264248
  async function runCommand(_context, args) {
264080
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
264249
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
264250
+ if (!workspaceDir) {
264251
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
264252
+ return;
264253
+ }
264081
264254
  if (!isKittWorkspace(workspaceDir)) {
264082
264255
  error("Not a KITT workspace. Run /init first.");
264083
264256
  return;
@@ -264135,7 +264308,11 @@ async function runCommand(_context, args) {
264135
264308
 
264136
264309
  // src/commands/create.ts
264137
264310
  async function createCommand2(context, _args) {
264138
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
264311
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
264312
+ if (!workspaceDir) {
264313
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
264314
+ return;
264315
+ }
264139
264316
  if (!isKittWorkspace(workspaceDir)) {
264140
264317
  error("Not a KITT workspace. Run /init first.");
264141
264318
  return;
@@ -264217,11 +264394,24 @@ async function createCommand2(context, _args) {
264217
264394
  warn(`AST transform skipped: ${transformError}`);
264218
264395
  }
264219
264396
  }
264220
- executeCommandPipeline(scaffoldResult.scaffolding.commands, {
264221
- workspaceDir,
264222
- packageManager: manifest.workspace.packageManager,
264223
- dryRun: context.dryRun
264224
- });
264397
+ let installSucceeded = true;
264398
+ if (!context.dryRun) {
264399
+ const installCmd = getCommand(manifest.workspace.packageManager, "install");
264400
+ info(`Installing dependencies (${installCmd})...`);
264401
+ try {
264402
+ execSync6(installCmd, { cwd: workspaceDir, stdio: "inherit" });
264403
+ } catch {
264404
+ installSucceeded = false;
264405
+ warn("Dependency install failed. Run the install command manually and then start your dev server.");
264406
+ }
264407
+ }
264408
+ if (installSucceeded) {
264409
+ executeCommandPipeline(scaffoldResult.scaffolding.commands, {
264410
+ workspaceDir,
264411
+ packageManager: manifest.workspace.packageManager,
264412
+ dryRun: context.dryRun
264413
+ });
264414
+ }
264225
264415
  const infraResult = await provisionInfrastructure({
264226
264416
  llmClient,
264227
264417
  mcpClient,
@@ -264240,7 +264430,7 @@ async function createCommand2(context, _args) {
264240
264430
  });
264241
264431
  logger.cmd("/create", "SUCCESS");
264242
264432
  success(`App ${selections.appName} created.`);
264243
- if (existsSync16(appDir)) {
264433
+ if (existsSync16(appDir) && installSucceeded) {
264244
264434
  const runCmd = getCommand(manifest.workspace.packageManager, "run");
264245
264435
  const scriptResolution = resolveDevScript(appDir);
264246
264436
  if (scriptResolution.found) {
@@ -264267,8 +264457,11 @@ async function createCommand2(context, _args) {
264267
264457
  }
264268
264458
 
264269
264459
  // src/commands/delete.ts
264460
+ init_dist2();
264461
+ init_logger();
264270
264462
  import { rmSync as rmSync4 } from "node:fs";
264271
264463
  import { join as join19 } from "node:path";
264464
+ init_display();
264272
264465
  function removePackages(manifest, packageNames) {
264273
264466
  const nextPackages = { ...manifest.packages };
264274
264467
  for (const name of packageNames) {
@@ -264277,7 +264470,11 @@ function removePackages(manifest, packageNames) {
264277
264470
  return { ...manifest, packages: nextPackages };
264278
264471
  }
264279
264472
  async function deleteCommand(context, args) {
264280
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
264473
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
264474
+ if (!workspaceDir) {
264475
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
264476
+ return;
264477
+ }
264281
264478
  if (!isKittWorkspace(workspaceDir)) {
264282
264479
  error("Not a KITT workspace.");
264283
264480
  return;
@@ -264343,11 +264540,15 @@ async function deleteCommand(context, args) {
264343
264540
  }
264344
264541
 
264345
264542
  // src/commands/deploy.ts
264346
- import { existsSync as existsSync17, readdirSync as readdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync13 } from "node:fs";
264347
- import { basename as basename2, join as join20 } from "node:path";
264543
+ init_dist2();
264544
+ init_logger();
264348
264545
  init_config();
264546
+ import { existsSync as existsSync17, readdirSync as readdirSync4, readFileSync as readFileSync12, writeFileSync as writeFileSync13 } from "node:fs";
264547
+ import { basename as basename2, join as join20 } from "node:path";
264548
+ init_lifecycle();
264349
264549
 
264350
264550
  // src/mcp/project-guard.ts
264551
+ init_logger();
264351
264552
  function createProjectGuard(projectId) {
264352
264553
  const auditLogger5 = createAuditLogger(".");
264353
264554
  const validateProjectId = (args) => {
@@ -264375,6 +264576,7 @@ function createProjectGuard(projectId) {
264375
264576
  }
264376
264577
 
264377
264578
  // src/commands/deploy.ts
264579
+ init_display();
264378
264580
  var SECRET_PATTERNS = [
264379
264581
  "SECRET",
264380
264582
  "KEY",
@@ -264450,7 +264652,7 @@ function listEnvFiles(workspaceDir) {
264450
264652
  if (!currentDir) {
264451
264653
  continue;
264452
264654
  }
264453
- const entries = readdirSync3(currentDir, { withFileTypes: true });
264655
+ const entries = readdirSync4(currentDir, { withFileTypes: true });
264454
264656
  for (const entry of entries) {
264455
264657
  const entryPath = join20(currentDir, entry.name);
264456
264658
  const relativePath = normalizePathForMatch(entryPath.replace(`${workspaceDir}/`, ""));
@@ -264486,9 +264688,9 @@ function scanEnvFilesForSecrets(workspaceDir) {
264486
264688
  }
264487
264689
  function getSelectedApps(args, manifest) {
264488
264690
  const appNames = Object.keys(manifest.apps);
264489
- const selectionArg = args[0] ?? "";
264691
+ const selectionArg = (args[0] ?? "").toLowerCase();
264490
264692
  if (selectionArg.length > 0) {
264491
- if (selectionArg.toLowerCase() === "all") {
264693
+ if (selectionArg === "all") {
264492
264694
  return appNames;
264493
264695
  }
264494
264696
  if (!manifest.apps[selectionArg]) {
@@ -264553,7 +264755,11 @@ function ensureRailwayToml(appName, framework, packageManager) {
264553
264755
  return true;
264554
264756
  }
264555
264757
  async function deployTemplateCommand(context, args) {
264556
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
264758
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
264759
+ if (!workspaceDir) {
264760
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
264761
+ return;
264762
+ }
264557
264763
  const logger = createAuditLogger(workspaceDir);
264558
264764
  logger.cmd("/deploy:template", "START");
264559
264765
  if (!isKittWorkspace(workspaceDir)) {
@@ -264634,7 +264840,11 @@ async function deployCommand(context, args, commandKey) {
264634
264840
  await deployTemplateCommand(context, args);
264635
264841
  return;
264636
264842
  }
264637
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
264843
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
264844
+ if (!workspaceDir) {
264845
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
264846
+ return;
264847
+ }
264638
264848
  const logger = createAuditLogger(workspaceDir);
264639
264849
  logger.cmd("/deploy", "START");
264640
264850
  if (!isKittWorkspace(workspaceDir)) {
@@ -264740,7 +264950,11 @@ async function deployCommand(context, args, commandKey) {
264740
264950
  }
264741
264951
 
264742
264952
  // src/commands/env.ts
264953
+ init_dist2();
264954
+ init_logger();
264743
264955
  init_config();
264956
+ init_lifecycle();
264957
+ init_display();
264744
264958
  async function validateCommandPrerequisites(workspaceDir) {
264745
264959
  if (!isKittWorkspace(workspaceDir)) {
264746
264960
  error("Not a KITT workspace.");
@@ -264801,7 +265015,11 @@ async function runLlmOperations(command, args, manifest, projectId) {
264801
265015
  }
264802
265016
  }
264803
265017
  async function envCreateCommand(context, args) {
264804
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265018
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
265019
+ if (!workspaceDir) {
265020
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
265021
+ return;
265022
+ }
264805
265023
  const logger = createAuditLogger(workspaceDir);
264806
265024
  logger.cmd("/env:create", "START");
264807
265025
  const prereqs = await validateCommandPrerequisites(workspaceDir);
@@ -264836,7 +265054,11 @@ async function envCreateCommand(context, args) {
264836
265054
  }
264837
265055
  }
264838
265056
  async function envVarsCommand(context, args) {
264839
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265057
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
265058
+ if (!workspaceDir) {
265059
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
265060
+ return;
265061
+ }
264840
265062
  const logger = createAuditLogger(workspaceDir);
264841
265063
  logger.cmd("/env:vars", "START");
264842
265064
  const prereqs = await validateCommandPrerequisites(workspaceDir);
@@ -264881,9 +265103,17 @@ async function envCommand(context, args, commandKey) {
264881
265103
  }
264882
265104
 
264883
265105
  // src/commands/domain.ts
265106
+ init_dist2();
265107
+ init_logger();
264884
265108
  init_config();
265109
+ init_lifecycle();
265110
+ init_display();
264885
265111
  async function domainCommand(_context, args, _commandKey) {
264886
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265112
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
265113
+ if (!workspaceDir) {
265114
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
265115
+ return;
265116
+ }
264887
265117
  const logger = createAuditLogger(workspaceDir);
264888
265118
  logger.cmd("/domain", "START");
264889
265119
  if (!isKittWorkspace(workspaceDir)) {
@@ -264964,9 +265194,17 @@ async function domainCommand(_context, args, _commandKey) {
264964
265194
  }
264965
265195
 
264966
265196
  // src/commands/logs.ts
265197
+ init_dist2();
265198
+ init_logger();
264967
265199
  init_config();
265200
+ init_lifecycle();
265201
+ init_display();
264968
265202
  async function logsCommand(_context, args, _commandKey) {
264969
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265203
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
265204
+ if (!workspaceDir) {
265205
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
265206
+ return;
265207
+ }
264970
265208
  const logger = createAuditLogger(workspaceDir);
264971
265209
  logger.cmd("/logs", "START");
264972
265210
  if (!isKittWorkspace(workspaceDir)) {
@@ -265047,24 +265285,25 @@ async function logsCommand(_context, args, _commandKey) {
265047
265285
  }
265048
265286
 
265049
265287
  // src/commands/status.ts
265050
- var import_picocolors7 = __toESM(require_picocolors(), 1);
265288
+ init_logger();
265051
265289
  init_config();
265290
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
265052
265291
 
265053
265292
  // src/manifest/drift.ts
265054
- import { existsSync as existsSync18, readdirSync as readdirSync4 } from "node:fs";
265293
+ import { existsSync as existsSync18, readdirSync as readdirSync5 } from "node:fs";
265055
265294
  import { join as join21 } from "node:path";
265056
265295
  function listDirectories(parentDir) {
265057
265296
  if (!existsSync18(parentDir)) {
265058
265297
  return [];
265059
265298
  }
265060
- return readdirSync4(parentDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort((left, right) => left.localeCompare(right));
265299
+ return readdirSync5(parentDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort((left, right) => left.localeCompare(right, "en"));
265061
265300
  }
265062
265301
  function detectSegmentDrift(options) {
265063
265302
  const { workspaceDir, segment, manifestEntries } = options;
265064
265303
  const segmentDir = join21(workspaceDir, segment);
265065
265304
  const diskDirectories = listDirectories(segmentDir);
265066
265305
  const diskSet = new Set(diskDirectories);
265067
- const manifestNames = Object.keys(manifestEntries).sort((left, right) => left.localeCompare(right));
265306
+ const manifestNames = Object.keys(manifestEntries).sort((left, right) => left.localeCompare(right, "en"));
265068
265307
  const orphanedDirectories = diskDirectories.filter((dirName) => !Object.prototype.hasOwnProperty.call(manifestEntries, dirName)).map((dirName) => `${segment}/${dirName}`);
265069
265308
  const missingDirectories = manifestNames.filter((entryName) => !diskSet.has(entryName)).map((entryName) => `${segment}/${entryName}`);
265070
265309
  return {
@@ -265090,8 +265329,36 @@ function detectDrift(workspaceDir, manifest) {
265090
265329
  }
265091
265330
 
265092
265331
  // src/commands/status.ts
265332
+ init_lifecycle();
265333
+ init_display();
265093
265334
  async function statusCommand(_context, _args, _commandKey) {
265094
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265335
+ const directWorkspace = findWorkspaceRoot(process.cwd());
265336
+ if (!directWorkspace) {
265337
+ const children = getChildWorkspaces(process.cwd());
265338
+ if (children.length === 0) {
265339
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
265340
+ return;
265341
+ }
265342
+ console.log("");
265343
+ info(`${import_picocolors7.default.bold("KITT Workspaces")} ${import_picocolors7.default.dim(`(${children.length} found)`)}`);
265344
+ console.log("");
265345
+ for (const child of children) {
265346
+ const m2 = child.manifest;
265347
+ const appCount = Object.keys(m2.apps).length;
265348
+ const appLabel = `${appCount} app${appCount !== 1 ? "s" : ""}`;
265349
+ const railway = m2.workspace.railway?.projectId ? import_picocolors7.default.green("● linked") : import_picocolors7.default.dim("○ unlinked");
265350
+ info(` ${import_picocolors7.default.bold(import_picocolors7.default.white(m2.workspace.name))} ${import_picocolors7.default.dim(appLabel)} ${railway} ${import_picocolors7.default.dim(m2.workspace.packageManager)}`);
265351
+ if (appCount > 0) {
265352
+ for (const [name, app] of Object.entries(m2.apps)) {
265353
+ const typeTag = app.type === "frontend" ? import_picocolors7.default.cyan("frontend") : import_picocolors7.default.magenta("backend");
265354
+ info(` ${import_picocolors7.default.dim("·")} ${name} ${typeTag} ${import_picocolors7.default.dim(app.framework)}`);
265355
+ }
265356
+ }
265357
+ }
265358
+ console.log("");
265359
+ return;
265360
+ }
265361
+ const workspaceDir = directWorkspace;
265095
265362
  const logger = createAuditLogger(workspaceDir);
265096
265363
  logger.cmd("/status", "START");
265097
265364
  if (!isKittWorkspace(workspaceDir)) {
@@ -265167,11 +265434,12 @@ async function statusCommand(_context, _args, _commandKey) {
265167
265434
  }
265168
265435
 
265169
265436
  // src/commands/login.ts
265437
+ init_dist2();
265438
+ init_config();
265439
+ var import_picocolors8 = __toESM(require_picocolors(), 1);
265170
265440
  import { existsSync as existsSync19, readFileSync as readFileSync13 } from "node:fs";
265171
265441
  import { homedir as homedir5 } from "node:os";
265172
265442
  import { join as join22 } from "node:path";
265173
- init_config();
265174
- var import_picocolors8 = __toESM(require_picocolors(), 1);
265175
265443
  var PROVIDER_LABELS = {
265176
265444
  anthropic: "Anthropic",
265177
265445
  openai: "OpenAI",
@@ -265201,10 +265469,10 @@ var MODEL_OPTIONS = {
265201
265469
  ]
265202
265470
  };
265203
265471
  var COPILOT_MODEL_OPTIONS = [
265204
- { value: "claude-sonnet-4.6", label: "claude-sonnet-4.6 (recommended — Claude Sonnet via Copilot)" },
265205
- { value: "claude-haiku-4.5", label: "claude-haiku-4.5 (fast & cheap Claude via Copilot)" },
265206
- { value: "claude-opus-4.6", label: "claude-opus-4.6 (most capable Claude via Copilot)" },
265207
- { value: "gpt-4.1", label: "gpt-4.1 (GPT-4.1 via Copilot)" }
265472
+ { value: "claude-haiku-4.5", label: "claude-haiku-4.5 (recommended — enabled for all Copilot plans)" },
265473
+ { value: "gpt-4.1", label: "gpt-4.1 (GPT-4.1 enabled for all Copilot plans)" },
265474
+ { value: "claude-sonnet-4.6", label: "claude-sonnet-4.6 (requires opt-in at github.com/settings/copilot)" },
265475
+ { value: "claude-opus-4.6", label: "claude-opus-4.6 (requires opt-in at github.com/settings/copilot)" }
265208
265476
  ];
265209
265477
  var GITHUB_DEVICE_CLIENT_ID = "Iv1.b507a08c87ecfe98";
265210
265478
  function cancelled() {
@@ -265317,7 +265585,7 @@ async function runGitHubDeviceFlow() {
265317
265585
  const intervalMs = (codeData.interval ?? 5) * 1000;
265318
265586
  const expiresAt = Date.now() + (codeData.expires_in ?? 900) * 1000;
265319
265587
  while (Date.now() < expiresAt) {
265320
- await new Promise((resolve6) => setTimeout(resolve6, intervalMs));
265588
+ await new Promise((resolve7) => setTimeout(resolve7, intervalMs));
265321
265589
  const tokenRes = await fetch("https://github.com/login/oauth/access_token", {
265322
265590
  method: "POST",
265323
265591
  headers: {
@@ -265340,7 +265608,7 @@ async function runGitHubDeviceFlow() {
265340
265608
  continue;
265341
265609
  }
265342
265610
  if (tokenData.error === "slow_down") {
265343
- await new Promise((resolve6) => setTimeout(resolve6, intervalMs));
265611
+ await new Promise((resolve7) => setTimeout(resolve7, intervalMs));
265344
265612
  continue;
265345
265613
  }
265346
265614
  console.log(import_picocolors8.default.red(tokenData.error_description ?? `GitHub login failed: ${tokenData.error}`));
@@ -265636,9 +265904,12 @@ async function loginCommand(context, args, commandKey = "login") {
265636
265904
  }
265637
265905
 
265638
265906
  // src/commands/versions.ts
265907
+ init_dist2();
265908
+ init_logger();
265909
+ var import_picocolors9 = __toESM(require_picocolors(), 1);
265639
265910
  import { existsSync as existsSync20, readFileSync as readFileSync14, writeFileSync as writeFileSync14 } from "node:fs";
265640
265911
  import { join as join23 } from "node:path";
265641
- var import_picocolors9 = __toESM(require_picocolors(), 1);
265912
+ init_display();
265642
265913
  var TABLE_HEADER_INTEGRATION = "Integration";
265643
265914
  var TABLE_HEADER_VERSION = "Version";
265644
265915
  var REGISTRY_TABLE_HEADER_CURRENT = "Current";
@@ -265673,9 +265944,9 @@ function formatRegistryTable(results) {
265673
265944
  }
265674
265945
  return rows;
265675
265946
  }
265676
- function loadVersionsContext(logger) {
265677
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265678
- if (!isKittWorkspace(workspaceDir)) {
265947
+ async function loadVersionsContext(logger) {
265948
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
265949
+ if (!workspaceDir || !isKittWorkspace(workspaceDir)) {
265679
265950
  error("Not a KITT workspace. Run /init first.");
265680
265951
  logger.cmd("/versions", "FAILED", "not a workspace");
265681
265952
  return null;
@@ -265703,7 +265974,7 @@ function writeVersionsFiles(versionsContext, entries) {
265703
265974
  writeVersionsLock(versionsContext.workspaceDir, hash);
265704
265975
  }
265705
265976
  async function runRegistryCheck(logger, commandName) {
265706
- const versionsContext = loadVersionsContext(logger);
265977
+ const versionsContext = await loadVersionsContext(logger);
265707
265978
  if (versionsContext === null) {
265708
265979
  return null;
265709
265980
  }
@@ -265730,7 +266001,7 @@ async function runRegistryCheck(logger, commandName) {
265730
266001
  };
265731
266002
  }
265732
266003
  async function runVersionsBaseCommand(logger) {
265733
- const versionsContext = loadVersionsContext(logger);
266004
+ const versionsContext = await loadVersionsContext(logger);
265734
266005
  if (versionsContext === null) {
265735
266006
  return;
265736
266007
  }
@@ -265830,7 +266101,7 @@ async function runVersionsSetCommand(logger, commandKey, args) {
265830
266101
  logger.cmd("/versions", "FAILED", `/versions set invalid semver: ${version}`);
265831
266102
  return;
265832
266103
  }
265833
- const versionsContext = loadVersionsContext(logger);
266104
+ const versionsContext = await loadVersionsContext(logger);
265834
266105
  if (versionsContext === null) {
265835
266106
  return;
265836
266107
  }
@@ -265847,8 +266118,8 @@ async function runVersionsSetCommand(logger, commandKey, args) {
265847
266118
  logger.cmd("/versions", "SUCCESS", `/versions set pinned ${integration} to ${version}`);
265848
266119
  }
265849
266120
  async function versionsCommand(_context, args, commandKey) {
265850
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
265851
- const logger = createAuditLogger(workspaceDir);
266121
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
266122
+ const logger = createAuditLogger(workspaceDir ?? ".");
265852
266123
  const sub = resolveSubcommand(commandKey, args);
265853
266124
  if (!sub || sub === "list") {
265854
266125
  await runVersionsBaseCommand(logger);
@@ -265870,9 +266141,14 @@ async function versionsCommand(_context, args, commandKey) {
265870
266141
  }
265871
266142
 
265872
266143
  // src/commands/list.ts
266144
+ init_display();
265873
266145
  var import_picocolors10 = __toESM(require_picocolors(), 1);
265874
266146
  async function listCommand(_context, _args, _commandKey) {
265875
- const workspaceDir = findWorkspaceRoot(process.cwd()) ?? ".";
266147
+ const workspaceDir = await resolveWorkspaceDir(process.cwd());
266148
+ if (!workspaceDir) {
266149
+ error("No KITT workspace found. Run /init to create one, or /switch to select an existing workspace.");
266150
+ return;
266151
+ }
265876
266152
  if (!isKittWorkspace(workspaceDir)) {
265877
266153
  error("Not a KITT workspace. Run /init first.");
265878
266154
  return;
@@ -266005,31 +266281,102 @@ function renderPackages(pkgs) {
266005
266281
  }
266006
266282
  }
266007
266283
 
266008
- // src/commands/help.ts
266284
+ // src/commands/switch.ts
266285
+ init_dist2();
266009
266286
  var import_picocolors11 = __toESM(require_picocolors(), 1);
266287
+ init_display();
266288
+ async function switchCommand(_context, args) {
266289
+ const cwd = process.cwd();
266290
+ const currentWorkspace = findWorkspaceRoot(cwd);
266291
+ const children = findChildWorkspaces(cwd);
266292
+ if (currentWorkspace) {
266293
+ const { dirname: dirname5 } = await import("node:path");
266294
+ const parentDir = dirname5(currentWorkspace);
266295
+ const siblings = findChildWorkspaces(parentDir);
266296
+ for (const sibling of siblings) {
266297
+ if (!children.some((c) => c.path === sibling.path)) {
266298
+ children.push(sibling);
266299
+ }
266300
+ }
266301
+ }
266302
+ if (children.length === 0 && !currentWorkspace) {
266303
+ error("No KITT workspaces found. Run /init to create one.");
266304
+ return;
266305
+ }
266306
+ const activePath = currentWorkspace ?? null;
266307
+ const options = children.map((child) => {
266308
+ const m2 = child.manifest;
266309
+ const appCount = Object.keys(m2.apps).length;
266310
+ const isActive = child.path === activePath;
266311
+ const label = isActive ? `${m2.workspace.name} ${import_picocolors11.default.green("(active)")}` : m2.workspace.name;
266312
+ const hint = `${appCount} app${appCount !== 1 ? "s" : ""} · ${m2.workspace.packageManager}`;
266313
+ return { value: child.path, label, hint };
266314
+ });
266315
+ if (options.length === 0) {
266316
+ info("Only one workspace available — already active.");
266317
+ return;
266318
+ }
266319
+ if (options.length === 1 && options[0].value === activePath) {
266320
+ info("Only one workspace available — already active.");
266321
+ return;
266322
+ }
266323
+ let targetPath = null;
266324
+ if (args[0]) {
266325
+ const name2 = args[0].toLowerCase();
266326
+ const match = children.find((c) => c.manifest.workspace.name.toLowerCase() === name2);
266327
+ if (match) {
266328
+ targetPath = match.path;
266329
+ } else {
266330
+ error(`Workspace "${args[0]}" not found.`);
266331
+ return;
266332
+ }
266333
+ } else {
266334
+ const selection = await ve({
266335
+ message: "Switch to workspace:",
266336
+ options
266337
+ });
266338
+ if (pD(selection)) {
266339
+ warn("Switch cancelled.");
266340
+ return;
266341
+ }
266342
+ targetPath = selection;
266343
+ }
266344
+ if (!targetPath || !isKittWorkspace(targetPath)) {
266345
+ error("Invalid workspace path.");
266346
+ return;
266347
+ }
266348
+ process.chdir(targetPath);
266349
+ setGlobalWorkspacePath(targetPath);
266350
+ const manifest = readManifest(targetPath);
266351
+ const name = manifest?.workspace.name ?? targetPath;
266352
+ success(`Switched to ${import_picocolors11.default.cyan(name)}`);
266353
+ }
266354
+
266355
+ // src/commands/help.ts
266356
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
266010
266357
  var W3 = 56;
266011
266358
  function box(lines) {
266012
- console.log(` ${import_picocolors11.default.dim("╭" + "─".repeat(W3) + "╮")}`);
266359
+ console.log(` ${import_picocolors12.default.dim("╭" + "─".repeat(W3) + "╮")}`);
266013
266360
  for (const line of lines) {
266014
- console.log(` ${import_picocolors11.default.dim("│")} ${line}`);
266361
+ console.log(` ${import_picocolors12.default.dim("│")} ${line}`);
266015
266362
  }
266016
- console.log(` ${import_picocolors11.default.dim("╰" + "─".repeat(W3) + "╯")}`);
266363
+ console.log(` ${import_picocolors12.default.dim("╰" + "─".repeat(W3) + "╯")}`);
266017
266364
  }
266018
266365
  function divider(label) {
266019
266366
  const pad = W3 - 2 - label.length;
266020
- console.log(` ${import_picocolors11.default.dim("┌─")} ${import_picocolors11.default.bold(import_picocolors11.default.white(label))} ${import_picocolors11.default.dim("─".repeat(Math.max(0, pad)) + "┐")}`);
266367
+ console.log(` ${import_picocolors12.default.dim("┌─")} ${import_picocolors12.default.bold(import_picocolors12.default.white(label))} ${import_picocolors12.default.dim("─".repeat(Math.max(0, pad)) + "┐")}`);
266021
266368
  }
266022
266369
  function cmd(command, argHint, desc) {
266023
266370
  const raw = `${command} ${argHint}`;
266024
266371
  const p2 = Math.max(0, 28 - raw.length);
266025
- const argPart = argHint ? ` ${import_picocolors11.default.dim(import_picocolors11.default.italic(argHint))}` : "";
266026
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.cyan(command)}${argPart}${" ".repeat(p2)} ${import_picocolors11.default.dim(desc)}`);
266372
+ const argPart = argHint ? ` ${import_picocolors12.default.dim(import_picocolors12.default.italic(argHint))}` : "";
266373
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.cyan(command)}${argPart}${" ".repeat(p2)} ${import_picocolors12.default.dim(desc)}`);
266027
266374
  }
266028
266375
  function row(label, value) {
266029
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim(label.padEnd(14))} ${import_picocolors11.default.white(value)}`);
266376
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim(label.padEnd(14))} ${import_picocolors12.default.white(value)}`);
266030
266377
  }
266031
266378
  function sectionEnd() {
266032
- console.log(` ${import_picocolors11.default.dim("└" + "─".repeat(W3))}`);
266379
+ console.log(` ${import_picocolors12.default.dim("└" + "─".repeat(W3))}`);
266033
266380
  console.log("");
266034
266381
  }
266035
266382
  function pad(text, width) {
@@ -266040,8 +266387,8 @@ function pad(text, width) {
266040
266387
  function renderHelp() {
266041
266388
  console.log("");
266042
266389
  box([
266043
- pad(`${import_picocolors11.default.bold(import_picocolors11.default.white("KITT"))} ${import_picocolors11.default.dim("— AI-powered monorepo CLI")}`, W3 - 1),
266044
- pad(`${import_picocolors11.default.dim("scaffold · deploy · manage · iterate")}`, W3 - 1)
266390
+ pad(`${import_picocolors12.default.bold(import_picocolors12.default.white("KITT"))} ${import_picocolors12.default.dim("— AI-powered monorepo CLI")}`, W3 - 1),
266391
+ pad(`${import_picocolors12.default.dim("scaffold · deploy · manage · iterate")}`, W3 - 1)
266045
266392
  ]);
266046
266393
  console.log("");
266047
266394
  divider("Setup");
@@ -266059,6 +266406,7 @@ function renderHelp() {
266059
266406
  cmd("/list", "", "List all apps, packages, and Railway services");
266060
266407
  cmd("/run", "[appName]", "Start an app dev server");
266061
266408
  cmd("/settings", "", "View or update workspace settings");
266409
+ cmd("/switch", "[name]", "Switch active workspace context");
266062
266410
  sectionEnd();
266063
266411
  divider("Deploy & Infrastructure");
266064
266412
  cmd("/deploy", "[appName]", "Deploy an app to Railway");
@@ -266085,16 +266433,16 @@ function renderHelp() {
266085
266433
  row("backend", "hono expressjs");
266086
266434
  sectionEnd();
266087
266435
  divider("Integrations");
266088
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("databases")} ${[import_picocolors11.default.blue("[postgresql]"), import_picocolors11.default.blue("[mysql]"), import_picocolors11.default.blue("[sqlite]")].join(" ")}`);
266089
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("orm")} ${[import_picocolors11.default.cyan("[drizzle]"), import_picocolors11.default.cyan("[prisma]")].join(" ")}`);
266090
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("auth")} ${import_picocolors11.default.yellow("[better-auth]")}`);
266091
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("payments")} ${[import_picocolors11.default.green("[stripe]"), import_picocolors11.default.green("[polar]")].join(" ")}`);
266092
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("email")} ${import_picocolors11.default.magenta("[resend]")}`);
266093
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("queues")} ${[import_picocolors11.default.red("[bullmq]"), import_picocolors11.default.red("[trigger-dev]")].join(" ")}`);
266094
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("cache")} ${import_picocolors11.default.red("[redis]")}`);
266095
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("ui")} ${[import_picocolors11.default.cyan("[tailwindcss]"), import_picocolors11.default.white("[shadcn]")].join(" ")}`);
266096
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("analytics")} ${[import_picocolors11.default.green("[posthog]"), import_picocolors11.default.red("[sentry]")].join(" ")}`);
266097
- console.log(` ${import_picocolors11.default.dim("│")} ${import_picocolors11.default.dim("testing")} ${[import_picocolors11.default.yellow("[vitest]"), import_picocolors11.default.cyan("[playwright]"), import_picocolors11.default.magenta("[storybook]")].join(" ")}`);
266436
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("databases")} ${[import_picocolors12.default.blue("[postgresql]"), import_picocolors12.default.blue("[mysql]"), import_picocolors12.default.blue("[sqlite]")].join(" ")}`);
266437
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("orm")} ${[import_picocolors12.default.cyan("[drizzle]"), import_picocolors12.default.cyan("[prisma]")].join(" ")}`);
266438
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("auth")} ${import_picocolors12.default.yellow("[better-auth]")}`);
266439
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("payments")} ${[import_picocolors12.default.green("[stripe]"), import_picocolors12.default.green("[polar]")].join(" ")}`);
266440
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("email")} ${import_picocolors12.default.magenta("[resend]")}`);
266441
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("queues")} ${[import_picocolors12.default.red("[bullmq]"), import_picocolors12.default.red("[trigger-dev]")].join(" ")}`);
266442
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("cache")} ${import_picocolors12.default.red("[redis]")}`);
266443
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("ui")} ${[import_picocolors12.default.cyan("[tailwindcss]"), import_picocolors12.default.white("[shadcn]")].join(" ")}`);
266444
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("analytics")} ${[import_picocolors12.default.green("[posthog]"), import_picocolors12.default.red("[sentry]")].join(" ")}`);
266445
+ console.log(` ${import_picocolors12.default.dim("│")} ${import_picocolors12.default.dim("testing")} ${[import_picocolors12.default.yellow("[vitest]"), import_picocolors12.default.cyan("[playwright]"), import_picocolors12.default.magenta("[storybook]")].join(" ")}`);
266098
266446
  sectionEnd();
266099
266447
  divider("CLI Flags");
266100
266448
  row("--verbose", "Enable verbose logging");
@@ -266115,7 +266463,7 @@ async function helpCommand(_context, _args) {
266115
266463
  // package.json
266116
266464
  var package_default = {
266117
266465
  name: "openkitt",
266118
- version: "0.3.14",
266466
+ version: "0.3.18",
266119
266467
  description: "AI-powered monorepo scaffolding CLI",
266120
266468
  keywords: [
266121
266469
  "cli",
@@ -266148,9 +266496,11 @@ var package_default = {
266148
266496
  build: "bun build src/cli.ts --target=node --outfile=dist/cli.js",
266149
266497
  "build:types": "tsc --noEmit",
266150
266498
  dev: "bun build src/cli.ts --target=node --outfile=dist/cli.js --watch",
266499
+ kitt: "node dist/cli.js",
266151
266500
  test: "vitest run",
266152
266501
  "test:watch": "vitest",
266153
- prepublishOnly: "npm run build"
266502
+ "test:e2e": "npm run build && vitest run --config vitest.config.e2e.ts",
266503
+ "test:all": "npm run test && npm run test:e2e"
266154
266504
  },
266155
266505
  engines: {
266156
266506
  node: ">=20.0.0"
@@ -266206,18 +266556,38 @@ var commandRegistry = {
266206
266556
  versions: { handler: versionsCommand },
266207
266557
  list: { handler: listCommand },
266208
266558
  run: { handler: runCommand },
266209
- help: { handler: helpCommand }
266559
+ help: { handler: helpCommand },
266560
+ switch: { handler: switchCommand }
266210
266561
  };
266211
266562
  function displayBanner() {
266212
- console.log(import_picocolors12.default.cyan(" ______ _______________________"));
266213
- console.log(import_picocolors12.default.cyan(" ___ //_/___ /__ __/__ __/"));
266214
- console.log(import_picocolors12.default.cyan(" __ ,< __ / __ / __ / "));
266215
- console.log(import_picocolors12.default.cyan(" _ /| | __/ / _ / _ / "));
266216
- console.log(import_picocolors12.default.cyan(" /_/ |_| /___/ /_/ /_/ "));
266563
+ console.log(import_picocolors13.default.cyan(" ______ _______________________"));
266564
+ console.log(import_picocolors13.default.cyan(" ___ //_/___ /__ __/__ __/"));
266565
+ console.log(import_picocolors13.default.cyan(" __ ,< __ / __ / __ / "));
266566
+ console.log(import_picocolors13.default.cyan(" _ /| | __/ / _ / _ / "));
266567
+ console.log(import_picocolors13.default.cyan(" /_/ |_| /___/ /_/ /_/ "));
266217
266568
  console.log("");
266218
- console.log(` ${import_picocolors12.default.bold(import_picocolors12.default.white("KITT"))} ${import_picocolors12.default.dim("v" + APP_VERSION)} ${import_picocolors12.default.dim("— AI-Powered App Scaffolding CLI")}`);
266219
- console.log(` ${import_picocolors12.default.dim("/login → /init → /create → /deploy → /publish")}`);
266220
- console.log(` ${import_picocolors12.default.dim("Type /help for all commands")}`);
266569
+ console.log(` ${import_picocolors13.default.bold(import_picocolors13.default.white("KITT"))} ${import_picocolors13.default.dim("v" + APP_VERSION)} ${import_picocolors13.default.dim("— AI-Powered App Scaffolding CLI")}`);
266570
+ console.log(` ${import_picocolors13.default.dim("/login → /init → /create → /deploy → /publish")}`);
266571
+ console.log(` ${import_picocolors13.default.dim("Type /help for all commands")}`);
266572
+ console.log("");
266573
+ }
266574
+ function displayWorkspaceHint(cwd) {
266575
+ if (findWorkspaceRoot(cwd))
266576
+ return;
266577
+ const children = findChildWorkspaces(cwd);
266578
+ if (children.length === 0)
266579
+ return;
266580
+ const lastActive = getGlobalWorkspacePath();
266581
+ const hasLastActive = !!(lastActive && isKittWorkspace(lastActive));
266582
+ if (children.length === 1) {
266583
+ return;
266584
+ }
266585
+ console.log(` ${import_picocolors13.default.dim(`${children.length} kitt spaces`)}`);
266586
+ if (hasLastActive) {
266587
+ const manifest = readManifest(lastActive);
266588
+ const name = manifest?.workspace.name ?? lastActive;
266589
+ console.log(` ${import_picocolors13.default.dim("Last active:")} ${import_picocolors13.default.cyan(name)}`);
266590
+ }
266221
266591
  console.log("");
266222
266592
  }
266223
266593
  function tokenizeCommand(inputValue) {
@@ -266248,23 +266618,27 @@ function parseCommand(inputValue) {
266248
266618
  };
266249
266619
  }
266250
266620
  function isVersionNewer(latest, current) {
266251
- const normalize4 = (value) => {
266252
- const [main] = value.trim().replace(/^v/i, "").split("-");
266253
- return main.split(".").map((segment) => Number.parseInt(segment, 10)).map((segment) => Number.isFinite(segment) ? segment : 0);
266621
+ const parse = (value) => {
266622
+ const trimmed = value.trim().replace(/^v/i, "");
266623
+ const [main, ...pre] = trimmed.split("-");
266624
+ return {
266625
+ parts: main.split(".").map((s) => Number.parseInt(s, 10)).map((n) => Number.isFinite(n) ? n : 0),
266626
+ prerelease: pre.length > 0
266627
+ };
266254
266628
  };
266255
- const latestParts = normalize4(latest);
266256
- const currentParts = normalize4(current);
266257
- const maxLen = Math.max(latestParts.length, currentParts.length);
266629
+ const l2 = parse(latest);
266630
+ const c = parse(current);
266631
+ const maxLen = Math.max(l2.parts.length, c.parts.length);
266258
266632
  for (let index = 0;index < maxLen; index += 1) {
266259
- const latestPart = latestParts[index] ?? 0;
266260
- const currentPart = currentParts[index] ?? 0;
266261
- if (latestPart > currentPart) {
266633
+ const lp = l2.parts[index] ?? 0;
266634
+ const cp = c.parts[index] ?? 0;
266635
+ if (lp > cp)
266262
266636
  return true;
266263
- }
266264
- if (latestPart < currentPart) {
266637
+ if (lp < cp)
266265
266638
  return false;
266266
- }
266267
266639
  }
266640
+ if (!l2.prerelease && c.prerelease)
266641
+ return true;
266268
266642
  return false;
266269
266643
  }
266270
266644
  function hasFreshUpdateCache(now) {
@@ -266355,25 +266729,16 @@ async function dispatchCommand(commandLine, context) {
266355
266729
  }
266356
266730
  const authCheck = await checkAuthGuard(parsed.key);
266357
266731
  if (!authCheck.allowed) {
266358
- console.log(import_picocolors12.default.red(`✗ ${authCheck.message}`));
266732
+ console.log(import_picocolors13.default.red(`✗ ${authCheck.message}`));
266359
266733
  return "continue";
266360
266734
  }
266361
- if (process.stdin.isTTY)
266362
- process.stdin.setRawMode(false);
266363
- try {
266364
- await resolveAndRunHandler(route, context, parsed.args, parsed.key);
266365
- } finally {
266366
- if (!process.stdin.destroyed)
266367
- process.stdin.resume();
266368
- if (process.stdin.isTTY)
266369
- process.stdin.setRawMode(true);
266370
- }
266735
+ await resolveAndRunHandler(route, context, parsed.args, parsed.key);
266371
266736
  return "continue";
266372
266737
  }
266373
266738
  async function runSingleCommand(commandLine, context) {
266374
266739
  const parsed = parseCommand(commandLine);
266375
266740
  if (parsed && STATE_CHANGING_COMMANDS.has(parsed.key) && !context.yes) {
266376
- console.log(import_picocolors12.default.red(`✗ Non-interactive mode requires --yes for state-changing commands.
266741
+ console.log(import_picocolors13.default.red(`✗ Non-interactive mode requires --yes for state-changing commands.
266377
266742
  Usage: npx openkitt --run "${parsed.key}" --yes`));
266378
266743
  return 1;
266379
266744
  }
@@ -266420,7 +266785,7 @@ function getBestCompletion(line, registry) {
266420
266785
  }
266421
266786
  function resolvePrompt() {
266422
266787
  let workspaceRoot = null;
266423
- let current = resolve6(process.cwd());
266788
+ let current = resolve7(process.cwd());
266424
266789
  while (true) {
266425
266790
  if (isKittWorkspace(current)) {
266426
266791
  workspaceRoot = current;
@@ -266431,17 +266796,57 @@ function resolvePrompt() {
266431
266796
  break;
266432
266797
  current = parent;
266433
266798
  }
266434
- if (!workspaceRoot)
266799
+ if (workspaceRoot) {
266800
+ const manifest = readManifest(workspaceRoot);
266801
+ const name = manifest?.workspace.name;
266802
+ if (name)
266803
+ return `${BASE_PROMPT} ${import_picocolors13.default.cyan(`[${name}]`)} > `;
266435
266804
  return `${BASE_PROMPT} > `;
266436
- const manifest = readManifest(workspaceRoot);
266437
- const name = manifest?.workspace.name;
266438
- if (!name)
266805
+ }
266806
+ const children = findChildWorkspaces(process.cwd());
266807
+ if (children.length === 1) {
266808
+ const name = children[0].manifest.workspace.name;
266809
+ return `${BASE_PROMPT} ${import_picocolors13.default.cyan(`[${name}]`)} > `;
266810
+ }
266811
+ if (children.length > 1) {
266812
+ const lastActive = getGlobalWorkspacePath();
266813
+ if (lastActive && isKittWorkspace(lastActive)) {
266814
+ const manifest = readManifest(lastActive);
266815
+ const name = manifest?.workspace.name;
266816
+ if (name)
266817
+ return `${BASE_PROMPT} ${import_picocolors13.default.cyan(`[${name}]`)} > `;
266818
+ }
266439
266819
  return `${BASE_PROMPT} > `;
266440
- return `${BASE_PROMPT} ${import_picocolors12.default.cyan(`[${name}]`)} > `;
266820
+ }
266821
+ return `${BASE_PROMPT} > `;
266441
266822
  }
266442
266823
  async function startRepl(context) {
266443
- const rl = createInterface({ input, output, prompt: resolvePrompt(), completer: makeCompleter(commandRegistry) });
266824
+ let rl;
266444
266825
  let ghostLen = 0;
266826
+ let replActive = false;
266827
+ let intentionalClose = false;
266828
+ const onKeypress = (_ch, key) => {
266829
+ if (!key || !replActive)
266830
+ return;
266831
+ if (key.name === "tab" && ghostLen > 0 || key.name === "right" && ghostLen > 0) {
266832
+ acceptGhost();
266833
+ return;
266834
+ }
266835
+ if (key.name === "return" || key.name === "enter") {
266836
+ clearGhost();
266837
+ return;
266838
+ }
266839
+ if (key.name === "escape" || key.sequence === "\x03") {
266840
+ clearGhost();
266841
+ return;
266842
+ }
266843
+ setImmediate(() => {
266844
+ if (!replActive)
266845
+ return;
266846
+ const ghost = getBestCompletion(rl.line, commandRegistry);
266847
+ drawGhost(ghost);
266848
+ });
266849
+ };
266445
266850
  function drawGhost(ghost) {
266446
266851
  if (!process.stdout.isTTY)
266447
266852
  return;
@@ -266468,64 +266873,74 @@ async function startRepl(context) {
266468
266873
  }
266469
266874
  }
266470
266875
  }
266471
- if (process.stdin.isTTY) {
266472
- emitKeypressEvents(process.stdin, rl);
266473
- process.stdin.setRawMode(true);
266474
- process.stdin.on("keypress", (_ch, key) => {
266475
- if (!key)
266476
- return;
266477
- if (key.name === "tab" && ghostLen > 0 || key.name === "right" && ghostLen > 0) {
266478
- acceptGhost();
266876
+ function teardownRl() {
266877
+ replActive = false;
266878
+ clearGhost();
266879
+ if (process.stdin.isTTY) {
266880
+ process.stdin.removeListener("keypress", onKeypress);
266881
+ try {
266882
+ process.stdin.setRawMode(false);
266883
+ } catch {}
266884
+ }
266885
+ rl.close();
266886
+ }
266887
+ function setupRl() {
266888
+ rl = createInterface({ input, output, prompt: resolvePrompt(), completer: makeCompleter(commandRegistry) });
266889
+ if (process.stdin.isTTY) {
266890
+ emitKeypressEvents(process.stdin, rl);
266891
+ try {
266892
+ process.stdin.setRawMode(true);
266893
+ } catch {}
266894
+ process.stdin.on("keypress", onKeypress);
266895
+ }
266896
+ rl.on("SIGINT", () => {
266897
+ clearGhost();
266898
+ console.log("Use /exit to quit.");
266899
+ rl.prompt();
266900
+ });
266901
+ rl.on("close", async () => {
266902
+ if (intentionalClose) {
266903
+ const { shutdownMcpServer: shutdownMcpServer2 } = await Promise.resolve().then(() => (init_lifecycle(), exports_lifecycle));
266904
+ await shutdownMcpServer2().catch(() => {});
266905
+ process.exitCode = 0;
266479
266906
  return;
266480
266907
  }
266481
- if (key.name === "return" || key.name === "enter") {
266482
- clearGhost();
266483
- return;
266908
+ if (replActive) {
266909
+ replActive = false;
266910
+ try {
266911
+ if (!process.stdin.destroyed)
266912
+ process.stdin.resume();
266913
+ setupRl();
266914
+ rl.prompt();
266915
+ } catch {}
266484
266916
  }
266485
- if (key.name === "escape" || key.sequence === "\x03") {
266486
- clearGhost();
266487
- return;
266917
+ });
266918
+ rl.on("line", async (line) => {
266919
+ clearGhost();
266920
+ teardownRl();
266921
+ try {
266922
+ const result = await dispatchCommand(line, context);
266923
+ if (result === "exit") {
266924
+ intentionalClose = true;
266925
+ const activeOnExit = findWorkspaceRoot(process.cwd());
266926
+ if (activeOnExit)
266927
+ setGlobalWorkspacePath(activeOnExit);
266928
+ const { shutdownMcpServer: shutdownMcpServer2 } = await Promise.resolve().then(() => (init_lifecycle(), exports_lifecycle));
266929
+ await shutdownMcpServer2().catch(() => {});
266930
+ process.exitCode = 0;
266931
+ return;
266932
+ }
266933
+ } catch (error4) {
266934
+ const message = error4 instanceof Error ? error4.message : "Unexpected error.";
266935
+ console.error(import_picocolors13.default.red(message));
266488
266936
  }
266489
- setImmediate(() => {
266490
- const ghost = getBestCompletion(rl.line, commandRegistry);
266491
- drawGhost(ghost);
266492
- });
266937
+ setupRl();
266938
+ rl.prompt();
266493
266939
  });
266940
+ replActive = true;
266494
266941
  }
266495
- rl.on("SIGINT", () => {
266496
- clearGhost();
266497
- console.log("Use /exit to quit.");
266498
- rl.prompt();
266499
- });
266500
- let intentionalClose = false;
266501
- rl.on("close", () => {
266502
- if (intentionalClose)
266503
- process.exit(0);
266504
- else {
266505
- if (!process.stdin.destroyed)
266506
- process.stdin.resume();
266507
- rl.prompt();
266508
- }
266509
- });
266942
+ setupRl();
266510
266943
  rl.prompt();
266511
- rl.on("line", async (line) => {
266512
- clearGhost();
266513
- try {
266514
- const result = await dispatchCommand(line, context);
266515
- if (result === "exit") {
266516
- intentionalClose = true;
266517
- rl.close();
266518
- return;
266519
- }
266520
- rl.setPrompt(resolvePrompt());
266521
- rl.prompt();
266522
- } catch (error4) {
266523
- const message = error4 instanceof Error ? error4.message : "Unexpected error.";
266524
- console.error(import_picocolors12.default.red(message));
266525
- rl.setPrompt(resolvePrompt());
266526
- rl.prompt();
266527
- }
266528
- });
266529
266944
  }
266530
266945
  async function main() {
266531
266946
  if (process.argv.includes("--version") || process.argv.includes("-v")) {
@@ -266538,7 +266953,20 @@ async function main() {
266538
266953
  const options = program2.opts();
266539
266954
  const appContext = buildAppContext(options);
266540
266955
  registerCleanupHandlers();
266956
+ const cwd = process.cwd();
266957
+ if (!findWorkspaceRoot(cwd)) {
266958
+ const lastActive = getGlobalWorkspacePath();
266959
+ if (lastActive && isKittWorkspace(lastActive)) {
266960
+ try {
266961
+ process.chdir(lastActive);
266962
+ } catch {}
266963
+ }
266964
+ } else {
266965
+ setGlobalWorkspacePath(findWorkspaceRoot(cwd));
266966
+ }
266541
266967
  displayBanner();
266968
+ if (!options.quiet)
266969
+ displayWorkspaceHint(process.cwd());
266542
266970
  if (!options.quiet) {
266543
266971
  const prerequisites = await checkPrerequisites();
266544
266972
  displayPrerequisites(prerequisites);
@@ -266559,7 +266987,7 @@ function isDirectExecution() {
266559
266987
  return false;
266560
266988
  }
266561
266989
  try {
266562
- const realEntry = pathToFileURL(realpathSync(entryPoint)).href;
266990
+ const realEntry = pathToFileURL(realpathSync2(entryPoint)).href;
266563
266991
  return import.meta.url === realEntry;
266564
266992
  } catch {
266565
266993
  return import.meta.url === pathToFileURL(entryPoint).href;