@myop/cli 0.1.54 → 0.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/myop-cli.js CHANGED
@@ -3,50 +3,52 @@ 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
4
  var ve = (o, t, e) => Ct(o, typeof t != "symbol" ? t + "" : t, e);
5
5
  import z from "ora";
6
- import { select as st, Separator as Le } from "@inquirer/prompts";
6
+ import { select as st, Separator as Ue } from "@inquirer/prompts";
7
7
  import { Command as Pt, Option as fe } from "commander";
8
8
  import { execSync as Q, spawn as Mt } from "child_process";
9
- import R, { join as je } from "path";
10
- import C, { readFileSync as Et } from "fs";
11
- import ze from "crypto";
9
+ import R, { join as Ae } from "path";
10
+ import P, { readFileSync as Et } from "fs";
11
+ import We from "crypto";
12
12
  import It from "http";
13
13
  import { URL as it, URLSearchParams as rt } from "url";
14
14
  import Ot from "open";
15
15
  import at from "os";
16
- const kt = `
17
- Usage: myop [OPTIONS] COMMAND [ARGS]...
16
+ const kt = "0.1.56", Rt = `
17
+ Usage: myop [OPTIONS] [COMMAND]
18
18
 
19
- A powerful command-line interface for managing your Myop projects.
19
+ Myop CLI - Remote UI Made Easy
20
20
 
21
21
  Options:
22
- -h, --help Show this help message and exit.
23
- -v, --version Show the version of the CLI.
24
- --config FILE Specify a configuration file. (default: config.yaml)
22
+ -h, --help Show this help message and exit
23
+ -v, --verbose Enable verbose output
24
+ -c, --config <path> Path to myop.config.json (default: ./myop.config.json)
25
+ -m, --monorepo Monorepo mode: serve multiple components
26
+ --ci CI mode: output status as JSON, no prompts
27
+ --version Show CLI version
25
28
 
26
29
  Commands:
27
- init Initialize a new project.
28
- start Start the project server.
29
- build Build the project for production.
30
- test Run tests on the project.
31
- deploy Deploy the project to the server.
32
- logs View logs of the project.
33
- help Show help for a specific command.
30
+ create Create a new Myop component (interactive)
31
+ dev Start dev server with file watching and HMR
32
+ push [componentId] Upload component to Myop platform
33
+ pull [componentId] Download component HTML from Myop platform
34
+ list [--org <orgId>] Browse, search, and batch pull/push components
35
+ login Authenticate with Myop (opens browser)
36
+ logout Clear stored credentials
37
+ whoami Show current authenticated user
38
+ train Install AI skills for coding assistants
39
+ mcp Configure MCP server for your IDE
34
40
 
35
- For more information, visit the documentation site:
36
- https://docs.mycli.dev
41
+ Run without a command to open the interactive menu.
37
42
 
38
- GitHub Repository:
39
- https://github.com/username/mycli
40
-
41
- Version: 1.0.0
43
+ Version: ${kt}
42
44
 
43
45
  Examples:
44
- mycli init
45
- mycli start --config custom_config.yaml
46
- mycli deploy
47
-
48
-
49
-
46
+ myop create
47
+ myop dev
48
+ myop dev -m
49
+ myop push
50
+ myop pull <componentId>
51
+ myop list
50
52
  `, v = {
51
53
  program: null,
52
54
  executionPath: "",
@@ -67,17 +69,17 @@ Examples:
67
69
  }
68
70
  process.exit();
69
71
  }
70
- }, Rt = (o) => {
72
+ }, Nt = (o) => {
71
73
  const t = R.join(v.executionPath, o);
72
74
  console.info(`reading config file from: ${t}`);
73
- const e = C.readFileSync(t, "utf8"), n = JSON.parse(e);
75
+ const e = P.readFileSync(t, "utf8"), n = JSON.parse(e);
74
76
  return console.info("config file loaded, ", n), n;
75
- }, We = (o, t) => {
77
+ }, Ve = (o, t) => {
76
78
  const e = R.join(v.executionPath, o);
77
79
  console.info(`writing config file to: ${e}`);
78
80
  try {
79
81
  const n = JSON.stringify(t, null, 2);
80
- C.writeFileSync(e, n), console.info(`config file updated ${n}`);
82
+ P.writeFileSync(e, n), console.info(`config file updated ${n}`);
81
83
  } catch (n) {
82
84
  throw console.info(`error ${n} while writing to ${e}, JSON: ${t}`), console.log(`
83
85
  ⚠️ Failed write config file to ${e}, for more info use verbose flag`), n;
@@ -87,7 +89,7 @@ Examples:
87
89
  value: "addFlow",
88
90
  description: "Adds flow to yours myop.config.json",
89
91
  _action: (o) => {
90
- v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), We(v.options.configPath, v.myopConfig);
92
+ v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), Ve(v.options.configPath, v.myopConfig);
91
93
  },
92
94
  action: async () => {
93
95
  }
@@ -96,7 +98,7 @@ Examples:
96
98
  value: "removeFlow",
97
99
  description: "Removes flow to yours myop.config.json",
98
100
  _action: (o) => {
99
- v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), We(v.options.configPath, v.myopConfig);
101
+ v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), Ve(v.options.configPath, v.myopConfig);
100
102
  },
101
103
  action: () => {
102
104
  }
@@ -107,29 +109,29 @@ Examples:
107
109
  action: () => {
108
110
  process.exit();
109
111
  }
110
- }, Nt = {
112
+ }, Tt = {
111
113
  name: "🟢 Create new component",
112
114
  value: "-",
113
115
  disabled: "(not available yet)"
114
- }, Tt = {
116
+ }, Ft = {
115
117
  name: "🔵 Create new experience",
116
118
  value: "-",
117
119
  disabled: "(not available yet)"
118
- }, Ft = {
120
+ }, jt = {
119
121
  name: "🟡 Create new skin",
120
122
  value: "-",
121
123
  disabled: "(not available yet)"
122
- }, jt = {
124
+ }, At = {
123
125
  name: "🔴 Create new flow",
124
126
  value: "-",
125
127
  disabled: "(not available yet)"
126
- }, At = {
128
+ }, Dt = {
127
129
  name: "🆕 Define new custom Myop message",
128
130
  value: "generateMyopMessage",
129
131
  description: "️Help you creates the right structure for a new Myop message, including types and handlers.",
130
132
  disabled: "(not available yet)"
131
- }, Dt = [At, Nt, Tt, Ft, jt];
132
- function Lt(o, t, e, n) {
133
+ }, Lt = [Dt, Tt, Ft, jt, At];
134
+ function Ut(o, t, e, n) {
133
135
  return `<!DOCTYPE html>
134
136
  <html lang="en">
135
137
  <head>
@@ -219,19 +221,19 @@ ${n}
219
221
  </body>
220
222
  </html>`;
221
223
  }
222
- function Ut(o) {
224
+ function Ht(o) {
223
225
  return o.includes("esbuild") && o.includes("another platform");
224
226
  }
225
- function Ht(o) {
227
+ function Bt(o) {
226
228
  return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
227
229
  }
228
- function Bt() {
230
+ function Jt() {
229
231
  console.error(`
230
232
  ❌ esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
231
233
  This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows → Mac, or Mac → Linux).
232
234
  `);
233
235
  }
234
- function Jt(o) {
236
+ function zt(o) {
235
237
  return new Promise((t) => {
236
238
  console.log(`🔧 Attempting to fix: removing node_modules and reinstalling...
237
239
  `);
@@ -261,11 +263,11 @@ async function pt(o, t, e, n, s = {}) {
261
263
  hasTriedInstall: r = !1,
262
264
  onRetry: p
263
265
  } = s, m = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
264
- return !i && Ut(m) ? (Bt(), await Jt(n) && p ? (console.log(`🔄 Retrying build...
265
- `), p(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : !r && Ht(m) ? (console.log("📦 Missing dependencies detected, running npm install..."), new Promise((l) => {
266
- n("npm install", (d, y, S) => {
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) => {
267
269
  if (d) {
268
- console.error("❌ Failed to install dependencies:", d.message), S && console.error(S), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
270
+ console.error("❌ Failed to install dependencies:", d.message), x && console.error(x), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
269
271
  return;
270
272
  }
271
273
  console.log("✅ Dependencies installed"), p && p(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
@@ -281,7 +283,7 @@ async function Ce() {
281
283
  } else
282
284
  i = t.default.dirname(import.meta.url);
283
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;
284
- let y = "./dist", S = !1, x = !1, g = !1, u = null;
286
+ let w = "./dist", x = !1, $ = !1, g = !1, u = null;
285
287
  const E = () => {
286
288
  try {
287
289
  const c = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
@@ -302,53 +304,53 @@ async function Ce() {
302
304
  let f;
303
305
  a === "darwin" ? f = `open "${c}"` : a === "win32" ? f = `start "" "${c}"` : f = `xdg-open "${c}"`, e(f, (h) => {
304
306
  });
305
- }, P = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
306
- let M, _, k = !1;
307
+ }, M = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
308
+ let C, N, k = !1;
307
309
  u = E();
308
310
  const L = O();
309
311
  try {
310
312
  const c = o.default.readFileSync(j, "utf-8"), a = JSON.parse(c);
311
- M = a.componentId || "DEV", _ = 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");
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");
312
314
  } catch (c) {
313
- u && !L ? (g = !0, M = "DEV", _ = 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));
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));
314
316
  }
315
317
  const D = async () => {
316
- if (M !== "DEV" && M !== "NEW")
317
- return M;
318
+ if (C !== "DEV" && C !== "NEW")
319
+ return C;
318
320
  try {
319
- const a = ((await new Promise((w, $) => {
321
+ const a = ((await new Promise((y, S) => {
320
322
  const I = {
321
323
  hostname: "localhost",
322
324
  port: d,
323
325
  path: "/_list",
324
326
  method: "GET",
325
327
  timeout: 1e3
326
- }, F = n.default.request(I, (H) => {
328
+ }, T = n.default.request(I, (H) => {
327
329
  let Y = "";
328
330
  H.on("data", (ee) => Y += ee), H.on("end", () => {
329
331
  try {
330
- w(JSON.parse(Y));
332
+ y(JSON.parse(Y));
331
333
  } catch {
332
- w({ components: [] });
334
+ y({ components: [] });
333
335
  }
334
336
  });
335
337
  });
336
- F.on("error", () => w({ components: [] })), F.on("timeout", () => {
337
- F.destroy(), w({ components: [] });
338
- }), F.end();
339
- })).components || []).map(([w]) => w).filter((w) => w === "DEV" || w === "NEW" || /^DEV\d+$/.test(w) || /^NEW\d+$/.test(w));
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));
340
342
  if (a.length === 0)
341
343
  return "DEV1";
342
- const f = a.map((w) => {
343
- if (w === "DEV" || w === "NEW") return 1;
344
- const $ = w.match(/^DEV(\d+)$/), I = w.match(/^NEW(\d+)$/);
345
- return $ ? parseInt($[1], 10) : I ? parseInt(I[1], 10) : 0;
346
- }).filter((w) => w > 0);
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);
347
349
  return `DEV${Math.max(...f, 0) + 1}`;
348
350
  } catch {
349
351
  return "DEV1";
350
352
  }
351
- }, T = process.cwd(), W = (c) => {
353
+ }, F = process.cwd(), W = (c) => {
352
354
  const a = t.default.extname(c).toLowerCase();
353
355
  return {
354
356
  ".html": "text/html",
@@ -361,14 +363,14 @@ async function Ce() {
361
363
  ".svg": "image/svg+xml",
362
364
  ".ico": "image/x-icon"
363
365
  }[a] || "application/octet-stream";
364
- }, N = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
366
+ }, _ = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
365
367
  if (c.url.startsWith("/_hmr/")) {
366
- const h = c.url.split("/_hmr/")[1], w = c.headers["sec-websocket-key"], $ = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
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");
367
369
  a.write(
368
370
  `HTTP/1.1 101 Switching Protocols\r
369
371
  Upgrade: websocket\r
370
372
  Connection: Upgrade\r
371
- Sec-WebSocket-Accept: ${$}\r
373
+ Sec-WebSocket-Accept: ${S}\r
372
374
  \r
