@myop/cli 0.1.56 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/myop-cli.js +948 -922
  2. package/package.json +1 -1
package/dist/myop-cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  var bt = Object.defineProperty;
3
3
  var Ct = (o, t, e) => t in o ? bt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
4
- var ve = (o, t, e) => Ct(o, typeof t != "symbol" ? t + "" : t, e);
5
- import z from "ora";
6
- import { select as st, Separator as Ue } from "@inquirer/prompts";
7
- import { Command as Pt, Option as fe } from "commander";
8
- import { execSync as Q, spawn as Mt } from "child_process";
9
- import R, { join as Ae } from "path";
4
+ var Se = (o, t, e) => Ct(o, typeof t != "symbol" ? t + "" : t, e);
5
+ import Y from "ora";
6
+ import { select as it, Separator as He } from "@inquirer/prompts";
7
+ import { Command as Mt, Option as ge } from "commander";
8
+ import { execSync as X, spawn as Pt } from "child_process";
9
+ import _, { join as De } from "path";
10
10
  import P, { readFileSync as Et } from "fs";
11
- import We from "crypto";
11
+ import Ve from "crypto";
12
12
  import It from "http";
13
- import { URL as it, URLSearchParams as rt } from "url";
13
+ import { URL as rt, URLSearchParams as at } from "url";
14
14
  import Ot from "open";
15
- import at from "os";
16
- const kt = "0.1.56", Rt = `
15
+ import lt from "os";
16
+ const kt = "0.1.57", Rt = `
17
17
  Usage: myop [OPTIONS] [COMMAND]
18
18
 
19
19
  Myop CLI - Remote UI Made Easy
@@ -57,25 +57,25 @@ Examples:
57
57
  verbose: !1
58
58
  },
59
59
  myopConfig: null
60
- }, lt = {
60
+ }, ct = {
61
61
  name: "📥 Install Myop generated dependencies",
62
62
  value: "myopInstall",
63
63
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
64
64
  action: async () => {
65
65
  console.info("installing... ");
66
66
  for (const o of v.myopConfig.flows) {
67
- const t = R.join(v.executionPath, "/node_modules/@myop/flow-types/");
67
+ const t = _.join(v.executionPath, "/node_modules/@myop/flow-types/");
68
68
  console.info(`Generate flow at ${t}`), console.info(`Generated flow at ${t}`);
69
69
  }
70
70
  process.exit();
71
71
  }
72
72
  }, Nt = (o) => {
73
- const t = R.join(v.executionPath, o);
73
+ const t = _.join(v.executionPath, o);
74
74
  console.info(`reading config file from: ${t}`);
75
75
  const e = P.readFileSync(t, "utf8"), n = JSON.parse(e);
76
76
  return console.info("config file loaded, ", n), n;
77
- }, Ve = (o, t) => {
78
- const e = R.join(v.executionPath, o);
77
+ }, Ye = (o, t) => {
78
+ const e = _.join(v.executionPath, o);
79
79
  console.info(`writing config file to: ${e}`);
80
80
  try {
81
81
  const n = JSON.stringify(t, null, 2);
@@ -84,21 +84,21 @@ Examples:
84
84
  throw console.info(`error ${n} while writing to ${e}, JSON: ${t}`), console.log(`
85
85
  ⚠️ Failed write config file to ${e}, for more info use verbose flag`), n;
86
86
  }
87
- }, ct = {
87
+ }, dt = {
88
88
  name: "🌟 Add flow definition to your project",
89
89
  value: "addFlow",
90
90
  description: "Adds flow to yours myop.config.json",
91
91
  _action: (o) => {
92
- v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), Ve(v.options.configPath, v.myopConfig);
92
+ v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), Ye(v.options.configPath, v.myopConfig);
93
93
  },
94
94
  action: async () => {
95
95
  }
96
- }, dt = {
96
+ }, pt = {
97
97
  name: "🚫 Remove flow definition from your project",
98
98
  value: "removeFlow",
99
99
  description: "Removes flow to yours myop.config.json",
100
100
  _action: (o) => {
101
- v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), Ve(v.options.configPath, v.myopConfig);
101
+ v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), Ye(v.options.configPath, v.myopConfig);
102
102
  },
103
103
  action: () => {
104
104
  }
@@ -246,7 +246,7 @@ function zt(o) {
246
246
  return;
247
247
  }
248
248
  console.log(" ✓ Removed node_modules"), console.log(` ⏳ Running npm install...
249
- `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, r, p) => {
249
+ `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, a, p) => {
250
250
  if (i) {
251
251
  console.error("❌ npm install failed:", i.message), p && console.error(p), t(!1);
252
252
  return;
@@ -257,101 +257,101 @@ function zt(o) {
257
257
  });
258
258
  });
259
259
  }
260
- async function pt(o, t, e, n, s = {}) {
260
+ async function mt(o, t, e, n, s = {}) {
261
261
  const {
262
262
  hasTriedPlatformFix: i = !1,
263
- hasTriedInstall: r = !1,
263
+ hasTriedInstall: a = !1,
264
264
  onRetry: p
265
265
  } = s, m = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
266
266
  return !i && Ht(m) ? (Jt(), await zt(n) && p ? (console.log(`🔄 Retrying build...
267
- `), p(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : !r && Bt(m) ? (console.log("📦 Missing dependencies detected, running npm install..."), new Promise((l) => {
268
- n("npm install", (d, w, x) => {
269
- if (d) {
270
- console.error("❌ Failed to install dependencies:", d.message), x && console.error(x), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
267
+ `), p(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: a }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: a }) : !a && Bt(m) ? (console.log("📦 Missing dependencies detected, running npm install..."), new Promise((r) => {
268
+ n("npm install", (c, y, S) => {
269
+ if (c) {
270
+ console.error("❌ Failed to install dependencies:", c.message), S && console.error(S), r({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
271
271
  return;
272
272
  }
273
- console.log("✅ Dependencies installed"), p && p(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
273
+ console.log("✅ Dependencies installed"), p && p(), r({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
274
274
  });
275
- })) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: r };
275
+ })) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: a };
276
276
  }
