@myop/cli 0.1.55 → 0.1.57

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