373
375
  `
374
376
  ), X.has(h) || X.set(h, /* @__PURE__ */ new Set()), X.get(h).add(a), console.log(`🔌 HMR client connected: ${h}`), a.on("close", () => {
@@ -384,11 +386,11 @@ Sec-WebSocket-Accept: ${$}\r
384
386
  let f = "";
385
387
  c.on("data", (h) => f += h), c.on("end", () => {
386
388
  try {
387
- const { componentId: h, distPath: w, componentName: $, htmlFile: I } = JSON.parse(f);
388
- N.set(h, { path: w, name: $ || null, htmlFile: I || null });
389
- const F = $ ? ` (${$})` : "";
390
- console.log(`✅ Registered: ${h}${F} -> ${w}${I ? "/" + I : ""}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(N.keys()) }));
391
- const H = Array.from(N.entries()).map(([Y, ee]) => ({
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]) => ({
392
394
  id: Y,
393
395
  path: ee.path,
394
396
  name: ee.name
@@ -413,17 +415,17 @@ Sec-WebSocket-Accept: ${$}\r
413
415
  c.on("data", (h) => f += h), c.on("end", () => {
414
416
  try {
415
417
  const { componentId: h } = JSON.parse(f);
416
- N.delete(h), console.log(`❌ Unregistered: ${h}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
417
- const w = Array.from(N.entries()).map(([$, I]) => ({
418
- id: $,
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,
419
421
  path: I.path,
420
422
  name: I.name
421
423
  }));
422
- q.forEach(($) => {
424
+ q.forEach((S) => {
423
425
  try {
424
- $.write(`data: ${JSON.stringify({
426
+ S.write(`data: ${JSON.stringify({
425
427
  type: "components",
426
- components: w
428
+ components: y
427
429
  })}
428
430
 
429
431
  `);
@@ -435,22 +437,22 @@ Sec-WebSocket-Accept: ${$}\r
435
437
  }
436
438
  });
437
439
  } else if (c.method === "GET" && c.url === "/_list")
438
- a.writeHead(200), a.end(JSON.stringify({ components: Array.from(N.entries()) }));
440
+ a.writeHead(200), a.end(JSON.stringify({ components: Array.from(_.entries()) }));
439
441
  else if (c.method === "POST" && c.url === "/_hmr_notify") {
440
442
  let f = "";
441
443
  c.on("data", (h) => f += h), c.on("end", () => {
442
444
  try {
443
- const { componentId: h, html: w } = JSON.parse(f), $ = X.get(h);
444
- if ($ && $.size > 0) {
445
- console.log(`🔥 Notifying ${$.size} HMR client(s) for: ${h}`);
446
- const I = JSON.stringify({ type: "update", html: w }), F = qe(I);
447
- $.forEach((H) => {
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) => {
448
450
  try {
449
- H.write(F);
451
+ H.write(T);
450
452
  } catch {
451
- $.delete(H);
453
+ S.delete(H);
452
454
  }
453
- }), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: $.size }));
455
+ }), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: S.size }));
454
456
  } else
455
457
  a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: 0 }));
456
458
  } catch (h) {
@@ -464,14 +466,14 @@ Sec-WebSocket-Accept: ${$}\r
464
466
  a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
465
467
  return;
466
468
  }
467
- const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, w = h.split("/").filter((J) => J);
469
+ const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, y = h.split("/").filter((J) => J);
468
470
  if (h.startsWith("/consume")) {
469
471
  const J = f.searchParams.get("id");
470
472
  if (!J) {
471
473
  a.writeHead(400, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
472
474
  return;
473
475
  }
474
- const V = N.get(J), G = V ? V.path : null, de = (te) => {
476
+ const V = _.get(J), G = V ? V.path : null, de = (te) => {
475
477
  let U = "Unknown", K = "Unknown";
476
478
  if (c.headers.referer || c.headers.referrer) {
477
479
  const B = c.headers.referer || c.headers.referrer;
@@ -492,12 +494,12 @@ Sec-WebSocket-Accept: ${$}\r
492
494
  const B = c.socket.remoteAddress;
493
495
  B === "::1" || B === "::ffff:127.0.0.1" ? (U = "localhost", K = "localhost (direct)") : (U = B, K = B.replace("::ffff:", ""));
494
496
  }
495
- const Te = c.headers.referer || c.headers.referrer || U, we = {
497
+ const Fe = c.headers.referer || c.headers.referrer || U, we = {
496
498
  type: "request",
497
499
  componentId: J,
498
500
  timestamp: Date.now(),
499
501
  servedLocally: te,
500
- referrer: Te,
502
+ referrer: Fe,
501
503
  origin: U,
502
504
  originLabel: K
503
505
  };
@@ -517,8 +519,8 @@ Sec-WebSocket-Accept: ${$}\r
517
519
  } catch {
518
520
  }
519
521
  }));
520
- const Fe = se.get(U);
521
- Fe.requestCount++, q.forEach((B) => {
522
+ const je = se.get(U);
523
+ je.requestCount++, q.forEach((B) => {
522
524
  try {
523
525
  B.write(`data: ${JSON.stringify({
524
526
  type: "origins",
@@ -544,7 +546,7 @@ Sec-WebSocket-Accept: ${$}\r
544
546
  console.log(`❌ File not found: ${te}`), a.writeHead(404, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "index.html not found" }));
545
547
  return;
546
548
  }
547
- const Te = ke(K, J), we = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Fe = {
549
+ const Fe = Re(K, J), we = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, je = {
548
550
  item: {
549
551
  name: J,
550
552
  id: J,
@@ -555,7 +557,7 @@ Sec-WebSocket-Accept: ${$}\r
555
557
  loader: {
556
558
  type: "HTMLLoader",
557
559
  shadowRootMode: "localFrame",
558
- HTML: Te
560
+ HTML: Fe
559
561
  }
560
562
  }
561
563
  ]
@@ -564,7 +566,7 @@ Sec-WebSocket-Accept: ${$}\r
564
566
  console.log(`✅ Serving consume JSON for: ${J}`), de(!0), a.writeHead(200, {
565
567
  "Content-Type": "application/json",
566
568
  "Access-Control-Allow-Origin": "*"
567
- }), a.end(JSON.stringify(Fe, null, 2));
569
+ }), a.end(JSON.stringify(je, null, 2));
568
570
  });
569
571
  } else {
570
572
  console.log(`📡 Proxying consume request to cloud.myop.dev for: ${J}`);
@@ -587,7 +589,7 @@ Sec-WebSocket-Accept: ${$}\r
587
589
  Connection: "keep-alive",
588
590
  "Access-Control-Allow-Origin": "*"
589
591
  }), q.push(a);
590
- const J = Array.from(N.entries()).map(([V, G]) => ({
592
+ const J = Array.from(_.entries()).map(([V, G]) => ({
591
593
  id: V,
592
594
  path: G.path,
593
595
  name: G.name
@@ -613,24 +615,24 @@ Sec-WebSocket-Accept: ${$}\r
613
615
  });
614
616
  return;
615
617
  }
616
- if (w.length === 0) {
617
- a.writeHead(200, { "Content-Type": "text/html" }), a.end(Lt(l, d, p, m));
618
+ if (y.length === 0) {
619
+ a.writeHead(200, { "Content-Type": "text/html" }), a.end(Ut(l, d, p, m));
618
620
  return;
619
621
  }
620
- if (w[0] !== "view") {
622
+ if (y[0] !== "view") {
621
623
  a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not found. Use /view/<componentId>/ to access components.");
622
624
  return;
623
625
  }
624
- if (w.length < 2) {
626
+ if (y.length < 2) {
625
627
  a.writeHead(400, { "Content-Type": "text/plain" }), a.end("Component ID required. Use /view/<componentId>/");
626
628
  return;
627
629
  }
628
- const $ = w[1], I = N.get($);
630
+ const S = y[1], I = _.get(S);
629
631
  if (!I) {
630
- a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${$}`);
632
+ a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${S}`);
631
633
  return;
632
634
  }
633
- const F = I.path, H = w.slice(2), Y = I.htmlFile || "index.html", ee = H.length === 0 ? Y : H.join("/"), ce = t.default.join(F, ee);
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);
634
636
  console.log(`📥 Request: ${c.url} -> ${ce}`), o.default.readFile(ce, (J, V) => {
635
637
  if (J) {
636
638
  console.log(`❌ File not found: ${ce}`), a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not Found");
@@ -641,20 +643,20 @@ Sec-WebSocket-Accept: ${$}\r
641
643
  let de = V;
642
644
  if (G === "text/html" && k) {
643
645
  const te = V.toString("utf-8");
644
- de = ke(te, $);
646
+ de = Re(te, S);
645
647
  }
646
648
  a.writeHead(200, {
647
649
  "Content-Type": G,
648
650
  "Access-Control-Allow-Origin": "*"
649
651
  }), a.end(de);
650
652
  });
651
- }), Ze = () => new Promise((c, a) => {
652
- const f = g ? t.default.resolve(T) : t.default.resolve(T, y), h = JSON.stringify({
653
- componentId: M,
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,
654
656
  distPath: f,
655
- componentName: _,
657
+ componentName: N,
656
658
  htmlFile: g ? u : null
657
- }), w = {
659
+ }), y = {
658
660
  hostname: "localhost",
659
661
  port: d,
660
662
  path: "/_register",
@@ -663,15 +665,15 @@ Sec-WebSocket-Accept: ${$}\r
663
665
  "Content-Type": "application/json",
664
666
  "Content-Length": Buffer.byteLength(h)
665
667
  }
666
- }, $ = n.default.request(w, (I) => {
667
- let F = "";
668
- I.on("data", (H) => F += H), I.on("end", () => {
669
- I.statusCode === 200 ? c(JSON.parse(F)) : a(new Error(`Registration failed: ${I.statusCode}`));
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}`));
670
672
  });
671
673
  });