277
- async function Ce() {
277
+ async function Me() {
278
278
  const o = await import("fs"), t = await import("path"), { exec: e } = await import("child_process"), n = await import("http"), { createHash: s } = await import("node:crypto");
279
279
  let i;
280
280
  if (import.meta.url.startsWith("file://")) {
281
- const a = new URL(import.meta.url).pathname, f = process.platform === "win32" && a.startsWith("/") ? a.slice(1) : a;
281
+ const l = new URL(import.meta.url).pathname, f = process.platform === "win32" && l.startsWith("/") ? l.slice(1) : l;
282
282
  i = t.default.dirname(f);
283
283
  } else
284
284
  i = t.default.dirname(import.meta.url);
285
- const r = t.default.join(i, "commands", "dev", "management-website"), p = o.default.readFileSync(t.default.join(r, "styles.css"), "utf-8"), m = o.default.readFileSync(t.default.join(r, "app.js"), "utf-8"), l = 9292, d = 9293;
286
- let w = "./dist", x = !1, $ = !1, g = !1, u = null;
285
+ const a = t.default.join(i, "commands", "dev", "management-website"), p = o.default.readFileSync(t.default.join(a, "styles.css"), "utf-8"), m = o.default.readFileSync(t.default.join(a, "app.js"), "utf-8"), r = 9292, c = 9293;
286
+ let y = "./dist", S = !1, $ = !1, h = !1, u = null;
287
287
  const E = () => {
288
288
  try {
289
- const c = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
290
- if (c.length === 1)
291
- return c[0];
289
+ const d = o.default.readdirSync(".").filter((l) => !l.endsWith(".html") || l.startsWith(".") ? !1 : o.default.statSync(l).isFile());
290
+ if (d.length === 1)
291
+ return d[0];
292
292
  } catch {
293
293
  }
294
294
  return null;
295
- }, O = () => {
295
+ }, k = () => {
296
296
  try {
297
- const c = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
298
- return !!(c.scripts && c.scripts.build);
297
+ const d = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
298
+ return !!(d.scripts && d.scripts.build);
299
299
  } catch {
300
300
  return !1;
301
301
  }
302
- }, b = (c) => {
303
- const a = process.platform;
302
+ }, C = (d) => {
303
+ const l = process.platform;
304
304
  let f;
305
- a === "darwin" ? f = `open "${c}"` : a === "win32" ? f = `start "" "${c}"` : f = `xdg-open "${c}"`, e(f, (h) => {
305
+ l === "darwin" ? f = `open "${d}"` : l === "win32" ? f = `start "" "${d}"` : f = `xdg-open "${d}"`, e(f, (g) => {
306
306
  });
307
- }, M = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
308
- let C, N, k = !1;
307
+ }, b = /* @__PURE__ */ new Map(), A = v.program.getOptionValue("config") || "./myop.config.json";
308
+ let M, N, R = !1;
309
309
  u = E();
310
- const L = O();
310
+ const U = k();
311
311
  try {
312
- const c = o.default.readFileSync(j, "utf-8"), a = JSON.parse(c);
313
- C = a.componentId || "DEV", N = a.componentName || a.name || null, k = a.HMR === !0, u && !L && (g = !0, k = !0, console.log(`📄 Single HTML file mode: ${u}`)), k && console.log("🔥 HMR enabled");
314
- } catch (c) {
315
- u && !L ? (g = !0, C = "DEV", N = t.default.basename(u, ".html"), k = !0, console.log(`📄 Single HTML file mode: ${u}`), console.log("🔥 HMR enabled")) : (console.error("❌ Error reading myop.config.json:", c.message), process.exit(1));
312
+ const d = o.default.readFileSync(A, "utf-8"), l = JSON.parse(d);
313
+ M = l.componentId || "DEV", N = l.componentName || l.name || null, R = l.HMR === !0, u && !U && (h = !0, R = !0, console.log(`📄 Single HTML file mode: ${u}`)), R && console.log("🔥 HMR enabled");
314
+ } catch (d) {
315
+ u && !U ? (h = !0, M = "DEV", N = t.default.basename(u, ".html"), R = !0, console.log(`📄 Single HTML file mode: ${u}`), console.log("🔥 HMR enabled")) : (console.error("❌ Error reading myop.config.json:", d.message), process.exit(1));
316
316
  }
317
317
  const D = async () => {
318
- if (C !== "DEV" && C !== "NEW")
319
- return C;
318
+ if (M !== "DEV" && M !== "NEW")
319
+ return M;
320
320
  try {
321
- const a = ((await new Promise((y, S) => {
321
+ const l = ((await new Promise((w, x) => {
322
322
  const I = {
323
323
  hostname: "localhost",
324
- port: d,
324
+ port: c,
325
325
  path: "/_list",
326
326
  method: "GET",
327
327
  timeout: 1e3
328
- }, T = n.default.request(I, (H) => {
329
- let Y = "";
330
- H.on("data", (ee) => Y += ee), H.on("end", () => {
328
+ }, j = n.default.request(I, (B) => {
329
+ let K = "";
330
+ B.on("data", (ne) => K += ne), B.on("end", () => {
331
331
  try {
332
- y(JSON.parse(Y));
332
+ w(JSON.parse(K));
333
333
  } catch {
334
- y({ components: [] });
334
+ w({ components: [] });
335
335
  }
336
336
  });
337
337
  });
338
- T.on("error", () => y({ components: [] })), T.on("timeout", () => {
339
- T.destroy(), y({ components: [] });
340
- }), T.end();
341
- })).components || []).map(([y]) => y).filter((y) => y === "DEV" || y === "NEW" || /^DEV\d+$/.test(y) || /^NEW\d+$/.test(y));
342
- if (a.length === 0)
338
+ j.on("error", () => w({ components: [] })), j.on("timeout", () => {
339
+ j.destroy(), w({ components: [] });
340
+ }), j.end();
341
+ })).components || []).map(([w]) => w).filter((w) => w === "DEV" || w === "NEW" || /^DEV\d+$/.test(w) || /^NEW\d+$/.test(w));
342
+ if (l.length === 0)
343
343
  return "DEV1";
344
- const f = a.map((y) => {
345
- if (y === "DEV" || y === "NEW") return 1;
346
- const S = y.match(/^DEV(\d+)$/), I = y.match(/^NEW(\d+)$/);
347
- return S ? parseInt(S[1], 10) : I ? parseInt(I[1], 10) : 0;
348
- }).filter((y) => y > 0);
344
+ const f = l.map((w) => {
345
+ if (w === "DEV" || w === "NEW") return 1;
346
+ const x = w.match(/^DEV(\d+)$/), I = w.match(/^NEW(\d+)$/);
347
+ return x ? parseInt(x[1], 10) : I ? parseInt(I[1], 10) : 0;
348
+ }).filter((w) => w > 0);
349
349
  return `DEV${Math.max(...f, 0) + 1}`;
350
350
  } catch {
351
351
  return "DEV1";
352
352
  }
353
- }, F = process.cwd(), W = (c) => {
354
- const a = t.default.extname(c).toLowerCase();
353
+ }, F = process.cwd(), T = (d) => {
354
+ const l = t.default.extname(d).toLowerCase();
355
355
  return {
356
356
  ".html": "text/html",
357
357
  ".js": "text/javascript",
@@ -362,336 +362,336 @@ async function Ce() {
362
362
  ".gif": "image/gif",
363
363
  ".svg": "image/svg+xml",
364
364
  ".ico": "image/x-icon"
365
- }[a] || "application/octet-stream";
366
- }, _ = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
367
- if (c.url.startsWith("/_hmr/")) {
368
- const h = c.url.split("/_hmr/")[1], y = c.headers["sec-websocket-key"], S = s("sha1").update(y + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
369
- a.write(
365
+ }[l] || "application/octet-stream";
366
+ }, O = /* @__PURE__ */ new Map(), z = [], ee = 50, W = [], oe = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Map(), Oe = (d, l, f) => {
367
+ if (d.url.startsWith("/_hmr/")) {
368
+ const g = d.url.split("/_hmr/")[1], w = d.headers["sec-websocket-key"], x = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
369
+ l.write(
370
370
  `HTTP/1.1 101 Switching Protocols\r
371
371
  Upgrade: websocket\r
372
372
  Connection: Upgrade\r
373
- Sec-WebSocket-Accept: ${S}\r
373
+ Sec-WebSocket-Accept: ${x}\r
374
374
  \r
375
375
  `
376
- ), X.has(h) || X.set(h, /* @__PURE__ */ new Set()), X.get(h).add(a), console.log(`🔌 HMR client connected: ${h}`), a.on("close", () => {
377
- const I = X.get(h);
378
- I && (I.delete(a), I.size === 0 && X.delete(h)), console.log(`🔌 HMR client disconnected: ${h}`);
379
- }), a.on("error", () => {
380
- const I = X.get(h);
381
- I && I.delete(a);
376
+ ), Q.has(g) || Q.set(g, /* @__PURE__ */ new Set()), Q.get(g).add(l), console.log(`🔌 HMR client connected: ${g}`), l.on("close", () => {
377
+ const I = Q.get(g);
378
+ I && (I.delete(l), I.size === 0 && Q.delete(g)), console.log(`🔌 HMR client disconnected: ${g}`);
379
+ }), l.on("error", () => {
380
+ const I = Q.get(g);
381
+ I && I.delete(l);
382
382
  });
383
383
  }
384
- }, Oe = n.default.createServer((c, a) => {
385
- if (a.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
384
+ }, ke = n.default.createServer((d, l) => {
385
+ if (l.setHeader("Content-Type", "application/json"), d.method === "POST" && d.url === "/_register") {
386
386
  let f = "";
387
- c.on("data", (h) => f += h), c.on("end", () => {
387
+ d.on("data", (g) => f += g), d.on("end", () => {
388
388
  try {
389
- const { componentId: h, distPath: y, componentName: S, htmlFile: I } = JSON.parse(f);
390
- _.set(h, { path: y, name: S || null, htmlFile: I || null });
391
- const T = S ? ` (${S})` : "";
392
- console.log(`✅ Registered: ${h}${T} -> ${y}${I ? "/" + I : ""}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(_.keys()) }));
393
- const H = Array.from(_.entries()).map(([Y, ee]) => ({
394
- id: Y,
395
- path: ee.path,
396
- name: ee.name
389
+ const { componentId: g, distPath: w, componentName: x, htmlFile: I } = JSON.parse(f);
390
+ O.set(g, { path: w, name: x || null, htmlFile: I || null });
391
+ const j = x ? ` (${x})` : "";
392
+ console.log(`✅ Registered: ${g}${j} -> ${w}${I ? "/" + I : ""}`), l.writeHead(200), l.end(JSON.stringify({ success: !0, registered: Array.from(O.keys()) }));
393
+ const B = Array.from(O.entries()).map(([K, ne]) => ({
394
+ id: K,
395
+ path: ne.path,
396
+ name: ne.name
397
397
  }));
398
- q.forEach((Y) => {
398
+ W.forEach((K) => {
399
399
  try {
400
- Y.write(`data: ${JSON.stringify({
400
+ K.write(`data: ${JSON.stringify({
401
401
  type: "components",
402
- components: H
402
+ components: B
403
403
  })}
404
404
 
405
405
  `);
406
406
  } catch {
407
407
  }
408
408
  });
409
- } catch (h) {
410
- a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
409
+ } catch (g) {
410
+ l.writeHead(400), l.end(JSON.stringify({ error: g.message }));
411
411
  }
412
412
  });
413
- } else if (c.method === "POST" && c.url === "/_unregister") {
413
+ } else if (d.method === "POST" && d.url === "/_unregister") {
414
414
  let f = "";
415
- c.on("data", (h) => f += h), c.on("end", () => {
415
+ d.on("data", (g) => f += g), d.on("end", () => {
416
416
  try {
417
- const { componentId: h } = JSON.parse(f);
418
- _.delete(h), console.log(`❌ Unregistered: ${h}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
419
- const y = Array.from(_.entries()).map(([S, I]) => ({
420
- id: S,
417
+ const { componentId: g } = JSON.parse(f);
418
+ O.delete(g), console.log(`❌ Unregistered: ${g}`), l.writeHead(200), l.end(JSON.stringify({ success: !0 }));
419
+ const w = Array.from(O.entries()).map(([x, I]) => ({
420
+ id: x,
421
421
  path: I.path,
422
422
  name: I.name
423
423
  }));
424
- q.forEach((S) => {
424
+ W.forEach((x) => {
425
425
  try {
426
- S.write(`data: ${JSON.stringify({
426
+ x.write(`data: ${JSON.stringify({
427
427
  type: "components",
428
- components: y
428
+ components: w
429
429
  })}
430
430
 
431
431
  `);
432
432
  } catch {
433
433
  }
434
434
  });
435
- } catch (h) {
436
- a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
435
+ } catch (g) {
436
+ l.writeHead(400), l.end(JSON.stringify({ error: g.message }));
437
437
  }
438
438
  });
439
- } else if (c.method === "GET" && c.url === "/_list")
440
- a.writeHead(200), a.end(JSON.stringify({ components: Array.from(_.entries()) }));
441
- else if (c.method === "POST" && c.url === "/_hmr_notify") {
439
+ } else if (d.method === "GET" && d.url === "/_list")
440
+ l.writeHead(200), l.end(JSON.stringify({ components: Array.from(O.entries()) }));
441
+ else if (d.method === "POST" && d.url === "/_hmr_notify") {
442
442
  let f = "";
443
- c.on("data", (h) => f += h), c.on("end", () => {
443
+ d.on("data", (g) => f += g), d.on("end", () => {
444
444
  try {
445
- const { componentId: h, html: y } = JSON.parse(f), S = X.get(h);
446
- if (S && S.size > 0) {
447
- console.log(`🔥 Notifying ${S.size} HMR client(s) for: ${h}`);
448
- const I = JSON.stringify({ type: "update", html: y }), T = qe(I);
449
- S.forEach((H) => {
445
+ const { componentId: g, html: w } = JSON.parse(f), x = Q.get(g);
446
+ if (x && x.size > 0) {
447
+ console.log(`🔥 Notifying ${x.size} HMR client(s) for: ${g}`);
448
+ const I = JSON.stringify({ type: "update", html: w }), j = Xe(I);
449
+ x.forEach((B) => {
450
450
  try {
451
- H.write(T);
451
+ B.write(j);
452
452
  } catch {
453
- S.delete(H);
453
+ x.delete(B);
454
454
  }
455
- }), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: S.size }));
455
+ }), l.writeHead(200), l.end(JSON.stringify({ success: !0, notified: x.size }));
456
456
  } else
457
- a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: 0 }));
458
- } catch (h) {
459
- a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
457
+ l.writeHead(200), l.end(JSON.stringify({ success: !0, notified: 0 }));
458
+ } catch (g) {
459
+ l.writeHead(400), l.end(JSON.stringify({ error: g.message }));
460
460
  }
461
461
  });
462
462
  } else
463
- a.writeHead(404), a.end(JSON.stringify({ error: "Not found" }));
464
- }), ge = n.default.createServer((c, a) => {
465
- if (c.url.includes("..")) {
466
- a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
463
+ l.writeHead(404), l.end(JSON.stringify({ error: "Not found" }));
464
+ }), he = n.default.createServer((d, l) => {
465
+ if (d.url.includes("..")) {
466
+ l.writeHead(403, { "Content-Type": "text/plain" }), l.end("Forbidden");
467
467
  return;
468
468
  }
469
- const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, y = h.split("/").filter((J) => J);
470
- if (h.startsWith("/consume")) {
471
- const J = f.searchParams.get("id");
472
- if (!J) {
473
- a.writeHead(400, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
469
+ const f = new URL(d.url, `http://localhost:${r}`), g = f.pathname, w = g.split("/").filter((V) => V);
470
+ if (g.startsWith("/consume")) {
471
+ const V = f.searchParams.get("id");
472
+ if (!V) {
473
+ l.writeHead(400, { "Content-Type": "application/json" }), l.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
474
474
  return;
475
475
  }
476
- const V = _.get(J), G = V ? V.path : null, de = (te) => {
477
- let U = "Unknown", K = "Unknown";
478
- if (c.headers.referer || c.headers.referrer) {
479
- const B = c.headers.referer || c.headers.referrer;
476
+ const G = O.get(V), Z = G ? G.path : null, pe = (se) => {
477
+ let H = "Unknown", q = "Unknown";
478
+ if (d.headers.referer || d.headers.referrer) {
479
+ const J = d.headers.referer || d.headers.referrer;
480
480
  try {
481
- const ie = new URL(B);
482
- U = ie.origin, K = ie.hostname || ie.origin;
481
+ const re = new URL(J);
482
+ H = re.origin, q = re.hostname || re.origin;
483
483
  } catch {
484
- U = B, K = B;
484
+ H = J, q = J;
485
485
  }
486
- } else if (c.headers.origin)
486
+ } else if (d.headers.origin)
487
487
  try {
488
- const B = new URL(c.headers.origin);
489
- U = B.origin, K = B.hostname || B.origin;
488
+ const J = new URL(d.headers.origin);
489
+ H = J.origin, q = J.hostname || J.origin;
490
490
  } catch {
491
- U = c.headers.origin, K = c.headers.origin;
491
+ H = d.headers.origin, q = d.headers.origin;
492
492
  }
493
- else if (c.socket.remoteAddress) {
494
- const B = c.socket.remoteAddress;
495
- B === "::1" || B === "::ffff:127.0.0.1" ? (U = "localhost", K = "localhost (direct)") : (U = B, K = B.replace("::ffff:", ""));
493
+ else if (d.socket.remoteAddress) {
494
+ const J = d.socket.remoteAddress;
495
+ J === "::1" || J === "::ffff:127.0.0.1" ? (H = "localhost", q = "localhost (direct)") : (H = J, q = J.replace("::ffff:", ""));
496
496
  }
497
- const Fe = c.headers.referer || c.headers.referrer || U, we = {
497
+ const je = d.headers.referer || d.headers.referrer || H, ve = {
498
498
  type: "request",
499
- componentId: J,
499
+ componentId: V,
500
500
  timestamp: Date.now(),
501
- servedLocally: te,
502
- referrer: Fe,
503
- origin: U,
504
- originLabel: K
501
+ servedLocally: se,
502
+ referrer: je,
503
+ origin: H,
504
+ originLabel: q
505
505
  };
506
- se.has(U) || (se.set(U, {
507
- url: U,
508
- label: K,
506
+ oe.has(H) || (oe.set(H, {
507
+ url: H,
508
+ label: q,
509
509
  firstSeen: Date.now(),
510
510
  requestCount: 0
511
- }), q.forEach((B) => {
511
+ }), W.forEach((J) => {
512
512
  try {
513
- B.write(`data: ${JSON.stringify({
513
+ J.write(`data: ${JSON.stringify({
514
514
  type: "origins",
515
- origins: Array.from(se.values())
515
+ origins: Array.from(oe.values())
516
516
  })}
517
517
 
518
518
  `);
519
519
  } catch {
520
520
  }
521
521
  }));
522
- const je = se.get(U);
523
- je.requestCount++, q.forEach((B) => {
522
+ const Ae = oe.get(H);
523
+ Ae.requestCount++, W.forEach((J) => {
524
524
  try {
525
- B.write(`data: ${JSON.stringify({
525
+ J.write(`data: ${JSON.stringify({
526
526
  type: "origins",
527
- origins: Array.from(se.values())
527
+ origins: Array.from(oe.values())
528
528
  })}
529
529
 
530
530
  `);
531
531
  } catch {
532
532
  }
533
- }), oe.push(we), oe.length > Ie && oe.shift(), q.forEach((B) => {
533
+ }), z.push(ve), z.length > ee && z.shift(), W.forEach((J) => {
534
534
  try {
535
- B.write(`data: ${JSON.stringify(we)}
535
+ J.write(`data: ${JSON.stringify(ve)}
536
536
 
537
537
  `);
538
538
  } catch {
539
539
  }
540
540
  });
541
541
  };
542
- if (G) {
543
- const te = V.htmlFile ? t.default.join(G, V.htmlFile) : t.default.join(G, "index.html");
544
- o.default.readFile(te, "utf-8", (U, K) => {
545
- if (U) {
546
- console.log(`❌ File not found: ${te}`), a.writeHead(404, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "index.html not found" }));
542
+ if (Z) {
543
+ const se = G.htmlFile ? t.default.join(Z, G.htmlFile) : t.default.join(Z, "index.html");
544
+ o.default.readFile(se, "utf-8", (H, q) => {
545
+ if (H) {
546
+ console.log(`❌ File not found: ${se}`), l.writeHead(404, { "Content-Type": "application/json" }), l.end(JSON.stringify({ error: "index.html not found" }));
547
547
  return;
548
548
  }
549
- const Fe = Re(K, J), we = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, je = {
549
+ const je = Ne(q, V), ve = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Ae = {
550
550
  item: {
551
- name: J,
552
- id: J,
551
+ name: V,
552
+ id: V,
553
553
  consume_variant: [
554
554
  {
555
- id: we,
555
+ id: ve,
556
556
  name: "dev version",
557
557
  loader: {
558
558
  type: "HTMLLoader",
559
559
  shadowRootMode: "localFrame",
560
- HTML: Fe
560
+ HTML: je
561
561
  }
562
562
  }
563
563
  ]
564
564
  }
565
565
  };
566
- console.log(`✅ Serving consume JSON for: ${J}`), de(!0), a.writeHead(200, {
566
+ console.log(`✅ Serving consume JSON for: ${V}`), pe(!0), l.writeHead(200, {
567
567
  "Content-Type": "application/json",
568
568
  "Access-Control-Allow-Origin": "*"
569
- }), a.end(JSON.stringify(je, null, 2));
569
+ }), l.end(JSON.stringify(Ae, null, 2));
570
570
  });
571
571
  } else {
572
- console.log(`📡 Proxying consume request to cloud.myop.dev for: ${J}`);
573
- const te = `https://cloud.myop.dev/consume${f.search}`;
574
- de(!1), fetch(te).then((U) => U.text()).then((U) => {
575
- a.writeHead(200, {
572
+ console.log(`📡 Proxying consume request to cloud.myop.dev for: ${V}`);
573
+ const se = `https://cloud.myop.dev/consume${f.search}`;
574
+ pe(!1), fetch(se).then((H) => H.text()).then((H) => {
575
+ l.writeHead(200, {
576
576
  "Content-Type": "application/json",
577
577
  "Access-Control-Allow-Origin": "*"
578
- }), a.end(U);
579
- }).catch((U) => {
580
- console.error(`❌ Proxy error: ${U.message}`), a.writeHead(502, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
578
+ }), l.end(H);
579
+ }).catch((H) => {
580
+ console.error(`❌ Proxy error: ${H.message}`), l.writeHead(502, { "Content-Type": "application/json" }), l.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
581
581
  });
582
582
  }
583
583
  return;
584
584
  }
585
- if (h === "/events") {
586
- a.writeHead(200, {
585
+ if (g === "/events") {
586
+ l.writeHead(200, {
587
587
  "Content-Type": "text/event-stream",
588
588
  "Cache-Control": "no-cache",
589
589
  Connection: "keep-alive",
590
590
  "Access-Control-Allow-Origin": "*"
591
- }), q.push(a);
592
- const J = Array.from(_.entries()).map(([V, G]) => ({
593
- id: V,
594
- path: G.path,
595
- name: G.name
591
+ }), W.push(l);
592
+ const V = Array.from(O.entries()).map(([G, Z]) => ({
593
+ id: G,
594
+ path: Z.path,
595
+ name: Z.name
596
596
  }));
597
- a.write(`data: ${JSON.stringify({
597
+ l.write(`data: ${JSON.stringify({
598
598
  type: "components",
599
- components: J
599
+ components: V
600
600
  })}
601
601
 
602
- `), a.write(`data: ${JSON.stringify({
602
+ `), l.write(`data: ${JSON.stringify({
603
603
  type: "origins",
604
- origins: Array.from(se.values())
604
+ origins: Array.from(oe.values())
605
605
  })}
606
606
 
607
- `), a.write(`data: ${JSON.stringify({
607
+ `), l.write(`data: ${JSON.stringify({
608
608
  type: "requestLog",
609
- log: oe
609
+ log: z
610
610
  })}
611
611
 
612
- `), c.on("close", () => {
613
- const V = q.indexOf(a);
614
- V !== -1 && q.splice(V, 1);
612
+ `), d.on("close", () => {
613
+ const G = W.indexOf(l);
614
+ G !== -1 && W.splice(G, 1);
615
615
  });
616
616
  return;
617
617
  }
618
- if (y.length === 0) {
619
- a.writeHead(200, { "Content-Type": "text/html" }), a.end(Ut(l, d, p, m));
618
+ if (w.length === 0) {
619
+ l.writeHead(200, { "Content-Type": "text/html" }), l.end(Ut(r, c, p, m));
620
620
  return;
621
621
  }
622
- if (y[0] !== "view") {
623
- a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not found. Use /view/<componentId>/ to access components.");
622
+ if (w[0] !== "view") {
623
+ l.writeHead(404, { "Content-Type": "text/plain" }), l.end("Not found. Use /view/<componentId>/ to access components.");
624
624
  return;
625
625
  }
626
- if (y.length < 2) {
627
- a.writeHead(400, { "Content-Type": "text/plain" }), a.end("Component ID required. Use /view/<componentId>/");
626
+ if (w.length < 2) {
627
+ l.writeHead(400, { "Content-Type": "text/plain" }), l.end("Component ID required. Use /view/<componentId>/");
628
628
  return;
629
629
  }
630
- const S = y[1], I = _.get(S);
630
+ const x = w[1], I = O.get(x);
631
631
  if (!I) {
632
- a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${S}`);
632
+ l.writeHead(404, { "Content-Type": "text/plain" }), l.end(`Component not found: ${x}`);
633
633
  return;
634
634
  }
635
- const T = I.path, H = y.slice(2), Y = I.htmlFile || "index.html", ee = H.length === 0 ? Y : H.join("/"), ce = t.default.join(T, ee);
636
- console.log(`📥 Request: ${c.url} -> ${ce}`), o.default.readFile(ce, (J, V) => {
637
- if (J) {
638
- console.log(`❌ File not found: ${ce}`), a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not Found");
635
+ const j = I.path, B = w.slice(2), K = I.htmlFile || "index.html", ne = B.length === 0 ? K : B.join("/"), de = t.default.join(j, ne);
636
+ console.log(`📥 Request: ${d.url} -> ${de}`), o.default.readFile(de, (V, G) => {
637
+ if (V) {
638
+ console.log(`❌ File not found: ${de}`), l.writeHead(404, { "Content-Type": "text/plain" }), l.end("Not Found");
639
639
  return;
640
640
  }
641
- const G = W(ce);
642
- console.log(`✅ Serving: ${ce} (${G})`);
643
- let de = V;
644
- if (G === "text/html" && k) {
645
- const te = V.toString("utf-8");
646
- de = Re(te, S);
641
+ const Z = T(de);
642
+ console.log(`✅ Serving: ${de} (${Z})`);
643
+ let pe = G;
644
+ if (Z === "text/html" && R) {
645
+ const se = G.toString("utf-8");
646
+ pe = Ne(se, x);
647
647
  }
648
- a.writeHead(200, {
649
- "Content-Type": G,
648
+ l.writeHead(200, {
649
+ "Content-Type": Z,
650
650
  "Access-Control-Allow-Origin": "*"
651
- }), a.end(de);
651
+ }), l.end(pe);
652
652
  });
653
- }), ke = () => new Promise((c, a) => {
654
- const f = g ? t.default.resolve(F) : t.default.resolve(F, w), h = JSON.stringify({
655
- componentId: C,
653
+ }), Re = () => new Promise((d, l) => {
654
+ const f = h ? t.default.resolve(F) : t.default.resolve(F, y), g = JSON.stringify({
655
+ componentId: M,
656
656
  distPath: f,
657
657
  componentName: N,
658
- htmlFile: g ? u : null
659
- }), y = {
658
+ htmlFile: h ? u : null
659
+ }), w = {
660
660
  hostname: "localhost",
661
- port: d,
661
+ port: c,
662
662
  path: "/_register",
663
663
  method: "POST",
664
664
  headers: {
665
665
  "Content-Type": "application/json",
666
- "Content-Length": Buffer.byteLength(h)
666
+ "Content-Length": Buffer.byteLength(g)
667
667
  }
668
- }, S = n.default.request(y, (I) => {
669
- let T = "";
670
- I.on("data", (H) => T += H), I.on("end", () => {
671
- I.statusCode === 200 ? c(JSON.parse(T)) : a(new Error(`Registration failed: ${I.statusCode}`));
668
+ }, x = n.default.request(w, (I) => {
669
+ let j = "";
670
+ I.on("data", (B) => j += B), I.on("end", () => {
671
+ I.statusCode === 200 ? d(JSON.parse(j)) : l(new Error(`Registration failed: ${I.statusCode}`));
672
672
  });
673
673
  });
674
- S.on("error", a), S.write(h), S.end();
675
- }), vt = () => new Promise((c, a) => {
676
- const f = JSON.stringify({ componentId: C }), h = {
674
+ x.on("error", l), x.write(g), x.end();
675
+ }), vt = () => new Promise((d, l) => {
676
+ const f = JSON.stringify({ componentId: M }), g = {
677
677
  hostname: "localhost",
678
- port: d,
678
+ port: c,
679
679
  path: "/_unregister",
680
680
  method: "POST",
681
681
  headers: {
682
682
  "Content-Type": "application/json",
683
683
  "Content-Length": Buffer.byteLength(f)
684
684
  }
685
- }, y = n.default.request(h, (S) => {
686
- c();
685
+ }, w = n.default.request(g, (x) => {
686
+ d();
687
687
  });
688
- y.on("error", () => c()), y.write(f), y.end();
689
- }), St = (c) => `
688
+ w.on("error", () => d()), w.write(f), w.end();
689
+ }), St = (d) => `
690
690
  <!-- MYOP HMR -->
691
691
  <script>
692
692
  (function() {
693
- const componentId = '${c}';
694
- const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
693
+ const componentId = '${d}';
694
+ const wsUrl = 'ws://localhost:${c}/_hmr/' + componentId;
695
695
  let ws;
696
696
  let reconnectAttempts = 0;
697
697
  const maxReconnectAttempts = 10;
@@ -791,64 +791,64 @@ Sec-WebSocket-Accept: ${S}\r
791
791
  connect();
792
792
  })();
793
793
  <\/script>
794
- `, Re = (c, a) => {
795
- if (!k) return c;
796
- const f = St(a);
797
- return c.includes("</body>") ? c.replace("</body>", `${f}</body>`) : c.includes("</html>") ? c.replace("</html>", `${f}</html>`) : c + f;
798
- }, qe = (c) => {
799
- const a = Buffer.from(c), f = a.length;
800
- let h;
801
- return f < 126 ? h = Buffer.concat([
794
+ `, Ne = (d, l) => {
795
+ if (!R) return d;
796
+ const f = St(l);
797
+ return d.includes("</body>") ? d.replace("</body>", `${f}</body>`) : d.includes("</html>") ? d.replace("</html>", `${f}</html>`) : d + f;
798
+ }, Xe = (d) => {
799
+ const l = Buffer.from(d), f = l.length;
800
+ let g;
801
+ return f < 126 ? g = Buffer.concat([
802
802
  Buffer.from([129, f]),
803
803
  // FIN + text frame, length
804
- a
805
- ]) : f < 65536 ? h = Buffer.concat([
804
+ l
805
+ ]) : f < 65536 ? g = Buffer.concat([
806
806
  Buffer.from([129, 126]),
807
807
  // FIN + text frame, extended length
808
808
  Buffer.from([f >> 8, f & 255]),
809
809
  // 16-bit length
810
- a
811
- ]) : h = Buffer.concat([
810
+ l
811
+ ]) : g = Buffer.concat([
812
812
  Buffer.from([129, 127]),
813
813
  // FIN + text frame, extended length
814
814
  Buffer.from([0, 0, 0, 0, f >> 24, f >> 16 & 255, f >> 8 & 255, f & 255]),
815
815
  // 64-bit length
816
- a
817
- ]), h;
818
- }, Xe = () => {
819
- if (!k) return;
820
- const c = g ? u : t.default.join(w, "index.html");
821
- let a;
816
+ l
817
+ ]), g;
818
+ }, et = () => {
819
+ if (!R) return;
820
+ const d = h ? u : t.default.join(y, "index.html");
821
+ let l;
822
822
  try {
823
- const f = o.default.readFileSync(c, "utf-8");
824
- a = Re(f, C);
823
+ const f = o.default.readFileSync(d, "utf-8");
824
+ l = Ne(f, M);
825
825
  } catch (f) {
826
826
  console.error("❌ Failed to read HTML for HMR:", f.message);
827
827
  return;
828
828
  }
829
- if (Te) {
830
- const f = X.get(C);
829
+ if (Fe) {
830
+ const f = Q.get(M);
831
831
  if (!f || f.size === 0)
832
832
  return;
833
833
  console.log(`🔥 Notifying ${f.size} HMR client(s)`);
834
- const h = JSON.stringify({
834
+ const g = JSON.stringify({
835
835
  type: "update",
836
- html: a
837
- }), y = qe(h);
838
- f.forEach((S) => {
836
+ html: l
837
+ }), w = Xe(g);
838
+ f.forEach((x) => {
839
839
  try {
840
- S.write(y);
840
+ x.write(w);
841
841
  } catch {
842
- f.delete(S);
842
+ f.delete(x);
843
843
  }
844
844
  });
845
845
  } else {
846
846
  const f = JSON.stringify({
847
- componentId: C,
848
- html: a
849
- }), h = {
847
+ componentId: M,
848
+ html: l
849
+ }), g = {
850
850
  hostname: "localhost",
851
- port: d,
851
+ port: c,
852
852
  path: "/_hmr_notify",
853
853
  method: "POST",
854
854
  headers: {
@@ -856,196 +856,196 @@ Sec-WebSocket-Accept: ${S}\r
856
856
  "Content-Length": Buffer.byteLength(f)
857
857
  },
858
858
  timeout: 5e3
859
- }, y = n.default.request(h, (S) => {
859
+ }, w = n.default.request(g, (x) => {
860
860
  let I = "";
861
- S.on("data", (T) => I += T), S.on("end", () => {
861
+ x.on("data", (j) => I += j), x.on("end", () => {
862
862
  try {
863
- const T = JSON.parse(I);
864
- T.notified > 0 && console.log(`🔥 Notified ${T.notified} HMR client(s) via server`);
863
+ const j = JSON.parse(I);
864
+ j.notified > 0 && console.log(`🔥 Notified ${j.notified} HMR client(s) via server`);
865
865
  } catch {
866
866
  }
867
867
  });
868
868
  });
869
- y.on("error", () => {
870
- }), y.on("timeout", () => {
871
- y.destroy();
872
- }), y.write(f), y.end();
869
+ w.on("error", () => {
870
+ }), w.on("timeout", () => {
871
+ w.destroy();
872
+ }), w.write(f), w.end();
873
873
  }
874
874
  };
875
- let Ne = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
876
- const he = (c) => {
877
- if (x) {
875
+ let _e = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
876
+ const ye = (d) => {
877
+ if (S) {
878
878
  $ = !0;
879
879
  return;
880
880
  }
881
- x = !0, console.log(`
882
- 🔨 Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (a, f, h) => {
883
- if (x = !1, a) {
884
- const y = await pt(a, f, h, e, {
885
- ...Ne,
886
- onRetry: () => he(c)
881
+ S = !0, console.log(`
882
+ 🔨 Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (l, f, g) => {
883
+ if (S = !1, l) {
884
+ const w = await mt(l, f, g, e, {
885
+ ..._e,
886
+ onRetry: () => ye(d)
887
887
  });
888
- Ne = { ...Ne, ...y }, y.handled || (console.error("❌ Build failed:", a.message), h && console.error(h));
888
+ _e = { ..._e, ...w }, w.handled || (console.error("❌ Build failed:", l.message), g && console.error(g));
889
889
  } else
890
- console.log("✅ Build completed"), f && console.log(f), Xe(), c && c();
891
- $ && ($ = !1, he());
890
+ console.log("✅ Build completed"), f && console.log(f), et(), d && d();
891
+ $ && ($ = !1, ye());
892
892
  });
893
- }, et = /* @__PURE__ */ new Set(), _e = (c) => {
894
- o.default.readdir(c, { withFileTypes: !0 }, (a, f) => {
895
- a || (f.forEach((h) => {
896
- const y = t.default.join(c, h.name);
897
- if (h.isDirectory())
898
- h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(y);
899
- else if (h.isFile()) {
900
- const S = t.default.extname(h.name);
901
- if (S === ".js" || S === ".css" || S === ".html")
893
+ }, tt = /* @__PURE__ */ new Set(), Te = (d) => {
894
+ o.default.readdir(d, { withFileTypes: !0 }, (l, f) => {
895
+ l || (f.forEach((g) => {
896
+ const w = t.default.join(d, g.name);
897
+ if (g.isDirectory())
898
+ g.name !== "node_modules" && g.name !== "dist" && !g.name.startsWith(".") && Te(w);
899
+ else if (g.isFile()) {
900
+ const x = t.default.extname(g.name);
901
+ if (x === ".js" || x === ".css" || x === ".html")
902
902
  try {
903
- const I = o.default.readFileSync(y, "utf-8");
904
- M.set(y, I);
903
+ const I = o.default.readFileSync(w, "utf-8");
904
+ b.set(w, I);
905
905
  } catch {
906
906
  }
907
907
  }
908
- }), et.has(c) || (et.add(c), o.default.watch(c, (h, y) => {
909
- if (!y) return;
910
- const S = t.default.extname(y);
911
- if (S !== ".js" && S !== ".css" && S !== ".html") return;
912
- const I = t.default.join(c, y);
908
+ }), tt.has(d) || (tt.add(d), o.default.watch(d, (g, w) => {
909
+ if (!w) return;
910
+ const x = t.default.extname(w);
911
+ if (x !== ".js" && x !== ".css" && x !== ".html") return;
912
+ const I = t.default.join(d, w);
913
913
  setTimeout(() => {
914
914
  try {
915
- const T = o.default.readFileSync(I, "utf-8"), H = M.get(I);
916
- T !== H && (M.set(I, T), console.log(`📝 File changed: ${I}`), g ? Xe() : he());
915
+ const j = o.default.readFileSync(I, "utf-8"), B = b.get(I);
916
+ j !== B && (b.set(I, j), console.log(`📝 File changed: ${I}`), h ? et() : ye());
917
917
  } catch {
918
918
  }
919
919
  }, 50);
920
920
  })));
921
921
  });
922
- }, tt = (c) => {
922
+ }, ot = (d) => {
923
923
  console.log(`
924
- 🔨 Component: ${C}`), g ? (console.log("📄 No build needed (single HTML file mode)"), _e(F), console.log(`👀 Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
925
- `), c && c()) : (he(c), _e(F), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
924
+ 🔨 Component: ${M}`), h ? (console.log("📄 No build needed (single HTML file mode)"), Te(F), console.log(`👀 Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
925
+ `), d && d()) : (ye(d), Te(F), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
926
926
  `));
927
- }, xt = () => new Promise((c) => {
928
- const a = {
927
+ }, xt = () => new Promise((d) => {
928
+ const l = {
929
929
  hostname: "localhost",
930
- port: d,
930
+ port: c,
931
931
  path: "/_list",
932
932
  method: "GET",
933
933
  timeout: 1e3
934
- }, f = n.default.request(a, (h) => {
935
- let y = "";
936
- h.on("data", (S) => y += S), h.on("end", () => {
934
+ }, f = n.default.request(l, (g) => {
935
+ let w = "";
936
+ g.on("data", (x) => w += x), g.on("end", () => {
937
937
  try {
938
- (JSON.parse(y).components || []).map((T) => T[0]).includes(C) || ke().then(() => {
939
- console.log(`🔄 Re-registered component: ${C}`);
938
+ (JSON.parse(w).components || []).map((j) => j[0]).includes(M) || Re().then(() => {
939
+ console.log(`🔄 Re-registered component: ${M}`);
940
940
  }).catch(() => {
941
941
  });
942
942
  } catch {
943
943
  }
944
- c(!0);
944
+ d(!0);
945
945
  });
946
946
  });
947
- f.on("error", () => c(!1)), f.on("timeout", () => {
948
- f.destroy(), c(!1);
947
+ f.on("error", () => d(!1)), f.on("timeout", () => {
948
+ f.destroy(), d(!1);
949
949
  }), f.end();
950
- }), $t = () => new Promise((c) => {
951
- const a = n.default.createServer((f, h) => {
952
- if (h.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
953
- let y = "";
954
- f.on("data", (S) => y += S), f.on("end", () => {
950
+ }), $t = () => new Promise((d) => {
951
+ const l = n.default.createServer((f, g) => {
952
+ if (g.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
953
+ let w = "";
954
+ f.on("data", (x) => w += x), f.on("end", () => {
955
955
  try {
956
- const { componentId: S, distPath: I, componentName: T, htmlFile: H } = JSON.parse(y);
957
- _.set(S, { path: I, name: T || null, htmlFile: H || null });
958
- const Y = T ? ` (${T})` : "";
959
- console.log(`✅ Registered: ${S}${Y} -> ${I}${H ? "/" + H : ""}`), h.writeHead(200), h.end(JSON.stringify({ success: !0, registered: Array.from(_.keys()) }));
960
- } catch (S) {
961
- h.writeHead(400), h.end(JSON.stringify({ error: S.message }));
956
+ const { componentId: x, distPath: I, componentName: j, htmlFile: B } = JSON.parse(w);
957
+ O.set(x, { path: I, name: j || null, htmlFile: B || null });
958
+ const K = j ? ` (${j})` : "";
959
+ console.log(`✅ Registered: ${x}${K} -> ${I}${B ? "/" + B : ""}`), g.writeHead(200), g.end(JSON.stringify({ success: !0, registered: Array.from(O.keys()) }));
960
+ } catch (x) {
961
+ g.writeHead(400), g.end(JSON.stringify({ error: x.message }));
962
962
  }
963
963
  });
964
964
  } else if (f.method === "POST" && f.url === "/_unregister") {
965
- let y = "";
966
- f.on("data", (S) => y += S), f.on("end", () => {
965
+ let w = "";
966
+ f.on("data", (x) => w += x), f.on("end", () => {
967
967
  try {
968
- const { componentId: S } = JSON.parse(y);
969
- _.delete(S), console.log(`❌ Unregistered: ${S}`), h.writeHead(200), h.end(JSON.stringify({ success: !0 }));
970
- } catch (S) {
971
- h.writeHead(400), h.end(JSON.stringify({ error: S.message }));
968
+ const { componentId: x } = JSON.parse(w);
969
+ O.delete(x), console.log(`❌ Unregistered: ${x}`), g.writeHead(200), g.end(JSON.stringify({ success: !0 }));
970
+ } catch (x) {
971
+ g.writeHead(400), g.end(JSON.stringify({ error: x.message }));
972
972
  }
973
973
  });
974
- } else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(_.entries()) }))) : (h.writeHead(404), h.end(JSON.stringify({ error: "Not found" })));
974
+ } else f.method === "GET" && f.url === "/_list" ? (g.writeHead(200), g.end(JSON.stringify({ components: Array.from(O.entries()) }))) : (g.writeHead(404), g.end(JSON.stringify({ error: "Not found" })));
975
975
  });
976
- a.on("error", () => {
977
- c(!1);
978
- }), a.listen(d, () => {
976
+ l.on("error", () => {
977
+ d(!1);
978
+ }), l.listen(c, () => {
979
979
  console.log(`
980
- 🔄 Taking over as server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", () => {
981
- a.close(), c(!1);
982
- }), ge.listen(l, () => {
983
- console.log(`📡 Main server running at http://localhost:${l}`);
984
- const f = g ? t.default.resolve(F) : t.default.resolve(F, w);
985
- _.set(C, {
980
+ 🔄 Taking over as server...`), console.log(`📡 Management server on port ${c}`), he.on("error", () => {
981
+ l.close(), d(!1);
982
+ }), he.listen(r, () => {
983
+ console.log(`📡 Main server running at http://localhost:${r}`);
984
+ const f = h ? t.default.resolve(F) : t.default.resolve(F, y);
985
+ O.set(M, {
986
986
  path: f,
987
987
  name: N,
988
- htmlFile: g ? u : null
988
+ htmlFile: h ? u : null
989
989
  });
990
- const h = N ? ` (${N})` : "";
991
- console.log(`✅ Registered component: ${C}${h}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), c(!0);
990
+ const g = N ? ` (${N})` : "";
991
+ console.log(`✅ Registered component: ${M}${g}`), console.log(`📡 Access at: http://localhost:${r}/view/${M}/`), d(!0);
992
992
  });
993
993
  });
994
994
  });
995
- let ye;
996
- const ot = () => {
997
- ye = setInterval(async () => {
998
- await xt() || (clearInterval(ye), console.log(`
999
- ⚠️ Server appears to be down, attempting to take over...`), await $t() ? (console.log("✅ Successfully took over as server"), Te = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
995
+ let we;
996
+ const nt = () => {
997
+ we = setInterval(async () => {
998
+ await xt() || (clearInterval(we), console.log(`
999
+ ⚠️ Server appears to be down, attempting to take over...`), await $t() ? (console.log("✅ Successfully took over as server"), Fe = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
1000
1000
  try {
1001
- await ke(), console.log(`✅ Re-registered component: ${C}`), ot();
1001
+ await Re(), console.log(`✅ Re-registered component: ${M}`), nt();
1002
1002
  } catch (f) {
1003
1003
  console.error("❌ Failed to re-register:", f.message);
1004
1004
  }
1005
1005
  }, 2e3)));
1006
1006
  }, 3e3);
1007
- }, nt = async () => {
1007
+ }, st = async () => {
1008
1008
  console.log(`
1009
1009
 
1010
- 🛑 Shutting down...`), ye && clearInterval(ye), await vt(), process.exit(0);
1010
+ 🛑 Shutting down...`), we && clearInterval(we), await vt(), process.exit(0);
1011
1011
  };
1012
- process.on("SIGINT", nt), process.on("SIGTERM", nt);
1013
- let Te = !1;
1014
- Oe.on("error", async (c) => {
1015
- if (c.code === "EADDRINUSE") {
1012
+ process.on("SIGINT", st), process.on("SIGTERM", st);
1013
+ let Fe = !1;
1014
+ ke.on("error", async (d) => {
1015
+ if (d.code === "EADDRINUSE") {
1016
1016
  console.log(`
1017
1017
  🔗 Connecting to existing dev server...`);
1018
1018
  try {
1019
- C = await D();
1020
- const a = await ke();
1021
- console.log(`✅ Registered component: ${C}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), console.log(`📋 All registered components: ${a.registered.join(", ")}`), tt(() => {
1022
- process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${C}/`);
1023
- }), ot();
1024
- } catch (a) {
1025
- console.error("❌ Failed to register component:", a.message), process.exit(1);
1019
+ M = await D();
1020
+ const l = await Re();
1021
+ console.log(`✅ Registered component: ${M}`), console.log(`📡 Access at: http://localhost:${r}/view/${M}/`), console.log(`📋 All registered components: ${l.registered.join(", ")}`), ot(() => {
1022
+ process.env.MYOP_NO_BROWSER || C(`http://localhost:${r}/view/${M}/`);
1023
+ }), nt();
1024
+ } catch (l) {
1025
+ console.error("❌ Failed to register component:", l.message), process.exit(1);
1026
1026
  }
1027
1027
  } else
1028
- console.error("❌ Management server error:", c.message), process.exit(1);
1029
- }), Oe.on("upgrade", wt), Oe.listen(d, async () => {
1030
- Te = !0, console.log(`
1031
- 🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", (c) => {
1032
- console.error("❌ Main server error:", c.message), process.exit(1);
1033
- }), ge.listen(l, async () => {
1034
- console.log(`📡 Main server running at http://localhost:${l}`), (C === "DEV" || C === "NEW") && (C = "DEV1");
1035
- const c = g ? t.default.resolve(F) : t.default.resolve(F, w);
1036
- _.set(C, {
1037
- path: c,
1028
+ console.error("❌ Management server error:", d.message), process.exit(1);
1029
+ }), ke.on("upgrade", Oe), ke.listen(c, async () => {
1030
+ Fe = !0, console.log(`
1031
+ 🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${c}`), he.on("error", (d) => {
1032
+ console.error("❌ Main server error:", d.message), process.exit(1);
1033
+ }), he.listen(r, async () => {
1034
+ console.log(`📡 Main server running at http://localhost:${r}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
1035
+ const d = h ? t.default.resolve(F) : t.default.resolve(F, y);
1036
+ O.set(M, {
1037
+ path: d,
1038
1038
  name: N,
1039
- htmlFile: g ? u : null
1039
+ htmlFile: h ? u : null
1040
1040
  });
1041
- const a = N ? ` (${N})` : "";
1042
- console.log(`✅ Registered component: ${C}${a}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), tt(() => {
1043
- process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${C}/`);
1041
+ const l = N ? ` (${N})` : "";
1042
+ console.log(`✅ Registered component: ${M}${l}`), console.log(`📡 Access at: http://localhost:${r}/view/${M}/`), ot(() => {
1043
+ process.env.MYOP_NO_BROWSER || C(`http://localhost:${r}/view/${M}/`);
1044
1044
  });
1045
1045
  });
1046
1046
  });
1047
1047
  }
1048
- const A = class A {
1048
+ const L = class L {
1049
1049
  constructor(t) {
1050
1050
  this.components = t.map(
1051
1051
  (e) => typeof e == "string" ? { name: e, path: "", id: "" } : e
@@ -1054,7 +1054,7 @@ const A = class A {
1054
1054
  this.logs.set(e.name, []), this.scrollPos.set(e.name, 0), this.statuses.set(e.name, "Initializing..."), this.statusKeys.set(e.name, "initializing");
1055
1055
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
1056
1056
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
1057
- }), this.setupKeyboardInput(), process.stdout.write(A.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1057
+ }), this.setupKeyboardInput(), process.stdout.write(L.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1058
1058
  }
1059
1059
  setupKeyboardInput() {
1060
1060
  process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (t) => {
@@ -1095,15 +1095,15 @@ const A = class A {
1095
1095
  const t = this.components.length, e = 38;
1096
1096
  let n;
1097
1097
  this.cols >= e * 3 + 4 ? n = Math.min(t, 3) : this.cols >= e * 2 + 2 ? n = Math.min(t, 2) : n = 1;
1098
- const s = Math.ceil(t / n), i = Math.floor(this.cols / n), r = 2, m = this.rows - r - 2, l = Math.floor(m / s);
1099
- this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
1100
- for (let d = 0; d < t; d++) {
1101
- const w = this.components[d], x = Math.floor(d / n), $ = d % n;
1102
- this.panelPositions.set(w.name, {
1103
- row: r + 1 + x * l,
1098
+ const s = Math.ceil(t / n), i = Math.floor(this.cols / n), a = 2, m = this.rows - a - 2, r = Math.floor(m / s);
1099
+ this.visibleLogLines = Math.max(2, r - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: r }, this.panelPositions.clear();
1100
+ for (let c = 0; c < t; c++) {
1101
+ const y = this.components[c], S = Math.floor(c / n), $ = c % n;
1102
+ this.panelPositions.set(y.name, {
1103
+ row: a + 1 + S * r,
1104
1104
  col: $ * i + 1,
1105
1105
  width: i,
1106
- height: l
1106
+ height: r
1107
1107
  });
1108
1108
  }
1109
1109
  }
@@ -1122,8 +1122,8 @@ const A = class A {
1122
1122
  s.includes("initializing") || s.includes("⏳") ? n = "initializing" : s.includes("starting") ? n = "starting" : s.includes("building") || s.includes("🔨") ? n = "building" : s.includes("ready") || s.includes("✅") ? n = "ready" : s.includes("changed") || s.includes("📝") ? n = "changed" : s.includes("hmr") ? n = "hmr_update" : s.includes("🔥") ? n = "hmr" : s.includes("error") || s.includes("❌") ? n = "error" : s.includes("warning") || s.includes("⚠") ? n = "warning" : (s.includes("stopped") || s.includes("exited")) && (n = "stopped"), this.statuses.set(t, e), this.statusKeys.set(t, n), this.queueUpdate(t);
1123
1123
  }
1124
1124
  scroll(t, e) {
1125
- const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), r = Math.max(0, Math.min(i, s + e));
1126
- r !== s && (this.scrollPos.set(t, r), this.queueUpdate(t));
1125
+ const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), a = Math.max(0, Math.min(i, s + e));
1126
+ a !== s && (this.scrollPos.set(t, a), this.queueUpdate(t));
1127
1127
  }
1128
1128
  queueUpdate(t) {
1129
1129
  this.pendingUpdates.add(t), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
@@ -1144,44 +1144,44 @@ const A = class A {
1144
1144
  return `${e}:${n.toString().padStart(2, "0")}`;
1145
1145
  }
1146
1146
  updateHeader() {
1147
- const t = A.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
1147
+ const t = L.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
1148
1148
  let s = `${t.dim}📡${t.reset} http://localhost:9292 ${t.gray}|${t.reset} `;
1149
- s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `⏱ ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += A.ESC.clearLine.slice(0, -1), process.stdout.write(A.ESC.moveTo(2, 1) + s);
1149
+ s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `⏱ ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += L.ESC.clearLine.slice(0, -1), process.stdout.write(L.ESC.moveTo(2, 1) + s);
1150
1150
  }
1151
1151
  renderPanel(t) {
1152
- const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
1152
+ const e = L.C, n = L.STATUS, s = this.panelPositions.get(t);
1153
1153
  if (!s) return;
1154
- const i = this.components.findIndex((D) => D.name === t), r = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", l = n[m], d = e[l.color], w = this.logs.get(t) || [], x = this.scrollPos.get(t) || 0, $ = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, $ - 20);
1155
- let O = `${g}┌─${e.reset} ${d}${l.icon}${e.reset} `;
1156
- O += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${d}${l.label}${e.reset} `;
1157
- const b = 5 + E.length + l.label.length + 3;
1158
- O += `${g}${"─".repeat(Math.max(0, $ - b))}┐${e.reset}`, u.push(A.ESC.moveTo(s.row, s.col) + O);
1159
- const M = (r.path || "").substring(0, $ - 6);
1160
- let j = `${g}│${e.reset} ${e.dim}${M}${e.reset}`;
1161
- j += " ".repeat(Math.max(0, $ - M.length - 3)), j += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 1, s.col) + j);
1162
- const C = w.length, N = C > this.visibleLogLines ? `${x + 1}-${Math.min(x + this.visibleLogLines, C)}/${C}` : "";
1163
- let k = `${g}├${"─".repeat($ - N.length - 4)}${e.reset}`;
1164
- N && (k += `${e.dim}${N}${e.reset}`), k += `${g}${"─".repeat(2)}┤${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
1165
- const L = w.slice(x, x + this.visibleLogLines);
1154
+ const i = this.components.findIndex((D) => D.name === t), a = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", r = n[m], c = e[r.color], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, $ = s.width - 1, h = p ? e.cyan : e.gray, u = [], E = a.name.substring(0, $ - 20);
1155
+ let k = `${h}┌─${e.reset} ${c}${r.icon}${e.reset} `;
1156
+ k += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${c}${r.label}${e.reset} `;
1157
+ const C = 5 + E.length + r.label.length + 3;
1158
+ k += `${h}${"─".repeat(Math.max(0, $ - C))}┐${e.reset}`, u.push(L.ESC.moveTo(s.row, s.col) + k);
1159
+ const b = (a.path || "").substring(0, $ - 6);
1160
+ let A = `${h}│${e.reset} ${e.dim}${b}${e.reset}`;
1161
+ A += " ".repeat(Math.max(0, $ - b.length - 3)), A += `${h}│${e.reset}`, u.push(L.ESC.moveTo(s.row + 1, s.col) + A);
1162
+ const M = y.length, N = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
1163
+ let R = `${h}├${"─".repeat($ - N.length - 4)}${e.reset}`;
1164
+ N && (R += `${e.dim}${N}${e.reset}`), R += `${h}${"─".repeat(2)}┤${e.reset}`, u.push(L.ESC.moveTo(s.row + 2, s.col) + R);
1165
+ const U = y.slice(S, S + this.visibleLogLines);
1166
1166
  for (let D = 0; D < this.visibleLogLines; D++) {
1167
- const F = L[D];
1168
- let W = `${g}│${e.reset}`;
1167
+ const F = U[D];
1168
+ let T = `${h}│${e.reset}`;
1169
1169
  if (F) {
1170
- let _ = e.white;
1171
- F.type === "success" ? _ = e.green : F.type === "error" ? _ = e.red : F.type === "warning" ? _ = e.yellow : F.type === "hmr" ? _ = e.magenta : F.type === "change" && (_ = e.blue);
1172
- const oe = F.message.substring(0, $ - 12);
1173
- W += `${e.dim}${F.timestamp}${e.reset} ${_}${oe}${e.reset}`;
1174
- const Ie = $ - F.timestamp.length - oe.length - 2;
1175
- W += " ".repeat(Math.max(0, Ie));
1170
+ let O = e.white;
1171
+ F.type === "success" ? O = e.green : F.type === "error" ? O = e.red : F.type === "warning" ? O = e.yellow : F.type === "hmr" ? O = e.magenta : F.type === "change" && (O = e.blue);
1172
+ const z = F.message.substring(0, $ - 12);
1173
+ T += `${e.dim}${F.timestamp}${e.reset} ${O}${z}${e.reset}`;
1174
+ const ee = $ - F.timestamp.length - z.length - 2;
1175
+ T += " ".repeat(Math.max(0, ee));
1176
1176
  } else
1177
- W += " ".repeat($ - 2);
1178
- W += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 3 + D, s.col) + W);
1177
+ T += " ".repeat($ - 2);
1178
+ T += `${h}│${e.reset}`, u.push(L.ESC.moveTo(s.row + 3 + D, s.col) + T);
1179
1179
  }
1180
- u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}└${"─".repeat($ - 2)}┘${e.reset}`), process.stdout.write(u.join(""));
1180
+ u.push(L.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${h}└${"─".repeat($ - 2)}┘${e.reset}`), process.stdout.write(u.join(""));
1181
1181
  }
1182
1182
  fullRender() {
1183
- const t = A.C;
1184
- process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1));
1183
+ const t = L.C;
1184
+ process.stdout.write(L.ESC.clearScreen + L.ESC.moveTo(1, 1));
1185
1185
  const e = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - e.length) / 2);
1186
1186
  process.stdout.write(`${t.cyan}${"━".repeat(n)}${t.bold}${t.bgCyan}${t.black}${e}${t.reset}${t.cyan}${"━".repeat(this.cols - n - e.length)}${t.reset}`), this.updateHeader();
1187
1187
  for (const s of this.components)
@@ -1189,26 +1189,26 @@ const A = class A {
1189
1189
  this.renderFooter();
1190
1190
  }
1191
1191
  renderFooter() {
1192
- const t = A.C, e = this.rows - 1;
1192
+ const t = L.C, e = this.rows - 1;
1193
1193
  let n = `${t.gray}`;
1194
- n += `${t.green}●${t.gray} Ready `, n += `${t.yellow}⟳${t.gray} Building `, n += `${t.magenta}⚡${t.gray} HMR `, n += `${t.red}✖${t.gray} Error `, n += `${t.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(A.ESC.moveTo(e, 1) + n);
1194
+ n += `${t.green}●${t.gray} Ready `, n += `${t.yellow}⟳${t.gray} Building `, n += `${t.magenta}⚡${t.gray} HMR `, n += `${t.red}✖${t.gray} Error `, n += `${t.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(L.ESC.moveTo(e, 1) + n);
1195
1195
  }
1196
1196
  render() {
1197
1197
  this.needsFullRedraw = !0, this.queueUpdate("__full__");
1198
1198
  }
1199
1199
  clear() {
1200
- this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1) + A.ESC.showCursor);
1200
+ this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(L.ESC.clearScreen + L.ESC.moveTo(1, 1) + L.ESC.showCursor);
1201
1201
  }
1202
1202
  };
1203
1203
  // ANSI escape codes
1204
- ve(A, "ESC", {
1204
+ Se(L, "ESC", {
1205
1205
  moveTo: (t, e) => `\x1B[${t};${e}H`,
1206
1206
  hideCursor: "\x1B[?25l",
1207
1207
  showCursor: "\x1B[?25h",
1208
1208
  clearScreen: "\x1B[2J",
1209
1209
  clearLine: "\x1B[2K"
1210
1210
  }), // Colors
1211
- ve(A, "C", {
1211
+ Se(L, "C", {
1212
1212
  reset: "\x1B[0m",
1213
1213
  bold: "\x1B[1m",
1214
1214
  dim: "\x1B[2m",
@@ -1223,7 +1223,7 @@ ve(A, "C", {
1223
1223
  bgCyan: "\x1B[46m",
1224
1224
  black: "\x1B[30m"
1225
1225
  }), // Status configs
1226
- ve(A, "STATUS", {
1226
+ Se(L, "STATUS", {
1227
1227
  initializing: { icon: "◔", color: "yellow", label: "Initializing" },
1228
1228
  starting: { icon: "◑", color: "yellow", label: "Starting" },
1229
1229
  building: { icon: "⟳", color: "yellow", label: "Building" },
@@ -1236,57 +1236,57 @@ ve(A, "STATUS", {
1236
1236
  warning: { icon: "⚠", color: "yellow", label: "Warning" },
1237
1237
  stopped: { icon: "■", color: "gray", label: "Stopped" }
1238
1238
  });
1239
- let He = A;
1239
+ let Be = L;
1240
1240
  async function Wt(o) {
1241
- const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((d) => ({
1242
- name: d.name,
1243
- path: d.path,
1244
- id: d.componentId || ""
1245
- })), i = new He(s), r = [], p = (d) => {
1246
- const w = process.platform;
1247
- let x;
1248
- w === "darwin" ? x = `open "${d}"` : w === "win32" ? x = `start "" "${d}"` : x = `xdg-open "${d}"`, e(x, () => {
1241
+ const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((c) => ({
1242
+ name: c.name,
1243
+ path: c.path,
1244
+ id: c.componentId || ""
1245
+ })), i = new Be(s), a = [], p = (c) => {
1246
+ const y = process.platform;
1247
+ let S;
1248
+ y === "darwin" ? S = `open "${c}"` : y === "win32" ? S = `start "" "${c}"` : S = `xdg-open "${c}"`, e(S, () => {
1249
1249
  });
1250
1250
  }, m = () => {
1251
1251
  i.clear(), console.log(`
1252
- 🛑 Shutting down all components...`), r.forEach((d) => {
1252
+ 🛑 Shutting down all components...`), a.forEach((c) => {
1253
1253
  try {
1254
- d.kill("SIGTERM");
1254
+ c.kill("SIGTERM");
1255
1255
  } catch {
1256
1256
  }
1257
1257
  }), setTimeout(() => process.exit(0), 500);
1258
1258
  };
1259
1259
  process.on("SIGINT", m), process.on("SIGTERM", m);
1260
- const l = process.argv[1];
1261
- for (let d = 0; d < o.length; d++) {
1262
- const w = o[d], x = w.name;
1263
- i.setStatus(x, "⏳ Starting..."), i.log(x, `Starting in ${w.path}`);
1264
- const $ = t("node", [l, "dev"], {
1265
- cwd: n.default.resolve(w.path),
1260
+ const r = process.argv[1];
1261
+ for (let c = 0; c < o.length; c++) {
1262
+ const y = o[c], S = y.name;
1263
+ i.setStatus(S, "⏳ Starting..."), i.log(S, `Starting in ${y.path}`);
1264
+ const $ = t("node", [r, "dev"], {
1265
+ cwd: n.default.resolve(y.path),
1266
1266
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1267
1267
  stdio: ["ignore", "pipe", "pipe"]
1268
1268
  });
1269
- r.push($);
1270
- let g = "";
1269
+ a.push($);
1270
+ let h = "";
1271
1271
  $.stdout.on("data", (u) => {
1272
- g += u.toString();
1273
- const E = g.split(`
1272
+ h += u.toString();
1273
+ const E = h.split(`
1274
1274
  `);
1275
- g = E.pop() || "";
1276
- for (const O of E) {
1277
- const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1278
- b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(x, "✅ Ready") : b.includes("Building...") || b.includes("Running initial build") ? i.setStatus(x, "🔨 Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? i.setStatus(x, "✅ Ready") : b.includes("Build failed") ? i.setStatus(x, "❌ Build Error") : b.includes("File changed") ? (i.setStatus(x, "📝 Changed"), setTimeout(() => i.setStatus(x, "✅ Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (i.setStatus(x, "🔥 HMR Update"), setTimeout(() => i.setStatus(x, "✅ Ready"), 1e3)) : b.includes("HMR client connected") && (i.setStatus(x, "🔥 HMR Connected"), setTimeout(() => i.setStatus(x, "✅ Ready"), 1e3)), !b.includes("Watching") && !b.includes("Press Ctrl+C") && !b.includes("Starting shared") && !b.includes("Management server") && !b.includes("Main server") && !b.includes("Access at:") && !b.includes("No build needed") && i.log(x, b));
1275
+ h = E.pop() || "";
1276
+ for (const k of E) {
1277
+ const C = k.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1278
+ C && (C.includes("Registered component") || C.includes("Registered:") ? i.setStatus(S, "✅ Ready") : C.includes("Building...") || C.includes("Running initial build") ? i.setStatus(S, "🔨 Building...") : C.includes("Build completed") || C.includes("Build succeeded") ? i.setStatus(S, "✅ Ready") : C.includes("Build failed") ? i.setStatus(S, "❌ Build Error") : C.includes("File changed") ? (i.setStatus(S, "📝 Changed"), setTimeout(() => i.setStatus(S, "✅ Ready"), 1500)) : C.includes("Notifying") && C.includes("HMR") ? (i.setStatus(S, "🔥 HMR Update"), setTimeout(() => i.setStatus(S, "✅ Ready"), 1e3)) : C.includes("HMR client connected") && (i.setStatus(S, "🔥 HMR Connected"), setTimeout(() => i.setStatus(S, "✅ Ready"), 1e3)), !C.includes("Watching") && !C.includes("Press Ctrl+C") && !C.includes("Starting shared") && !C.includes("Management server") && !C.includes("Main server") && !C.includes("Access at:") && !C.includes("No build needed") && i.log(S, C));
1279
1279
  }
1280
1280
  }), $.stderr.on("data", (u) => {
1281
1281
  const E = u.toString().split(`
1282
1282
  `);
1283
- for (const O of E) {
1284
- const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1285
- b && (i.log(x, `⚠️ ${b}`), i.setStatus(x, "⚠️ Warning"));
1283
+ for (const k of E) {
1284
+ const C = k.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1285
+ C && (i.log(S, `⚠️ ${C}`), i.setStatus(S, "⚠️ Warning"));
1286
1286
  }
1287
1287
  }), $.on("exit", (u) => {
1288
- u !== 0 && u !== null && (i.setStatus(x, `❌ Exited (${u})`), i.log(x, `Process exited with code ${u}`));
1289
- }), d < o.length - 1 && await new Promise((u) => setTimeout(u, 500));
1288
+ u !== 0 && u !== null && (i.setStatus(S, `❌ Exited (${u})`), i.log(S, `Process exited with code ${u}`));
1289
+ }), c < o.length - 1 && await new Promise((u) => setTimeout(u, 500));
1290
1290
  }
1291
1291
  i.render(), setTimeout(() => {
1292
1292
  p("http://localhost:9292");
@@ -1294,10 +1294,10 @@ async function Wt(o) {
1294
1294
  }
1295
1295
  const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1296
1296
  __proto__: null,
1297
- devCommand: Ce,
1297
+ devCommand: Me,
1298
1298
  monorepoDevCommand: Wt
1299
1299
  }, Symbol.toStringTag, { value: "Module" })), Yt = "https://cloud.myop.dev";
1300
- async function mt(o, t) {
1300
+ async function ut(o, t) {
1301
1301
  const e = await fetch(o, {
1302
1302
  headers: { Authorization: `Bearer ${t}` }
1303
1303
  });
@@ -1307,14 +1307,14 @@ async function mt(o, t) {
1307
1307
  }
1308
1308
  return e.json();
1309
1309
  }
1310
- function pe(o, t, e) {
1311
- const n = R.resolve(R.join(o, t)), s = R.resolve(o);
1312
- if (!n.startsWith(s + R.sep))
1310
+ function me(o, t, e) {
1311
+ const n = _.resolve(_.join(o, t)), s = _.resolve(o);
1312
+ if (!n.startsWith(s + _.sep))
1313
1313
  throw new Error(`Invalid path: "${t}" escapes output directory`);
1314
- P.mkdirSync(R.dirname(n), { recursive: !0 }), P.writeFileSync(n, JSON.stringify(e, null, 2));
1314
+ P.mkdirSync(_.dirname(n), { recursive: !0 }), P.writeFileSync(n, JSON.stringify(e, null, 2));
1315
1315
  }
1316
- async function $e(o, t, e, n) {
1317
- return mt(
1316
+ async function be(o, t, e, n) {
1317
+ return ut(
1318
1318
  `${o}/export?componentId=${encodeURIComponent(e)}&env=${encodeURIComponent(n)}`,
1319
1319
  t
1320
1320
  );
@@ -1322,20 +1322,20 @@ async function $e(o, t, e, n) {
1322
1322
  async function Gt(o, t, e, n) {
1323
1323
  let s = 0;
1324
1324
  const i = /* @__PURE__ */ new Set();
1325
- for (const r of n) {
1326
- const { componentId: p, environment: m } = r;
1325
+ for (const a of n) {
1326
+ const { componentId: p, environment: m } = a;
1327
1327
  if (!(!p || !m)) {
1328
1328
  try {
1329
- const l = await $e(o, t, p, m);
1330
- pe(e, `components/${p}/${m}.json`, l), s++;
1331
- } catch (l) {
1332
- console.warn(` Warning: ${p}/${m}: ${l.message}`);
1329
+ const r = await be(o, t, p, m);
1330
+ me(e, `components/${p}/${m}.json`, r), s++;
1331
+ } catch (r) {
1332
+ console.warn(` Warning: ${p}/${m}: ${r.message}`);
1333
1333
  }
1334
1334
  if (!i.has(p)) {
1335
1335
  i.add(p);
1336
1336
  try {
1337
- const l = await $e(o, t, p, "preview");
1338
- pe(e, `components/${p}/preview.json`, l), s++;
1337
+ const r = await be(o, t, p, "preview");
1338
+ me(e, `components/${p}/preview.json`, r), s++;
1339
1339
  } catch {
1340
1340
  }
1341
1341
  }
@@ -1344,20 +1344,20 @@ async function Gt(o, t, e, n) {
1344
1344
  return s;
1345
1345
  }
1346
1346
  async function Kt(o, t, e) {
1347
- const n = await mt(`${o}/export`, t);
1348
- pe(e, "manifest.json", n);
1347
+ const n = await ut(`${o}/export`, t);
1348
+ me(e, "manifest.json", n);
1349
1349
  let s = 0, i = 0;
1350
- for (const r of n.components || []) {
1351
- for (const p of r.environments || [])
1350
+ for (const a of n.components || []) {
1351
+ for (const p of a.environments || [])
1352
1352
  try {
1353
- const m = await $e(o, t, r.id, p);
1354
- pe(e, `components/${r.id}/${p}.json`, m), s++;
1353
+ const m = await be(o, t, a.id, p);
1354
+ me(e, `components/${a.id}/${p}.json`, m), s++;
1355
1355
  } catch (m) {
1356
- console.warn(` Warning: ${r.id}/${p}: ${m.message}`), i++;
1356
+ console.warn(` Warning: ${a.id}/${p}: ${m.message}`), i++;
1357
1357
  }
1358
1358
  try {
1359
- const p = await $e(o, t, r.id, "preview");
1360
- pe(e, `components/${r.id}/preview.json`, p), s++;
1359
+ const p = await be(o, t, a.id, "preview");
1360
+ me(e, `components/${a.id}/preview.json`, p), s++;
1361
1361
  } catch {
1362
1362
  }
1363
1363
  }
@@ -1377,55 +1377,55 @@ function Qt() {
1377
1377
  }
1378
1378
  else o.component && o.env && (s = [{ componentId: o.component, environment: o.env }]);
1379
1379
  if (s) {
1380
- const r = z(`Incremental export: ${s.length} component(s)...`).start();
1380
+ const a = Y(`Incremental export: ${s.length} component(s)...`).start();
1381
1381
  try {
1382
1382
  const p = await Gt(e, t, n, s);
1383
- r.succeed(`Incremental export done. ${p} file(s) written to ${n}/`);
1383
+ a.succeed(`Incremental export done. ${p} file(s) written to ${n}/`);
1384
1384
  } catch (p) {
1385
- r.fail(`Export failed: ${p.message}`), process.exit(1);
1385
+ a.fail(`Export failed: ${p.message}`), process.exit(1);
1386
1386
  }
1387
1387
  } else {
1388
- const r = z(`Full export from ${e}...`).start();
1388
+ const a = Y(`Full export from ${e}...`).start();
1389
1389
  try {
1390
- const { manifest: p, fileCount: m, errorCount: l } = await Kt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
1391
- r.succeed(
1392
- `Full export done. ${m} file(s) from ${d} component(s) written to ${n}/`
1393
- ), l > 0 && console.warn(` ${l} file(s) failed.`);
1390
+ const { manifest: p, fileCount: m, errorCount: r } = await Kt(e, t, n), c = ((i = p.components) == null ? void 0 : i.length) || 0;
1391
+ a.succeed(
1392
+ `Full export done. ${m} file(s) from ${c} component(s) written to ${n}/`
1393
+ ), r > 0 && console.warn(` ${r} file(s) failed.`);
1394
1394
  } catch (p) {
1395
- r.fail(`Export failed: ${p.message}`), process.exit(1);
1395
+ a.fail(`Export failed: ${p.message}`), process.exit(1);
1396
1396
  }
1397
1397
  }
1398
1398
  process.exit(0);
1399
1399
  });
1400
1400
  }
1401
- const Be = R.join(at.homedir(), ".myop"), ue = R.join(Be, "credentials.json");
1401
+ const Je = _.join(lt.homedir(), ".myop"), fe = _.join(Je, "credentials.json");
1402
1402
  function Zt() {
1403
- P.existsSync(Be) || P.mkdirSync(Be, { recursive: !0, mode: 448 });
1403
+ P.existsSync(Je) || P.mkdirSync(Je, { recursive: !0, mode: 448 });
1404
1404
  }
1405
- function Ye() {
1405
+ function Ge() {
1406
1406
  try {
1407
- if (!P.existsSync(ue))
1407
+ if (!P.existsSync(fe))
1408
1408
  return null;
1409
- const o = P.readFileSync(ue, "utf8");
1409
+ const o = P.readFileSync(fe, "utf8");
1410
1410
  return JSON.parse(o);
1411
1411
  } catch (o) {
1412
1412
  return console.info("Failed to read credentials:", o.message), null;
1413
1413
  }
1414
1414
  }
1415
- function ut(o) {
1415
+ function ft(o) {
1416
1416
  Zt();
1417
1417
  const t = {
1418
1418
  ...o,
1419
1419
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
1420
1420
  };
1421
- P.writeFileSync(ue, JSON.stringify(t, null, 2), {
1421
+ P.writeFileSync(fe, JSON.stringify(t, null, 2), {
1422
1422
  mode: 384
1423
1423
  // Read/write for owner only
1424
1424
  });
1425
1425
  }
1426
- function ft() {
1426
+ function gt() {
1427
1427
  try {
1428
- return P.existsSync(ue) && P.unlinkSync(ue), !0;
1428
+ return P.existsSync(fe) && P.unlinkSync(fe), !0;
1429
1429
  } catch (o) {
1430
1430
  return console.error("Failed to clear credentials:", o.message), !1;
1431
1431
  }
@@ -1437,26 +1437,26 @@ function qt(o) {
1437
1437
  return Date.now() > e - t;
1438
1438
  }
1439
1439
  function Pe() {
1440
- const o = Ye();
1440
+ const o = Ge();
1441
1441
  return o ? {
1442
1442
  email: o.userEmail,
1443
1443
  userId: o.userId
1444
1444
  } : null;
1445
1445
  }
1446
- const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284, Ge = `http://localhost:${xe}/callback`, Xt = "myop-cli";
1446
+ const ce = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", $e = 19284, Ke = `http://localhost:${$e}/callback`, Xt = "myop-cli";
1447
1447
  function eo() {
1448
- return We.randomBytes(32).toString("base64url");
1448
+ return Ve.randomBytes(32).toString("base64url");
1449
1449
  }
1450
1450
  function to(o) {
1451
- return We.createHash("sha256").update(o).digest("base64url");
1451
+ return Ve.createHash("sha256").update(o).digest("base64url");
1452
1452
  }
1453
1453
  async function oo() {
1454
- const o = await fetch(`${le}/oauth/register`, {
1454
+ const o = await fetch(`${ce}/oauth/register`, {
1455
1455
  method: "POST",
1456
1456
  headers: { "Content-Type": "application/json" },
1457
1457
  body: JSON.stringify({
1458
1458
  client_name: Xt,
1459
- redirect_uris: [Ge],
1459
+ redirect_uris: [Ke],
1460
1460
  grant_types: ["authorization_code", "refresh_token"],
1461
1461
  response_types: ["code"]
1462
1462
  })
@@ -1467,7 +1467,7 @@ async function oo() {
1467
1467
  }
1468
1468
  return o.json();
1469
1469
  }
1470
- function Se(o, t, e, n = null) {
1470
+ function xe(o, t, e, n = null) {
1471
1471
  const s = {
1472
1472
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
1473
1473
  <circle cx="12" cy="12" r="10"/>
@@ -1485,7 +1485,7 @@ function Se(o, t, e, n = null) {
1485
1485
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
1486
1486
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
1487
1487
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
1488
- }, { accent: r, glow: p } = i[o] || i.error;
1488
+ }, { accent: a, glow: p } = i[o] || i.error;
1489
1489
  return `<!DOCTYPE html>
1490
1490
  <html lang="en">
1491
1491
  <head>
@@ -1546,7 +1546,7 @@ function Se(o, t, e, n = null) {
1546
1546
  h1 {
1547
1547
  font-size: 20px;
1548
1548
  font-weight: 500;
1549
- color: ${r};
1549
+ color: ${a};
1550
1550
  margin-bottom: 12px;
1551
1551
  letter-spacing: -0.5px;
1552
1552
  }
@@ -1579,7 +1579,7 @@ function Se(o, t, e, n = null) {
1579
1579
  align-items: center;
1580
1580
  gap: 8px;
1581
1581
  background: ${p};
1582
- border: 1px solid ${r}33;
1582
+ border: 1px solid ${a}33;
1583
1583
  border-radius: 4px;
1584
1584
  padding: 10px 16px;
1585
1585
  font-size: 12px;
@@ -1636,20 +1636,20 @@ function Se(o, t, e, n = null) {
1636
1636
  function no(o) {
1637
1637
  return new Promise((t, e) => {
1638
1638
  const n = It.createServer((s, i) => {
1639
- const r = new it(s.url, `http://localhost:${xe}`);
1640
- if (r.pathname === "/callback") {
1641
- const p = r.searchParams.get("code"), m = r.searchParams.get("state"), l = r.searchParams.get("error");
1642
- if (l) {
1643
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
1639
+ const a = new rt(s.url, `http://localhost:${$e}`);
1640
+ if (a.pathname === "/callback") {
1641
+ const p = a.searchParams.get("code"), m = a.searchParams.get("state"), r = a.searchParams.get("error");
1642
+ if (r) {
1643
+ i.writeHead(200, { "Content-Type": "text/html" }), i.end(xe(
1644
1644
  "error",
1645
1645
  "Authentication Failed",
1646
1646
  "Unable to complete the authentication process.",
1647
- l
1648
- )), n.close(), e(new Error(`OAuth error: ${l}`));
1647
+ r
1648
+ )), n.close(), e(new Error(`OAuth error: ${r}`));
1649
1649
  return;
1650
1650
  }
1651
1651
  if (m !== o) {
1652
- i.writeHead(400, { "Content-Type": "text/html" }), i.end(Se(
1652
+ i.writeHead(400, { "Content-Type": "text/html" }), i.end(xe(
1653
1653
  "warning",
1654
1654
  "Security Error",
1655
1655
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
@@ -1658,7 +1658,7 @@ function no(o) {
1658
1658
  return;
1659
1659
  }
1660
1660
  if (!p) {
1661
- i.writeHead(400, { "Content-Type": "text/html" }), i.end(Se(
1661
+ i.writeHead(400, { "Content-Type": "text/html" }), i.end(xe(
1662
1662
  "error",
1663
1663
  "Missing Authorization Code",
1664
1664
  "No authorization code was received from the server.",
@@ -1666,7 +1666,7 @@ function no(o) {
1666
1666
  )), n.close(), e(new Error("No authorization code"));
1667
1667
  return;
1668
1668
  }
1669
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
1669
+ i.writeHead(200, { "Content-Type": "text/html" }), i.end(xe(
1670
1670
  "success",
1671
1671
  "Authentication Successful",
1672
1672
  "You have been authenticated successfully. Return to the terminal to continue."
@@ -1674,22 +1674,22 @@ function no(o) {
1674
1674
  } else
1675
1675
  i.writeHead(404), i.end("Not found");
1676
1676
  });
1677
- n.listen(xe, () => {
1678
- console.info(`OAuth callback server listening on port ${xe}`);
1677
+ n.listen($e, () => {
1678
+ console.info(`OAuth callback server listening on port ${$e}`);
1679
1679
  }), setTimeout(() => {
1680
1680
  n.close(), e(new Error("Authentication timed out"));
1681
1681
  }, 5 * 60 * 1e3);
1682
1682
  });
1683
1683
  }
1684
1684
  async function so(o, t, e) {
1685
- const n = await fetch(`${le}/oauth/token`, {
1685
+ const n = await fetch(`${ce}/oauth/token`, {
1686
1686
  method: "POST",
1687
1687
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1688
- body: new rt({
1688
+ body: new at({
1689
1689
  grant_type: "authorization_code",
1690
1690
  code: o,
1691
1691
  client_id: t,
1692
- redirect_uri: Ge,
1692
+ redirect_uri: Ke,
1693
1693
  code_verifier: e
1694
1694
  })
1695
1695
  });
@@ -1700,10 +1700,10 @@ async function so(o, t, e) {
1700
1700
  return n.json();
1701
1701
  }
1702
1702
  async function io(o, t) {
1703
- const e = await fetch(`${le}/oauth/token`, {
1703
+ const e = await fetch(`${ce}/oauth/token`, {
1704
1704
  method: "POST",
1705
1705
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1706
- body: new rt({
1706
+ body: new at({
1707
1707
  grant_type: "refresh_token",
1708
1708
  refresh_token: o,
1709
1709
  client_id: t
@@ -1716,8 +1716,8 @@ async function io(o, t) {
1716
1716
  return e.json();
1717
1717
  }
1718
1718
  async function ro(o) {
1719
- var s, i, r;
1720
- const t = await fetch(`${le}/mcp`, {
1719
+ var s, i, a;
1720
+ const t = await fetch(`${ce}/mcp`, {
1721
1721
  method: "POST",
1722
1722
  headers: {
1723
1723
  "Content-Type": "application/json",
@@ -1738,60 +1738,60 @@ async function ro(o) {
1738
1738
  const e = await t.json();
1739
1739
  if (e.error)
1740
1740
  throw new Error(e.error.message);
1741
- const n = (r = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : r.text;
1741
+ const n = (a = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : a.text;
1742
1742
  if (n)
1743
1743
  return JSON.parse(n);
1744
1744
  throw new Error("Invalid response from whoami");
1745
1745
  }
1746
- async function me() {
1747
- const o = z("Starting authentication...").start();
1746
+ async function ue() {
1747
+ const o = Y("Starting authentication...").start();
1748
1748
  try {
1749
1749
  o.text = "Registering OAuth client...";
1750
- const e = (await oo()).client_id, n = eo(), s = to(n), i = We.randomBytes(16).toString("hex");
1750
+ const e = (await oo()).client_id, n = eo(), s = to(n), i = Ve.randomBytes(16).toString("hex");
1751
1751
  o.text = "Waiting for authorization...";
1752
- const r = no(i), p = new it(`${le}/oauth/authorize`);
1753
- p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri", Ge), p.searchParams.set("code_challenge", s), p.searchParams.set("code_challenge_method", "S256"), p.searchParams.set("state", i), o.stop(), console.log(`
1752
+ const a = no(i), p = new rt(`${ce}/oauth/authorize`);
1753
+ p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri", Ke), p.searchParams.set("code_challenge", s), p.searchParams.set("code_challenge_method", "S256"), p.searchParams.set("state", i), o.stop(), console.log(`
1754
1754
  🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${p.toString()}
1755
1755
  `), await Ot(p.toString());
1756
- const m = await r;
1756
+ const m = await a;
1757
1757
  o.start("Exchanging authorization code...");
1758
- const l = await so(m, e, n);
1758
+ const r = await so(m, e, n);
1759
1759
  o.text = "Getting user info...";
1760
- const d = await ro(l.access_token), w = {
1761
- accessToken: l.access_token,
1762
- refreshToken: l.refresh_token,
1763
- expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
1760
+ const c = await ro(r.access_token), y = {
1761
+ accessToken: r.access_token,
1762
+ refreshToken: r.refresh_token,
1763
+ expiresAt: new Date(Date.now() + r.expires_in * 1e3).toISOString(),
1764
1764
  clientId: e,
1765
- userId: d.userId,
1766
- userEmail: d.email
1765
+ userId: c.userId,
1766
+ userEmail: c.email
1767
1767
  };
1768
- return ut(w), o.succeed(`Authenticated as ${d.email}`), w;
1768
+ return ft(y), o.succeed(`Authenticated as ${c.email}`), y;
1769
1769
  } catch (t) {
1770
1770
  throw o.fail(`Authentication failed: ${t.message}`), t;
1771
1771
  }
1772
1772
  }
1773
- async function gt() {
1774
- const o = Ye();
1773
+ async function ht() {
1774
+ const o = Ge();
1775
1775
  if (!o) {
1776
1776
  console.log("Not currently logged in.");
1777
1777
  return;
1778
1778
  }
1779
- ft(), console.log(`✅ Logged out (was: ${o.userEmail})`);
1779
+ gt(), console.log(`✅ Logged out (was: ${o.userEmail})`);
1780
1780
  }
1781
1781
  function ao(o) {
1782
1782
  var e, n;
1783
1783
  const t = (o == null ? void 0 : o.message) || "";
1784
1784
  return t.includes("ECONNREFUSED") || t.includes("ENOTFOUND") || t.includes("ETIMEDOUT") || t.includes("fetch failed") || t.includes("network") || (o == null ? void 0 : o.code) === "ECONNREFUSED" || ((e = o == null ? void 0 : o.cause) == null ? void 0 : e.code) === "ECONNREFUSED" || ((n = o == null ? void 0 : o.cause) == null ? void 0 : n.code) === "ENOTFOUND";
1785
1785
  }
1786
- async function Ke() {
1787
- let o = Ye();
1786
+ async function Qe() {
1787
+ let o = Ge();
1788
1788
  if (!o)
1789
1789
  return console.log(`Not logged in. Starting authentication...
1790
- `), await me();
1790
+ `), await ue();
1791
1791
  if (!qt(o))
1792
1792
  return o;
1793
1793
  if (o.refreshToken) {
1794
- const t = z("Refreshing access token...").start();
1794
+ const t = Y("Refreshing access token...").start();
1795
1795
  try {
1796
1796
  const e = await io(
1797
1797
  o.refreshToken,
@@ -1802,37 +1802,37 @@ async function Ke() {
1802
1802
  accessToken: e.access_token,
1803
1803
  refreshToken: e.refresh_token,
1804
1804
  expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
1805
- }, ut(o), t.succeed("Token refreshed"), o;
1805
+ }, ft(o), t.succeed("Token refreshed"), o;
1806
1806
  } catch (e) {
1807
1807
  if (ao(e))
1808
1808
  throw t.fail("Network error during token refresh"), e;
1809
- return t.warn("Token refresh failed, please log in again"), ft(), await me();
1809
+ return t.warn("Token refresh failed, please log in again"), gt(), await ue();
1810
1810
  }
1811
1811
  }
1812
1812
  return console.log(`Session expired. Please log in again.
1813
- `), await me();
1813
+ `), await ue();
1814
1814
  }
1815
- function Me() {
1816
- return le;
1815
+ function Ee() {
1816
+ return ce;
1817
1817
  }
1818
- const Z = "@myop/cli", De = process.platform === "win32";
1818
+ const te = "@myop/cli", Le = process.platform === "win32";
1819
1819
  function lo() {
1820
1820
  try {
1821
- return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1821
+ return X("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1822
1822
  } catch {
1823
1823
  return "https://registry.npmjs.org/";
1824
1824
  }
1825
1825
  }
1826
1826
  function co() {
1827
1827
  try {
1828
- return Q("npm config get prefix", { encoding: "utf-8" }).trim();
1828
+ return X("npm config get prefix", { encoding: "utf-8" }).trim();
1829
1829
  } catch {
1830
1830
  return null;
1831
1831
  }
1832
1832
  }
1833
1833
  async function po() {
1834
1834
  try {
1835
- const o = lo().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
1835
+ const o = lo().replace(/\/$/, ""), t = await fetch(`${o}/${te}/latest`);
1836
1836
  return t.ok ? (await t.json()).version : null;
1837
1837
  } catch {
1838
1838
  return null;
@@ -1841,14 +1841,14 @@ async function po() {
1841
1841
  function mo(o, t) {
1842
1842
  const e = o.split(".").map(Number), n = t.split(".").map(Number);
1843
1843
  for (let s = 0; s < Math.max(e.length, n.length); s++) {
1844
- const i = e[s] || 0, r = n[s] || 0;
1845
- if (i > r) return 1;
1846
- if (i < r) return -1;
1844
+ const i = e[s] || 0, a = n[s] || 0;
1845
+ if (i > a) return 1;
1846
+ if (i < a) return -1;
1847
1847
  }
1848
1848
  return 0;
1849
1849
  }
1850
1850
  async function uo(o) {
1851
- const t = z({
1851
+ const t = Y({
1852
1852
  text: "Checking for updates...",
1853
1853
  color: "cyan"
1854
1854
  }).start(), e = await po();
@@ -1859,7 +1859,7 @@ async function uo(o) {
1859
1859
  `);
1860
1860
  let n;
1861
1861
  try {
1862
- n = await st({
1862
+ n = await it({
1863
1863
  message: "Would you like to update now?",
1864
1864
  choices: [
1865
1865
  { name: "Yes, update now", value: !0 },
@@ -1873,51 +1873,51 @@ async function uo(o) {
1873
1873
  `), process.exit(0)), s;
1874
1874
  }
1875
1875
  if (n) {
1876
- const s = z({
1877
- text: `Updating ${Z} to v${e}...`,
1876
+ const s = Y({
1877
+ text: `Updating ${te} to v${e}...`,
1878
1878
  color: "green"
1879
- }).start(), i = `npm install -g ${Z}@latest`, r = co();
1879
+ }).start(), i = `npm install -g ${te}@latest`, a = co();
1880
1880
  try {
1881
- Q(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
1881
+ X(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
1882
1882
  } catch {
1883
1883
  s.stop(), console.log(`
1884
1884
  🔐 Elevated permissions required.
1885
1885
  `);
1886
1886
  try {
1887
- if (De) {
1888
- const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${r ? `install -g ${Z}@latest --prefix \\"${r}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
1889
- Q(`powershell -Command "${d}"`, { stdio: "inherit" });
1887
+ if (Le) {
1888
+ const c = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${a ? `install -g ${te}@latest --prefix \\"${a}\\"` : `install -g ${te}@latest`}' -Verb RunAs -Wait`;
1889
+ X(`powershell -Command "${c}"`, { stdio: "inherit" });
1890
1890
  } else {
1891
- const l = r ? `sudo npm install -g ${Z}@latest --prefix "${r}"` : `sudo ${i}`;
1892
- Q(l, { stdio: "inherit" });
1891
+ const r = a ? `sudo npm install -g ${te}@latest --prefix "${a}"` : `sudo ${i}`;
1892
+ X(r, { stdio: "inherit" });
1893
1893
  }
1894
1894
  console.log(`
1895
1895
  ✅ Updated to v${e}`);
1896
1896
  } catch {
1897
1897
  console.log(`
1898
1898
  ❌ Update failed`);
1899
- const d = De ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
1899
+ const c = Le ? `npm install -g ${te}@latest (run as Administrator)` : `sudo npm install -g ${te}@latest`;
1900
1900
  console.log(`
1901
- Please run manually: ${d}
1901
+ Please run manually: ${c}
1902
1902
  `), process.exit(1);
1903
1903
  }
1904
1904
  }
1905
1905
  let p = null;
1906
1906
  try {
1907
1907
  let m;
1908
- r ? m = De ? Ae(r, "node_modules") : Ae(r, "lib", "node_modules") : m = Q("npm root -g", { encoding: "utf-8" }).trim();
1909
- const l = Ae(m, Z, "package.json"), d = Et(l, "utf-8");
1910
- p = JSON.parse(d).version;
1908
+ a ? m = Le ? De(a, "node_modules") : De(a, "lib", "node_modules") : m = X("npm root -g", { encoding: "utf-8" }).trim();
1909
+ const r = De(m, te, "package.json"), c = Et(r, "utf-8");
1910
+ p = JSON.parse(c).version;
1911
1911
  } catch {
1912
1912
  }
1913
1913
  if (p === e)
1914
1914
  return console.log(`
1915
1915
  🔄 Restarting...
1916
- `), Mt(process.argv[0], process.argv.slice(1), {
1916
+ `), Pt(process.argv[0], process.argv.slice(1), {
1917
1917
  stdio: "inherit",
1918
1918
  shell: !0
1919
- }).on("close", (l) => {
1920
- process.exit(l || 0);
1919
+ }).on("close", (r) => {
1920
+ process.exit(r || 0);
1921
1921
  }), !0;
1922
1922
  console.log(`
1923
1923
  Please run myop again to use the new version.
@@ -1925,15 +1925,15 @@ Please run myop again to use the new version.
1925
1925
  }
1926
1926
  return !1;
1927
1927
  }
1928
- const Je = R.join(at.homedir(), ".myop"), ze = R.join(Je, "preferences.json");
1928
+ const ze = _.join(lt.homedir(), ".myop"), We = _.join(ze, "preferences.json");
1929
1929
  function fo() {
1930
- P.existsSync(Je) || P.mkdirSync(Je, { recursive: !0, mode: 448 });
1930
+ P.existsSync(ze) || P.mkdirSync(ze, { recursive: !0, mode: 448 });
1931
1931
  }
1932
- function ht() {
1932
+ function yt() {
1933
1933
  try {
1934
- if (!P.existsSync(ze))
1934
+ if (!P.existsSync(We))
1935
1935
  return {};
1936
- const o = P.readFileSync(ze, "utf8");
1936
+ const o = P.readFileSync(We, "utf8");
1937
1937
  return JSON.parse(o);
1938
1938
  } catch {
1939
1939
  return {};
@@ -1941,19 +1941,19 @@ function ht() {
1941
1941
  }
1942
1942
  function go(o) {
1943
1943
  fo();
1944
- const e = { ...ht(), ...o };
1945
- P.writeFileSync(ze, JSON.stringify(e, null, 2), {
1944
+ const e = { ...yt(), ...o };
1945
+ P.writeFileSync(We, JSON.stringify(e, null, 2), {
1946
1946
  mode: 384
1947
1947
  });
1948
1948
  }
1949
1949
  function ho() {
1950
- return ht().defaultOrganization || null;
1950
+ return yt().defaultOrganization || null;
1951
1951
  }
1952
- function Le({ id: o, name: t }) {
1952
+ function Ue({ id: o, name: t }) {
1953
1953
  go({ defaultOrganization: { id: o, name: t } });
1954
1954
  }
1955
1955
  async function yo(o, t, e, n = {}) {
1956
- var p, m, l;
1956
+ var p, m, r;
1957
1957
  const s = await fetch(`${o}/mcp`, {
1958
1958
  method: "POST",
1959
1959
  headers: {
@@ -1975,18 +1975,18 @@ async function yo(o, t, e, n = {}) {
1975
1975
  const i = await s.json();
1976
1976
  if (i.error)
1977
1977
  throw new Error(i.error.message || "MCP error");
1978
- const r = (l = (m = (p = i.result) == null ? void 0 : p.content) == null ? void 0 : m[0]) == null ? void 0 : l.text;
1979
- if (!r)
1978
+ const a = (r = (m = (p = i.result) == null ? void 0 : p.content) == null ? void 0 : m[0]) == null ? void 0 : r.text;
1979
+ if (!a)
1980
1980
  throw new Error(`No content returned from ${e}`);
1981
- return JSON.parse(r);
1981
+ return JSON.parse(a);
1982
1982
  }
1983
1983
  const wo = (o) => new Promise((t) => setTimeout(t, o));
1984
- function re(o) {
1984
+ function ae(o) {
1985
1985
  var e, n;
1986
1986
  const t = (o == null ? void 0 : o.message) || "";
1987
1987
  return t.includes("ECONNREFUSED") || t.includes("ENOTFOUND") || t.includes("ETIMEDOUT") || t.includes("fetch failed") || t.includes("network") || (o == null ? void 0 : o.code) === "ECONNREFUSED" || ((e = o == null ? void 0 : o.cause) == null ? void 0 : e.code) === "ECONNREFUSED" || ((n = o == null ? void 0 : o.cause) == null ? void 0 : n.code) === "ENOTFOUND";
1988
1988
  }
1989
- function ae(o) {
1989
+ function le(o) {
1990
1990
  console.error(`
1991
1991
  This usually happens in sandboxed environments (Claude Web, containers)`), console.error(` where outbound HTTP is restricted.
1992
1992
  `), console.error(" [MYOP_MCP_FALLBACK] Use Myop MCP tools instead:"), console.error(o === "push" ? " - Use the upload_component MCP tool with htmlContent parameter" : o === "pull" ? " - Use the get_component MCP tool" : " - Use list_organizations + list_components MCP tools"), console.error(" - Do NOT use presigned URL / curl flow — same network restrictions apply"), console.error("");
@@ -1994,18 +1994,18 @@ function ae(o) {
1994
1994
  const vo = () => {
1995
1995
  let o = new URL(import.meta.url).pathname;
1996
1996
  process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1997
- const t = R.dirname(o);
1998
- return R.join(t, "skills");
1997
+ const t = _.dirname(o);
1998
+ return _.join(t, "skills");
1999
1999
  }, So = (o) => {
2000
2000
  try {
2001
- const t = R.join(o, "package.json");
2001
+ const t = _.join(o, "package.json");
2002
2002
  if (!P.existsSync(t)) return [];
2003
2003
  const e = JSON.parse(P.readFileSync(t, "utf-8"));
2004
2004
  return Object.keys({ ...e.dependencies, ...e.devDependencies });
2005
2005
  } catch {
2006
2006
  return [];
2007
2007
  }
2008
- }, Qe = async (o) => {
2008
+ }, Ze = async (o) => {
2009
2009
  const t = vo();
2010
2010
  if (!P.existsSync(t))
2011
2011
  return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
@@ -2015,31 +2015,31 @@ const vo = () => {
2015
2015
  { deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
2016
2016
  { deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
2017
2017
  { deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
2018
- ], i = s.filter(({ deps: l }) => l.some((d) => e.includes(d))).map(({ skill: l }) => l), r = s.flatMap(({ deps: l }) => l.filter((d) => e.includes(d)));
2019
- i.length > 0 ? n.push(...i) : n.push(...s.map((l) => l.skill));
2020
- const p = n.map((l) => `--skill ${l}`).join(" "), m = `npx -y skills add "${t}" ${p} --agent '*' --copy -y`;
2021
- return Q(m, { cwd: o, stdio: "pipe" }), { success: !0, detected: r, skillNames: n };
2018
+ ], i = s.filter(({ deps: r }) => r.some((c) => e.includes(c))).map(({ skill: r }) => r), a = s.flatMap(({ deps: r }) => r.filter((c) => e.includes(c)));
2019
+ i.length > 0 ? n.push(...i) : n.push(...s.map((r) => r.skill));
2020
+ const p = n.map((r) => `--skill ${r}`).join(" "), m = `npx -y skills add "${t}" ${p} --agent '*' --copy -y`;
2021
+ return X(m, { cwd: o, stdio: "pipe" }), { success: !0, detected: a, skillNames: n };
2022
2022
  } catch (e) {
2023
2023
  return console.info("Failed to install skills:", e.message), { success: !1 };
2024
2024
  }
2025
- }, Ze = (o = ".", t = 3, e = 0) => {
2025
+ }, qe = (o = ".", t = 3, e = 0) => {
2026
2026
  const n = [];
2027
2027
  if (e > t) return n;
2028
2028
  try {
2029
2029
  const s = P.readdirSync(o, { withFileTypes: !0 });
2030
2030
  for (const i of s) {
2031
- const r = R.join(o, i.name);
2031
+ const a = _.join(o, i.name);
2032
2032
  if (i.isDirectory()) {
2033
2033
  if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
2034
2034
  continue;
2035
- n.push(...Ze(r, t, e + 1));
2035
+ n.push(...qe(a, t, e + 1));
2036
2036
  } else if (i.name === "myop.config.json")
2037
2037
  try {
2038
- const p = P.readFileSync(r, "utf-8"), m = JSON.parse(p);
2038
+ const p = P.readFileSync(a, "utf-8"), m = JSON.parse(p);
2039
2039
  n.push({
2040
2040
  path: o,
2041
- configPath: r,
2042
- name: m.name || m.componentName || R.basename(o),
2041
+ configPath: a,
2042
+ name: m.name || m.componentName || _.basename(o),
2043
2043
  componentId: m.componentId || null,
2044
2044
  config: m
2045
2045
  });
@@ -2051,7 +2051,7 @@ const vo = () => {
2051
2051
  return n;
2052
2052
  };
2053
2053
  v.executionPath = process.cwd();
2054
- const Ee = (o = !1) => {
2054
+ const Ie = (o = !1) => {
2055
2055
  const t = v.program.getOptionValue("verbose");
2056
2056
  t || (console.info = () => {
2057
2057
  }), console.info("📝 verbose mode on"), v.options = {
@@ -2069,7 +2069,7 @@ const Ee = (o = !1) => {
2069
2069
  author: "@myop-cli",
2070
2070
  flows: []
2071
2071
  };
2072
- return Ve(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
2072
+ return Ye(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
2073
2073
  } catch {
2074
2074
  return console.info("Error details :", e), { configFound: !1, error: e };
2075
2075
  }
@@ -2078,36 +2078,36 @@ const Ee = (o = !1) => {
2078
2078
  }
2079
2079
  };
2080
2080
  [
2081
- new Ue(),
2081
+ new He(),
2082
2082
  ...Lt
2083
2083
  ];
2084
- const xo = "0.1.56";
2085
- v.program = new Pt();
2084
+ const xo = "0.1.57";
2085
+ v.program = new Mt();
2086
2086
  v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(xo);
2087
- v.program.addOption(new fe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
2088
- v.program.addOption(new fe("-h, --help", "Show helpful information"));
2089
- v.program.addOption(new fe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
2090
- v.program.addOption(new fe("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
2091
- v.program.addOption(new fe("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
2087
+ v.program.addOption(new ge("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
2088
+ v.program.addOption(new ge("-h, --help", "Show helpful information"));
2089
+ v.program.addOption(new ge("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
2090
+ v.program.addOption(new ge("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
2091
+ v.program.addOption(new ge("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
2092
2092
  v.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, t) => {
2093
- Ee(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && ct._action(t), process.exit();
2093
+ Ie(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && dt._action(t), process.exit();
2094
2094
  });
2095
2095
  v.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, t) => {
2096
- Ee(), console.info("removing ", o, t, v.options.configPath), o === "flow" && dt._action(t), process.exit();
2096
+ Ie(), console.info("removing ", o, t, v.options.configPath), o === "flow" && pt._action(t), process.exit();
2097
2097
  });
2098
2098
  v.program.command("install").description("Install Myop assets").action(async () => {
2099
- Ee(), await lt.action();
2099
+ Ie(), await ct.action();
2100
2100
  });
2101
2101
  v.program.command("login").description("Authenticate with Myop platform").action(async () => {
2102
2102
  try {
2103
- await me();
2103
+ await ue();
2104
2104
  } catch (o) {
2105
2105
  console.error("Login failed:", o.message), process.exit(1);
2106
2106
  }
2107
2107
  process.exit(0);
2108
2108
  });
2109
2109
  v.program.command("logout").description("Clear stored credentials").action(async () => {
2110
- await gt(), process.exit(0);
2110
+ await ht(), process.exit(0);
2111
2111
  });
2112
2112
  v.program.command("whoami").description("Show current authenticated user").action(async () => {
2113
2113
  const o = Pe();
@@ -2125,7 +2125,7 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
2125
2125
  process.exit(0);
2126
2126
  });
2127
2127
  v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
2128
- var x, $, g;
2128
+ var S, $, h;
2129
2129
  const t = v.program.getOptionValue("config") || "./myop.config.json";
2130
2130
  let e = {};
2131
2131
  if (P.existsSync(t))
@@ -2135,7 +2135,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
2135
2135
  console.error(`⚠️ Failed to parse ${t}:`, u.message);
2136
2136
  }
2137
2137
  o && (e.componentId = o);
2138
- const n = e.name || e.componentName || R.basename(process.cwd());
2138
+ const n = e.name || e.componentName || _.basename(process.cwd());
2139
2139
  console.log(`
2140
2140
  📋 Component: ${n}`);
2141
2141
  let s = null, i = !1;
@@ -2155,51 +2155,51 @@ v.program.command("push").description("Upload component to Myop platform").argum
2155
2155
  else if (i) {
2156
2156
  const { exec: u } = await import("child_process");
2157
2157
  let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
2158
- const O = (M = !1) => new Promise((j) => {
2159
- const C = z(M ? "Retrying build..." : "Building project...").start();
2160
- u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (N, k, L) => {
2158
+ const k = (b = !1) => new Promise((A) => {
2159
+ const M = Y(b ? "Retrying build..." : "Building project...").start();
2160
+ u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (N, R, U) => {
2161
2161
  if (!N) {
2162
- C.succeed("Build completed"), j(!0);
2162
+ M.succeed("Build completed"), A(!0);
2163
2163
  return;
2164
2164
  }
2165
- if (C.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
2166
- const D = await pt(N, k, L, u, E);
2165
+ if (M.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
2166
+ const D = await mt(N, R, U, u, E);
2167
2167
  if (E = { ...E, ...D }, D.handled) {
2168
- const F = await O(!0);
2169
- j(F);
2168
+ const F = await k(!0);
2169
+ A(F);
2170
2170
  return;
2171
2171
  }
2172
2172
  }
2173
- console.error(N.message), j(!1);
2173
+ console.error(N.message), A(!1);
2174
2174
  });
2175
2175
  });
2176
- await O() || process.exit(1);
2176
+ await k() || process.exit(1);
2177
2177
  }
2178
- let r;
2178
+ let a;
2179
2179
  if (s)
2180
- r = s;
2180
+ a = s;
2181
2181
  else if (P.existsSync("./dist/index.html"))
2182
- r = "./dist/index.html";
2182
+ a = "./dist/index.html";
2183
2183
  else {
2184
2184
  const u = P.readdirSync(".").filter(
2185
2185
  (E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
2186
2186
  );
2187
- u.length === 1 ? r = u[0] : (console.error("❌ No HTML file found to upload."), console.log(" Expected: a single .html file in root or ./dist/index.html"), process.exit(1));
2187
+ u.length === 1 ? a = u[0] : (console.error("❌ No HTML file found to upload."), console.log(" Expected: a single .html file in root or ./dist/index.html"), process.exit(1));
2188
2188
  }
2189
- const p = P.readFileSync(r, "utf-8");
2190
- console.log(` File: ${r} (${(p.length / 1024).toFixed(1)} KB)`);
2189
+ const p = P.readFileSync(a, "utf-8");
2190
+ console.log(` File: ${a} (${(p.length / 1024).toFixed(1)} KB)`);
2191
2191
  let m;
2192
2192
  try {
2193
- m = await Ke();
2193
+ m = await Qe();
2194
2194
  } catch (u) {
2195
- re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("❌ Authentication failed:", u.message), console.error(`
2195
+ ae(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), le("push")) : (console.error("❌ Authentication failed:", u.message), console.error(`
2196
2196
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2197
2197
  `)), process.exit(1);
2198
2198
  }
2199
- const l = Me();
2200
- let d = z("Uploading...").start(), w;
2199
+ const r = Ee();
2200
+ let c = Y("Uploading...").start(), y;
2201
2201
  try {
2202
- const u = await fetch(`${l}/mcp`, {
2202
+ const u = await fetch(`${r}/mcp`, {
2203
2203
  method: "POST",
2204
2204
  headers: {
2205
2205
  "Content-Type": "application/json",
@@ -2225,27 +2225,27 @@ v.program.command("push").description("Upload component to Myop platform").argum
2225
2225
  const E = await u.json();
2226
2226
  if (E.error)
2227
2227
  throw new Error(E.error.message);
2228
- const O = (g = ($ = (x = E.result) == null ? void 0 : x.content) == null ? void 0 : $[0]) == null ? void 0 : g.text;
2229
- if (w = JSON.parse(O), !w.success)
2230
- throw new Error(w.error);
2231
- d.succeed("Pushed successfully");
2228
+ const k = (h = ($ = (S = E.result) == null ? void 0 : S.content) == null ? void 0 : $[0]) == null ? void 0 : h.text;
2229
+ if (y = JSON.parse(k), !y.success)
2230
+ throw new Error(y.error);
2231
+ c.succeed("Pushed successfully");
2232
2232
  } catch (u) {
2233
- d.fail("Upload failed"), re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", u.message), process.exit(1);
2233
+ c.fail("Upload failed"), ae(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), le("push")) : console.error(" ", u.message), process.exit(1);
2234
2234
  }
2235
- if (w.isNewComponent || !e.componentId || e.componentId === "DEV") {
2236
- e.componentId = w.componentId, e.organization = w.orgId, e.name || (e.name = w.componentName);
2235
+ if (y.isNewComponent || !e.componentId || e.componentId === "DEV") {
2236
+ e.componentId = y.componentId, e.organization = y.orgId, e.name || (e.name = y.componentName);
2237
2237
  try {
2238
2238
  P.writeFileSync(t, JSON.stringify(e, null, 2));
2239
2239
  } catch (u) {
2240
- console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${w.componentId}" manually`);
2240
+ console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
2241
2241
  }
2242
2242
  }
2243
2243
  console.log(`
2244
- ${w.componentName}`), console.log(` ${w.dashboardUrl}
2244
+ ${y.componentName}`), console.log(` ${y.dashboardUrl}
2245
2245
  `), process.exit(0);
2246
2246
  });
2247
2247
  v.program.command("pull").description("Download component HTML from Myop platform").argument("[componentId]", "Component ID to pull (overrides myop.config.json)").option("-o, --output <path>", "Output file path (default: index.html or dist/index.html)").option("-e, --env <environment>", "Pull the variant released to this environment (e.g., staging, production)").action(async (o, t) => {
2248
- var u, E, O;
2248
+ var U, D, F;
2249
2249
  const e = v.program.getOptionValue("config") || "./myop.config.json";
2250
2250
  let n = {};
2251
2251
  if (P.existsSync(e))
@@ -2256,24 +2256,22 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2256
2256
  const s = o || n.componentId;
2257
2257
  (!s || s === "DEV") && (console.error("❌ No component ID provided."), console.log(" Pass a component ID: myop pull <componentId>"), console.log(" Or ensure myop.config.json has a valid componentId."), process.exit(1));
2258
2258
  const i = n.name || n.componentName || s;
2259
- console.log(`
2260
- 📥 Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
2261
- let r;
2259
+ let a;
2262
2260
  try {
2263
- r = await Ke();
2264
- } catch (b) {
2265
- re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("❌ Authentication failed:", b.message), console.error(`
2261
+ a = await Qe();
2262
+ } catch (T) {
2263
+ ae(T) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), le("pull")) : (console.error("❌ Authentication failed:", T.message), console.error(`
2266
2264
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2267
2265
  `)), process.exit(1);
2268
2266
  }
2269
- const p = Me(), m = z("Fetching component...").start();
2270
- let l;
2267
+ const p = Ee(), m = Y("Fetching component...").start();
2268
+ let r;
2271
2269
  try {
2272
- const b = await fetch(`${p}/mcp`, {
2270
+ const T = await fetch(`${p}/mcp`, {
2273
2271
  method: "POST",
2274
2272
  headers: {
2275
2273
  "Content-Type": "application/json",
2276
- Authorization: `Bearer ${r.accessToken}`
2274
+ Authorization: `Bearer ${a.accessToken}`
2277
2275
  },
2278
2276
  body: JSON.stringify({
2279
2277
  jsonrpc: "2.0",
@@ -2285,68 +2283,96 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2285
2283
  }
2286
2284
  })
2287
2285
  });
2288
- if (!b.ok)
2289
- throw new Error(`Server returned ${b.status}`);
2290
- const M = await b.json();
2291
- if (M.error)
2292
- throw new Error(M.error.message);
2293
- const j = (O = (E = (u = M.result) == null ? void 0 : u.content) == null ? void 0 : E[0]) == null ? void 0 : O.text;
2294
- l = JSON.parse(j), !l.success && !l.html && (m.fail("Failed to fetch component"), console.error(" ", l.error || "No HTML content returned"), l.message && console.error(" ", l.message), process.exit(1)), m.succeed("Component fetched");
2295
- } catch (b) {
2296
- m.fail("Failed to fetch component"), re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", b.message), process.exit(1);
2297
- }
2298
- let d = t.output;
2299
- d || (P.existsSync("./dist/index.html") ? d = "./dist/index.html" : d = "./index.html");
2300
- const w = l.htmlContent || l.html, x = R.dirname(d);
2301
- x && !P.existsSync(x) && P.mkdirSync(x, { recursive: !0 }), P.writeFileSync(d, w), console.log(` Saved to: ${d} (${(w.length / 1024).toFixed(1)} KB)`);
2302
- const $ = P.existsSync(e);
2303
- let g = !1;
2304
- if ($ ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
2305
- name: l.name || R.basename(process.cwd()),
2286
+ if (!T.ok)
2287
+ throw new Error(`Server returned ${T.status}`);
2288
+ const O = await T.json();
2289
+ if (O.error)
2290
+ throw new Error(O.error.message);
2291
+ const z = (F = (D = (U = O.result) == null ? void 0 : U.content) == null ? void 0 : D[0]) == null ? void 0 : F.text;
2292
+ r = JSON.parse(z), !r.success && !r.html && (m.fail("Failed to fetch component"), console.error(" ", r.error || "No HTML content returned"), r.message && console.error(" ", r.message), process.exit(1)), m.succeed("Component fetched");
2293
+ } catch (T) {
2294
+ m.fail("Failed to fetch component"), ae(T) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), le("pull")) : console.error(" ", T.message), process.exit(1);
2295
+ }
2296
+ let c = t.output;
2297
+ c || (P.existsSync("./dist/index.html") ? c = "./dist/index.html" : c = "./index.html");
2298
+ const y = r.htmlContent || r.html;
2299
+ let S = [];
2300
+ P.existsSync(c) && (S = P.readFileSync(c, "utf-8").split(`
2301
+ `));
2302
+ const $ = y.split(`
2303
+ `), h = _.dirname(c);
2304
+ h && !P.existsSync(h) && P.mkdirSync(h, { recursive: !0 }), P.writeFileSync(c, y);
2305
+ const u = P.existsSync(e);
2306
+ let E = !1;
2307
+ if (u ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, E = !0), !n.name && r.name && (n.name = r.name, E = !0)) : (n = {
2308
+ name: r.name || _.basename(process.cwd()),
2306
2309
  componentId: s,
2307
2310
  type: "html",
2308
2311
  author: "@myop-cli",
2309
2312
  HMR: !0
2310
- }, g = !0), g)
2313
+ }, E = !0), E)
2311
2314
  try {
2312
- P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${$ ? "Updated" : "Created"} ${e}`);
2313
- } catch (b) {
2314
- console.log(` ⚠️ Could not write ${e}: ${b.message}`);
2315
+ P.writeFileSync(e, JSON.stringify(n, null, 2));
2316
+ } catch {
2315
2317
  }
2318
+ const k = (T) => {
2319
+ if (!T) return "";
2320
+ const O = Math.floor((Date.now() - new Date(T).getTime()) / 1e3);
2321
+ if (O < 60) return "just now";
2322
+ const z = Math.floor(O / 60);
2323
+ if (z < 60) return `${z} minute${z !== 1 ? "s" : ""} ago`;
2324
+ const ee = Math.floor(z / 60);
2325
+ if (ee < 24) return `${ee} hour${ee !== 1 ? "s" : ""} ago`;
2326
+ const W = Math.floor(ee / 24);
2327
+ return `${W} day${W !== 1 ? "s" : ""} ago`;
2328
+ }, C = r.latestVariant, b = r.component || r, A = (b == null ? void 0 : b.name) || i, M = t.env ? ` [${t.env}]` : "";
2316
2329
  console.log(`
2317
- Pull completed!
2318
- `), process.exit(0);
2330
+ From myop.dev (${A})${M}`), C != null && C.name ? console.log(` * variant ${C.name} -> ${c}`) : console.log(` * -> ${c}`);
2331
+ const N = (C == null ? void 0 : C.updatedBy) || (b == null ? void 0 : b.updatedBy), R = (C == null ? void 0 : C.updatedOn) || (b == null ? void 0 : b.updatedOn);
2332
+ if (N || R) {
2333
+ const T = [N, k(R)].filter(Boolean);
2334
+ console.log(` author ${T.join(", ")}`);
2335
+ }
2336
+ if (S.length > 0 && S.join(`
2337
+ `) === y)
2338
+ console.log("Already up to date.");
2339
+ else if (S.length > 0) {
2340
+ const T = Math.max(0, $.length - S.length), O = Math.max(0, S.length - $.length), z = Math.abs($.length - S.length), W = z > 0 ? Math.min(1, 20 / z) : 0, oe = Math.round(T * W) || (T > 0 ? 1 : 0), Q = Math.round(O * W) || (O > 0 ? 1 : 0), Oe = "\x1B[32m" + "+".repeat(oe) + "\x1B[31m" + "-".repeat(Q) + "\x1B[0m";
2341
+ console.log(` ${_.basename(c)} | ${Oe}`), console.log(` 1 file changed, \x1B[32m+${T}\x1B[0m \x1B[31m-${O}\x1B[0m lines`);
2342
+ } else
2343
+ console.log(` ${_.basename(c)} (new file, ${$.length} lines)`);
2344
+ console.log(""), process.exit(0);
2319
2345
  });
2320
2346
  v.program.command("list").description("Browse and pull/push remote components").option("--org <orgId>", "Organization ID to use").action(async (o) => {
2321
2347
  const { search: t, select: e } = await import("@inquirer/prompts");
2322
2348
  let n;
2323
2349
  try {
2324
- n = await Ke();
2325
- } catch (g) {
2326
- re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("❌ Authentication failed:", g.message), console.error(`
2350
+ n = await Qe();
2351
+ } catch (h) {
2352
+ ae(h) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), le("list")) : (console.error("❌ Authentication failed:", h.message), console.error(`
2327
2353
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2328
2354
  `)), process.exit(1);
2329
2355
  }
2330
- const s = Me(), i = (g, u) => yo(s, n.accessToken, g, u);
2331
- let r = z("Loading organizations...").start(), p;
2356
+ const s = Ee(), i = (h, u) => yo(s, n.accessToken, h, u);
2357
+ let a = Y("Loading organizations...").start(), p;
2332
2358
  try {
2333
- const g = await i("list_organizations");
2334
- if (p = g.organizations || g, !Array.isArray(p))
2359
+ const h = await i("list_organizations");
2360
+ if (p = h.organizations || h, !Array.isArray(p))
2335
2361
  throw new Error("Unexpected response from list_organizations");
2336
- } catch (g) {
2337
- r.fail("Failed to load organizations"), re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", g.message), process.exit(1);
2362
+ } catch (h) {
2363
+ a.fail("Failed to load organizations"), ae(h) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), le("list")) : console.error(" ", h.message), process.exit(1);
2338
2364
  }
2339
- p.length === 0 && (r.fail("No organizations found for this account"), process.exit(1)), r.stop();
2340
- let m, l;
2365
+ p.length === 0 && (a.fail("No organizations found for this account"), process.exit(1)), a.stop();
2366
+ let m, r;
2341
2367
  if (o.org) {
2342
- const g = p.find((u) => u.id === o.org || u._id === o.org);
2343
- g || (console.error(`Organization "${o.org}" not found. Available:`), p.forEach((u) => console.log(` ${u.id || u._id} ${u.name}`)), process.exit(1)), m = g.id || g._id, l = g.name, Le({ id: m, name: l });
2368
+ const h = p.find((u) => u.id === o.org || u._id === o.org);
2369
+ h || (console.error(`Organization "${o.org}" not found. Available:`), p.forEach((u) => console.log(` ${u.id || u._id} ${u.name}`)), process.exit(1)), m = h.id || h._id, r = h.name, Ue({ id: m, name: r });
2344
2370
  } else {
2345
- const g = ho();
2346
- if (g && p.find((u) => (u.id || u._id) === g.id))
2347
- m = g.id, l = g.name;
2371
+ const h = ho();
2372
+ if (h && p.find((u) => (u.id || u._id) === h.id))
2373
+ m = h.id, r = h.name;
2348
2374
  else if (p.length === 1)
2349
- m = p[0].id || p[0]._id, l = p[0].name, Le({ id: m, name: l });
2375
+ m = p[0].id || p[0]._id, r = p[0].name, Ue({ id: m, name: r });
2350
2376
  else
2351
2377
  try {
2352
2378
  const u = await e({
@@ -2356,7 +2382,7 @@ v.program.command("list").description("Browse and pull/push remote components").
2356
2382
  value: { id: E.id || E._id, name: E.name }
2357
2383
  }))
2358
2384
  });
2359
- m = u.id, l = u.name, Le({ id: m, name: l });
2385
+ m = u.id, r = u.name, Ue({ id: m, name: r });
2360
2386
  } catch (u) {
2361
2387
  throw u.name === "ExitPromptError" && (console.log(`
2362
2388
 
@@ -2364,146 +2390,146 @@ v.program.command("list").description("Browse and pull/push remote components").
2364
2390
  `), process.exit(0)), u;
2365
2391
  }
2366
2392
  }
2367
- console.log(` Using organization: ${l}`), r = z("Loading components...").start();
2368
- let d;
2393
+ console.log(` Using organization: ${r}`), a = Y("Loading components...").start();
2394
+ let c;
2369
2395
  try {
2370
- const g = await i("list_components", { organizationId: m });
2371
- if (d = g.components || g, !Array.isArray(d))
2396
+ const h = await i("list_components", { organizationId: m });
2397
+ if (c = h.components || h, !Array.isArray(c))
2372
2398
  throw new Error("Unexpected response from list_components");
2373
- } catch (g) {
2374
- r.fail("Failed to load components"), console.error(" ", g.message), process.exit(1);
2399
+ } catch (h) {
2400
+ a.fail("Failed to load components"), console.error(" ", h.message), process.exit(1);
2375
2401
  }
2376
- r.stop(), d.length === 0 && (console.log(` No components found in this organization.
2377
- `), process.exit(0)), console.log(` ${l} - ${d.length} component(s)
2402
+ a.stop(), c.length === 0 && (console.log(` No components found in this organization.
2403
+ `), process.exit(0)), console.log(` ${r} - ${c.length} component(s)
2378
2404
  `);
2379
- const w = [];
2405
+ const y = [];
2380
2406
  for (; ; ) {
2381
- const g = `[Done - pull/push ${w.length} selected]`, u = "__done__", E = new Set(w.map((M) => M.id || M._id || M.componentId));
2382
- let O;
2407
+ const h = `[Done - pull/push ${y.length} selected]`, u = "__done__", E = new Set(y.map((b) => b.id || b._id || b.componentId));
2408
+ let k;
2383
2409
  try {
2384
- O = await t({
2410
+ k = await t({
2385
2411
  message: "Search & select components:",
2386
- source: (M) => {
2387
- const j = (M || "").toLowerCase(), C = d.filter((k) => {
2388
- const L = k.id || k._id || k.componentId;
2389
- return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
2412
+ source: (b) => {
2413
+ const A = (b || "").toLowerCase(), M = c.filter((R) => {
2414
+ const U = R.id || R._id || R.componentId;
2415
+ return E.has(U) ? !1 : A ? (R.name || "").toLowerCase().includes(A) : !0;
2390
2416
  }), N = [
2391
- { name: g, value: u }
2417
+ { name: h, value: u }
2392
2418
  ];
2393
- for (const k of C) {
2394
- const L = k.id || k._id || k.componentId, D = L ? L.substring(0, 8) + "..." : "";
2419
+ for (const R of M) {
2420
+ const U = R.id || R._id || R.componentId, D = U ? U.substring(0, 8) + "..." : "";
2395
2421
  N.push({
2396
- name: `${k.name} (${D})`,
2397
- value: L
2422
+ name: `${R.name} (${D})`,
2423
+ value: U
2398
2424
  });
2399
2425
  }
2400
2426
  return N;
2401
2427
  }
2402
2428
  });
2403
- } catch (M) {
2404
- throw M.name === "ExitPromptError" && (console.log(`
2429
+ } catch (b) {
2430
+ throw b.name === "ExitPromptError" && (console.log(`
2405
2431
 
2406
2432
  👋 Goodbye!
2407
- `), process.exit(0)), M;
2433
+ `), process.exit(0)), b;
2408
2434
  }
2409
- if (O === u)
2435
+ if (k === u)
2410
2436
  break;
2411
- const b = d.find((M) => (M.id || M._id || M.componentId) === O);
2412
- b && (w.push(b), console.log(` + ${b.name}`));
2437
+ const C = c.find((b) => (b.id || b._id || b.componentId) === k);
2438
+ C && (y.push(C), console.log(` + ${C.name}`));
2413
2439
  }
2414
- w.length === 0 && (console.log(` No components selected.
2440
+ y.length === 0 && (console.log(` No components selected.
2415
2441
  `), process.exit(0));
2416
- let x;
2442
+ let S;
2417
2443
  try {
2418
- x = await e({
2419
- message: `${w.length} component(s) selected:`,
2444
+ S = await e({
2445
+ message: `${y.length} component(s) selected:`,
2420
2446
  choices: [
2421
2447
  { name: "Pull selected", value: "pull" },
2422
2448
  { name: "Push selected", value: "push" },
2423
2449
  { name: "Cancel", value: "cancel" }
2424
2450
  ]
2425
2451
  });
2426
- } catch (g) {
2427
- throw g.name === "ExitPromptError" && (console.log(`
2452
+ } catch (h) {
2453
+ throw h.name === "ExitPromptError" && (console.log(`
2428
2454
 
2429
2455
  👋 Goodbye!
2430
- `), process.exit(0)), g;
2456
+ `), process.exit(0)), h;
2431
2457
  }
2432
- x === "cancel" && (console.log(` Cancelled.
2458
+ S === "cancel" && (console.log(` Cancelled.
2433
2459
  `), process.exit(0));
2434
- const $ = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2435
- if (x === "pull") {
2460
+ const $ = (h) => h.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2461
+ if (S === "pull") {
2436
2462
  console.log(`
2437
- Pulling ${w.length} components...
2463
+ Pulling ${y.length} components...
2438
2464
  `);
2439
- const g = await Promise.all(w.map(async (O) => {
2440
- const b = O.id || O._id || O.componentId;
2465
+ const h = await Promise.all(y.map(async (k) => {
2466
+ const C = k.id || k._id || k.componentId;
2441
2467
  try {
2442
- const M = await i("get_component", { componentId: b }), j = $(O.name);
2443
- P.mkdirSync(j, { recursive: !0 });
2444
- const C = M.htmlContent || M.html;
2445
- if (!C)
2468
+ const b = await i("get_component", { componentId: C }), A = $(k.name);
2469
+ P.mkdirSync(A, { recursive: !0 });
2470
+ const M = b.htmlContent || b.html;
2471
+ if (!M)
2446
2472
  throw new Error("No HTML content returned");
2447
- return P.writeFileSync(R.join(j, "index.html"), C), P.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
2448
- name: O.name,
2449
- componentId: b,
2473
+ return P.writeFileSync(_.join(A, "index.html"), M), P.writeFileSync(_.join(A, "myop.config.json"), JSON.stringify({
2474
+ name: k.name,
2475
+ componentId: C,
2450
2476
  organization: m,
2451
2477
  type: "html",
2452
2478
  author: "@myop-cli",
2453
2479
  HMR: !0
2454
- }, null, 2)), { name: O.name, status: "ok", dir: j };
2455
- } catch (M) {
2456
- return { name: O.name, status: "failed", error: M.message };
2480
+ }, null, 2)), { name: k.name, status: "ok", dir: A };
2481
+ } catch (b) {
2482
+ return { name: k.name, status: "failed", error: b.message };
2457
2483
  }
2458
2484
  }));
2459
2485
  let u = 0, E = 0;
2460
- for (const O of g)
2461
- O.status === "ok" ? (console.log(` \x1B[32m✔\x1B[0m ${O.name} -> ./${O.dir}/`), u++) : (console.log(` \x1B[31m✖\x1B[0m ${O.name} - ${O.error}`), E++);
2486
+ for (const k of h)
2487
+ k.status === "ok" ? (console.log(` \x1B[32m✔\x1B[0m ${k.name} -> ./${k.dir}/`), u++) : (console.log(` \x1B[31m✖\x1B[0m ${k.name} - ${k.error}`), E++);
2462
2488
  console.log(`
2463
2489
  Done! Pulled ${u} component${u !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
2464
2490
  `);
2465
- } else if (x === "push") {
2491
+ } else if (S === "push") {
2466
2492
  console.log(`
2467
- Pushing ${w.length} components...
2493
+ Pushing ${y.length} components...
2468
2494
  `);
2469
- const g = Ze(".", 3), u = await Promise.all(w.map(async (M) => {
2470
- const j = M.id || M._id || M.componentId, C = g.find((N) => N.componentId === j);
2471
- if (!C)
2472
- return { name: M.name, status: "skipped", reason: "no local match" };
2495
+ const h = qe(".", 3), u = await Promise.all(y.map(async (b) => {
2496
+ const A = b.id || b._id || b.componentId, M = h.find((N) => N.componentId === A);
2497
+ if (!M)
2498
+ return { name: b.name, status: "skipped", reason: "no local match" };
2473
2499
  try {
2474
2500
  let N;
2475
- const k = C.path;
2476
- if (P.existsSync(R.join(k, "dist", "index.html")))
2477
- N = R.join(k, "dist", "index.html");
2501
+ const R = M.path;
2502
+ if (P.existsSync(_.join(R, "dist", "index.html")))
2503
+ N = _.join(R, "dist", "index.html");
2478
2504
  else {
2479
- const W = P.readdirSync(k).filter(
2480
- (_) => _.endsWith(".html") && !_.startsWith(".") && P.statSync(R.join(k, _)).isFile()
2505
+ const T = P.readdirSync(R).filter(
2506
+ (O) => O.endsWith(".html") && !O.startsWith(".") && P.statSync(_.join(R, O)).isFile()
2481
2507
  );
2482
- if (W.length === 1)
2483
- N = R.join(k, W[0]);
2484
- else if (W.includes("index.html"))
2485
- N = R.join(k, "index.html");
2508
+ if (T.length === 1)
2509
+ N = _.join(R, T[0]);
2510
+ else if (T.includes("index.html"))
2511
+ N = _.join(R, "index.html");
2486
2512
  else
2487
2513
  throw new Error("No HTML file found");
2488
2514
  }
2489
- const L = P.readFileSync(N, "utf-8"), D = C.name || M.name, F = await i("upload_component", {
2515
+ const U = P.readFileSync(N, "utf-8"), D = M.name || b.name, F = await i("upload_component", {
2490
2516
  name: D,
2491
- componentId: j,
2517
+ componentId: A,
2492
2518
  organization: m,
2493
- htmlContent: L
2519
+ htmlContent: U
2494
2520
  });
2495
2521
  if (!F.success)
2496
2522
  throw new Error(F.error || "Upload failed");
2497
2523
  return { name: D, status: "ok" };
2498
2524
  } catch (N) {
2499
- return { name: M.name, status: "failed", error: N.message };
2525
+ return { name: b.name, status: "failed", error: N.message };
2500
2526
  }
2501
2527
  }));
2502
- let E = 0, O = 0, b = 0;
2503
- for (const M of u)
2504
- M.status === "ok" ? (console.log(` \x1B[32m✔\x1B[0m ${M.name}`), E++) : M.status === "skipped" ? (console.log(` \x1B[33m⊘\x1B[0m ${M.name} (${M.reason})`), O++) : (console.log(` \x1B[31m✖\x1B[0m ${M.name} - ${M.error}`), b++);
2528
+ let E = 0, k = 0, C = 0;
2529
+ for (const b of u)
2530
+ b.status === "ok" ? (console.log(` \x1B[32m✔\x1B[0m ${b.name}`), E++) : b.status === "skipped" ? (console.log(` \x1B[33m⊘\x1B[0m ${b.name} (${b.reason})`), k++) : (console.log(` \x1B[31m✖\x1B[0m ${b.name} - ${b.error}`), C++);
2505
2531
  console.log(`
2506
- Done! Pushed ${E}${O ? `, skipped ${O}` : ""}${b ? `, ${b} failed` : ""}.
2532
+ Done! Pushed ${E}${k ? `, skipped ${k}` : ""}${C ? `, ${C} failed` : ""}.
2507
2533
  `);
2508
2534
  }
2509
2535
  process.exit(0);
@@ -2532,7 +2558,7 @@ v.program.command("create").description("Create a new Myop HTML component and st
2532
2558
  HMR: !0
2533
2559
  };
2534
2560
  t.writeFileSync("myop.config.json", JSON.stringify(i, null, 2));
2535
- const r = `<!DOCTYPE html>
2561
+ const a = `<!DOCTYPE html>
2536
2562
  <html lang="en">
2537
2563
  <head>
2538
2564
  <meta charset="UTF-8">
@@ -2654,24 +2680,24 @@ v.program.command("create").description("Create a new Myop HTML component and st
2654
2680
  <\/script>
2655
2681
  </body>
2656
2682
  </html>`;
2657
- t.writeFileSync("index.html", r);
2658
- const p = await Qe(process.cwd());
2683
+ t.writeFileSync("index.html", a);
2684
+ const p = await Ze(process.cwd());
2659
2685
  console.log(`
2660
- ✅ Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Ce();
2686
+ ✅ Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Me();
2661
2687
  });
2662
- v.program.command("dev").description("Start development server with file watching").action(Ce);
2663
- const yt = async () => {
2664
- const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Qe(o);
2688
+ v.program.command("dev").description("Start development server with file watching").action(Me);
2689
+ const wt = async () => {
2690
+ const o = process.cwd(), t = Y("Installing AI agent skills...").start(), e = await Ze(o);
2665
2691
  e.success ? (t.succeed("AI agent skills installed"), e.detected.length > 0 && console.log(` Detected: ${e.detected.join(", ")}`), console.log(` Skills: ${e.skillNames.join(", ")}`)) : t.fail("Failed to install skills"), process.exit(e.success ? 0 : 1);
2666
2692
  };
2667
- v.program.command("skill").description("Install or update AI agent skills in the current directory").action(yt);
2668
- v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(yt);
2693
+ v.program.command("skill").description("Install or update AI agent skills in the current directory").action(wt);
2694
+ v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(wt);
2669
2695
  v.program.command("mcp").description("Configure Myop MCP server for your AI coding assistant").action(async () => {
2670
- const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Me() + "/mcp", i = [
2696
+ const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Ee() + "/mcp", i = [
2671
2697
  {
2672
2698
  name: "Claude Code",
2673
2699
  value: "claude",
2674
- configPath: R.join(n, ".claude.json"),
2700
+ configPath: _.join(n, ".claude.json"),
2675
2701
  getEntry: () => ({ type: "http", url: s }),
2676
2702
  nextSteps: [
2677
2703
  "Restart Claude Code to pick up the new MCP config.",
@@ -2683,7 +2709,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2683
2709
  {
2684
2710
  name: "Cursor",
2685
2711
  value: "cursor",
2686
- configPath: R.join(n, ".cursor", "mcp.json"),
2712
+ configPath: _.join(n, ".cursor", "mcp.json"),
2687
2713
  getEntry: () => ({ url: s }),
2688
2714
  nextSteps: [
2689
2715
  'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
@@ -2696,7 +2722,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2696
2722
  {
2697
2723
  name: "Windsurf",
2698
2724
  value: "windsurf",
2699
- configPath: R.join(n, ".codeium", "windsurf", "mcp_config.json"),
2725
+ configPath: _.join(n, ".codeium", "windsurf", "mcp_config.json"),
2700
2726
  getEntry: () => ({ url: s }),
2701
2727
  nextSteps: [
2702
2728
  "Open Cascade and click the hammer icon (top-right) to see MCP servers.",
@@ -2708,7 +2734,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2708
2734
  {
2709
2735
  name: "VS Code (GitHub Copilot)",
2710
2736
  value: "vscode",
2711
- configPath: process.platform === "darwin" ? R.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? R.join(process.env.APPDATA || R.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : R.join(n, ".config", "Code", "User", "mcp.json"),
2737
+ configPath: process.platform === "darwin" ? _.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? _.join(process.env.APPDATA || _.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : _.join(n, ".config", "Code", "User", "mcp.json"),
2712
2738
  getEntry: () => ({ type: "http", url: s }),
2713
2739
  nextSteps: [
2714
2740
  "Requires VS Code 1.99+ and GitHub Copilot extension.",
@@ -2723,64 +2749,64 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2723
2749
  console.log(`
2724
2750
  Configure Myop MCP server for your AI coding assistant.
2725
2751
  `);
2726
- let r;
2752
+ let a;
2727
2753
  try {
2728
- r = await o({
2754
+ a = await o({
2729
2755
  message: "Select your AI coding assistant:",
2730
- choices: i.map((d) => ({ name: d.name, value: d.value }))
2756
+ choices: i.map((c) => ({ name: c.name, value: c.value }))
2731
2757
  });
2732
- } catch (d) {
2733
- throw d.name === "ExitPromptError" && (console.log(`
2758
+ } catch (c) {
2759
+ throw c.name === "ExitPromptError" && (console.log(`
2734
2760
 
2735
2761
  👋 Goodbye!
2736
- `), process.exit(0)), d;
2762
+ `), process.exit(0)), c;
2737
2763
  }
2738
- const p = i.find((d) => d.value === r);
2764
+ const p = i.find((c) => c.value === a);
2739
2765
  let m = {};
2740
2766
  try {
2741
- const d = P.readFileSync(p.configPath, "utf-8");
2742
- m = JSON.parse(d);
2767
+ const c = P.readFileSync(p.configPath, "utf-8");
2768
+ m = JSON.parse(c);
2743
2769
  } catch {
2744
2770
  }
2745
2771
  m.mcpServers || (m.mcpServers = {});
2746
- const l = m.mcpServers.myop;
2747
- if (l && l.url === s) {
2772
+ const r = m.mcpServers.myop;
2773
+ if (r && r.url === s) {
2748
2774
  console.log(`
2749
2775
  Myop MCP is already configured for ${p.name}.`), console.log(` Config: ${p.configPath}`), console.log(`
2750
2776
  \x1B[1mNext steps:\x1B[0m`);
2751
- for (const d of p.nextSteps)
2752
- console.log(` ${d}`);
2777
+ for (const c of p.nextSteps)
2778
+ console.log(` ${c}`);
2753
2779
  console.log(""), process.exit(0);
2754
2780
  }
2755
- if (l) {
2781
+ if (r) {
2756
2782
  console.log(`
2757
- Myop MCP is already configured (URL: ${l.url}).`);
2783
+ Myop MCP is already configured (URL: ${r.url}).`);
2758
2784
  try {
2759
2785
  await t({ message: "Update to latest URL?", default: !0 }) || process.exit(0);
2760
- } catch (d) {
2761
- throw d.name === "ExitPromptError" && process.exit(0), d;
2786
+ } catch (c) {
2787
+ throw c.name === "ExitPromptError" && process.exit(0), c;
2762
2788
  }
2763
2789
  }
2764
- m.mcpServers.myop = p.getEntry(), P.mkdirSync(R.dirname(p.configPath), { recursive: !0 }), P.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
2790
+ m.mcpServers.myop = p.getEntry(), P.mkdirSync(_.dirname(p.configPath), { recursive: !0 }), P.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
2765
2791
  \x1B[32m✔\x1B[0m Myop MCP configured for ${p.name}`), console.log(` Config: ${p.configPath}`), console.log(` Server: ${s}`), console.log(`
2766
2792
  \x1B[1mNext steps:\x1B[0m`);
2767
- for (const d of p.nextSteps)
2768
- console.log(` ${d}`);
2793
+ for (const c of p.nextSteps)
2794
+ console.log(` ${c}`);
2769
2795
  console.log(""), process.exit(0);
2770
2796
  });
2771
2797
  const $o = () => {
2772
2798
  try {
2773
- Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2799
+ X("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2774
2800
  } catch {
2775
2801
  return { gitNotInstalled: !0 };
2776
2802
  }
2777
2803
  try {
2778
- Q("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2804
+ X("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2779
2805
  } catch {
2780
2806
  return { notARepo: !0 };
2781
2807
  }
2782
2808
  try {
2783
- const o = Q("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
2809
+ const o = X("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
2784
2810
  encoding: "utf-8",
2785
2811
  stdio: ["pipe", "pipe", "pipe"]
2786
2812
  }).trim();
@@ -2800,12 +2826,12 @@ const $o = () => {
2800
2826
  } catch {
2801
2827
  return null;
2802
2828
  }
2803
- }, ne = async (o = !1, t = !1) => {
2804
- var d, w, x;
2805
- const e = Pe(), n = !!(e != null && e.email), s = ((d = v.myopConfig) == null ? void 0 : d.name) || ((w = v.myopConfig) == null ? void 0 : w.componentName), i = (x = v.myopConfig) == null ? void 0 : x.componentId, r = $o();
2829
+ }, ie = async (o = !1, t = !1) => {
2830
+ var c, y, S;
2831
+ const e = Pe(), n = !!(e != null && e.email), s = ((c = v.myopConfig) == null ? void 0 : c.name) || ((y = v.myopConfig) == null ? void 0 : y.componentName), i = (S = v.myopConfig) == null ? void 0 : S.componentId, a = $o();
2806
2832
  console.log(`
2807
2833
  ┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Welcome to Myop CLI - Remote UI Made Easy │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
2808
- `), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`), r != null && r.gitNotInstalled ? (console.log(" Changes: Git not installed"), console.log(" Install: https://git-scm.com/downloads"), console.log(" Mac: brew install git | Windows: https://gitforwindows.org")) : r != null && r.notARepo ? console.log(" Changes: Not a git repository") : r && (r.insertions > 0 || r.deletions > 0) ? console.log(` Changes: ${r.files} file${r.files !== 1 ? "s" : ""} | \x1B[32m+${r.insertions}\x1B[0m \x1B[31m-${r.deletions}\x1B[0m`) : r && console.log(" Changes: No uncommitted changes"), console.log("");
2834
+ `), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`), a != null && a.gitNotInstalled ? (console.log(" Changes: Git not installed"), console.log(" Install: https://git-scm.com/downloads"), console.log(" Mac: brew install git | Windows: https://gitforwindows.org")) : a != null && a.notARepo ? console.log(" Changes: Not a git repository") : a && (a.insertions > 0 || a.deletions > 0) ? console.log(` Changes: ${a.files} file${a.files !== 1 ? "s" : ""} | \x1B[32m+${a.insertions}\x1B[0m \x1B[31m-${a.deletions}\x1B[0m`) : a && console.log(" Changes: No uncommitted changes"), console.log("");
2809
2835
  const m = [
2810
2836
  {
2811
2837
  emoji: "🚀",
@@ -2835,7 +2861,7 @@ const $o = () => {
2835
2861
  disabled: $.disabled
2836
2862
  }));
2837
2863
  m.push(
2838
- new Ue(),
2864
+ new He(),
2839
2865
  {
2840
2866
  name: t && n ? `🔓 Logout (${e.email})
2841
2867
  Clears stored credentials from this machine` : t && !n ? `🔐 Login to Myop
@@ -2846,15 +2872,15 @@ const $o = () => {
2846
2872
  name: t ? "📖 Hide help" : "📖 Show help",
2847
2873
  value: "help"
2848
2874
  },
2849
- new Ue(),
2875
+ new He(),
2850
2876
  {
2851
2877
  name: "👋 Exit",
2852
2878
  value: "exit"
2853
2879
  }
2854
2880
  );
2855
- let l;
2881
+ let r;
2856
2882
  try {
2857
- l = await st({
2883
+ r = await it({
2858
2884
  message: "What would you like to do?",
2859
2885
  choices: m
2860
2886
  });
@@ -2864,9 +2890,9 @@ const $o = () => {
2864
2890
  👋 Goodbye!
2865
2891
  `), process.exit(0)), $;
2866
2892
  }
2867
- switch (l) {
2893
+ switch (r) {
2868
2894
  case "init":
2869
- await Mo();
2895
+ await Po();
2870
2896
  break;
2871
2897
  case "sync":
2872
2898
  console.log(`
@@ -2877,32 +2903,32 @@ Pushing component...
2877
2903
  $("node " + process.argv[1] + " push", { stdio: "inherit" });
2878
2904
  } catch {
2879
2905
  }
2880
- await ne(!0, t);
2906
+ await ie(!0, t);
2881
2907
  break;
2882
2908
  case "dev":
2883
- await Ce();
2909
+ await Me();
2884
2910
  break;
2885
2911
  case "login":
2886
2912
  try {
2887
- await me(), console.log(`
2888
- `), await ne(o, t);
2889
- } catch (g) {
2890
- console.error("Login failed:", g.message), await ne(o, t);
2913
+ await ue(), console.log(`
2914
+ `), await ie(o, t);
2915
+ } catch (h) {
2916
+ console.error("Login failed:", h.message), await ie(o, t);
2891
2917
  }
2892
2918
  break;
2893
2919
  case "logout":
2894
- await gt(), console.log(`
2895
- `), await ne(o, t);
2920
+ await ht(), console.log(`
2921
+ `), await ie(o, t);
2896
2922
  break;
2897
2923
  case "help":
2898
- await ne(o, !t);
2924
+ await ie(o, !t);
2899
2925
  break;
2900
2926
  case "exit":
2901
2927
  process.exit(0);
2902
2928
  }
2903
- }, be = ".myop-monorepo.json", bo = () => {
2929
+ }, Ce = ".myop-monorepo.json", bo = () => {
2904
2930
  try {
2905
- const o = P.readFileSync(be, "utf-8");
2931
+ const o = P.readFileSync(Ce, "utf-8");
2906
2932
  return JSON.parse(o);
2907
2933
  } catch {
2908
2934
  return null;
@@ -2913,37 +2939,37 @@ Pushing component...
2913
2939
  selectedComponents: o,
2914
2940
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2915
2941
  };
2916
- P.writeFileSync(be, JSON.stringify(t, null, 2));
2942
+ P.writeFileSync(Ce, JSON.stringify(t, null, 2));
2917
2943
  } catch {
2918
2944
  }
2919
- }, Po = async () => {
2945
+ }, Mo = async () => {
2920
2946
  const o = Pe(), t = !!(o != null && o.email);
2921
2947
  console.log(`
2922
2948
  ┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Myop CLI - Monorepo Mode │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
2923
2949
  `);
2924
- const e = z("Scanning for components...").start(), n = Ze(".");
2950
+ const e = Y("Scanning for components...").start(), n = qe(".");
2925
2951
  e.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2926
2952
  `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2927
- const s = bo(), i = (s == null ? void 0 : s.selectedComponents) || [], r = i.length > 0;
2953
+ const s = bo(), i = (s == null ? void 0 : s.selectedComponents) || [], a = i.length > 0;
2928
2954
  console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
2929
- `), n.forEach((w, x) => {
2930
- const $ = w.componentId ? "✅" : "⚪", g = w.componentId ? w.componentId.substring(0, 8) + "..." : "(not pushed)";
2931
- console.log(` ${$} ${w.name}`), console.log(` Path: ${w.path}`), console.log(` ID: ${g}`), console.log("");
2932
- }), console.log(` User: ${t ? o.email : "Not logged in"}`), r && console.log(` 📋 Using saved selection from ${be}`), console.log("");
2955
+ `), n.forEach((y, S) => {
2956
+ const $ = y.componentId ? "✅" : "⚪", h = y.componentId ? y.componentId.substring(0, 8) + "..." : "(not pushed)";
2957
+ console.log(` ${$} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${h}`), console.log("");
2958
+ }), console.log(` User: ${t ? o.email : "Not logged in"}`), a && console.log(` 📋 Using saved selection from ${Ce}`), console.log("");
2933
2959
  const p = v.program.getOptionValue("ci");
2934
2960
  let m;
2935
2961
  if (p)
2936
- r ? (m = i, console.log(` 🤖 CI mode: using saved selection (${m.length} components)`)) : (m = n.map((w) => w.path), console.log(` 🤖 CI mode: no saved selection, using all ${m.length} components`));
2962
+ a ? (m = i, console.log(` 🤖 CI mode: using saved selection (${m.length} components)`)) : (m = n.map((y) => y.path), console.log(` 🤖 CI mode: no saved selection, using all ${m.length} components`));
2937
2963
  else {
2938
- const { checkbox: w } = await import("@inquirer/prompts"), x = n.map(($) => ({
2964
+ const { checkbox: y } = await import("@inquirer/prompts"), S = n.map(($) => ({
2939
2965
  name: `${$.name} (${$.path})`,
2940
2966
  value: $.path,
2941
- checked: r ? i.includes($.path) : !0
2967
+ checked: a ? i.includes($.path) : !0
2942
2968
  }));
2943
2969
  try {
2944
- m = await w({
2970
+ m = await y({
2945
2971
  message: "Select components to start in dev mode:",
2946
- choices: x
2972
+ choices: S
2947
2973
  });
2948
2974
  } catch ($) {
2949
2975
  throw $.name === "ExitPromptError" && (console.log(`
@@ -2955,20 +2981,20 @@ Pushing component...
2955
2981
  m.length === 0 && (console.log(`
2956
2982
  ⚠️ No components selected.
2957
2983
  `), process.exit(0)), p || (Co(m), console.log(`
2958
- 💾 Selection saved to ${be}`));
2959
- const l = n.filter((w) => m.includes(w.path));
2960
- console.log(`🚀 Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
2984
+ 💾 Selection saved to ${Ce}`));
2985
+ const r = n.filter((y) => m.includes(y.path));
2986
+ console.log(`🚀 Starting dev mode for ${r.length} component${r.length > 1 ? "s" : ""}...
2961
2987
  `);
2962
- const { monorepoDevCommand: d } = await Promise.resolve().then(() => Vt);
2963
- await d(l);
2964
- }, Mo = async () => {
2988
+ const { monorepoDevCommand: c } = await Promise.resolve().then(() => Vt);
2989
+ await c(r);
2990
+ }, Po = async () => {
2965
2991
  const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
2966
- let i, r;
2992
+ let i, a;
2967
2993
  try {
2968
2994
  i = await o({
2969
2995
  message: "Component name:",
2970
2996
  default: s
2971
- }), r = await t({
2997
+ }), a = await t({
2972
2998
  message: "Component type:",
2973
2999
  choices: [
2974
3000
  { name: "📄 HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -2977,22 +3003,22 @@ Pushing component...
2977
3003
  { name: "🅰️ Angular", value: "angular", disabled: "(coming soon)" }
2978
3004
  ]
2979
3005
  });
2980
- } catch (l) {
2981
- throw l.name === "ExitPromptError" && (console.log(`
3006
+ } catch (r) {
3007
+ throw r.name === "ExitPromptError" && (console.log(`
2982
3008
 
2983
3009
  👋 Goodbye!
2984
- `), process.exit(0)), l;
3010
+ `), process.exit(0)), r;
2985
3011
  }
2986
3012
  const p = {
2987
3013
  name: i,
2988
- type: r,
3014
+ type: a,
2989
3015
  author: "@myop-cli",
2990
3016
  HMR: !0
2991
3017
  }, m = v.program.getOptionValue("config") || "./myop.config.json";
2992
3018
  try {
2993
3019
  e.writeFileSync(m, JSON.stringify(p, null, 2)), console.log(`
2994
3020
  ✅ Created ${m}`);
2995
- const l = {
3021
+ const r = {
2996
3022
  name: i.toLowerCase().replace(/\s+/g, "-"),
2997
3023
  version: "1.0.0",
2998
3024
  type: "module",
@@ -3004,7 +3030,7 @@ Pushing component...
3004
3030
  esbuild: "^0.24.0"
3005
3031
  }
3006
3032
  };
3007
- e.writeFileSync("package.json", JSON.stringify(l, null, 2)), console.log("✅ Created package.json"), e.mkdirSync("src/modules", { recursive: !0 }), e.mkdirSync("src/styles", { recursive: !0 }), e.writeFileSync("build.js", `import * as esbuild from 'esbuild';
3033
+ e.writeFileSync("package.json", JSON.stringify(r, null, 2)), console.log("✅ Created package.json"), e.mkdirSync("src/modules", { recursive: !0 }), e.mkdirSync("src/styles", { recursive: !0 }), e.writeFileSync("build.js", `import * as esbuild from 'esbuild';
3008
3034
  import fs from 'fs';
3009
3035
  import path from 'path';
3010
3036
 
@@ -3084,7 +3110,7 @@ fs.writeFileSync('dist/index.html', html);
3084
3110
  console.log('✅ Built dist/index.html');
3085
3111
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
3086
3112
  `), console.log("✅ Created build.js");
3087
- const w = `<!DOCTYPE html>
3113
+ const y = `<!DOCTYPE html>
3088
3114
  <html lang="en">
3089
3115
  <head>
3090
3116
  <meta charset="UTF-8">
@@ -3101,8 +3127,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
3101
3127
  </body>
3102
3128
  </html>
3103
3129
  `;
3104
- e.writeFileSync("index.html", w), console.log("✅ Created index.html");
3105
- const x = `// ${i} - Entry Point
3130
+ e.writeFileSync("index.html", y), console.log("✅ Created index.html");
3131
+ const S = `// ${i} - Entry Point
3106
3132
  import { init } from './modules/app.js';
3107
3133
  import { setupMyopInterface } from './modules/myop.js';
3108
3134
 
@@ -3111,7 +3137,7 @@ document.addEventListener('DOMContentLoaded', () => {
3111
3137
  setupMyopInterface();
3112
3138
  });
3113
3139
  `;
3114
- e.writeFileSync("src/index.js", x), console.log("✅ Created src/index.js");
3140
+ e.writeFileSync("src/index.js", S), console.log("✅ Created src/index.js");
3115
3141
  const $ = `// ${i} - Main Application Logic
3116
3142
 
3117
3143
  export function init() {
@@ -3176,12 +3202,12 @@ dist/
3176
3202
  .temp-styles.css
3177
3203
  .DS_Store
3178
3204
  `), console.log("✅ Created .gitignore");
3179
- const b = await Qe(process.cwd());
3180
- b.success && console.log("✅ Installed AI agent skills");
3181
- const M = await import("./index-DuEoKctW.js").then((C) => C.i), j = process.cwd();
3205
+ const C = await Ze(process.cwd());
3206
+ C.success && console.log("✅ Installed AI agent skills");
3207
+ const b = await import("./index-DuEoKctW.js").then((M) => M.i), A = process.cwd();
3182
3208
  try {
3183
- await M.init({ fs: e, dir: j });
3184
- const C = [
3209
+ await b.init({ fs: e, dir: A });
3210
+ const M = [
3185
3211
  "myop.config.json",
3186
3212
  "package.json",
3187
3213
  "build.js",
@@ -3193,85 +3219,85 @@ dist/
3193
3219
  "src/styles/index.css",
3194
3220
  "src/styles/main.css"
3195
3221
  ];
3196
- if (b.success) {
3197
- const N = (k, L) => {
3222
+ if (C.success) {
3223
+ const N = (R, U) => {
3198
3224
  try {
3199
- const D = e.readdirSync(k, { withFileTypes: !0 });
3225
+ const D = e.readdirSync(R, { withFileTypes: !0 });
3200
3226
  for (const F of D) {
3201
- const W = n.join(k, F.name), _ = n.join(L, F.name);
3202
- F.isDirectory() ? N(W, _) : C.push(_);
3227
+ const T = n.join(R, F.name), O = n.join(U, F.name);
3228
+ F.isDirectory() ? N(T, O) : M.push(O);
3203
3229
  }
3204
3230
  } catch {
3205
3231
  }
3206
3232
  };
3207
3233
  try {
3208
- const k = e.readdirSync(".", { withFileTypes: !0 });
3209
- for (const L of k)
3210
- if (L.isDirectory() && L.name.startsWith(".")) {
3211
- const D = n.join(L.name, "skills");
3234
+ const R = e.readdirSync(".", { withFileTypes: !0 });
3235
+ for (const U of R)
3236
+ if (U.isDirectory() && U.name.startsWith(".")) {
3237
+ const D = n.join(U.name, "skills");
3212
3238
  e.existsSync(D) && N(D, D);
3213
3239
  }
3214
3240
  } catch {
3215
3241
  }
3216
3242
  }
3217
- for (const N of C)
3218
- await M.add({ fs: e, dir: j, filepath: N });
3219
- await M.commit({
3243
+ for (const N of M)
3244
+ await b.add({ fs: e, dir: A, filepath: N });
3245
+ await b.commit({
3220
3246
  fs: e,
3221
- dir: j,
3247
+ dir: A,
3222
3248
  message: "init",
3223
3249
  author: { name: "myop-cli", email: "cli@myop.dev" }
3224
3250
  }), console.log("✅ Initialized git repository");
3225
- } catch (C) {
3226
- console.log("⚠️ Failed to initialize git repository:", C.message);
3251
+ } catch (M) {
3252
+ console.log("⚠️ Failed to initialize git repository:", M.message);
3227
3253
  }
3228
3254
  console.log(`
3229
3255
  📦 Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
3230
- `), v.myopConfig = p, await ne(!0);
3231
- } catch (l) {
3232
- console.error(`Failed to initialize component: ${l.message}`), process.exit(1);
3256
+ `), v.myopConfig = p, await ie(!0);
3257
+ } catch (r) {
3258
+ console.error(`Failed to initialize component: ${r.message}`), process.exit(1);
3233
3259
  }
3234
3260
  };
3235
3261
  v.program.command("default", { isDefault: !0 }).action(async () => {
3236
3262
  if (v.program.getOptionValue("help") && (console.log(Rt), process.exit()), v.program.getOptionValue("monorepo")) {
3237
- await Po();
3263
+ await Mo();
3238
3264
  return;
3239
3265
  }
3240
3266
  if (v.program.getOptionValue("ci")) {
3241
- const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), d = Pe();
3242
- let w = { found: !1 };
3267
+ const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", r = v.program.version(), c = Pe();
3268
+ let y = { found: !1 };
3243
3269
  try {
3244
3270
  if (p.existsSync(m)) {
3245
- const $ = p.readFileSync(m, "utf-8"), g = JSON.parse($);
3246
- w = {
3271
+ const $ = p.readFileSync(m, "utf-8"), h = JSON.parse($);
3272
+ y = {
3247
3273
  found: !0,
3248
3274
  path: m,
3249
- name: g.name || g.componentName || null,
3250
- componentId: g.componentId || null,
3251
- organization: g.organization || null
3275
+ name: h.name || h.componentName || null,
3276
+ componentId: h.componentId || null,
3277
+ organization: h.organization || null
3252
3278
  };
3253
3279
  }
3254
3280
  } catch ($) {
3255
- w = { found: !1, error: $.message };
3281
+ y = { found: !1, error: $.message };
3256
3282
  }
3257
- const x = {
3258
- version: l,
3259
- config: w,
3283
+ const S = {
3284
+ version: r,
3285
+ config: y,
3260
3286
  auth: {
3261
- loggedIn: !!(d != null && d.email),
3262
- email: (d == null ? void 0 : d.email) || null
3287
+ loggedIn: !!(c != null && c.email),
3288
+ email: (c == null ? void 0 : c.email) || null
3263
3289
  }
3264
3290
  };
3265
- console.log(JSON.stringify(x, null, 2)), process.exit(0);
3291
+ console.log(JSON.stringify(S, null, 2)), process.exit(0);
3266
3292
  }
3267
- let n = z({
3293
+ let n = Y({
3268
3294
  text: "Loading Myop CLI...",
3269
3295
  color: "green"
3270
3296
  }).start();
3271
- const s = Ee();
3297
+ const s = Ie();
3272
3298
  await wo(500), n.stop();
3273
3299
  const i = v.program.version();
3274
- await uo(i) || await ne(s.configFound);
3300
+ await uo(i) || await ie(s.configFound);
3275
3301
  });
3276
3302
  Qt();
3277
3303
  v.program.parse(process.argv);