672
- $.on("error", a), $.write(h), $.end();
674
+ S.on("error", a), S.write(h), S.end();
673
675
  }), vt = () => new Promise((c, a) => {
674
- const f = JSON.stringify({ componentId: M }), h = {
676
+ const f = JSON.stringify({ componentId: C }), h = {
675
677
  hostname: "localhost",
676
678
  port: d,
677
679
  path: "/_unregister",
@@ -680,10 +682,10 @@ Sec-WebSocket-Accept: ${$}\r
680
682
  "Content-Type": "application/json",
681
683
  "Content-Length": Buffer.byteLength(f)
682
684
  }
683
- }, w = n.default.request(h, ($) => {
685
+ }, y = n.default.request(h, (S) => {
684
686
  c();
685
687
  });
686
- w.on("error", () => c()), w.write(f), w.end();
688
+ y.on("error", () => c()), y.write(f), y.end();
687
689
  }), St = (c) => `
688
690
  <!-- MYOP HMR -->
689
691
  <script>
@@ -789,7 +791,7 @@ Sec-WebSocket-Accept: ${$}\r
789
791
  connect();
790
792
  })();
791
793
  <\/script>
792
- `, ke = (c, a) => {
794
+ `, Re = (c, a) => {
793
795
  if (!k) return c;
794
796
  const f = St(a);
795
797
  return c.includes("</body>") ? c.replace("</body>", `${f}</body>`) : c.includes("</html>") ? c.replace("</html>", `${f}</html>`) : c + f;
@@ -815,34 +817,34 @@ Sec-WebSocket-Accept: ${$}\r
815
817
  ]), h;
816
818
  }, Xe = () => {
817
819
  if (!k) return;
818
- const c = g ? u : t.default.join(y, "index.html");
820
+ const c = g ? u : t.default.join(w, "index.html");
819
821
  let a;
820
822
  try {
821
823
  const f = o.default.readFileSync(c, "utf-8");
822
- a = ke(f, M);
824
+ a = Re(f, C);
823
825
  } catch (f) {
824
826
  console.error("❌ Failed to read HTML for HMR:", f.message);
825
827
  return;
826
828
  }
827
- if (Ne) {
828
- const f = X.get(M);
829
+ if (Te) {
830
+ const f = X.get(C);
829
831
  if (!f || f.size === 0)
830
832
  return;
831
833
  console.log(`🔥 Notifying ${f.size} HMR client(s)`);
832
834
  const h = JSON.stringify({
833
835
  type: "update",
834
836
  html: a
835
- }), w = qe(h);
836
- f.forEach(($) => {
837
+ }), y = qe(h);
838
+ f.forEach((S) => {
837
839
  try {
838
- $.write(w);
840
+ S.write(y);
839
841
  } catch {
840
- f.delete($);
842
+ f.delete(S);
841
843
  }
842
844
  });
843
845
  } else {
844
846
  const f = JSON.stringify({
845
- componentId: M,
847
+ componentId: C,
846
848
  html: a
847
849
  }), h = {
848
850
  hostname: "localhost",
@@ -854,64 +856,64 @@ Sec-WebSocket-Accept: ${$}\r
854
856
  "Content-Length": Buffer.byteLength(f)
855
857
  },
856
858
  timeout: 5e3
857
- }, w = n.default.request(h, ($) => {
859
+ }, y = n.default.request(h, (S) => {
858
860
  let I = "";
859
- $.on("data", (F) => I += F), $.on("end", () => {
861
+ S.on("data", (T) => I += T), S.on("end", () => {
860
862
  try {
861
- const F = JSON.parse(I);
862
- F.notified > 0 && console.log(`🔥 Notified ${F.notified} HMR client(s) via server`);
863
+ const T = JSON.parse(I);
864
+ T.notified > 0 && console.log(`🔥 Notified ${T.notified} HMR client(s) via server`);
863
865
  } catch {
864
866
  }
865
867
  });
866
868
  });
867
- w.on("error", () => {
868
- }), w.on("timeout", () => {
869
- w.destroy();
870
- }), w.write(f), w.end();
869
+ y.on("error", () => {
870
+ }), y.on("timeout", () => {
871
+ y.destroy();
872
+ }), y.write(f), y.end();
871
873
  }
872
874
  };
873
- let Re = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
875
+ let Ne = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
876
  const he = (c) => {
875
- if (S) {
876
- x = !0;
877
+ if (x) {
878
+ $ = !0;
877
879
  return;
878
880
  }
879
- S = !0, console.log(`
881
+ x = !0, console.log(`
880
882
  🔨 Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (a, f, h) => {
881
- if (S = !1, a) {
882
- const w = await pt(a, f, h, e, {
883
- ...Re,
883
+ if (x = !1, a) {
884
+ const y = await pt(a, f, h, e, {
885
+ ...Ne,
884
886
  onRetry: () => he(c)
885
887
  });
886
- Re = { ...Re, ...w }, w.handled || (console.error("❌ Build failed:", a.message), h && console.error(h));
888
+ Ne = { ...Ne, ...y }, y.handled || (console.error("❌ Build failed:", a.message), h && console.error(h));
887
889
  } else
888
890
  console.log("✅ Build completed"), f && console.log(f), Xe(), c && c();
889
- x && (x = !1, he());
891
+ $ && ($ = !1, he());
890
892
  });
891
893
  }, et = /* @__PURE__ */ new Set(), _e = (c) => {
892
894
  o.default.readdir(c, { withFileTypes: !0 }, (a, f) => {
893
895
  a || (f.forEach((h) => {
894
- const w = t.default.join(c, h.name);
896
+ const y = t.default.join(c, h.name);
895
897
  if (h.isDirectory())
896
- h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(w);
898
+ h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(y);
897
899
  else if (h.isFile()) {
898
- const $ = t.default.extname(h.name);
899
- if ($ === ".js" || $ === ".css" || $ === ".html")
900
+ const S = t.default.extname(h.name);
901
+ if (S === ".js" || S === ".css" || S === ".html")
900
902
  try {
901
- const I = o.default.readFileSync(w, "utf-8");
902
- P.set(w, I);
903
+ const I = o.default.readFileSync(y, "utf-8");
904
+ M.set(y, I);
903
905
  } catch {
904
906
  }
905
907
  }
906
- }), et.has(c) || (et.add(c), o.default.watch(c, (h, w) => {
907
- if (!w) return;
908
- const $ = t.default.extname(w);
909
- if ($ !== ".js" && $ !== ".css" && $ !== ".html") return;
910
- const I = t.default.join(c, w);
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);
911
913
  setTimeout(() => {
912
914
  try {
913
- const F = o.default.readFileSync(I, "utf-8"), H = P.get(I);
914
- F !== H && (P.set(I, F), console.log(`📝 File changed: ${I}`), g ? Xe() : he());
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
917
  } catch {
916
918
  }
917
919
  }, 50);
@@ -919,8 +921,8 @@ Sec-WebSocket-Accept: ${$}\r
919
921
  });
920
922
  }, tt = (c) => {
921
923
  console.log(`
922
- 🔨 Component: ${M}`), g ? (console.log("📄 No build needed (single HTML file mode)"), _e(T), console.log(`👀 Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
923
- `), c && c()) : (he(c), _e(T), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
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
926
  `));
925
927
  }, xt = () => new Promise((c) => {
926
928
  const a = {
@@ -930,7 +932,17 @@ Sec-WebSocket-Accept: ${$}\r
930
932
  method: "GET",
931
933
  timeout: 1e3
932
934
  }, f = n.default.request(a, (h) => {
933
- c(!0);
935
+ let y = "";
936
+ h.on("data", (S) => y += S), h.on("end", () => {
937
+ try {
938
+ (JSON.parse(y).components || []).map((T) => T[0]).includes(C) || ke().then(() => {
939
+ console.log(`🔄 Re-registered component: ${C}`);
940
+ }).catch(() => {
941
+ });
942
+ } catch {
943
+ }
944
+ c(!0);
945
+ });
934
946
  });
935
947
  f.on("error", () => c(!1)), f.on("timeout", () => {
936
948
  f.destroy(), c(!1);
@@ -938,28 +950,28 @@ Sec-WebSocket-Accept: ${$}\r
938
950
  }), $t = () => new Promise((c) => {
939
951
  const a = n.default.createServer((f, h) => {
940
952
  if (h.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
941
- let w = "";
942
- f.on("data", ($) => w += $), f.on("end", () => {
953
+ let y = "";
954
+ f.on("data", (S) => y += S), f.on("end", () => {
943
955
  try {
944
- const { componentId: $, distPath: I, componentName: F, htmlFile: H } = JSON.parse(w);
945
- N.set($, { path: I, name: F || null, htmlFile: H || null });
946
- const Y = F ? ` (${F})` : "";
947
- console.log(`✅ Registered: ${$}${Y} -> ${I}${H ? "/" + H : ""}`), h.writeHead(200), h.end(JSON.stringify({ success: !0, registered: Array.from(N.keys()) }));
948
- } catch ($) {
949
- h.writeHead(400), h.end(JSON.stringify({ error: $.message }));
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 }));
950
962
  }
951
963
  });
952
964
  } else if (f.method === "POST" && f.url === "/_unregister") {
953
- let w = "";
954
- f.on("data", ($) => w += $), f.on("end", () => {
965
+ let y = "";
966
+ f.on("data", (S) => y += S), f.on("end", () => {
955
967
  try {
956
- const { componentId: $ } = JSON.parse(w);
957
- N.delete($), console.log(`❌ Unregistered: ${$}`), h.writeHead(200), h.end(JSON.stringify({ success: !0 }));
958
- } catch ($) {
959
- h.writeHead(400), h.end(JSON.stringify({ error: $.message }));
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 }));
960
972
  }
961
973
  });
962
- } else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(N.entries()) }))) : (h.writeHead(404), h.end(JSON.stringify({ error: "Not found" })));
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" })));
963
975
  });
964
976
  a.on("error", () => {
965
977
  c(!1);
@@ -969,14 +981,14 @@ Sec-WebSocket-Accept: ${$}\r
969
981
  a.close(), c(!1);
970
982
  }), ge.listen(l, () => {
971
983
  console.log(`📡 Main server running at http://localhost:${l}`);
972
- const f = g ? t.default.resolve(T) : t.default.resolve(T, y);
973
- N.set(M, {
984
+ const f = g ? t.default.resolve(F) : t.default.resolve(F, w);
985
+ _.set(C, {
974
986
  path: f,
975
- name: _,
987
+ name: N,
976
988
  htmlFile: g ? u : null
977
989
  });
978
- const h = _ ? ` (${_})` : "";
979
- console.log(`✅ Registered component: ${M}${h}`), console.log(`📡 Access at: http://localhost:${l}/view/${M}/`), c(!0);
990
+ const h = N ? ` (${N})` : "";
991
+ console.log(`✅ Registered component: ${C}${h}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), c(!0);
980
992
  });
981
993
  });
982
994
  });
@@ -984,9 +996,9 @@ Sec-WebSocket-Accept: ${$}\r
984
996
  const ot = () => {
985
997
  ye = setInterval(async () => {
986
998
  await xt() || (clearInterval(ye), console.log(`
987
- ⚠️ Server appears to be down, attempting to take over...`), await $t() ? (console.log("✅ Successfully took over as server"), Ne = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
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 () => {
988
1000
  try {
989
- await Ze(), console.log(`✅ Re-registered component: ${M}`), ot();
1001
+ await ke(), console.log(`✅ Re-registered component: ${C}`), ot();
990
1002
  } catch (f) {
991
1003
  console.error("❌ Failed to re-register:", f.message);
992
1004
  }
@@ -998,16 +1010,16 @@ Sec-WebSocket-Accept: ${$}\r
998
1010
  🛑 Shutting down...`), ye && clearInterval(ye), await vt(), process.exit(0);
999
1011
  };
1000
1012
  process.on("SIGINT", nt), process.on("SIGTERM", nt);
1001
- let Ne = !1;
1013
+ let Te = !1;
1002
1014
  Oe.on("error", async (c) => {
1003
1015
  if (c.code === "EADDRINUSE") {
1004
1016
  console.log(`
1005
1017
  🔗 Connecting to existing dev server...`);
1006
1018
  try {
1007
- M = await D();
1008
- const a = await Ze();
1009
- console.log(`✅ Registered component: ${M}`), console.log(`📡 Access at: http://localhost:${l}/view/${M}/`), console.log(`📋 All registered components: ${a.registered.join(", ")}`), tt(() => {
1010
- process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${M}/`);
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}/`);
1011
1023
  }), ot();
1012
1024
  } catch (a) {
1013
1025
  console.error("❌ Failed to register component:", a.message), process.exit(1);
@@ -1015,20 +1027,20 @@ Sec-WebSocket-Accept: ${$}\r
1015
1027
  } else
1016
1028
  console.error("❌ Management server error:", c.message), process.exit(1);
1017
1029
  }), Oe.on("upgrade", wt), Oe.listen(d, async () => {
1018
- Ne = !0, console.log(`
1030
+ Te = !0, console.log(`
1019
1031
  🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", (c) => {
1020
1032
  console.error("❌ Main server error:", c.message), process.exit(1);
1021
1033
  }), ge.listen(l, async () => {
1022
- console.log(`📡 Main server running at http://localhost:${l}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
1023
- const c = g ? t.default.resolve(T) : t.default.resolve(T, y);
1024
- N.set(M, {
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, {
1025
1037
  path: c,
1026
- name: _,
1038
+ name: N,
1027
1039
  htmlFile: g ? u : null
1028
1040
  });
1029
- const a = _ ? ` (${_})` : "";
1030
- console.log(`✅ Registered component: ${M}${a}`), console.log(`📡 Access at: http://localhost:${l}/view/${M}/`), tt(() => {
1031
- process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${M}/`);
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}/`);
1032
1044
  });
1033
1045
  });
1034
1046
  });
@@ -1086,10 +1098,10 @@ const A = class A {
1086
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);
1087
1099
  this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
1088
1100
  for (let d = 0; d < t; d++) {
1089
- const y = this.components[d], S = Math.floor(d / n), x = d % n;
1090
- this.panelPositions.set(y.name, {
1091
- row: r + 1 + S * l,
1092
- col: x * i + 1,
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,
1104
+ col: $ * i + 1,
1093
1105
  width: i,
1094
1106
  height: l
1095
1107
  });
@@ -1139,33 +1151,33 @@ const A = class A {
1139
1151
  renderPanel(t) {
1140
1152
  const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
1141
1153
  if (!s) return;
1142
- 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], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, x - 20);
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);
1143
1155
  let O = `${g}┌─${e.reset} ${d}${l.icon}${e.reset} `;
1144
1156
  O += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${d}${l.label}${e.reset} `;
1145
1157
  const b = 5 + E.length + l.label.length + 3;
1146
- O += `${g}${"─".repeat(Math.max(0, x - b))}┐${e.reset}`, u.push(A.ESC.moveTo(s.row, s.col) + O);
1147
- const P = (r.path || "").substring(0, x - 6);
1148
- let j = `${g}│${e.reset} ${e.dim}${P}${e.reset}`;
1149
- j += " ".repeat(Math.max(0, x - P.length - 3)), j += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 1, s.col) + j);
1150
- const M = y.length, _ = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
1151
- let k = `${g}├${"─".repeat(x - _.length - 4)}${e.reset}`;
1152
- _ && (k += `${e.dim}${_}${e.reset}`), k += `${g}${"─".repeat(2)}┤${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
1153
- const L = y.slice(S, S + this.visibleLogLines);
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
1166
  for (let D = 0; D < this.visibleLogLines; D++) {
1155
- const T = L[D];
1167
+ const F = L[D];
1156
1168
  let W = `${g}│${e.reset}`;
1157
- if (T) {
1158
- let N = e.white;
1159
- T.type === "success" ? N = e.green : T.type === "error" ? N = e.red : T.type === "warning" ? N = e.yellow : T.type === "hmr" ? N = e.magenta : T.type === "change" && (N = e.blue);
1160
- const oe = T.message.substring(0, x - 12);
1161
- W += `${e.dim}${T.timestamp}${e.reset} ${N}${oe}${e.reset}`;
1162
- const Ie = x - T.timestamp.length - oe.length - 2;
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;
1163
1175
  W += " ".repeat(Math.max(0, Ie));
1164
1176
  } else
1165
- W += " ".repeat(x - 2);
1177
+ W += " ".repeat($ - 2);
1166
1178
  W += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 3 + D, s.col) + W);
1167
1179
  }
1168
- u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}└${"─".repeat(x - 2)}┘${e.reset}`), process.stdout.write(u.join(""));
1180
+ u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}└${"─".repeat($ - 2)}┘${e.reset}`), process.stdout.write(u.join(""));
1169
1181
  }
1170
1182
  fullRender() {
1171
1183
  const t = A.C;
@@ -1224,16 +1236,16 @@ ve(A, "STATUS", {
1224
1236
  warning: { icon: "⚠", color: "yellow", label: "Warning" },
1225
1237
  stopped: { icon: "■", color: "gray", label: "Stopped" }
1226
1238
  });
1227
- let Ue = A;
1228
- async function zt(o) {
1239
+ let He = A;
1240
+ async function Wt(o) {
1229
1241
  const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((d) => ({
1230
1242
  name: d.name,
1231
1243
  path: d.path,
1232
1244
  id: d.componentId || ""
1233
- })), i = new Ue(s), r = [], p = (d) => {
1234
- const y = process.platform;
1235
- let S;
1236
- y === "darwin" ? S = `open "${d}"` : y === "win32" ? S = `start "" "${d}"` : S = `xdg-open "${d}"`, e(S, () => {
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, () => {
1237
1249
  });
1238
1250
  }, m = () => {
1239
1251
  i.clear(), console.log(`
@@ -1247,44 +1259,44 @@ async function zt(o) {
1247
1259
  process.on("SIGINT", m), process.on("SIGTERM", m);
1248
1260
  const l = process.argv[1];
1249
1261
  for (let d = 0; d < o.length; d++) {
1250
- const y = o[d], S = y.name;
1251
- i.setStatus(S, "⏳ Starting..."), i.log(S, `Starting in ${y.path}`);
1252
- const x = t("node", [l, "dev"], {
1253
- cwd: n.default.resolve(y.path),
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),
1254
1266
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1255
1267
  stdio: ["ignore", "pipe", "pipe"]
1256
1268
  });
1257
- r.push(x);
1269
+ r.push($);
1258
1270
  let g = "";
1259
- x.stdout.on("data", (u) => {
1271
+ $.stdout.on("data", (u) => {
1260
1272
  g += u.toString();
1261
1273
  const E = g.split(`
1262
1274
  `);
1263
1275
  g = E.pop() || "";
1264
1276
  for (const O of E) {
1265
1277
  const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
- b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(S, "✅ Ready") : b.includes("Building...") || b.includes("Running initial build") ? i.setStatus(S, "🔨 Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? i.setStatus(S, "✅ Ready") : b.includes("Build failed") ? i.setStatus(S, "❌ Build Error") : b.includes("File changed") ? (i.setStatus(S, "📝 Changed"), setTimeout(() => i.setStatus(S, "✅ Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (i.setStatus(S, "🔥 HMR Update"), setTimeout(() => i.setStatus(S, "✅ Ready"), 1e3)) : b.includes("HMR client connected") && (i.setStatus(S, "🔥 HMR Connected"), setTimeout(() => i.setStatus(S, "✅ 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(S, b));
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));
1267
1279
  }
1268
- }), x.stderr.on("data", (u) => {
1280
+ }), $.stderr.on("data", (u) => {
1269
1281
  const E = u.toString().split(`
1270
1282
  `);
1271
1283
  for (const O of E) {
1272
1284
  const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
- b && (i.log(S, `⚠️ ${b}`), i.setStatus(S, "⚠️ Warning"));
1285
+ b && (i.log(x, `⚠️ ${b}`), i.setStatus(x, "⚠️ Warning"));
1274
1286
  }
1275
- }), x.on("exit", (u) => {
1276
- u !== 0 && u !== null && (i.setStatus(S, `❌ Exited (${u})`), i.log(S, `Process exited with code ${u}`));
1287
+ }), $.on("exit", (u) => {
1288
+ u !== 0 && u !== null && (i.setStatus(x, `❌ Exited (${u})`), i.log(x, `Process exited with code ${u}`));
1277
1289
  }), d < o.length - 1 && await new Promise((u) => setTimeout(u, 500));
1278
1290
  }
1279
1291
  i.render(), setTimeout(() => {
1280
1292
  p("http://localhost:9292");
1281
1293
  }, 2e3);
1282
1294
  }
1283
- const Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1295
+ const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1284
1296
  __proto__: null,
1285
1297
  devCommand: Ce,
1286
- monorepoDevCommand: zt
1287
- }, Symbol.toStringTag, { value: "Module" })), Vt = "https://cloud.myop.dev";
1298
+ monorepoDevCommand: Wt
1299
+ }, Symbol.toStringTag, { value: "Module" })), Yt = "https://cloud.myop.dev";
1288
1300
  async function mt(o, t) {
1289
1301
  const e = await fetch(o, {
1290
1302
  headers: { Authorization: `Bearer ${t}` }
@@ -1299,7 +1311,7 @@ function pe(o, t, e) {
1299
1311
  const n = R.resolve(R.join(o, t)), s = R.resolve(o);
1300
1312
  if (!n.startsWith(s + R.sep))
1301
1313
  throw new Error(`Invalid path: "${t}" escapes output directory`);
1302
- C.mkdirSync(R.dirname(n), { recursive: !0 }), C.writeFileSync(n, JSON.stringify(e, null, 2));
1314
+ P.mkdirSync(R.dirname(n), { recursive: !0 }), P.writeFileSync(n, JSON.stringify(e, null, 2));
1303
1315
  }
1304
1316
  async function $e(o, t, e, n) {
1305
1317
  return mt(
@@ -1307,7 +1319,7 @@ async function $e(o, t, e, n) {
1307
1319
  t
1308
1320
  );
1309
1321
  }
1310
- async function Yt(o, t, e, n) {
1322
+ async function Gt(o, t, e, n) {
1311
1323
  let s = 0;
1312
1324
  const i = /* @__PURE__ */ new Set();
1313
1325
  for (const r of n) {
@@ -1331,7 +1343,7 @@ async function Yt(o, t, e, n) {
1331
1343
  }
1332
1344
  return s;
1333
1345
  }
1334
- async function Gt(o, t, e) {
1346
+ async function Kt(o, t, e) {
1335
1347
  const n = await mt(`${o}/export`, t);
1336
1348
  pe(e, "manifest.json", n);
1337
1349
  let s = 0, i = 0;
@@ -1351,10 +1363,10 @@ async function Gt(o, t, e) {
1351
1363
  }
1352
1364
  return { manifest: n, fileCount: s, errorCount: i };
1353
1365
  }
1354
- function Kt() {
1366
+ function Qt() {
1355
1367
  v.program.command("export").description("Export components as static JSON for self-hosting").option("-k, --api-key <key>", "Myop API key (or set MYOP_API_KEY env var)").option("-o, --output <dir>", "Output directory", "./myop-static").option("-u, --url <url>", "Myop API URL (or set MYOP_API_URL env var)").option("--releases <json>", "JSON array of releases for incremental sync (from webhook payload)").option("--component <id>", "Single component ID for incremental sync").option("--env <env>", "Environment for single component sync (used with --component)").action(async (o) => {
1356
1368
  var i;
1357
- const t = o.apiKey || process.env.MYOP_API_KEY, e = o.url || process.env.MYOP_API_URL || Vt, n = o.output || process.env.OUTPUT_DIR || "./myop-static";
1369
+ const t = o.apiKey || process.env.MYOP_API_KEY, e = o.url || process.env.MYOP_API_URL || Yt, n = o.output || process.env.OUTPUT_DIR || "./myop-static";
1358
1370
  t || (console.error("Error: API key required. Use --api-key or set MYOP_API_KEY env var."), console.error("Create one at: Dashboard > Rollout Settings > Self-Hosting > API Keys"), process.exit(1));
1359
1371
  let s = null;
1360
1372
  if (o.releases)
@@ -1367,7 +1379,7 @@ function Kt() {
1367
1379
  if (s) {
1368
1380
  const r = z(`Incremental export: ${s.length} component(s)...`).start();
1369
1381
  try {
1370
- const p = await Yt(e, t, n, s);
1382
+ const p = await Gt(e, t, n, s);
1371
1383
  r.succeed(`Incremental export done. ${p} file(s) written to ${n}/`);
1372
1384
  } catch (p) {
1373
1385
  r.fail(`Export failed: ${p.message}`), process.exit(1);
@@ -1375,7 +1387,7 @@ function Kt() {
1375
1387
  } else {
1376
1388
  const r = z(`Full export from ${e}...`).start();
1377
1389
  try {
1378
- const { manifest: p, fileCount: m, errorCount: l } = await Gt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
1390
+ const { manifest: p, fileCount: m, errorCount: l } = await Kt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
1379
1391
  r.succeed(
1380
1392
  `Full export done. ${m} file(s) from ${d} component(s) written to ${n}/`
1381
1393
  ), l > 0 && console.warn(` ${l} file(s) failed.`);
@@ -1386,65 +1398,65 @@ function Kt() {
1386
1398
  process.exit(0);
1387
1399
  });
1388
1400
  }
1389
- const He = R.join(at.homedir(), ".myop"), ue = R.join(He, "credentials.json");
1390
- function Qt() {
1391
- C.existsSync(He) || C.mkdirSync(He, { recursive: !0, mode: 448 });
1401
+ const Be = R.join(at.homedir(), ".myop"), ue = R.join(Be, "credentials.json");
1402
+ function Zt() {
1403
+ P.existsSync(Be) || P.mkdirSync(Be, { recursive: !0, mode: 448 });
1392
1404
  }
1393
- function Ve() {
1405
+ function Ye() {
1394
1406
  try {
1395
- if (!C.existsSync(ue))
1407
+ if (!P.existsSync(ue))
1396
1408
  return null;
1397
- const o = C.readFileSync(ue, "utf8");
1409
+ const o = P.readFileSync(ue, "utf8");
1398
1410
  return JSON.parse(o);
1399
1411
  } catch (o) {
1400
1412
  return console.info("Failed to read credentials:", o.message), null;
1401
1413
  }
1402
1414
  }
1403
1415
  function ut(o) {
1404
- Qt();
1416
+ Zt();
1405
1417
  const t = {
1406
1418
  ...o,
1407
1419
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
1408
1420
  };
1409
- C.writeFileSync(ue, JSON.stringify(t, null, 2), {
1421
+ P.writeFileSync(ue, JSON.stringify(t, null, 2), {
1410
1422
  mode: 384
1411
1423
  // Read/write for owner only
1412
1424
  });
1413
1425
  }
1414
1426
  function ft() {
1415
1427
  try {
1416
- return C.existsSync(ue) && C.unlinkSync(ue), !0;
1428
+ return P.existsSync(ue) && P.unlinkSync(ue), !0;
1417
1429
  } catch (o) {
1418
1430
  return console.error("Failed to clear credentials:", o.message), !1;
1419
1431
  }
1420
1432
  }
1421
- function Zt(o) {
1433
+ function qt(o) {
1422
1434
  if (!o || !o.expiresAt)
1423
1435
  return !0;
1424
1436
  const t = 5 * 60 * 1e3, e = new Date(o.expiresAt).getTime();
1425
1437
  return Date.now() > e - t;
1426
1438
  }
1427
1439
  function Pe() {
1428
- const o = Ve();
1440
+ const o = Ye();
1429
1441
  return o ? {
1430
1442
  email: o.userEmail,
1431
1443
  userId: o.userId
1432
1444
  } : null;
1433
1445
  }
1434
- const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284, Ye = `http://localhost:${xe}/callback`, qt = "myop-cli";
1435
- function Xt() {
1436
- return ze.randomBytes(32).toString("base64url");
1446
+ const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284, Ge = `http://localhost:${xe}/callback`, Xt = "myop-cli";
1447
+ function eo() {
1448
+ return We.randomBytes(32).toString("base64url");
1437
1449
  }
1438
- function eo(o) {
1439
- return ze.createHash("sha256").update(o).digest("base64url");
1450
+ function to(o) {
1451
+ return We.createHash("sha256").update(o).digest("base64url");
1440
1452
  }
1441
- async function to() {
1453
+ async function oo() {
1442
1454
  const o = await fetch(`${le}/oauth/register`, {
1443
1455
  method: "POST",
1444
1456
  headers: { "Content-Type": "application/json" },
1445
1457
  body: JSON.stringify({
1446
- client_name: qt,
1447
- redirect_uris: [Ye],
1458
+ client_name: Xt,
1459
+ redirect_uris: [Ge],
1448
1460
  grant_types: ["authorization_code", "refresh_token"],
1449
1461
  response_types: ["code"]
1450
1462
  })
@@ -1621,7 +1633,7 @@ function Se(o, t, e, n = null) {
1621
1633
  </body>
1622
1634
  </html>`;
1623
1635
  }
1624
- function oo(o) {
1636
+ function no(o) {
1625
1637
  return new Promise((t, e) => {
1626
1638
  const n = It.createServer((s, i) => {
1627
1639
  const r = new it(s.url, `http://localhost:${xe}`);
@@ -1669,7 +1681,7 @@ function oo(o) {
1669
1681
  }, 5 * 60 * 1e3);
1670
1682
  });
1671
1683
  }
1672
- async function no(o, t, e) {
1684
+ async function so(o, t, e) {
1673
1685
  const n = await fetch(`${le}/oauth/token`, {
1674
1686
  method: "POST",
1675
1687
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
@@ -1677,7 +1689,7 @@ async function no(o, t, e) {
1677
1689
  grant_type: "authorization_code",
1678
1690
  code: o,
1679
1691
  client_id: t,
1680
- redirect_uri: Ye,
1692
+ redirect_uri: Ge,
1681
1693
  code_verifier: e
1682
1694
  })
1683
1695
  });
@@ -1687,7 +1699,7 @@ async function no(o, t, e) {
1687
1699
  }
1688
1700
  return n.json();
1689
1701
  }
1690
- async function so(o, t) {
1702
+ async function io(o, t) {
1691
1703
  const e = await fetch(`${le}/oauth/token`, {
1692
1704
  method: "POST",
1693
1705
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
@@ -1703,7 +1715,7 @@ async function so(o, t) {
1703
1715
  }
1704
1716
  return e.json();
1705
1717
  }
1706
- async function io(o) {
1718
+ async function ro(o) {
1707
1719
  var s, i, r;
1708
1720
  const t = await fetch(`${le}/mcp`, {
1709
1721
  method: "POST",
@@ -1735,17 +1747,17 @@ async function me() {
1735
1747
  const o = z("Starting authentication...").start();
1736
1748
  try {
1737
1749
  o.text = "Registering OAuth client...";
1738
- const e = (await to()).client_id, n = Xt(), s = eo(n), i = ze.randomBytes(16).toString("hex");
1750
+ const e = (await oo()).client_id, n = eo(), s = to(n), i = We.randomBytes(16).toString("hex");
1739
1751
  o.text = "Waiting for authorization...";
1740
- const r = oo(i), p = new it(`${le}/oauth/authorize`);
1741
- p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri", Ye), p.searchParams.set("code_challenge", s), p.searchParams.set("code_challenge_method", "S256"), p.searchParams.set("state", i), o.stop(), console.log(`
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(`
1742
1754
  🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${p.toString()}
1743
1755
  `), await Ot(p.toString());
1744
1756
  const m = await r;
1745
1757
  o.start("Exchanging authorization code...");
1746
- const l = await no(m, e, n);
1758
+ const l = await so(m, e, n);
1747
1759
  o.text = "Getting user info...";
1748
- const d = await io(l.access_token), y = {
1760
+ const d = await ro(l.access_token), w = {
1749
1761
  accessToken: l.access_token,
1750
1762
  refreshToken: l.refresh_token,
1751
1763
  expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
@@ -1753,35 +1765,35 @@ async function me() {
1753
1765
  userId: d.userId,
1754
1766
  userEmail: d.email
1755
1767
  };
1756
- return ut(y), o.succeed(`Authenticated as ${d.email}`), y;
1768
+ return ut(w), o.succeed(`Authenticated as ${d.email}`), w;
1757
1769
  } catch (t) {
1758
1770
  throw o.fail(`Authentication failed: ${t.message}`), t;
1759
1771
  }
1760
1772
  }
1761
1773
  async function gt() {
1762
- const o = Ve();
1774
+ const o = Ye();
1763
1775
  if (!o) {
1764
1776
  console.log("Not currently logged in.");
1765
1777
  return;
1766
1778
  }
1767
1779
  ft(), console.log(`✅ Logged out (was: ${o.userEmail})`);
1768
1780
  }
1769
- function ro(o) {
1781
+ function ao(o) {
1770
1782
  var e, n;
1771
1783
  const t = (o == null ? void 0 : o.message) || "";
1772
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";
1773
1785
  }
1774
- async function Ge() {
1775
- let o = Ve();
1786
+ async function Ke() {
1787
+ let o = Ye();
1776
1788
  if (!o)
1777
1789
  return console.log(`Not logged in. Starting authentication...
1778
1790
  `), await me();
1779
- if (!Zt(o))
1791
+ if (!qt(o))
1780
1792
  return o;
1781
1793
  if (o.refreshToken) {
1782
1794
  const t = z("Refreshing access token...").start();
1783
1795
  try {
1784
- const e = await so(
1796
+ const e = await io(
1785
1797
  o.refreshToken,
1786
1798
  o.clientId
1787
1799
  );
@@ -1792,7 +1804,7 @@ async function Ge() {
1792
1804
  expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
1793
1805
  }, ut(o), t.succeed("Token refreshed"), o;
1794
1806
  } catch (e) {
1795
- if (ro(e))
1807
+ if (ao(e))
1796
1808
  throw t.fail("Network error during token refresh"), e;
1797
1809
  return t.warn("Token refresh failed, please log in again"), ft(), await me();
1798
1810
  }
@@ -1803,30 +1815,30 @@ async function Ge() {
1803
1815
  function Me() {
1804
1816
  return le;
1805
1817
  }
1806
- const Z = "@myop/cli", Ae = process.platform === "win32";
1807
- function ao() {
1818
+ const Z = "@myop/cli", De = process.platform === "win32";
1819
+ function lo() {
1808
1820
  try {
1809
1821
  return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1810
1822
  } catch {
1811
1823
  return "https://registry.npmjs.org/";
1812
1824
  }
1813
1825
  }
1814
- function lo() {
1826
+ function co() {
1815
1827
  try {
1816
1828
  return Q("npm config get prefix", { encoding: "utf-8" }).trim();
1817
1829
  } catch {
1818
1830
  return null;
1819
1831
  }
1820
1832
  }
1821
- async function co() {
1833
+ async function po() {
1822
1834
  try {
1823
- const o = ao().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
1835
+ const o = lo().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
1824
1836
  return t.ok ? (await t.json()).version : null;
1825
1837
  } catch {
1826
1838
  return null;
1827
1839
  }
1828
1840
  }
1829
- function po(o, t) {
1841
+ function mo(o, t) {
1830
1842
  const e = o.split(".").map(Number), n = t.split(".").map(Number);
1831
1843
  for (let s = 0; s < Math.max(e.length, n.length); s++) {
1832
1844
  const i = e[s] || 0, r = n[s] || 0;
@@ -1835,12 +1847,12 @@ function po(o, t) {
1835
1847
  }
1836
1848
  return 0;
1837
1849
  }
1838
- async function mo(o) {
1850
+ async function uo(o) {
1839
1851
  const t = z({
1840
1852
  text: "Checking for updates...",
1841
1853
  color: "cyan"
1842
- }).start(), e = await co();
1843
- if (t.stop(), !e || po(e, o) <= 0)
1854
+ }).start(), e = await po();
1855
+ if (t.stop(), !e || mo(e, o) <= 0)
1844
1856
  return !1;
1845
1857
  console.log(`
1846
1858
  📦 New version available: ${o} → ${e}
@@ -1864,7 +1876,7 @@ async function mo(o) {
1864
1876
  const s = z({
1865
1877
  text: `Updating ${Z} to v${e}...`,
1866
1878
  color: "green"
1867
- }).start(), i = `npm install -g ${Z}@latest`, r = lo();
1879
+ }).start(), i = `npm install -g ${Z}@latest`, r = co();
1868
1880
  try {
1869
1881
  Q(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
1870
1882
  } catch {
@@ -1872,7 +1884,7 @@ async function mo(o) {
1872
1884
  🔐 Elevated permissions required.
1873
1885
  `);
1874
1886
  try {
1875
- if (Ae) {
1887
+ if (De) {
1876
1888
  const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${r ? `install -g ${Z}@latest --prefix \\"${r}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
1877
1889
  Q(`powershell -Command "${d}"`, { stdio: "inherit" });
1878
1890
  } else {
@@ -1884,7 +1896,7 @@ async function mo(o) {
1884
1896
  } catch {
1885
1897
  console.log(`
1886
1898
  ❌ Update failed`);
1887
- const d = Ae ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
1899
+ const d = De ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
1888
1900
  console.log(`
1889
1901
  Please run manually: ${d}
1890
1902
  `), process.exit(1);
@@ -1893,8 +1905,8 @@ Please run manually: ${d}
1893
1905
  let p = null;
1894
1906
  try {
1895
1907
  let m;
1896
- r ? m = Ae ? je(r, "node_modules") : je(r, "lib", "node_modules") : m = Q("npm root -g", { encoding: "utf-8" }).trim();
1897
- const l = je(m, Z, "package.json"), d = Et(l, "utf-8");
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");
1898
1910
  p = JSON.parse(d).version;
1899
1911
  } catch {
1900
1912
  }
@@ -1913,34 +1925,34 @@ Please run myop again to use the new version.
1913
1925
  }
1914
1926
  return !1;
1915
1927
  }
1916
- const Be = R.join(at.homedir(), ".myop"), Je = R.join(Be, "preferences.json");
1917
- function uo() {
1918
- C.existsSync(Be) || C.mkdirSync(Be, { recursive: !0, mode: 448 });
1928
+ const Je = R.join(at.homedir(), ".myop"), ze = R.join(Je, "preferences.json");
1929
+ function fo() {
1930
+ P.existsSync(Je) || P.mkdirSync(Je, { recursive: !0, mode: 448 });
1919
1931
  }
1920
1932
  function ht() {
1921
1933
  try {
1922
- if (!C.existsSync(Je))
1934
+ if (!P.existsSync(ze))
1923
1935
  return {};
1924
- const o = C.readFileSync(Je, "utf8");
1936
+ const o = P.readFileSync(ze, "utf8");
1925
1937
  return JSON.parse(o);
1926
1938
  } catch {
1927
1939
  return {};
1928
1940
  }
1929
1941
  }
1930
- function fo(o) {
1931
- uo();
1942
+ function go(o) {
1943
+ fo();
1932
1944
  const e = { ...ht(), ...o };
1933
- C.writeFileSync(Je, JSON.stringify(e, null, 2), {
1945
+ P.writeFileSync(ze, JSON.stringify(e, null, 2), {
1934
1946
  mode: 384
1935
1947
  });
1936
1948
  }
1937
- function go() {
1949
+ function ho() {
1938
1950
  return ht().defaultOrganization || null;
1939
1951
  }
1940
- function De({ id: o, name: t }) {
1941
- fo({ defaultOrganization: { id: o, name: t } });
1952
+ function Le({ id: o, name: t }) {
1953
+ go({ defaultOrganization: { id: o, name: t } });
1942
1954
  }
1943
- async function ho(o, t, e, n = {}) {
1955
+ async function yo(o, t, e, n = {}) {
1944
1956
  var p, m, l;
1945
1957
  const s = await fetch(`${o}/mcp`, {
1946
1958
  method: "POST",
@@ -1968,7 +1980,7 @@ async function ho(o, t, e, n = {}) {
1968
1980
  throw new Error(`No content returned from ${e}`);
1969
1981
  return JSON.parse(r);
1970
1982
  }
1971
- const yo = (o) => new Promise((t) => setTimeout(t, o));
1983
+ const wo = (o) => new Promise((t) => setTimeout(t, o));
1972
1984
  function re(o) {
1973
1985
  var e, n;
1974
1986
  const t = (o == null ? void 0 : o.message) || "";
@@ -1979,26 +1991,26 @@ function ae(o) {
1979
1991
  This usually happens in sandboxed environments (Claude Web, containers)`), console.error(` where outbound HTTP is restricted.
1980
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("");
1981
1993
  }
1982
- const wo = () => {
1994
+ const vo = () => {
1983
1995
  let o = new URL(import.meta.url).pathname;
1984
1996
  process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1985
1997
  const t = R.dirname(o);
1986
1998
  return R.join(t, "skills");
1987
- }, vo = (o) => {
1999
+ }, So = (o) => {
1988
2000
  try {
1989
2001
  const t = R.join(o, "package.json");
1990
- if (!C.existsSync(t)) return [];
1991
- const e = JSON.parse(C.readFileSync(t, "utf-8"));
2002
+ if (!P.existsSync(t)) return [];
2003
+ const e = JSON.parse(P.readFileSync(t, "utf-8"));
1992
2004
  return Object.keys({ ...e.dependencies, ...e.devDependencies });
1993
2005
  } catch {
1994
2006
  return [];
1995
2007
  }
1996
- }, Ke = async (o) => {
1997
- const t = wo();
1998
- if (!C.existsSync(t))
2008
+ }, Qe = async (o) => {
2009
+ const t = vo();
2010
+ if (!P.existsSync(t))
1999
2011
  return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
2000
2012
  try {
2001
- const e = vo(o), n = ["myop-cli", "myop-component"], s = [
2013
+ const e = So(o), n = ["myop-cli", "myop-component"], s = [
2002
2014
  { deps: ["@myop/react", "react"], skill: "myop-react-host" },
2003
2015
  { deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
2004
2016
  { deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
@@ -2010,20 +2022,20 @@ const wo = () => {
2010
2022
  } catch (e) {
2011
2023
  return console.info("Failed to install skills:", e.message), { success: !1 };
2012
2024
  }
2013
- }, Qe = (o = ".", t = 3, e = 0) => {
2025
+ }, Ze = (o = ".", t = 3, e = 0) => {
2014
2026
  const n = [];
2015
2027
  if (e > t) return n;
2016
2028
  try {
2017
- const s = C.readdirSync(o, { withFileTypes: !0 });
2029
+ const s = P.readdirSync(o, { withFileTypes: !0 });
2018
2030
  for (const i of s) {
2019
2031
  const r = R.join(o, i.name);
2020
2032
  if (i.isDirectory()) {
2021
2033
  if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
2022
2034
  continue;
2023
- n.push(...Qe(r, t, e + 1));
2035
+ n.push(...Ze(r, t, e + 1));
2024
2036
  } else if (i.name === "myop.config.json")
2025
2037
  try {
2026
- const p = C.readFileSync(r, "utf-8"), m = JSON.parse(p);
2038
+ const p = P.readFileSync(r, "utf-8"), m = JSON.parse(p);
2027
2039
  n.push({
2028
2040
  path: o,
2029
2041
  configPath: r,
@@ -2047,7 +2059,7 @@ const Ee = (o = !1) => {
2047
2059
  verbose: t
2048
2060
  };
2049
2061
  try {
2050
- return v.myopConfig = Rt(v.options.configPath), { configFound: !0 };
2062
+ return v.myopConfig = Nt(v.options.configPath), { configFound: !0 };
2051
2063
  } catch (e) {
2052
2064
  if (o) {
2053
2065
  console.info(`
@@ -2057,7 +2069,7 @@ const Ee = (o = !1) => {
2057
2069
  author: "@myop-cli",
2058
2070
  flows: []
2059
2071
  };
2060
- return We(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
2072
+ return Ve(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
2061
2073
  } catch {
2062
2074
  return console.info("Error details :", e), { configFound: !1, error: e };
2063
2075
  }
@@ -2066,12 +2078,12 @@ const Ee = (o = !1) => {
2066
2078
  }
2067
2079
  };
2068
2080
  [
2069
- new Le(),
2070
- ...Dt
2081
+ new Ue(),
2082
+ ...Lt
2071
2083
  ];
2072
- const So = "0.1.54";
2084
+ const xo = "0.1.56";
2073
2085
  v.program = new Pt();
2074
- v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(So);
2086
+ v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(xo);
2075
2087
  v.program.addOption(new fe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
2076
2088
  v.program.addOption(new fe("-h, --help", "Show helpful information"));
2077
2089
  v.program.addOption(new fe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
@@ -2113,12 +2125,12 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
2113
2125
  process.exit(0);
2114
2126
  });
2115
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) => {
2116
- var S, x, g;
2128
+ var x, $, g;
2117
2129
  const t = v.program.getOptionValue("config") || "./myop.config.json";
2118
2130
  let e = {};
2119
- if (C.existsSync(t))
2131
+ if (P.existsSync(t))
2120
2132
  try {
2121
- e = JSON.parse(C.readFileSync(t, "utf-8"));
2133
+ e = JSON.parse(P.readFileSync(t, "utf-8"));
2122
2134
  } catch (u) {
2123
2135
  console.error(`⚠️ Failed to parse ${t}:`, u.message);
2124
2136
  }
@@ -2128,13 +2140,13 @@ v.program.command("push").description("Upload component to Myop platform").argum
2128
2140
  📋 Component: ${n}`);
2129
2141
  let s = null, i = !1;
2130
2142
  try {
2131
- const u = JSON.parse(C.readFileSync("package.json", "utf-8"));
2143
+ const u = JSON.parse(P.readFileSync("package.json", "utf-8"));
2132
2144
  i = !!(u.scripts && u.scripts.build);
2133
2145
  } catch {
2134
2146
  }
2135
2147
  if (!i) {
2136
- const u = C.readdirSync(".").filter(
2137
- (E) => E.endsWith(".html") && !E.startsWith(".") && C.statSync(E).isFile()
2148
+ const u = P.readdirSync(".").filter(
2149
+ (E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
2138
2150
  );
2139
2151
  u.length === 1 && (s = u[0]);
2140
2152
  }
@@ -2143,22 +2155,22 @@ v.program.command("push").description("Upload component to Myop platform").argum
2143
2155
  else if (i) {
2144
2156
  const { exec: u } = await import("child_process");
2145
2157
  let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
2146
- const O = (P = !1) => new Promise((j) => {
2147
- const M = z(P ? "Retrying build..." : "Building project...").start();
2148
- u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (_, k, L) => {
2149
- if (!_) {
2150
- M.succeed("Build completed"), j(!0);
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) => {
2161
+ if (!N) {
2162
+ C.succeed("Build completed"), j(!0);
2151
2163
  return;
2152
2164
  }
2153
- if (M.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
2154
- const D = await pt(_, k, L, u, E);
2165
+ if (C.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
2166
+ const D = await pt(N, k, L, u, E);
2155
2167
  if (E = { ...E, ...D }, D.handled) {
2156
- const T = await O(!0);
2157
- j(T);
2168
+ const F = await O(!0);
2169
+ j(F);
2158
2170
  return;
2159
2171
  }
2160
2172
  }
2161
- console.error(_.message), j(!1);
2173
+ console.error(N.message), j(!1);
2162
2174
  });
2163
2175
  });
2164
2176
  await O() || process.exit(1);
@@ -2166,26 +2178,26 @@ v.program.command("push").description("Upload component to Myop platform").argum
2166
2178
  let r;
2167
2179
  if (s)
2168
2180
  r = s;
2169
- else if (C.existsSync("./dist/index.html"))
2181
+ else if (P.existsSync("./dist/index.html"))
2170
2182
  r = "./dist/index.html";
2171
2183
  else {
2172
- const u = C.readdirSync(".").filter(
2173
- (E) => E.endsWith(".html") && !E.startsWith(".") && C.statSync(E).isFile()
2184
+ const u = P.readdirSync(".").filter(
2185
+ (E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
2174
2186
  );
2175
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));
2176
2188
  }
2177
- const p = C.readFileSync(r, "utf-8");
2189
+ const p = P.readFileSync(r, "utf-8");
2178
2190
  console.log(` File: ${r} (${(p.length / 1024).toFixed(1)} KB)`);
2179
2191
  let m;
2180
2192
  try {
2181
- m = await Ge();
2193
+ m = await Ke();
2182
2194
  } catch (u) {
2183
2195
  re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("❌ Authentication failed:", u.message), console.error(`
2184
2196
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2185
2197
  `)), process.exit(1);
2186
2198
  }
2187
2199
  const l = Me();
2188
- let d = z("Uploading...").start(), y;
2200
+ let d = z("Uploading...").start(), w;
2189
2201
  try {
2190
2202
  const u = await fetch(`${l}/mcp`, {
2191
2203
  method: "POST",
@@ -2213,32 +2225,32 @@ v.program.command("push").description("Upload component to Myop platform").argum
2213
2225
  const E = await u.json();
2214
2226
  if (E.error)
2215
2227
  throw new Error(E.error.message);
2216
- const O = (g = (x = (S = E.result) == null ? void 0 : S.content) == null ? void 0 : x[0]) == null ? void 0 : g.text;
2217
- if (y = JSON.parse(O), !y.success)
2218
- throw new Error(y.error);
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);
2219
2231
  d.succeed("Pushed successfully");
2220
2232
  } catch (u) {
2221
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);
2222
2234
  }
2223
- if (y.isNewComponent || !e.componentId || e.componentId === "DEV") {
2224
- e.componentId = y.componentId, e.organization = y.orgId, e.name || (e.name = y.componentName);
2235
+ if (w.isNewComponent || !e.componentId || e.componentId === "DEV") {
2236
+ e.componentId = w.componentId, e.organization = w.orgId, e.name || (e.name = w.componentName);
2225
2237
  try {
2226
- C.writeFileSync(t, JSON.stringify(e, null, 2));
2238
+ P.writeFileSync(t, JSON.stringify(e, null, 2));
2227
2239
  } catch (u) {
2228
- console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
2240
+ console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${w.componentId}" manually`);
2229
2241
  }
2230
2242
  }
2231
2243
  console.log(`
2232
- ${y.componentName}`), console.log(` ${y.dashboardUrl}
2244
+ ${w.componentName}`), console.log(` ${w.dashboardUrl}
2233
2245
  `), process.exit(0);
2234
2246
  });
2235
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) => {
2236
2248
  var u, E, O;
2237
2249
  const e = v.program.getOptionValue("config") || "./myop.config.json";
2238
2250
  let n = {};
2239
- if (C.existsSync(e))
2251
+ if (P.existsSync(e))
2240
2252
  try {
2241
- n = JSON.parse(C.readFileSync(e, "utf-8"));
2253
+ n = JSON.parse(P.readFileSync(e, "utf-8"));
2242
2254
  } catch {
2243
2255
  }
2244
2256
  const s = o || n.componentId;
@@ -2248,7 +2260,7 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2248
2260
  📥 Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
2249
2261
  let r;
2250
2262
  try {
2251
- r = await Ge();
2263
+ r = await Ke();
2252
2264
  } catch (b) {
2253
2265
  re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("❌ Authentication failed:", b.message), console.error(`
2254
2266
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
@@ -2275,21 +2287,21 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2275
2287
  });
2276
2288
  if (!b.ok)
2277
2289
  throw new Error(`Server returned ${b.status}`);
2278
- const P = await b.json();
2279
- if (P.error)
2280
- throw new Error(P.error.message);
2281
- const j = (O = (E = (u = P.result) == null ? void 0 : u.content) == null ? void 0 : E[0]) == null ? void 0 : O.text;
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;
2282
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");
2283
2295
  } catch (b) {
2284
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);
2285
2297
  }
2286
2298
  let d = t.output;
2287
- d || (C.existsSync("./dist/index.html") ? d = "./dist/index.html" : d = "./index.html");
2288
- const y = l.htmlContent || l.html, S = R.dirname(d);
2289
- S && !C.existsSync(S) && C.mkdirSync(S, { recursive: !0 }), C.writeFileSync(d, y), console.log(` Saved to: ${d} (${(y.length / 1024).toFixed(1)} KB)`);
2290
- const x = C.existsSync(e);
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);
2291
2303
  let g = !1;
2292
- if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
2304
+ if ($ ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
2293
2305
  name: l.name || R.basename(process.cwd()),
2294
2306
  componentId: s,
2295
2307
  type: "html",
@@ -2297,7 +2309,7 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2297
2309
  HMR: !0
2298
2310
  }, g = !0), g)
2299
2311
  try {
2300
- C.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${x ? "Updated" : "Created"} ${e}`);
2312
+ P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${$ ? "Updated" : "Created"} ${e}`);
2301
2313
  } catch (b) {
2302
2314
  console.log(` ⚠️ Could not write ${e}: ${b.message}`);
2303
2315
  }
@@ -2309,13 +2321,13 @@ v.program.command("list").description("Browse and pull/push remote components").
2309
2321
  const { search: t, select: e } = await import("@inquirer/prompts");
2310
2322
  let n;
2311
2323
  try {
2312
- n = await Ge();
2324
+ n = await Ke();
2313
2325
  } catch (g) {
2314
2326
  re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("❌ Authentication failed:", g.message), console.error(`
2315
2327
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2316
2328
  `)), process.exit(1);
2317
2329
  }
2318
- const s = Me(), i = (g, u) => ho(s, n.accessToken, g, u);
2330
+ const s = Me(), i = (g, u) => yo(s, n.accessToken, g, u);
2319
2331
  let r = z("Loading organizations...").start(), p;
2320
2332
  try {
2321
2333
  const g = await i("list_organizations");
@@ -2328,13 +2340,13 @@ v.program.command("list").description("Browse and pull/push remote components").
2328
2340
  let m, l;
2329
2341
  if (o.org) {
2330
2342
  const g = p.find((u) => u.id === o.org || u._id === o.org);
2331
- 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, De({ id: m, name: l });
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 });
2332
2344
  } else {
2333
- const g = go();
2345
+ const g = ho();
2334
2346
  if (g && p.find((u) => (u.id || u._id) === g.id))
2335
2347
  m = g.id, l = g.name;
2336
2348
  else if (p.length === 1)
2337
- m = p[0].id || p[0]._id, l = p[0].name, De({ id: m, name: l });
2349
+ m = p[0].id || p[0]._id, l = p[0].name, Le({ id: m, name: l });
2338
2350
  else
2339
2351
  try {
2340
2352
  const u = await e({
@@ -2344,7 +2356,7 @@ v.program.command("list").description("Browse and pull/push remote components").
2344
2356
  value: { id: E.id || E._id, name: E.name }
2345
2357
  }))
2346
2358
  });
2347
- m = u.id, l = u.name, De({ id: m, name: l });
2359
+ m = u.id, l = u.name, Le({ id: m, name: l });
2348
2360
  } catch (u) {
2349
2361
  throw u.name === "ExitPromptError" && (console.log(`
2350
2362
 
@@ -2364,47 +2376,47 @@ v.program.command("list").description("Browse and pull/push remote components").
2364
2376
  r.stop(), d.length === 0 && (console.log(` No components found in this organization.
2365
2377
  `), process.exit(0)), console.log(` ${l} - ${d.length} component(s)
2366
2378
  `);
2367
- const y = [];
2379
+ const w = [];
2368
2380
  for (; ; ) {
2369
- const g = `[Done - pull/push ${y.length} selected]`, u = "__done__", E = new Set(y.map((P) => P.id || P._id || P.componentId));
2381
+ const g = `[Done - pull/push ${w.length} selected]`, u = "__done__", E = new Set(w.map((M) => M.id || M._id || M.componentId));
2370
2382
  let O;
2371
2383
  try {
2372
2384
  O = await t({
2373
2385
  message: "Search & select components:",
2374
- source: (P) => {
2375
- const j = (P || "").toLowerCase(), M = d.filter((k) => {
2386
+ source: (M) => {
2387
+ const j = (M || "").toLowerCase(), C = d.filter((k) => {
2376
2388
  const L = k.id || k._id || k.componentId;
2377
2389
  return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
2378
- }), _ = [
2390
+ }), N = [
2379
2391
  { name: g, value: u }
2380
2392
  ];
2381
- for (const k of M) {
2393
+ for (const k of C) {
2382
2394
  const L = k.id || k._id || k.componentId, D = L ? L.substring(0, 8) + "..." : "";
2383
- _.push({
2395
+ N.push({
2384
2396
  name: `${k.name} (${D})`,
2385
2397
  value: L
2386
2398
  });
2387
2399
  }
2388
- return _;
2400
+ return N;
2389
2401
  }
2390
2402
  });
2391
- } catch (P) {
2392
- throw P.name === "ExitPromptError" && (console.log(`
2403
+ } catch (M) {
2404
+ throw M.name === "ExitPromptError" && (console.log(`
2393
2405
 
2394
2406
  👋 Goodbye!
2395
- `), process.exit(0)), P;
2407
+ `), process.exit(0)), M;
2396
2408
  }
2397
2409
  if (O === u)
2398
2410
  break;
2399
- const b = d.find((P) => (P.id || P._id || P.componentId) === O);
2400
- b && (y.push(b), console.log(` + ${b.name}`));
2411
+ const b = d.find((M) => (M.id || M._id || M.componentId) === O);
2412
+ b && (w.push(b), console.log(` + ${b.name}`));
2401
2413
  }
2402
- y.length === 0 && (console.log(` No components selected.
2414
+ w.length === 0 && (console.log(` No components selected.
2403
2415
  `), process.exit(0));
2404
- let S;
2416
+ let x;
2405
2417
  try {
2406
- S = await e({
2407
- message: `${y.length} component(s) selected:`,
2418
+ x = await e({
2419
+ message: `${w.length} component(s) selected:`,
2408
2420
  choices: [
2409
2421
  { name: "Pull selected", value: "pull" },
2410
2422
  { name: "Push selected", value: "push" },
@@ -2417,22 +2429,22 @@ v.program.command("list").description("Browse and pull/push remote components").
2417
2429
  👋 Goodbye!
2418
2430
  `), process.exit(0)), g;
2419
2431
  }
2420
- S === "cancel" && (console.log(` Cancelled.
2432
+ x === "cancel" && (console.log(` Cancelled.
2421
2433
  `), process.exit(0));
2422
- const x = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2423
- if (S === "pull") {
2434
+ const $ = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2435
+ if (x === "pull") {
2424
2436
  console.log(`
2425
- Pulling ${y.length} components...
2437
+ Pulling ${w.length} components...
2426
2438
  `);
2427
- const g = await Promise.all(y.map(async (O) => {
2439
+ const g = await Promise.all(w.map(async (O) => {
2428
2440
  const b = O.id || O._id || O.componentId;
2429
2441
  try {
2430
- const P = await i("get_component", { componentId: b }), j = x(O.name);
2431
- C.mkdirSync(j, { recursive: !0 });
2432
- const M = P.htmlContent || P.html;
2433
- if (!M)
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)
2434
2446
  throw new Error("No HTML content returned");
2435
- return C.writeFileSync(R.join(j, "index.html"), M), C.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
2447
+ return P.writeFileSync(R.join(j, "index.html"), C), P.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
2436
2448
  name: O.name,
2437
2449
  componentId: b,
2438
2450
  organization: m,
@@ -2440,8 +2452,8 @@ v.program.command("list").description("Browse and pull/push remote components").
2440
2452
  author: "@myop-cli",
2441
2453
  HMR: !0
2442
2454
  }, null, 2)), { name: O.name, status: "ok", dir: j };
2443
- } catch (P) {
2444
- return { name: O.name, status: "failed", error: P.message };
2455
+ } catch (M) {
2456
+ return { name: O.name, status: "failed", error: M.message };
2445
2457
  }
2446
2458
  }));
2447
2459
  let u = 0, E = 0;
@@ -2450,46 +2462,46 @@ v.program.command("list").description("Browse and pull/push remote components").
2450
2462
  console.log(`
2451
2463
  Done! Pulled ${u} component${u !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
2452
2464
  `);
2453
- } else if (S === "push") {
2465
+ } else if (x === "push") {
2454
2466
  console.log(`
2455
- Pushing ${y.length} components...
2467
+ Pushing ${w.length} components...
2456
2468
  `);
2457
- const g = Qe(".", 3), u = await Promise.all(y.map(async (P) => {
2458
- const j = P.id || P._id || P.componentId, M = g.find((_) => _.componentId === j);
2459
- if (!M)
2460
- return { name: P.name, status: "skipped", reason: "no local match" };
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" };
2461
2473
  try {
2462
- let _;
2463
- const k = M.path;
2464
- if (C.existsSync(R.join(k, "dist", "index.html")))
2465
- _ = R.join(k, "dist", "index.html");
2474
+ 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");
2466
2478
  else {
2467
- const W = C.readdirSync(k).filter(
2468
- (N) => N.endsWith(".html") && !N.startsWith(".") && C.statSync(R.join(k, N)).isFile()
2479
+ const W = P.readdirSync(k).filter(
2480
+ (_) => _.endsWith(".html") && !_.startsWith(".") && P.statSync(R.join(k, _)).isFile()
2469
2481
  );
2470
2482
  if (W.length === 1)
2471
- _ = R.join(k, W[0]);
2483
+ N = R.join(k, W[0]);
2472
2484
  else if (W.includes("index.html"))
2473
- _ = R.join(k, "index.html");
2485
+ N = R.join(k, "index.html");
2474
2486
  else
2475
2487
  throw new Error("No HTML file found");
2476
2488
  }
2477
- const L = C.readFileSync(_, "utf-8"), D = M.name || P.name, T = await i("upload_component", {
2489
+ const L = P.readFileSync(N, "utf-8"), D = C.name || M.name, F = await i("upload_component", {
2478
2490
  name: D,
2479
2491
  componentId: j,
2480
2492
  organization: m,
2481
2493
  htmlContent: L
2482
2494
  });
2483
- if (!T.success)
2484
- throw new Error(T.error || "Upload failed");
2495
+ if (!F.success)
2496
+ throw new Error(F.error || "Upload failed");
2485
2497
  return { name: D, status: "ok" };
2486
- } catch (_) {
2487
- return { name: P.name, status: "failed", error: _.message };
2498
+ } catch (N) {
2499
+ return { name: M.name, status: "failed", error: N.message };
2488
2500
  }
2489
2501
  }));
2490
2502
  let E = 0, O = 0, b = 0;
2491
- for (const P of u)
2492
- P.status === "ok" ? (console.log(` \x1B[32m✔\x1B[0m ${P.name}`), E++) : P.status === "skipped" ? (console.log(` \x1B[33m⊘\x1B[0m ${P.name} (${P.reason})`), O++) : (console.log(` \x1B[31m✖\x1B[0m ${P.name} - ${P.error}`), b++);
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++);
2493
2505
  console.log(`
2494
2506
  Done! Pushed ${E}${O ? `, skipped ${O}` : ""}${b ? `, ${b} failed` : ""}.
2495
2507
  `);
@@ -2643,13 +2655,13 @@ v.program.command("create").description("Create a new Myop HTML component and st
2643
2655
  </body>
2644
2656
  </html>`;
2645
2657
  t.writeFileSync("index.html", r);
2646
- const p = await Ke(process.cwd());
2658
+ const p = await Qe(process.cwd());
2647
2659
  console.log(`
2648
2660
  ✅ Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Ce();
2649
2661
  });
2650
2662
  v.program.command("dev").description("Start development server with file watching").action(Ce);
2651
2663
  const yt = async () => {
2652
- const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Ke(o);
2664
+ const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Qe(o);
2653
2665
  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);
2654
2666
  };
2655
2667
  v.program.command("skill").description("Install or update AI agent skills in the current directory").action(yt);
@@ -2726,7 +2738,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2726
2738
  const p = i.find((d) => d.value === r);
2727
2739
  let m = {};
2728
2740
  try {
2729
- const d = C.readFileSync(p.configPath, "utf-8");
2741
+ const d = P.readFileSync(p.configPath, "utf-8");
2730
2742
  m = JSON.parse(d);
2731
2743
  } catch {
2732
2744
  }
@@ -2749,14 +2761,14 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2749
2761
  throw d.name === "ExitPromptError" && process.exit(0), d;
2750
2762
  }
2751
2763
  }
2752
- m.mcpServers.myop = p.getEntry(), C.mkdirSync(R.dirname(p.configPath), { recursive: !0 }), C.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
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(`
2753
2765
  \x1B[32m✔\x1B[0m Myop MCP configured for ${p.name}`), console.log(` Config: ${p.configPath}`), console.log(` Server: ${s}`), console.log(`
2754
2766
  \x1B[1mNext steps:\x1B[0m`);
2755
2767
  for (const d of p.nextSteps)
2756
2768
  console.log(` ${d}`);
2757
2769
  console.log(""), process.exit(0);
2758
2770
  });
2759
- const xo = () => {
2771
+ const $o = () => {
2760
2772
  try {
2761
2773
  Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2762
2774
  } catch {
@@ -2789,8 +2801,8 @@ const xo = () => {
2789
2801
  return null;
2790
2802
  }
2791
2803
  }, ne = async (o = !1, t = !1) => {
2792
- var d, y, S;
2793
- const e = Pe(), n = !!(e != null && e.email), s = ((d = v.myopConfig) == null ? void 0 : d.name) || ((y = v.myopConfig) == null ? void 0 : y.componentName), i = (S = v.myopConfig) == null ? void 0 : S.componentId, r = xo();
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();
2794
2806
  console.log(`
2795
2807
  ┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Welcome to Myop CLI - Remote UI Made Easy │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
2796
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("");
@@ -2816,14 +2828,14 @@ const xo = () => {
2816
2828
  help: "Builds project & uploads dist/index.html to Myop",
2817
2829
  disabled: o ? n ? !1 : "(login required)" : "(no config file)"
2818
2830
  }
2819
- ].map((x) => ({
2820
- name: t && !x.disabled ? `${x.emoji} ${x.label}
2821
- ${x.help}` : `${x.emoji} ${x.label}`,
2822
- value: x.value,
2823
- disabled: x.disabled
2831
+ ].map(($) => ({
2832
+ name: t && !$.disabled ? `${$.emoji} ${$.label}
2833
+ ${$.help}` : `${$.emoji} ${$.label}`,
2834
+ value: $.value,
2835
+ disabled: $.disabled
2824
2836
  }));
2825
2837
  m.push(
2826
- new Le(),
2838
+ new Ue(),
2827
2839
  {
2828
2840
  name: t && n ? `🔓 Logout (${e.email})
2829
2841
  Clears stored credentials from this machine` : t && !n ? `🔐 Login to Myop
@@ -2834,7 +2846,7 @@ const xo = () => {
2834
2846
  name: t ? "📖 Hide help" : "📖 Show help",
2835
2847
  value: "help"
2836
2848
  },
2837
- new Le(),
2849
+ new Ue(),
2838
2850
  {
2839
2851
  name: "👋 Exit",
2840
2852
  value: "exit"
@@ -2846,23 +2858,23 @@ const xo = () => {
2846
2858
  message: "What would you like to do?",
2847
2859
  choices: m
2848
2860
  });
2849
- } catch (x) {
2850
- throw x.name === "ExitPromptError" && (console.log(`
2861
+ } catch ($) {
2862
+ throw $.name === "ExitPromptError" && (console.log(`
2851
2863
 
2852
2864
  👋 Goodbye!
2853
- `), process.exit(0)), x;
2865
+ `), process.exit(0)), $;
2854
2866
  }
2855
2867
  switch (l) {
2856
2868
  case "init":
2857
- await Po();
2869
+ await Mo();
2858
2870
  break;
2859
2871
  case "sync":
2860
2872
  console.log(`
2861
2873
  Pushing component...
2862
2874
  `);
2863
- const { execSync: x } = await import("child_process");
2875
+ const { execSync: $ } = await import("child_process");
2864
2876
  try {
2865
- x("node " + process.argv[1] + " push", { stdio: "inherit" });
2877
+ $("node " + process.argv[1] + " push", { stdio: "inherit" });
2866
2878
  } catch {
2867
2879
  }
2868
2880
  await ne(!0, t);
@@ -2888,68 +2900,68 @@ Pushing component...
2888
2900
  case "exit":
2889
2901
  process.exit(0);
2890
2902
  }
2891
- }, be = ".myop-monorepo.json", $o = () => {
2903
+ }, be = ".myop-monorepo.json", bo = () => {
2892
2904
  try {
2893
- const o = C.readFileSync(be, "utf-8");
2905
+ const o = P.readFileSync(be, "utf-8");
2894
2906
  return JSON.parse(o);
2895
2907
  } catch {
2896
2908
  return null;
2897
2909
  }
2898
- }, bo = (o) => {
2910
+ }, Co = (o) => {
2899
2911
  try {
2900
2912
  const t = {
2901
2913
  selectedComponents: o,
2902
2914
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2903
2915
  };
2904
- C.writeFileSync(be, JSON.stringify(t, null, 2));
2916
+ P.writeFileSync(be, JSON.stringify(t, null, 2));
2905
2917
  } catch {
2906
2918
  }
2907
- }, Co = async () => {
2919
+ }, Po = async () => {
2908
2920
  const o = Pe(), t = !!(o != null && o.email);
2909
2921
  console.log(`
2910
2922
  ┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Myop CLI - Monorepo Mode │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
2911
2923
  `);
2912
- const e = z("Scanning for components...").start(), n = Qe(".");
2924
+ const e = z("Scanning for components...").start(), n = Ze(".");
2913
2925
  e.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2914
2926
  `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2915
- const s = $o(), i = (s == null ? void 0 : s.selectedComponents) || [], r = i.length > 0;
2927
+ const s = bo(), i = (s == null ? void 0 : s.selectedComponents) || [], r = i.length > 0;
2916
2928
  console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
2917
- `), n.forEach((y, S) => {
2918
- const x = y.componentId ? "✅" : "⚪", g = y.componentId ? y.componentId.substring(0, 8) + "..." : "(not pushed)";
2919
- console.log(` ${x} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${g}`), console.log("");
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("");
2920
2932
  }), console.log(` User: ${t ? o.email : "Not logged in"}`), r && console.log(` 📋 Using saved selection from ${be}`), console.log("");
2921
2933
  const p = v.program.getOptionValue("ci");
2922
2934
  let m;
2923
2935
  if (p)
2924
- r ? (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`));
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`));
2925
2937
  else {
2926
- const { checkbox: y } = await import("@inquirer/prompts"), S = n.map((x) => ({
2927
- name: `${x.name} (${x.path})`,
2928
- value: x.path,
2929
- checked: r ? i.includes(x.path) : !0
2938
+ const { checkbox: w } = await import("@inquirer/prompts"), x = n.map(($) => ({
2939
+ name: `${$.name} (${$.path})`,
2940
+ value: $.path,
2941
+ checked: r ? i.includes($.path) : !0
2930
2942
  }));
2931
2943
  try {
2932
- m = await y({
2944
+ m = await w({
2933
2945
  message: "Select components to start in dev mode:",
2934
- choices: S
2946
+ choices: x
2935
2947
  });
2936
- } catch (x) {
2937
- throw x.name === "ExitPromptError" && (console.log(`
2948
+ } catch ($) {
2949
+ throw $.name === "ExitPromptError" && (console.log(`
2938
2950
 
2939
2951
  👋 Goodbye!
2940
- `), process.exit(0)), x;
2952
+ `), process.exit(0)), $;
2941
2953
  }
2942
2954
  }
2943
2955
  m.length === 0 && (console.log(`
2944
2956
  ⚠️ No components selected.
2945
- `), process.exit(0)), p || (bo(m), console.log(`
2957
+ `), process.exit(0)), p || (Co(m), console.log(`
2946
2958
  💾 Selection saved to ${be}`));
2947
- const l = n.filter((y) => m.includes(y.path));
2959
+ const l = n.filter((w) => m.includes(w.path));
2948
2960
  console.log(`🚀 Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
2949
2961
  `);
2950
- const { monorepoDevCommand: d } = await Promise.resolve().then(() => Wt);
2962
+ const { monorepoDevCommand: d } = await Promise.resolve().then(() => Vt);
2951
2963
  await d(l);
2952
- }, Po = async () => {
2964
+ }, Mo = async () => {
2953
2965
  const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
2954
2966
  let i, r;
2955
2967
  try {
@@ -3072,7 +3084,7 @@ fs.writeFileSync('dist/index.html', html);
3072
3084
  console.log('✅ Built dist/index.html');
3073
3085
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
3074
3086
  `), console.log("✅ Created build.js");
3075
- const y = `<!DOCTYPE html>
3087
+ const w = `<!DOCTYPE html>
3076
3088
  <html lang="en">
3077
3089
  <head>
3078
3090
  <meta charset="UTF-8">
@@ -3089,8 +3101,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
3089
3101
  </body>
3090
3102
  </html>
3091
3103
  `;
3092
- e.writeFileSync("index.html", y), console.log("✅ Created index.html");
3093
- const S = `// ${i} - Entry Point
3104
+ e.writeFileSync("index.html", w), console.log("✅ Created index.html");
3105
+ const x = `// ${i} - Entry Point
3094
3106
  import { init } from './modules/app.js';
3095
3107
  import { setupMyopInterface } from './modules/myop.js';
3096
3108
 
@@ -3099,8 +3111,8 @@ document.addEventListener('DOMContentLoaded', () => {
3099
3111
  setupMyopInterface();
3100
3112
  });
3101
3113
  `;
3102
- e.writeFileSync("src/index.js", S), console.log("✅ Created src/index.js");
3103
- const x = `// ${i} - Main Application Logic
3114
+ e.writeFileSync("src/index.js", x), console.log("✅ Created src/index.js");
3115
+ const $ = `// ${i} - Main Application Logic
3104
3116
 
3105
3117
  export function init() {
3106
3118
  console.log('${i} loaded');
@@ -3108,7 +3120,7 @@ export function init() {
3108
3120
  // Your component logic here
3109
3121
  }
3110
3122
  `;
3111
- e.writeFileSync("src/modules/app.js", x), console.log("✅ Created src/modules/app.js"), e.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
3123
+ e.writeFileSync("src/modules/app.js", $), console.log("✅ Created src/modules/app.js"), e.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
3112
3124
 
3113
3125
  export function setupMyopInterface() {
3114
3126
  // Called when host app sends data to this component
@@ -3164,12 +3176,12 @@ dist/
3164
3176
  .temp-styles.css
3165
3177
  .DS_Store
3166
3178
  `), console.log("✅ Created .gitignore");
3167
- const b = await Ke(process.cwd());
3179
+ const b = await Qe(process.cwd());
3168
3180
  b.success && console.log("✅ Installed AI agent skills");
3169
- const P = await import("./index-DuEoKctW.js").then((M) => M.i), j = process.cwd();
3181
+ const M = await import("./index-DuEoKctW.js").then((C) => C.i), j = process.cwd();
3170
3182
  try {
3171
- await P.init({ fs: e, dir: j });
3172
- const M = [
3183
+ await M.init({ fs: e, dir: j });
3184
+ const C = [
3173
3185
  "myop.config.json",
3174
3186
  "package.json",
3175
3187
  "build.js",
@@ -3182,12 +3194,12 @@ dist/
3182
3194
  "src/styles/main.css"
3183
3195
  ];
3184
3196
  if (b.success) {
3185
- const _ = (k, L) => {
3197
+ const N = (k, L) => {
3186
3198
  try {
3187
3199
  const D = e.readdirSync(k, { withFileTypes: !0 });
3188
- for (const T of D) {
3189
- const W = n.join(k, T.name), N = n.join(L, T.name);
3190
- T.isDirectory() ? _(W, N) : M.push(N);
3200
+ 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(_);
3191
3203
  }
3192
3204
  } catch {
3193
3205
  }
@@ -3197,21 +3209,21 @@ dist/
3197
3209
  for (const L of k)
3198
3210
  if (L.isDirectory() && L.name.startsWith(".")) {
3199
3211
  const D = n.join(L.name, "skills");
3200
- e.existsSync(D) && _(D, D);
3212
+ e.existsSync(D) && N(D, D);
3201
3213
  }
3202
3214
  } catch {
3203
3215
  }
3204
3216
  }
3205
- for (const _ of M)
3206
- await P.add({ fs: e, dir: j, filepath: _ });
3207
- await P.commit({
3217
+ for (const N of C)
3218
+ await M.add({ fs: e, dir: j, filepath: N });
3219
+ await M.commit({
3208
3220
  fs: e,
3209
3221
  dir: j,
3210
3222
  message: "init",
3211
3223
  author: { name: "myop-cli", email: "cli@myop.dev" }
3212
3224
  }), console.log("✅ Initialized git repository");
3213
- } catch (M) {
3214
- console.log("⚠️ Failed to initialize git repository:", M.message);
3225
+ } catch (C) {
3226
+ console.log("⚠️ Failed to initialize git repository:", C.message);
3215
3227
  }
3216
3228
  console.log(`
3217
3229
  📦 Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
@@ -3221,17 +3233,17 @@ dist/
3221
3233
  }
3222
3234
  };
3223
3235
  v.program.command("default", { isDefault: !0 }).action(async () => {
3224
- if (v.program.getOptionValue("help") && (console.log(kt), process.exit()), v.program.getOptionValue("monorepo")) {
3225
- await Co();
3236
+ if (v.program.getOptionValue("help") && (console.log(Rt), process.exit()), v.program.getOptionValue("monorepo")) {
3237
+ await Po();
3226
3238
  return;
3227
3239
  }
3228
3240
  if (v.program.getOptionValue("ci")) {
3229
3241
  const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), d = Pe();
3230
- let y = { found: !1 };
3242
+ let w = { found: !1 };
3231
3243
  try {
3232
3244
  if (p.existsSync(m)) {
3233
- const x = p.readFileSync(m, "utf-8"), g = JSON.parse(x);
3234
- y = {
3245
+ const $ = p.readFileSync(m, "utf-8"), g = JSON.parse($);
3246
+ w = {
3235
3247
  found: !0,
3236
3248
  path: m,
3237
3249
  name: g.name || g.componentName || null,
@@ -3239,28 +3251,28 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
3239
3251
  organization: g.organization || null
3240
3252
  };
3241
3253
  }
3242
- } catch (x) {
3243
- y = { found: !1, error: x.message };
3254
+ } catch ($) {
3255
+ w = { found: !1, error: $.message };
3244
3256
  }
3245
- const S = {
3257
+ const x = {
3246
3258
  version: l,
3247
- config: y,
3259
+ config: w,
3248
3260
  auth: {
3249
3261
  loggedIn: !!(d != null && d.email),
3250
3262
  email: (d == null ? void 0 : d.email) || null
3251
3263
  }
3252
3264
  };
3253
- console.log(JSON.stringify(S, null, 2)), process.exit(0);
3265
+ console.log(JSON.stringify(x, null, 2)), process.exit(0);
3254
3266
  }
3255
3267
  let n = z({
3256
3268
  text: "Loading Myop CLI...",
3257
3269
  color: "green"
3258
3270
  }).start();
3259
3271
  const s = Ee();
3260
- await yo(500), n.stop();
3272
+ await wo(500), n.stop();
3261
3273
  const i = v.program.version();
3262
- await mo(i) || await ne(s.configFound);
3274
+ await uo(i) || await ne(s.configFound);
3263
3275
  });
3264
- Kt();
3276
+ Qt();
3265
3277
  v.program.parse(process.argv);
3266
3278
  v.program.opts();