@myop/cli 0.1.40 β†’ 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/myop-cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- var ct = Object.defineProperty;
3
- var dt = (o, e, t) => e in o ? ct(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
4
- var he = (o, e, t) => dt(o, typeof e != "symbol" ? e + "" : e, t);
5
- import V from "ora";
6
- import { select as Ge, Separator as Fe } from "@inquirer/prompts";
7
- import { Command as pt, Option as pe } from "commander";
8
- import { execSync as Q, spawn as mt } from "child_process";
9
- import ne, { join as Ee } from "path";
10
- import D, { readFileSync as ut } from "fs";
11
- import ke from "crypto";
12
- import gt from "http";
13
- import { URL as Ye, URLSearchParams as Ke } from "url";
14
- import ft from "open";
15
- import ht from "os";
16
- const yt = `
2
+ var ut = Object.defineProperty;
3
+ var gt = (o, e, t) => e in o ? ut(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
4
+ var ye = (o, e, t) => gt(o, typeof e != "symbol" ? e + "" : e, t);
5
+ import G from "ora";
6
+ import { select as Ye, Separator as Fe } from "@inquirer/prompts";
7
+ import { Command as ft, Option as me } from "commander";
8
+ import { execSync as q, spawn as ht } from "child_process";
9
+ import H, { join as Oe } from "path";
10
+ import R, { readFileSync as yt } from "fs";
11
+ import Le from "crypto";
12
+ import wt from "http";
13
+ import { URL as Ke, URLSearchParams as Qe } from "url";
14
+ import St from "open";
15
+ import vt from "os";
16
+ const bt = `
17
17
  Usage: myop [OPTIONS] COMMAND [ARGS]...
18
18
 
19
19
  A powerful command-line interface for managing your Myop projects.
@@ -55,81 +55,81 @@ Examples:
55
55
  verbose: !1
56
56
  },
57
57
  myopConfig: null
58
- }, Qe = {
58
+ }, Ze = {
59
59
  name: "πŸ“₯ Install Myop generated dependencies",
60
60
  value: "myopInstall",
61
61
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
62
62
  action: async () => {
63
63
  console.info("installing... ");
64
64
  for (const o of y.myopConfig.flows) {
65
- const e = ne.join(y.executionPath, "/node_modules/@myop/flow-types/");
65
+ const e = H.join(y.executionPath, "/node_modules/@myop/flow-types/");
66
66
  console.info(`Generate flow at ${e}`), console.info(`Generated flow at ${e}`);
67
67
  }
68
68
  process.exit();
69
69
  }
70
- }, wt = (o) => {
71
- const e = ne.join(y.executionPath, o);
70
+ }, xt = (o) => {
71
+ const e = H.join(y.executionPath, o);
72
72
  console.info(`reading config file from: ${e}`);
73
- const t = D.readFileSync(e, "utf8"), n = JSON.parse(t);
73
+ const t = R.readFileSync(e, "utf8"), n = JSON.parse(t);
74
74
  return console.info("config file loaded, ", n), n;
75
- }, _e = (o, e) => {
76
- const t = ne.join(y.executionPath, o);
75
+ }, Ae = (o, e) => {
76
+ const t = H.join(y.executionPath, o);
77
77
  console.info(`writing config file to: ${t}`);
78
78
  try {
79
79
  const n = JSON.stringify(e, null, 2);
80
- D.writeFileSync(t, n), console.info(`config file updated ${n}`);
80
+ R.writeFileSync(t, n), console.info(`config file updated ${n}`);
81
81
  } catch (n) {
82
82
  throw console.info(`error ${n} while writing to ${t}, JSON: ${e}`), console.log(`
83
83
  ⚠️ Failed write config file to ${t}, for more info use verbose flag`), n;
84
84
  }
85
- }, Ze = {
85
+ }, Xe = {
86
86
  name: "🌟 Add flow definition to your project",
87
87
  value: "addFlow",
88
88
  description: "Adds flow to yours myop.config.json",
89
89
  _action: (o) => {
90
- y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o), _e(y.options.configPath, y.myopConfig);
90
+ y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o), Ae(y.options.configPath, y.myopConfig);
91
91
  },
92
92
  action: async () => {
93
93
  }
94
- }, Xe = {
94
+ }, qe = {
95
95
  name: "🚫 Remove flow definition from your project",
96
96
  value: "removeFlow",
97
97
  description: "Removes flow to yours myop.config.json",
98
98
  _action: (o) => {
99
- y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o), _e(y.options.configPath, y.myopConfig);
99
+ y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o), Ae(y.options.configPath, y.myopConfig);
100
100
  },
101
101
  action: () => {
102
102
  }
103
- }, vt = {
103
+ }, $t = {
104
104
  name: "πŸ‘‹ Quit",
105
105
  value: "quit",
106
106
  description: "Quit and continue coding.",
107
107
  action: () => {
108
108
  process.exit();
109
109
  }
110
- }, bt = {
110
+ }, Ct = {
111
111
  name: "🟒 Create new component",
112
112
  value: "-",
113
113
  disabled: "(not available yet)"
114
- }, St = {
114
+ }, Mt = {
115
115
  name: "πŸ”΅ Create new experience",
116
116
  value: "-",
117
117
  disabled: "(not available yet)"
118
- }, $t = {
118
+ }, Pt = {
119
119
  name: "🟑 Create new skin",
120
120
  value: "-",
121
121
  disabled: "(not available yet)"
122
- }, xt = {
122
+ }, Tt = {
123
123
  name: "πŸ”΄ Create new flow",
124
124
  value: "-",
125
125
  disabled: "(not available yet)"
126
- }, Ct = {
126
+ }, Rt = {
127
127
  name: "πŸ†• Define new custom Myop message",
128
128
  value: "generateMyopMessage",
129
129
  description: "️Help you creates the right structure for a new Myop message, including types and handlers.",
130
130
  disabled: "(not available yet)"
131
- }, Mt = [Ct, bt, St, $t, xt];
132
- function Pt(o, e, t, n) {
131
+ }, Et = [Rt, Ct, Mt, Pt, Tt];
132
+ function It(o, e, t, n) {
133
133
  return `<!DOCTYPE html>
134
134
  <html lang="en">
135
135
  <head>
@@ -219,32 +219,32 @@ ${n}
219
219
  </body>
220
220
  </html>`;
221
221
  }
222
- function Rt(o) {
222
+ function Ot(o) {
223
223
  return o.includes("esbuild") && o.includes("another platform");
224
224
  }
225
- function Tt(o) {
225
+ function kt(o) {
226
226
  return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
227
227
  }
228
- function Ot() {
228
+ function Ft() {
229
229
  console.error(`
230
230
  ❌ esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
231
231
  This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows β†’ Mac, or Mac β†’ Linux).
232
232
  `);
233
233
  }
234
- function Et(o) {
234
+ function jt(o) {
235
235
  return new Promise((e) => {
236
236
  console.log(`πŸ”§ Attempting to fix: removing node_modules and reinstalling...
237
237
  `);
238
238
  const n = process.platform === "win32" ? "rmdir /s /q node_modules" : "rm -rf node_modules";
239
- o(n, (r) => {
240
- if (r) {
241
- console.error("❌ Failed to remove node_modules:", r.message), console.error(`
239
+ o(n, (i) => {
240
+ if (i) {
241
+ console.error("❌ Failed to remove node_modules:", i.message), console.error(`
242
242
  Please run manually:`), console.error(` \x1B[36m${n} && npm install\x1B[0m
243
243
  `), e(!1);
244
244
  return;
245
245
  }
246
246
  console.log(" βœ“ Removed node_modules"), console.log(` ⏳ Running npm install...
247
- `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (s, d, w) => {
247
+ `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (s, l, w) => {
248
248
  if (s) {
249
249
  console.error("❌ npm install failed:", s.message), w && console.error(w), e(!1);
250
250
  return;
@@ -255,101 +255,101 @@ function Et(o) {
255
255
  });
256
256
  });
257
257
  }
258
- async function qe(o, e, t, n, r = {}) {
258
+ async function et(o, e, t, n, i = {}) {
259
259
  const {
260
260
  hasTriedPlatformFix: s = !1,
261
- hasTriedInstall: d = !1,
261
+ hasTriedInstall: l = !1,
262
262
  onRetry: w
263
- } = r, $ = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
264
- return !s && Rt($) ? (Ot(), await Et(n) && w ? (console.log(`πŸ”„ Retrying build...
265
- `), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && Tt($) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((m) => {
266
- n("npm install", (p, S, g) => {
267
- if (p) {
268
- console.error("❌ Failed to install dependencies:", p.message), g && console.error(g), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
263
+ } = i, v = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
264
+ return !s && Ot(v) ? (Ft(), await jt(n) && w ? (console.log(`πŸ”„ Retrying build...
265
+ `), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : !l && kt(v) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((m) => {
266
+ n("npm install", (d, C, u) => {
267
+ if (d) {
268
+ console.error("❌ Failed to install dependencies:", d.message), u && console.error(u), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
269
269
  return;
270
270
  }
271
271
  console.log("βœ… Dependencies installed"), w && w(), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
272
272
  });
273
- })) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: d };
273
+ })) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: l };
274
274
  }
275
- async function Le() {
276
- const o = await import("fs"), e = await import("path"), { exec: t } = await import("child_process"), n = await import("http"), { createHash: r } = await import("node:crypto");
275
+ async function be() {
276
+ const o = await import("fs"), e = await import("path"), { exec: t } = await import("child_process"), n = await import("http"), { createHash: i } = await import("node:crypto");
277
277
  let s;
278
278
  if (import.meta.url.startsWith("file://")) {
279
- const i = new URL(import.meta.url).pathname, l = process.platform === "win32" && i.startsWith("/") ? i.slice(1) : i;
280
- s = e.default.dirname(l);
279
+ const r = new URL(import.meta.url).pathname, c = process.platform === "win32" && r.startsWith("/") ? r.slice(1) : r;
280
+ s = e.default.dirname(c);
281
281
  } else
282
282
  s = e.default.dirname(import.meta.url);
283
- const d = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(d, "styles.css"), "utf-8"), $ = o.default.readFileSync(e.default.join(d, "app.js"), "utf-8"), m = 9292, p = 9293;
284
- let S = "./dist", g = !1, b = !1, x = !1, C = null;
285
- const L = () => {
283
+ const l = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(l, "styles.css"), "utf-8"), v = o.default.readFileSync(e.default.join(l, "app.js"), "utf-8"), m = 9292, d = 9293;
284
+ let C = "./dist", u = !1, S = !1, M = !1, T = null;
285
+ const D = () => {
286
286
  try {
287
- const a = o.default.readdirSync(".").filter((i) => !i.endsWith(".html") || i.startsWith(".") ? !1 : o.default.statSync(i).isFile());
287
+ const a = o.default.readdirSync(".").filter((r) => !r.endsWith(".html") || r.startsWith(".") ? !1 : o.default.statSync(r).isFile());
288
288
  if (a.length === 1)
289
289
  return a[0];
290
290
  } catch {
291
291
  }
292
292
  return null;
293
- }, H = () => {
293
+ }, P = () => {
294
294
  try {
295
295
  const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
296
  return !!(a.scripts && a.scripts.build);
297
297
  } catch {
298
298
  return !1;
299
299
  }
300
- }, f = (a) => {
301
- const i = process.platform;
302
- let l;
303
- i === "darwin" ? l = `open "${a}"` : i === "win32" ? l = `start "" "${a}"` : l = `xdg-open "${a}"`, t(l, (c) => {
300
+ }, x = (a) => {
301
+ const r = process.platform;
302
+ let c;
303
+ r === "darwin" ? c = `open "${a}"` : r === "win32" ? c = `start "" "${a}"` : c = `xdg-open "${a}"`, t(c, (p) => {
304
304
  });
305
- }, P = /* @__PURE__ */ new Map(), E = y.program.getOptionValue("config") || "./myop.config.json";
306
- let M, I, _ = !1;
307
- C = L();
308
- const te = H();
305
+ }, j = /* @__PURE__ */ new Map(), b = y.program.getOptionValue("config") || "./myop.config.json";
306
+ let f, E, _ = !1;
307
+ T = D();
308
+ const B = P();
309
309
  try {
310
- const a = o.default.readFileSync(E, "utf-8"), i = JSON.parse(a);
311
- M = i.componentId || "DEV", I = i.componentName || i.name || null, _ = i.HMR === !0, C && !te && (x = !0, _ = !0, console.log(`πŸ“„ Single HTML file mode: ${C}`)), _ && console.log("πŸ”₯ HMR enabled");
310
+ const a = o.default.readFileSync(b, "utf-8"), r = JSON.parse(a);
311
+ f = r.componentId || "DEV", E = r.componentName || r.name || null, _ = r.HMR === !0, T && !B && (M = !0, _ = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`)), _ && console.log("πŸ”₯ HMR enabled");
312
312
  } catch (a) {
313
- C && !te ? (x = !0, M = "DEV", I = e.default.basename(C, ".html"), _ = !0, console.log(`πŸ“„ Single HTML file mode: ${C}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", a.message), process.exit(1));
313
+ T && !B ? (M = !0, f = "DEV", E = e.default.basename(T, ".html"), _ = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", a.message), process.exit(1));
314
314
  }
315
315
  const U = async () => {
316
- if (M !== "DEV" && M !== "NEW")
317
- return M;
316
+ if (f !== "DEV" && f !== "NEW")
317
+ return f;
318
318
  try {
319
- const i = ((await new Promise((u, h) => {
320
- const v = {
319
+ const r = ((await new Promise((g, h) => {
320
+ const $ = {
321
321
  hostname: "localhost",
322
- port: p,
322
+ port: d,
323
323
  path: "/_list",
324
324
  method: "GET",
325
325
  timeout: 1e3
326
- }, R = n.default.request(v, (N) => {
327
- let J = "";
328
- N.on("data", (q) => J += q), N.on("end", () => {
326
+ }, O = n.default.request($, (L) => {
327
+ let V = "";
328
+ L.on("data", (te) => V += te), L.on("end", () => {
329
329
  try {
330
- u(JSON.parse(J));
330
+ g(JSON.parse(V));
331
331
  } catch {
332
- u({ components: [] });
332
+ g({ components: [] });
333
333
  }
334
334
  });
335
335
  });
336
- R.on("error", () => u({ components: [] })), R.on("timeout", () => {
337
- R.destroy(), u({ components: [] });
338
- }), R.end();
339
- })).components || []).map(([u]) => u).filter((u) => u === "DEV" || u === "NEW" || /^DEV\d+$/.test(u) || /^NEW\d+$/.test(u));
340
- if (i.length === 0)
336
+ O.on("error", () => g({ components: [] })), O.on("timeout", () => {
337
+ O.destroy(), g({ components: [] });
338
+ }), O.end();
339
+ })).components || []).map(([g]) => g).filter((g) => g === "DEV" || g === "NEW" || /^DEV\d+$/.test(g) || /^NEW\d+$/.test(g));
340
+ if (r.length === 0)
341
341
  return "DEV1";
342
- const l = i.map((u) => {
343
- if (u === "DEV" || u === "NEW") return 1;
344
- const h = u.match(/^DEV(\d+)$/), v = u.match(/^NEW(\d+)$/);
345
- return h ? parseInt(h[1], 10) : v ? parseInt(v[1], 10) : 0;
346
- }).filter((u) => u > 0);
347
- return `DEV${Math.max(...l, 0) + 1}`;
342
+ const c = r.map((g) => {
343
+ if (g === "DEV" || g === "NEW") return 1;
344
+ const h = g.match(/^DEV(\d+)$/), $ = g.match(/^NEW(\d+)$/);
345
+ return h ? parseInt(h[1], 10) : $ ? parseInt($[1], 10) : 0;
346
+ }).filter((g) => g > 0);
347
+ return `DEV${Math.max(...c, 0) + 1}`;
348
348
  } catch {
349
349
  return "DEV1";
350
350
  }
351
- }, F = process.cwd(), G = (a) => {
352
- const i = e.default.extname(a).toLowerCase();
351
+ }, k = process.cwd(), z = (a) => {
352
+ const r = e.default.extname(a).toLowerCase();
353
353
  return {
354
354
  ".html": "text/html",
355
355
  ".js": "text/javascript",
@@ -360,336 +360,336 @@ async function Le() {
360
360
  ".gif": "image/gif",
361
361
  ".svg": "image/svg+xml",
362
362
  ".ico": "image/x-icon"
363
- }[i] || "application/octet-stream";
364
- }, T = /* @__PURE__ */ new Map(), Y = [], $e = 50, Z = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), st = (a, i, l) => {
363
+ }[r] || "application/octet-stream";
364
+ }, I = /* @__PURE__ */ new Map(), Z = [], se = 50, Y = [], ie = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), lt = (a, r, c) => {
365
365
  if (a.url.startsWith("/_hmr/")) {
366
- const c = a.url.split("/_hmr/")[1], u = a.headers["sec-websocket-key"], h = r("sha1").update(u + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
367
- i.write(
366
+ const p = a.url.split("/_hmr/")[1], g = a.headers["sec-websocket-key"], h = i("sha1").update(g + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
367
+ r.write(
368
368
  `HTTP/1.1 101 Switching Protocols\r
369
369
  Upgrade: websocket\r
370
370
  Connection: Upgrade\r
371
371
  Sec-WebSocket-Accept: ${h}\r
372
372
  \r
373
373
  `
374
- ), X.has(c) || X.set(c, /* @__PURE__ */ new Set()), X.get(c).add(i), console.log(`πŸ”Œ HMR client connected: ${c}`), i.on("close", () => {
375
- const v = X.get(c);
376
- v && (v.delete(i), v.size === 0 && X.delete(c)), console.log(`πŸ”Œ HMR client disconnected: ${c}`);
377
- }), i.on("error", () => {
378
- const v = X.get(c);
379
- v && v.delete(i);
374
+ ), ee.has(p) || ee.set(p, /* @__PURE__ */ new Set()), ee.get(p).add(r), console.log(`πŸ”Œ HMR client connected: ${p}`), r.on("close", () => {
375
+ const $ = ee.get(p);
376
+ $ && ($.delete(r), $.size === 0 && ee.delete(p)), console.log(`πŸ”Œ HMR client disconnected: ${p}`);
377
+ }), r.on("error", () => {
378
+ const $ = ee.get(p);
379
+ $ && $.delete(r);
380
380
  });
381
381
  }
382
- }, xe = n.default.createServer((a, i) => {
383
- if (i.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
384
- let l = "";
385
- a.on("data", (c) => l += c), a.on("end", () => {
382
+ }, Ce = n.default.createServer((a, r) => {
383
+ if (r.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
384
+ let c = "";
385
+ a.on("data", (p) => c += p), a.on("end", () => {
386
386
  try {
387
- const { componentId: c, distPath: u, componentName: h, htmlFile: v } = JSON.parse(l);
388
- T.set(c, { path: u, name: h || null, htmlFile: v || null });
389
- const R = h ? ` (${h})` : "";
390
- console.log(`βœ… Registered: ${c}${R} -> ${u}${v ? "/" + v : ""}`), i.writeHead(200), i.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
391
- const N = Array.from(T.entries()).map(([J, q]) => ({
392
- id: J,
393
- path: q.path,
394
- name: q.name
387
+ const { componentId: p, distPath: g, componentName: h, htmlFile: $ } = JSON.parse(c);
388
+ I.set(p, { path: g, name: h || null, htmlFile: $ || null });
389
+ const O = h ? ` (${h})` : "";
390
+ console.log(`βœ… Registered: ${p}${O} -> ${g}${$ ? "/" + $ : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(I.keys()) }));
391
+ const L = Array.from(I.entries()).map(([V, te]) => ({
392
+ id: V,
393
+ path: te.path,
394
+ name: te.name
395
395
  }));
396
- Z.forEach((J) => {
396
+ Y.forEach((V) => {
397
397
  try {
398
- J.write(`data: ${JSON.stringify({
398
+ V.write(`data: ${JSON.stringify({
399
399
  type: "components",
400
- components: N
400
+ components: L
401
401
  })}
402
402
 
403
403
  `);
404
404
  } catch {
405
405
  }
406
406
  });
407
- } catch (c) {
408
- i.writeHead(400), i.end(JSON.stringify({ error: c.message }));
407
+ } catch (p) {
408
+ r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
409
409
  }
410
410
  });
411
411
  } else if (a.method === "POST" && a.url === "/_unregister") {
412
- let l = "";
413
- a.on("data", (c) => l += c), a.on("end", () => {
412
+ let c = "";
413
+ a.on("data", (p) => c += p), a.on("end", () => {
414
414
  try {
415
- const { componentId: c } = JSON.parse(l);
416
- T.delete(c), console.log(`❌ Unregistered: ${c}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
417
- const u = Array.from(T.entries()).map(([h, v]) => ({
415
+ const { componentId: p } = JSON.parse(c);
416
+ I.delete(p), console.log(`❌ Unregistered: ${p}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
417
+ const g = Array.from(I.entries()).map(([h, $]) => ({
418
418
  id: h,
419
- path: v.path,
420
- name: v.name
419
+ path: $.path,
420
+ name: $.name
421
421
  }));
422
- Z.forEach((h) => {
422
+ Y.forEach((h) => {
423
423
  try {
424
424
  h.write(`data: ${JSON.stringify({
425
425
  type: "components",
426
- components: u
426
+ components: g
427
427
  })}
428
428
 
429
429
  `);
430
430
  } catch {
431
431
  }
432
432
  });
433
- } catch (c) {
434
- i.writeHead(400), i.end(JSON.stringify({ error: c.message }));
433
+ } catch (p) {
434
+ r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
435
435
  }
436
436
  });
437
437
  } else if (a.method === "GET" && a.url === "/_list")
438
- i.writeHead(200), i.end(JSON.stringify({ components: Array.from(T.entries()) }));
438
+ r.writeHead(200), r.end(JSON.stringify({ components: Array.from(I.entries()) }));
439
439
  else if (a.method === "POST" && a.url === "/_hmr_notify") {
440
- let l = "";
441
- a.on("data", (c) => l += c), a.on("end", () => {
440
+ let c = "";
441
+ a.on("data", (p) => c += p), a.on("end", () => {
442
442
  try {
443
- const { componentId: c, html: u } = JSON.parse(l), h = X.get(c);
443
+ const { componentId: p, html: g } = JSON.parse(c), h = ee.get(p);
444
444
  if (h && h.size > 0) {
445
- console.log(`πŸ”₯ Notifying ${h.size} HMR client(s) for: ${c}`);
446
- const v = JSON.stringify({ type: "update", html: u }), R = Ue(v);
447
- h.forEach((N) => {
445
+ console.log(`πŸ”₯ Notifying ${h.size} HMR client(s) for: ${p}`);
446
+ const $ = JSON.stringify({ type: "update", html: g }), O = Je($);
447
+ h.forEach((L) => {
448
448
  try {
449
- N.write(R);
449
+ L.write(O);
450
450
  } catch {
451
- h.delete(N);
451
+ h.delete(L);
452
452
  }
453
- }), i.writeHead(200), i.end(JSON.stringify({ success: !0, notified: h.size }));
453
+ }), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: h.size }));
454
454
  } else
455
- i.writeHead(200), i.end(JSON.stringify({ success: !0, notified: 0 }));
456
- } catch (c) {
457
- i.writeHead(400), i.end(JSON.stringify({ error: c.message }));
455
+ r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
456
+ } catch (p) {
457
+ r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
458
458
  }
459
459
  });
460
460
  } else
461
- i.writeHead(404), i.end(JSON.stringify({ error: "Not found" }));
462
- }), me = n.default.createServer((a, i) => {
461
+ r.writeHead(404), r.end(JSON.stringify({ error: "Not found" }));
462
+ }), ue = n.default.createServer((a, r) => {
463
463
  if (a.url.includes("..")) {
464
- i.writeHead(403, { "Content-Type": "text/plain" }), i.end("Forbidden");
464
+ r.writeHead(403, { "Content-Type": "text/plain" }), r.end("Forbidden");
465
465
  return;
466
466
  }
467
- const l = new URL(a.url, `http://localhost:${m}`), c = l.pathname, u = c.split("/").filter((A) => A);
468
- if (c.startsWith("/consume")) {
469
- const A = l.searchParams.get("id");
470
- if (!A) {
471
- i.writeHead(400, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
467
+ const c = new URL(a.url, `http://localhost:${m}`), p = c.pathname, g = p.split("/").filter((J) => J);
468
+ if (p.startsWith("/consume")) {
469
+ const J = c.searchParams.get("id");
470
+ if (!J) {
471
+ r.writeHead(400, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
472
472
  return;
473
473
  }
474
- const B = T.get(A), z = B ? B.path : null, le = (ee) => {
475
- let j = "Unknown", W = "Unknown";
474
+ const W = I.get(J), K = W ? W.path : null, ce = (oe) => {
475
+ let N = "Unknown", Q = "Unknown";
476
476
  if (a.headers.referer || a.headers.referrer) {
477
- const k = a.headers.referer || a.headers.referrer;
477
+ const A = a.headers.referer || a.headers.referrer;
478
478
  try {
479
- const ie = new URL(k);
480
- j = ie.origin, W = ie.hostname || ie.origin;
479
+ const re = new URL(A);
480
+ N = re.origin, Q = re.hostname || re.origin;
481
481
  } catch {
482
- j = k, W = k;
482
+ N = A, Q = A;
483
483
  }
484
484
  } else if (a.headers.origin)
485
485
  try {
486
- const k = new URL(a.headers.origin);
487
- j = k.origin, W = k.hostname || k.origin;
486
+ const A = new URL(a.headers.origin);
487
+ N = A.origin, Q = A.hostname || A.origin;
488
488
  } catch {
489
- j = a.headers.origin, W = a.headers.origin;
489
+ N = a.headers.origin, Q = a.headers.origin;
490
490
  }
491
491
  else if (a.socket.remoteAddress) {
492
- const k = a.socket.remoteAddress;
493
- k === "::1" || k === "::ffff:127.0.0.1" ? (j = "localhost", W = "localhost (direct)") : (j = k, W = k.replace("::ffff:", ""));
492
+ const A = a.socket.remoteAddress;
493
+ A === "::1" || A === "::ffff:127.0.0.1" ? (N = "localhost", Q = "localhost (direct)") : (N = A, Q = A.replace("::ffff:", ""));
494
494
  }
495
- const Te = a.headers.referer || a.headers.referrer || j, fe = {
495
+ const Ee = a.headers.referer || a.headers.referrer || N, he = {
496
496
  type: "request",
497
- componentId: A,
497
+ componentId: J,
498
498
  timestamp: Date.now(),
499
- servedLocally: ee,
500
- referrer: Te,
501
- origin: j,
502
- originLabel: W
499
+ servedLocally: oe,
500
+ referrer: Ee,
501
+ origin: N,
502
+ originLabel: Q
503
503
  };
504
- se.has(j) || (se.set(j, {
505
- url: j,
506
- label: W,
504
+ ie.has(N) || (ie.set(N, {
505
+ url: N,
506
+ label: Q,
507
507
  firstSeen: Date.now(),
508
508
  requestCount: 0
509
- }), Z.forEach((k) => {
509
+ }), Y.forEach((A) => {
510
510
  try {
511
- k.write(`data: ${JSON.stringify({
511
+ A.write(`data: ${JSON.stringify({
512
512
  type: "origins",
513
- origins: Array.from(se.values())
513
+ origins: Array.from(ie.values())
514
514
  })}
515
515
 
516
516
  `);
517
517
  } catch {
518
518
  }
519
519
  }));
520
- const Oe = se.get(j);
521
- Oe.requestCount++, Z.forEach((k) => {
520
+ const Ie = ie.get(N);
521
+ Ie.requestCount++, Y.forEach((A) => {
522
522
  try {
523
- k.write(`data: ${JSON.stringify({
523
+ A.write(`data: ${JSON.stringify({
524
524
  type: "origins",
525
- origins: Array.from(se.values())
525
+ origins: Array.from(ie.values())
526
526
  })}
527
527
 
528
528
  `);
529
529
  } catch {
530
530
  }
531
- }), Y.push(fe), Y.length > $e && Y.shift(), Z.forEach((k) => {
531
+ }), Z.push(he), Z.length > se && Z.shift(), Y.forEach((A) => {
532
532
  try {
533
- k.write(`data: ${JSON.stringify(fe)}
533
+ A.write(`data: ${JSON.stringify(he)}
534
534
 
535
535
  `);
536
536
  } catch {
537
537
  }
538
538
  });
539
539
  };
540
- if (z) {
541
- const ee = B.htmlFile ? e.default.join(z, B.htmlFile) : e.default.join(z, "index.html");
542
- o.default.readFile(ee, "utf-8", (j, W) => {
543
- if (j) {
544
- console.log(`❌ File not found: ${ee}`), i.writeHead(404, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "index.html not found" }));
540
+ if (K) {
541
+ const oe = W.htmlFile ? e.default.join(K, W.htmlFile) : e.default.join(K, "index.html");
542
+ o.default.readFile(oe, "utf-8", (N, Q) => {
543
+ if (N) {
544
+ console.log(`❌ File not found: ${oe}`), r.writeHead(404, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "index.html not found" }));
545
545
  return;
546
546
  }
547
- const Te = Ce(W, A), fe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Oe = {
547
+ const Ee = Me(Q, J), he = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Ie = {
548
548
  item: {
549
- name: A,
550
- id: A,
549
+ name: J,
550
+ id: J,
551
551
  consume_variant: [
552
552
  {
553
- id: fe,
553
+ id: he,
554
554
  name: "dev version",
555
555
  loader: {
556
556
  type: "HTMLLoader",
557
557
  shadowRootMode: "localFrame",
558
- HTML: Te
558
+ HTML: Ee
559
559
  }
560
560
  }
561
561
  ]
562
562
  }
563
563
  };
564
- console.log(`βœ… Serving consume JSON for: ${A}`), le(!0), i.writeHead(200, {
564
+ console.log(`βœ… Serving consume JSON for: ${J}`), ce(!0), r.writeHead(200, {
565
565
  "Content-Type": "application/json",
566
566
  "Access-Control-Allow-Origin": "*"
567
- }), i.end(JSON.stringify(Oe, null, 2));
567
+ }), r.end(JSON.stringify(Ie, null, 2));
568
568
  });
569
569
  } else {
570
- console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${A}`);
571
- const ee = `https://cloud.myop.dev/consume${l.search}`;
572
- le(!1), fetch(ee).then((j) => j.text()).then((j) => {
573
- i.writeHead(200, {
570
+ console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${J}`);
571
+ const oe = `https://cloud.myop.dev/consume${c.search}`;
572
+ ce(!1), fetch(oe).then((N) => N.text()).then((N) => {
573
+ r.writeHead(200, {
574
574
  "Content-Type": "application/json",
575
575
  "Access-Control-Allow-Origin": "*"
576
- }), i.end(j);
577
- }).catch((j) => {
578
- console.error(`❌ Proxy error: ${j.message}`), i.writeHead(502, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
576
+ }), r.end(N);
577
+ }).catch((N) => {
578
+ console.error(`❌ Proxy error: ${N.message}`), r.writeHead(502, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
579
579
  });
580
580
  }
581
581
  return;
582
582
  }
583
- if (c === "/events") {
584
- i.writeHead(200, {
583
+ if (p === "/events") {
584
+ r.writeHead(200, {
585
585
  "Content-Type": "text/event-stream",
586
586
  "Cache-Control": "no-cache",
587
587
  Connection: "keep-alive",
588
588
  "Access-Control-Allow-Origin": "*"
589
- }), Z.push(i);
590
- const A = Array.from(T.entries()).map(([B, z]) => ({
591
- id: B,
592
- path: z.path,
593
- name: z.name
589
+ }), Y.push(r);
590
+ const J = Array.from(I.entries()).map(([W, K]) => ({
591
+ id: W,
592
+ path: K.path,
593
+ name: K.name
594
594
  }));
595
- i.write(`data: ${JSON.stringify({
595
+ r.write(`data: ${JSON.stringify({
596
596
  type: "components",
597
- components: A
597
+ components: J
598
598
  })}
599
599
 
600
- `), i.write(`data: ${JSON.stringify({
600
+ `), r.write(`data: ${JSON.stringify({
601
601
  type: "origins",
602
- origins: Array.from(se.values())
602
+ origins: Array.from(ie.values())
603
603
  })}
604
604
 
605
- `), i.write(`data: ${JSON.stringify({
605
+ `), r.write(`data: ${JSON.stringify({
606
606
  type: "requestLog",
607
- log: Y
607
+ log: Z
608
608
  })}
609
609
 
610
610
  `), a.on("close", () => {
611
- const B = Z.indexOf(i);
612
- B !== -1 && Z.splice(B, 1);
611
+ const W = Y.indexOf(r);
612
+ W !== -1 && Y.splice(W, 1);
613
613
  });
614
614
  return;
615
615
  }
616
- if (u.length === 0) {
617
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(Pt(m, p, w, $));
616
+ if (g.length === 0) {
617
+ r.writeHead(200, { "Content-Type": "text/html" }), r.end(It(m, d, w, v));
618
618
  return;
619
619
  }
620
- if (u[0] !== "view") {
621
- i.writeHead(404, { "Content-Type": "text/plain" }), i.end("Not found. Use /view/<componentId>/ to access components.");
620
+ if (g[0] !== "view") {
621
+ r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not found. Use /view/<componentId>/ to access components.");
622
622
  return;
623
623
  }
624
- if (u.length < 2) {
625
- i.writeHead(400, { "Content-Type": "text/plain" }), i.end("Component ID required. Use /view/<componentId>/");
624
+ if (g.length < 2) {
625
+ r.writeHead(400, { "Content-Type": "text/plain" }), r.end("Component ID required. Use /view/<componentId>/");
626
626
  return;
627
627
  }
628
- const h = u[1], v = T.get(h);
629
- if (!v) {
630
- i.writeHead(404, { "Content-Type": "text/plain" }), i.end(`Component not found: ${h}`);
628
+ const h = g[1], $ = I.get(h);
629
+ if (!$) {
630
+ r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${h}`);
631
631
  return;
632
632
  }
633
- const R = v.path, N = u.slice(2), J = v.htmlFile || "index.html", q = N.length === 0 ? J : N.join("/"), ae = e.default.join(R, q);
634
- console.log(`πŸ“₯ Request: ${a.url} -> ${ae}`), o.default.readFile(ae, (A, B) => {
635
- if (A) {
636
- console.log(`❌ File not found: ${ae}`), i.writeHead(404, { "Content-Type": "text/plain" }), i.end("Not Found");
633
+ const O = $.path, L = g.slice(2), V = $.htmlFile || "index.html", te = L.length === 0 ? V : L.join("/"), le = e.default.join(O, te);
634
+ console.log(`πŸ“₯ Request: ${a.url} -> ${le}`), o.default.readFile(le, (J, W) => {
635
+ if (J) {
636
+ console.log(`❌ File not found: ${le}`), r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not Found");
637
637
  return;
638
638
  }
639
- const z = G(ae);
640
- console.log(`βœ… Serving: ${ae} (${z})`);
641
- let le = B;
642
- if (z === "text/html" && _) {
643
- const ee = B.toString("utf-8");
644
- le = Ce(ee, h);
639
+ const K = z(le);
640
+ console.log(`βœ… Serving: ${le} (${K})`);
641
+ let ce = W;
642
+ if (K === "text/html" && _) {
643
+ const oe = W.toString("utf-8");
644
+ ce = Me(oe, h);
645
645
  }
646
- i.writeHead(200, {
647
- "Content-Type": z,
646
+ r.writeHead(200, {
647
+ "Content-Type": K,
648
648
  "Access-Control-Allow-Origin": "*"
649
- }), i.end(le);
649
+ }), r.end(ce);
650
650
  });
651
- }), De = () => new Promise((a, i) => {
652
- const l = x ? e.default.resolve(F) : e.default.resolve(F, S), c = JSON.stringify({
653
- componentId: M,
654
- distPath: l,
655
- componentName: I,
656
- htmlFile: x ? C : null
657
- }), u = {
651
+ }), Ue = () => new Promise((a, r) => {
652
+ const c = M ? e.default.resolve(k) : e.default.resolve(k, C), p = JSON.stringify({
653
+ componentId: f,
654
+ distPath: c,
655
+ componentName: E,
656
+ htmlFile: M ? T : null
657
+ }), g = {
658
658
  hostname: "localhost",
659
- port: p,
659
+ port: d,
660
660
  path: "/_register",
661
661
  method: "POST",
662
662
  headers: {
663
663
  "Content-Type": "application/json",
664
- "Content-Length": Buffer.byteLength(c)
664
+ "Content-Length": Buffer.byteLength(p)
665
665
  }
666
- }, h = n.default.request(u, (v) => {
667
- let R = "";
668
- v.on("data", (N) => R += N), v.on("end", () => {
669
- v.statusCode === 200 ? a(JSON.parse(R)) : i(new Error(`Registration failed: ${v.statusCode}`));
666
+ }, h = n.default.request(g, ($) => {
667
+ let O = "";
668
+ $.on("data", (L) => O += L), $.on("end", () => {
669
+ $.statusCode === 200 ? a(JSON.parse(O)) : r(new Error(`Registration failed: ${$.statusCode}`));
670
670
  });
671
671
  });
672
- h.on("error", i), h.write(c), h.end();
673
- }), it = () => new Promise((a, i) => {
674
- const l = JSON.stringify({ componentId: M }), c = {
672
+ h.on("error", r), h.write(p), h.end();
673
+ }), ct = () => new Promise((a, r) => {
674
+ const c = JSON.stringify({ componentId: f }), p = {
675
675
  hostname: "localhost",
676
- port: p,
676
+ port: d,
677
677
  path: "/_unregister",
678
678
  method: "POST",
679
679
  headers: {
680
680
  "Content-Type": "application/json",
681
- "Content-Length": Buffer.byteLength(l)
681
+ "Content-Length": Buffer.byteLength(c)
682
682
  }
683
- }, u = n.default.request(c, (h) => {
683
+ }, g = n.default.request(p, (h) => {
684
684
  a();
685
685
  });
686
- u.on("error", () => a()), u.write(l), u.end();
687
- }), rt = (a) => `
686
+ g.on("error", () => a()), g.write(c), g.end();
687
+ }), dt = (a) => `
688
688
  <!-- MYOP HMR -->
689
689
  <script>
690
690
  (function() {
691
691
  const componentId = '${a}';
692
- const wsUrl = 'ws://localhost:${p}/_hmr/' + componentId;
692
+ const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
693
693
  let ws;
694
694
  let reconnectAttempts = 0;
695
695
  const maxReconnectAttempts = 10;
@@ -789,251 +789,251 @@ Sec-WebSocket-Accept: ${h}\r
789
789
  connect();
790
790
  })();
791
791
  <\/script>
792
- `, Ce = (a, i) => {
792
+ `, Me = (a, r) => {
793
793
  if (!_) return a;
794
- const l = rt(i);
795
- return a.includes("</body>") ? a.replace("</body>", `${l}</body>`) : a.includes("</html>") ? a.replace("</html>", `${l}</html>`) : a + l;
796
- }, Ue = (a) => {
797
- const i = Buffer.from(a), l = i.length;
798
- let c;
799
- return l < 126 ? c = Buffer.concat([
800
- Buffer.from([129, l]),
794
+ const c = dt(r);
795
+ return a.includes("</body>") ? a.replace("</body>", `${c}</body>`) : a.includes("</html>") ? a.replace("</html>", `${c}</html>`) : a + c;
796
+ }, Je = (a) => {
797
+ const r = Buffer.from(a), c = r.length;
798
+ let p;
799
+ return c < 126 ? p = Buffer.concat([
800
+ Buffer.from([129, c]),
801
801
  // FIN + text frame, length
802
- i
803
- ]) : l < 65536 ? c = Buffer.concat([
802
+ r
803
+ ]) : c < 65536 ? p = Buffer.concat([
804
804
  Buffer.from([129, 126]),
805
805
  // FIN + text frame, extended length
806
- Buffer.from([l >> 8, l & 255]),
806
+ Buffer.from([c >> 8, c & 255]),
807
807
  // 16-bit length
808
- i
809
- ]) : c = Buffer.concat([
808
+ r
809
+ ]) : p = Buffer.concat([
810
810
  Buffer.from([129, 127]),
811
811
  // FIN + text frame, extended length
812
- Buffer.from([0, 0, 0, 0, l >> 24, l >> 16 & 255, l >> 8 & 255, l & 255]),
812
+ Buffer.from([0, 0, 0, 0, c >> 24, c >> 16 & 255, c >> 8 & 255, c & 255]),
813
813
  // 64-bit length
814
- i
815
- ]), c;
814
+ r
815
+ ]), p;
816
816
  }, Be = () => {
817
817
  if (!_) return;
818
- const a = x ? C : e.default.join(S, "index.html");
819
- let i;
818
+ const a = M ? T : e.default.join(C, "index.html");
819
+ let r;
820
820
  try {
821
- const l = o.default.readFileSync(a, "utf-8");
822
- i = Ce(l, M);
823
- } catch (l) {
824
- console.error("❌ Failed to read HTML for HMR:", l.message);
821
+ const c = o.default.readFileSync(a, "utf-8");
822
+ r = Me(c, f);
823
+ } catch (c) {
824
+ console.error("❌ Failed to read HTML for HMR:", c.message);
825
825
  return;
826
826
  }
827
827
  if (Re) {
828
- const l = X.get(M);
829
- if (!l || l.size === 0)
828
+ const c = ee.get(f);
829
+ if (!c || c.size === 0)
830
830
  return;
831
- console.log(`πŸ”₯ Notifying ${l.size} HMR client(s)`);
832
- const c = JSON.stringify({
831
+ console.log(`πŸ”₯ Notifying ${c.size} HMR client(s)`);
832
+ const p = JSON.stringify({
833
833
  type: "update",
834
- html: i
835
- }), u = Ue(c);
836
- l.forEach((h) => {
834
+ html: r
835
+ }), g = Je(p);
836
+ c.forEach((h) => {
837
837
  try {
838
- h.write(u);
838
+ h.write(g);
839
839
  } catch {
840
- l.delete(h);
840
+ c.delete(h);
841
841
  }
842
842
  });
843
843
  } else {
844
- const l = JSON.stringify({
845
- componentId: M,
846
- html: i
847
- }), c = {
844
+ const c = JSON.stringify({
845
+ componentId: f,
846
+ html: r
847
+ }), p = {
848
848
  hostname: "localhost",
849
- port: p,
849
+ port: d,
850
850
  path: "/_hmr_notify",
851
851
  method: "POST",
852
852
  headers: {
853
853
  "Content-Type": "application/json",
854
- "Content-Length": Buffer.byteLength(l)
854
+ "Content-Length": Buffer.byteLength(c)
855
855
  },
856
856
  timeout: 5e3
857
- }, u = n.default.request(c, (h) => {
858
- let v = "";
859
- h.on("data", (R) => v += R), h.on("end", () => {
857
+ }, g = n.default.request(p, (h) => {
858
+ let $ = "";
859
+ h.on("data", (O) => $ += O), h.on("end", () => {
860
860
  try {
861
- const R = JSON.parse(v);
862
- R.notified > 0 && console.log(`πŸ”₯ Notified ${R.notified} HMR client(s) via server`);
861
+ const O = JSON.parse($);
862
+ O.notified > 0 && console.log(`πŸ”₯ Notified ${O.notified} HMR client(s) via server`);
863
863
  } catch {
864
864
  }
865
865
  });
866
866
  });
867
- u.on("error", () => {
868
- }), u.on("timeout", () => {
869
- u.destroy();
870
- }), u.write(l), u.end();
867
+ g.on("error", () => {
868
+ }), g.on("timeout", () => {
869
+ g.destroy();
870
+ }), g.write(c), g.end();
871
871
  }
872
872
  };
873
- let Me = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
- const ue = (a) => {
875
- if (g) {
876
- b = !0;
873
+ let Pe = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
+ const ge = (a) => {
875
+ if (u) {
876
+ S = !0;
877
877
  return;
878
878
  }
879
- g = !0, console.log(`
880
- πŸ”¨ Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (i, l, c) => {
881
- if (g = !1, i) {
882
- const u = await qe(i, l, c, t, {
883
- ...Me,
884
- onRetry: () => ue(a)
879
+ u = !0, console.log(`
880
+ πŸ”¨ Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, c, p) => {
881
+ if (u = !1, r) {
882
+ const g = await et(r, c, p, t, {
883
+ ...Pe,
884
+ onRetry: () => ge(a)
885
885
  });
886
- Me = { ...Me, ...u }, u.handled || (console.error("❌ Build failed:", i.message), c && console.error(c));
886
+ Pe = { ...Pe, ...g }, g.handled || (console.error("❌ Build failed:", r.message), p && console.error(p));
887
887
  } else
888
- console.log("βœ… Build completed"), l && console.log(l), Be(), a && a();
889
- b && (b = !1, ue());
888
+ console.log("βœ… Build completed"), c && console.log(c), Be(), a && a();
889
+ S && (S = !1, ge());
890
890
  });
891
- }, Je = /* @__PURE__ */ new Set(), Pe = (a) => {
892
- o.default.readdir(a, { withFileTypes: !0 }, (i, l) => {
893
- i || (l.forEach((c) => {
894
- const u = e.default.join(a, c.name);
895
- if (c.isDirectory())
896
- c.name !== "node_modules" && c.name !== "dist" && !c.name.startsWith(".") && Pe(u);
897
- else if (c.isFile()) {
898
- const h = e.default.extname(c.name);
891
+ }, ze = /* @__PURE__ */ new Set(), Te = (a) => {
892
+ o.default.readdir(a, { withFileTypes: !0 }, (r, c) => {
893
+ r || (c.forEach((p) => {
894
+ const g = e.default.join(a, p.name);
895
+ if (p.isDirectory())
896
+ p.name !== "node_modules" && p.name !== "dist" && !p.name.startsWith(".") && Te(g);
897
+ else if (p.isFile()) {
898
+ const h = e.default.extname(p.name);
899
899
  if (h === ".js" || h === ".css" || h === ".html")
900
900
  try {
901
- const v = o.default.readFileSync(u, "utf-8");
902
- P.set(u, v);
901
+ const $ = o.default.readFileSync(g, "utf-8");
902
+ j.set(g, $);
903
903
  } catch {
904
904
  }
905
905
  }
906
- }), Je.has(a) || (Je.add(a), o.default.watch(a, (c, u) => {
907
- if (!u) return;
908
- const h = e.default.extname(u);
906
+ }), ze.has(a) || (ze.add(a), o.default.watch(a, (p, g) => {
907
+ if (!g) return;
908
+ const h = e.default.extname(g);
909
909
  if (h !== ".js" && h !== ".css" && h !== ".html") return;
910
- const v = e.default.join(a, u);
910
+ const $ = e.default.join(a, g);
911
911
  setTimeout(() => {
912
912
  try {
913
- const R = o.default.readFileSync(v, "utf-8"), N = P.get(v);
914
- R !== N && (P.set(v, R), console.log(`πŸ“ File changed: ${v}`), x ? Be() : ue());
913
+ const O = o.default.readFileSync($, "utf-8"), L = j.get($);
914
+ O !== L && (j.set($, O), console.log(`πŸ“ File changed: ${$}`), M ? Be() : ge());
915
915
  } catch {
916
916
  }
917
917
  }, 50);
918
918
  })));
919
919
  });
920
- }, ze = (a) => {
920
+ }, We = (a) => {
921
921
  console.log(`
922
- πŸ”¨ Component: ${M}`), x ? (console.log("πŸ“„ No build needed (single HTML file mode)"), Pe(F), console.log(`πŸ‘€ Watching ${C} for changes...`), console.log(`Press Ctrl+C to stop
923
- `), a && a()) : (ue(a), Pe(F), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
922
+ πŸ”¨ Component: ${f}`), M ? (console.log("πŸ“„ No build needed (single HTML file mode)"), Te(k), console.log(`πŸ‘€ Watching ${T} for changes...`), console.log(`Press Ctrl+C to stop
923
+ `), a && a()) : (ge(a), Te(k), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
924
924
  `));
925
- }, at = () => new Promise((a) => {
926
- const i = {
925
+ }, pt = () => new Promise((a) => {
926
+ const r = {
927
927
  hostname: "localhost",
928
- port: p,
928
+ port: d,
929
929
  path: "/_list",
930
930
  method: "GET",
931
931
  timeout: 1e3
932
- }, l = n.default.request(i, (c) => {
932
+ }, c = n.default.request(r, (p) => {
933
933
  a(!0);
934
934
  });
935
- l.on("error", () => a(!1)), l.on("timeout", () => {
936
- l.destroy(), a(!1);
937
- }), l.end();
938
- }), lt = () => new Promise((a) => {
939
- const i = n.default.createServer((l, c) => {
940
- if (c.setHeader("Content-Type", "application/json"), l.method === "POST" && l.url === "/_register") {
941
- let u = "";
942
- l.on("data", (h) => u += h), l.on("end", () => {
935
+ c.on("error", () => a(!1)), c.on("timeout", () => {
936
+ c.destroy(), a(!1);
937
+ }), c.end();
938
+ }), mt = () => new Promise((a) => {
939
+ const r = n.default.createServer((c, p) => {
940
+ if (p.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
941
+ let g = "";
942
+ c.on("data", (h) => g += h), c.on("end", () => {
943
943
  try {
944
- const { componentId: h, distPath: v, componentName: R, htmlFile: N } = JSON.parse(u);
945
- T.set(h, { path: v, name: R || null, htmlFile: N || null });
946
- const J = R ? ` (${R})` : "";
947
- console.log(`βœ… Registered: ${h}${J} -> ${v}${N ? "/" + N : ""}`), c.writeHead(200), c.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
944
+ const { componentId: h, distPath: $, componentName: O, htmlFile: L } = JSON.parse(g);
945
+ I.set(h, { path: $, name: O || null, htmlFile: L || null });
946
+ const V = O ? ` (${O})` : "";
947
+ console.log(`βœ… Registered: ${h}${V} -> ${$}${L ? "/" + L : ""}`), p.writeHead(200), p.end(JSON.stringify({ success: !0, registered: Array.from(I.keys()) }));
948
948
  } catch (h) {
949
- c.writeHead(400), c.end(JSON.stringify({ error: h.message }));
949
+ p.writeHead(400), p.end(JSON.stringify({ error: h.message }));
950
950
  }
951
951
  });
952
- } else if (l.method === "POST" && l.url === "/_unregister") {
953
- let u = "";
954
- l.on("data", (h) => u += h), l.on("end", () => {
952
+ } else if (c.method === "POST" && c.url === "/_unregister") {
953
+ let g = "";
954
+ c.on("data", (h) => g += h), c.on("end", () => {
955
955
  try {
956
- const { componentId: h } = JSON.parse(u);
957
- T.delete(h), console.log(`❌ Unregistered: ${h}`), c.writeHead(200), c.end(JSON.stringify({ success: !0 }));
956
+ const { componentId: h } = JSON.parse(g);
957
+ I.delete(h), console.log(`❌ Unregistered: ${h}`), p.writeHead(200), p.end(JSON.stringify({ success: !0 }));
958
958
  } catch (h) {
959
- c.writeHead(400), c.end(JSON.stringify({ error: h.message }));
959
+ p.writeHead(400), p.end(JSON.stringify({ error: h.message }));
960
960
  }
961
961
  });
962
- } else l.method === "GET" && l.url === "/_list" ? (c.writeHead(200), c.end(JSON.stringify({ components: Array.from(T.entries()) }))) : (c.writeHead(404), c.end(JSON.stringify({ error: "Not found" })));
962
+ } else c.method === "GET" && c.url === "/_list" ? (p.writeHead(200), p.end(JSON.stringify({ components: Array.from(I.entries()) }))) : (p.writeHead(404), p.end(JSON.stringify({ error: "Not found" })));
963
963
  });
964
- i.on("error", () => {
964
+ r.on("error", () => {
965
965
  a(!1);
966
- }), i.listen(p, () => {
966
+ }), r.listen(d, () => {
967
967
  console.log(`
968
- πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${p}`), me.on("error", () => {
969
- i.close(), a(!1);
970
- }), me.listen(m, () => {
968
+ πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${d}`), ue.on("error", () => {
969
+ r.close(), a(!1);
970
+ }), ue.listen(m, () => {
971
971
  console.log(`πŸ“‘ Main server running at http://localhost:${m}`);
972
- const l = x ? e.default.resolve(F) : e.default.resolve(F, S);
973
- T.set(M, {
974
- path: l,
975
- name: I,
976
- htmlFile: x ? C : null
972
+ const c = M ? e.default.resolve(k) : e.default.resolve(k, C);
973
+ I.set(f, {
974
+ path: c,
975
+ name: E,
976
+ htmlFile: M ? T : null
977
977
  });
978
- const c = I ? ` (${I})` : "";
979
- console.log(`βœ… Registered component: ${M}${c}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${M}/`), a(!0);
978
+ const p = E ? ` (${E})` : "";
979
+ console.log(`βœ… Registered component: ${f}${p}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), a(!0);
980
980
  });
981
981
  });
982
982
  });
983
- let ge;
984
- const We = () => {
985
- ge = setInterval(async () => {
986
- await at() || (clearInterval(ge), console.log(`
987
- ⚠️ Server appears to be down, attempting to take over...`), await lt() ? (console.log("βœ… Successfully took over as server"), Re = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
983
+ let fe;
984
+ const Ve = () => {
985
+ fe = setInterval(async () => {
986
+ await pt() || (clearInterval(fe), console.log(`
987
+ ⚠️ Server appears to be down, attempting to take over...`), await mt() ? (console.log("βœ… Successfully took over as server"), Re = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
988
988
  try {
989
- await De(), console.log(`βœ… Re-registered component: ${M}`), We();
990
- } catch (l) {
991
- console.error("❌ Failed to re-register:", l.message);
989
+ await Ue(), console.log(`βœ… Re-registered component: ${f}`), Ve();
990
+ } catch (c) {
991
+ console.error("❌ Failed to re-register:", c.message);
992
992
  }
993
993
  }, 2e3)));
994
994
  }, 3e3);
995
- }, Ve = async () => {
995
+ }, Ge = async () => {
996
996
  console.log(`
997
997
 
998
- πŸ›‘ Shutting down...`), ge && clearInterval(ge), await it(), process.exit(0);
998
+ πŸ›‘ Shutting down...`), fe && clearInterval(fe), await ct(), process.exit(0);
999
999
  };
1000
- process.on("SIGINT", Ve), process.on("SIGTERM", Ve);
1000
+ process.on("SIGINT", Ge), process.on("SIGTERM", Ge);
1001
1001
  let Re = !1;
1002
- xe.on("error", async (a) => {
1002
+ Ce.on("error", async (a) => {
1003
1003
  if (a.code === "EADDRINUSE") {
1004
1004
  console.log(`
1005
1005
  πŸ”— Connecting to existing dev server...`);
1006
1006
  try {
1007
- M = await U();
1008
- const i = await De();
1009
- console.log(`βœ… Registered component: ${M}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${M}/`), console.log(`πŸ“‹ All registered components: ${i.registered.join(", ")}`), ze(() => {
1010
- process.env.MYOP_NO_BROWSER || f(`http://localhost:${m}/view/${M}/`);
1011
- }), We();
1012
- } catch (i) {
1013
- console.error("❌ Failed to register component:", i.message), process.exit(1);
1007
+ f = await U();
1008
+ const r = await Ue();
1009
+ console.log(`βœ… Registered component: ${f}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), console.log(`πŸ“‹ All registered components: ${r.registered.join(", ")}`), We(() => {
1010
+ process.env.MYOP_NO_BROWSER || x(`http://localhost:${m}/view/${f}/`);
1011
+ }), Ve();
1012
+ } catch (r) {
1013
+ console.error("❌ Failed to register component:", r.message), process.exit(1);
1014
1014
  }
1015
1015
  } else
1016
1016
  console.error("❌ Management server error:", a.message), process.exit(1);
1017
- }), xe.on("upgrade", st), xe.listen(p, async () => {
1017
+ }), Ce.on("upgrade", lt), Ce.listen(d, async () => {
1018
1018
  Re = !0, console.log(`
1019
- πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${p}`), me.on("error", (a) => {
1019
+ πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${d}`), ue.on("error", (a) => {
1020
1020
  console.error("❌ Main server error:", a.message), process.exit(1);
1021
- }), me.listen(m, async () => {
1022
- console.log(`πŸ“‘ Main server running at http://localhost:${m}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
1023
- const a = x ? e.default.resolve(F) : e.default.resolve(F, S);
1024
- T.set(M, {
1021
+ }), ue.listen(m, async () => {
1022
+ console.log(`πŸ“‘ Main server running at http://localhost:${m}`), (f === "DEV" || f === "NEW") && (f = "DEV1");
1023
+ const a = M ? e.default.resolve(k) : e.default.resolve(k, C);
1024
+ I.set(f, {
1025
1025
  path: a,
1026
- name: I,
1027
- htmlFile: x ? C : null
1026
+ name: E,
1027
+ htmlFile: M ? T : null
1028
1028
  });
1029
- const i = I ? ` (${I})` : "";
1030
- console.log(`βœ… Registered component: ${M}${i}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${M}/`), ze(() => {
1031
- process.env.MYOP_NO_BROWSER || f(`http://localhost:${m}/view/${M}/`);
1029
+ const r = E ? ` (${E})` : "";
1030
+ console.log(`βœ… Registered component: ${f}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), We(() => {
1031
+ process.env.MYOP_NO_BROWSER || x(`http://localhost:${m}/view/${f}/`);
1032
1032
  });
1033
1033
  });
1034
1034
  });
1035
1035
  }
1036
- const O = class O {
1036
+ const F = class F {
1037
1037
  constructor(e) {
1038
1038
  this.components = e.map(
1039
1039
  (t) => typeof t == "string" ? { name: t, path: "", id: "" } : t
@@ -1042,7 +1042,7 @@ const O = class O {
1042
1042
  this.logs.set(t.name, []), this.scrollPos.set(t.name, 0), this.statuses.set(t.name, "Initializing..."), this.statusKeys.set(t.name, "initializing");
1043
1043
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
1044
1044
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
1045
- }), this.setupKeyboardInput(), process.stdout.write(O.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1045
+ }), this.setupKeyboardInput(), process.stdout.write(F.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1046
1046
  }
1047
1047
  setupKeyboardInput() {
1048
1048
  process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (e) => {
@@ -1073,8 +1073,8 @@ const O = class O {
1073
1073
  this.scrollPos.set(t, 0), this.queueUpdate(t);
1074
1074
  break;
1075
1075
  case "G":
1076
- const r = this.logs.get(t) || [];
1077
- this.scrollPos.set(t, Math.max(0, r.length - this.visibleLogLines)), this.queueUpdate(t);
1076
+ const i = this.logs.get(t) || [];
1077
+ this.scrollPos.set(t, Math.max(0, i.length - this.visibleLogLines)), this.queueUpdate(t);
1078
1078
  break;
1079
1079
  }
1080
1080
  }));
@@ -1083,35 +1083,35 @@ const O = class O {
1083
1083
  const e = this.components.length, t = 38;
1084
1084
  let n;
1085
1085
  this.cols >= t * 3 + 4 ? n = Math.min(e, 3) : this.cols >= t * 2 + 2 ? n = Math.min(e, 2) : n = 1;
1086
- const r = Math.ceil(e / n), s = Math.floor(this.cols / n), d = 2, $ = this.rows - d - 2, m = Math.floor($ / r);
1087
- this.visibleLogLines = Math.max(2, m - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: r, panelHeight: m }, this.panelPositions.clear();
1088
- for (let p = 0; p < e; p++) {
1089
- const S = this.components[p], g = Math.floor(p / n), b = p % n;
1090
- this.panelPositions.set(S.name, {
1091
- row: d + 1 + g * m,
1092
- col: b * s + 1,
1086
+ const i = Math.ceil(e / n), s = Math.floor(this.cols / n), l = 2, v = this.rows - l - 2, m = Math.floor(v / i);
1087
+ this.visibleLogLines = Math.max(2, m - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: i, panelHeight: m }, this.panelPositions.clear();
1088
+ for (let d = 0; d < e; d++) {
1089
+ const C = this.components[d], u = Math.floor(d / n), S = d % n;
1090
+ this.panelPositions.set(C.name, {
1091
+ row: l + 1 + u * m,
1092
+ col: S * s + 1,
1093
1093
  width: s,
1094
1094
  height: m
1095
1095
  });
1096
1096
  }
1097
1097
  }
1098
1098
  log(e, t, n = "info") {
1099
- const r = this.logs.get(e) || [], s = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1099
+ const i = this.logs.get(e) || [], s = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1100
1100
  hour12: !1,
1101
1101
  hour: "2-digit",
1102
1102
  minute: "2-digit",
1103
1103
  second: "2-digit"
1104
1104
  });
1105
- t.includes("βœ…") || t.includes("completed") ? n = "success" : t.includes("❌") || t.includes("failed") ? n = "error" : t.includes("⚠") ? n = "warning" : t.includes("πŸ”₯") || t.includes("HMR") ? n = "hmr" : (t.includes("πŸ“") || t.includes("changed")) && (n = "change"), r.push({ timestamp: s, message: t.replace(/[βœ…βŒβš πŸ”₯πŸ“πŸ”¨]/g, "").trim(), type: n }), this.logs.set(e, r), r.length > this.visibleLogLines && this.scrollPos.set(e, r.length - this.visibleLogLines), this.queueUpdate(e);
1105
+ t.includes("βœ…") || t.includes("completed") ? n = "success" : t.includes("❌") || t.includes("failed") ? n = "error" : t.includes("⚠") ? n = "warning" : t.includes("πŸ”₯") || t.includes("HMR") ? n = "hmr" : (t.includes("πŸ“") || t.includes("changed")) && (n = "change"), i.push({ timestamp: s, message: t.replace(/[βœ…βŒβš πŸ”₯πŸ“πŸ”¨]/g, "").trim(), type: n }), this.logs.set(e, i), i.length > this.visibleLogLines && this.scrollPos.set(e, i.length - this.visibleLogLines), this.queueUpdate(e);
1106
1106
  }
1107
1107
  setStatus(e, t) {
1108
1108
  let n = "ready";
1109
- const r = t.toLowerCase();
1110
- r.includes("initializing") || r.includes("⏳") ? n = "initializing" : r.includes("starting") ? n = "starting" : r.includes("building") || r.includes("πŸ”¨") ? n = "building" : r.includes("ready") || r.includes("βœ…") ? n = "ready" : r.includes("changed") || r.includes("πŸ“") ? n = "changed" : r.includes("hmr") ? n = "hmr_update" : r.includes("πŸ”₯") ? n = "hmr" : r.includes("error") || r.includes("❌") ? n = "error" : r.includes("warning") || r.includes("⚠") ? n = "warning" : (r.includes("stopped") || r.includes("exited")) && (n = "stopped"), this.statuses.set(e, t), this.statusKeys.set(e, n), this.queueUpdate(e);
1109
+ const i = t.toLowerCase();
1110
+ i.includes("initializing") || i.includes("⏳") ? n = "initializing" : i.includes("starting") ? n = "starting" : i.includes("building") || i.includes("πŸ”¨") ? n = "building" : i.includes("ready") || i.includes("βœ…") ? n = "ready" : i.includes("changed") || i.includes("πŸ“") ? n = "changed" : i.includes("hmr") ? n = "hmr_update" : i.includes("πŸ”₯") ? n = "hmr" : i.includes("error") || i.includes("❌") ? n = "error" : i.includes("warning") || i.includes("⚠") ? n = "warning" : (i.includes("stopped") || i.includes("exited")) && (n = "stopped"), this.statuses.set(e, t), this.statusKeys.set(e, n), this.queueUpdate(e);
1111
1111
  }
1112
1112
  scroll(e, t) {
1113
- const n = this.logs.get(e) || [], r = this.scrollPos.get(e) || 0, s = Math.max(0, n.length - this.visibleLogLines), d = Math.max(0, Math.min(s, r + t));
1114
- d !== r && (this.scrollPos.set(e, d), this.queueUpdate(e));
1113
+ const n = this.logs.get(e) || [], i = this.scrollPos.get(e) || 0, s = Math.max(0, n.length - this.visibleLogLines), l = Math.max(0, Math.min(s, i + t));
1114
+ l !== i && (this.scrollPos.set(e, l), this.queueUpdate(e));
1115
1115
  }
1116
1116
  queueUpdate(e) {
1117
1117
  this.pendingUpdates.add(e), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
@@ -1132,71 +1132,71 @@ const O = class O {
1132
1132
  return `${t}:${n.toString().padStart(2, "0")}`;
1133
1133
  }
1134
1134
  updateHeader() {
1135
- const e = O.C, t = Array.from(this.statusKeys.values()).filter((s) => s === "ready").length, n = this.components.length;
1136
- let r = `${e.dim}πŸ“‘${e.reset} http://localhost:9292 ${e.gray}|${e.reset} `;
1137
- r += `${e.green}${t}${e.reset}/${n} ready ${e.gray}|${e.reset} `, r += `⏱ ${this.getUptime()} ${e.gray}|${e.reset} `, r += `Press ${e.yellow}Ctrl+C${e.reset} to stop`, r += O.ESC.clearLine.slice(0, -1), process.stdout.write(O.ESC.moveTo(2, 1) + r);
1135
+ const e = F.C, t = Array.from(this.statusKeys.values()).filter((s) => s === "ready").length, n = this.components.length;
1136
+ let i = `${e.dim}πŸ“‘${e.reset} http://localhost:9292 ${e.gray}|${e.reset} `;
1137
+ i += `${e.green}${t}${e.reset}/${n} ready ${e.gray}|${e.reset} `, i += `⏱ ${this.getUptime()} ${e.gray}|${e.reset} `, i += `Press ${e.yellow}Ctrl+C${e.reset} to stop`, i += F.ESC.clearLine.slice(0, -1), process.stdout.write(F.ESC.moveTo(2, 1) + i);
1138
1138
  }
1139
1139
  renderPanel(e) {
1140
- const t = O.C, n = O.STATUS, r = this.panelPositions.get(e);
1141
- if (!r) return;
1142
- const s = this.components.findIndex((U) => U.name === e), d = this.components[s], w = s === this.selectedPanel, $ = this.statusKeys.get(e) || "initializing", m = n[$], p = t[m.color], S = this.logs.get(e) || [], g = this.scrollPos.get(e) || 0, b = r.width - 1, x = w ? t.cyan : t.gray, C = [], L = d.name.substring(0, b - 20);
1143
- let H = `${x}β”Œβ”€${t.reset} ${p}${m.icon}${t.reset} `;
1144
- H += `${t.bold}${L}${t.reset} ${t.gray}─${t.reset} ${p}${m.label}${t.reset} `;
1145
- const f = 5 + L.length + m.label.length + 3;
1146
- H += `${x}${"─".repeat(Math.max(0, b - f))}┐${t.reset}`, C.push(O.ESC.moveTo(r.row, r.col) + H);
1147
- const P = (d.path || "").substring(0, b - 6);
1148
- let E = `${x}β”‚${t.reset} ${t.dim}${P}${t.reset}`;
1149
- E += " ".repeat(Math.max(0, b - P.length - 3)), E += `${x}β”‚${t.reset}`, C.push(O.ESC.moveTo(r.row + 1, r.col) + E);
1150
- const M = S.length, I = M > this.visibleLogLines ? `${g + 1}-${Math.min(g + this.visibleLogLines, M)}/${M}` : "";
1151
- let _ = `${x}β”œ${"─".repeat(b - I.length - 4)}${t.reset}`;
1152
- I && (_ += `${t.dim}${I}${t.reset}`), _ += `${x}${"─".repeat(2)}─${t.reset}`, C.push(O.ESC.moveTo(r.row + 2, r.col) + _);
1153
- const te = S.slice(g, g + this.visibleLogLines);
1140
+ const t = F.C, n = F.STATUS, i = this.panelPositions.get(e);
1141
+ if (!i) return;
1142
+ const s = this.components.findIndex((U) => U.name === e), l = this.components[s], w = s === this.selectedPanel, v = this.statusKeys.get(e) || "initializing", m = n[v], d = t[m.color], C = this.logs.get(e) || [], u = this.scrollPos.get(e) || 0, S = i.width - 1, M = w ? t.cyan : t.gray, T = [], D = l.name.substring(0, S - 20);
1143
+ let P = `${M}β”Œβ”€${t.reset} ${d}${m.icon}${t.reset} `;
1144
+ P += `${t.bold}${D}${t.reset} ${t.gray}─${t.reset} ${d}${m.label}${t.reset} `;
1145
+ const x = 5 + D.length + m.label.length + 3;
1146
+ P += `${M}${"─".repeat(Math.max(0, S - x))}┐${t.reset}`, T.push(F.ESC.moveTo(i.row, i.col) + P);
1147
+ const j = (l.path || "").substring(0, S - 6);
1148
+ let b = `${M}β”‚${t.reset} ${t.dim}${j}${t.reset}`;
1149
+ b += " ".repeat(Math.max(0, S - j.length - 3)), b += `${M}β”‚${t.reset}`, T.push(F.ESC.moveTo(i.row + 1, i.col) + b);
1150
+ const f = C.length, E = f > this.visibleLogLines ? `${u + 1}-${Math.min(u + this.visibleLogLines, f)}/${f}` : "";
1151
+ let _ = `${M}β”œ${"─".repeat(S - E.length - 4)}${t.reset}`;
1152
+ E && (_ += `${t.dim}${E}${t.reset}`), _ += `${M}${"─".repeat(2)}─${t.reset}`, T.push(F.ESC.moveTo(i.row + 2, i.col) + _);
1153
+ const B = C.slice(u, u + this.visibleLogLines);
1154
1154
  for (let U = 0; U < this.visibleLogLines; U++) {
1155
- const F = te[U];
1156
- let G = `${x}β”‚${t.reset}`;
1157
- if (F) {
1158
- let T = t.white;
1159
- F.type === "success" ? T = t.green : F.type === "error" ? T = t.red : F.type === "warning" ? T = t.yellow : F.type === "hmr" ? T = t.magenta : F.type === "change" && (T = t.blue);
1160
- const Y = F.message.substring(0, b - 12);
1161
- G += `${t.dim}${F.timestamp}${t.reset} ${T}${Y}${t.reset}`;
1162
- const $e = b - F.timestamp.length - Y.length - 2;
1163
- G += " ".repeat(Math.max(0, $e));
1155
+ const k = B[U];
1156
+ let z = `${M}β”‚${t.reset}`;
1157
+ if (k) {
1158
+ let I = t.white;
1159
+ k.type === "success" ? I = t.green : k.type === "error" ? I = t.red : k.type === "warning" ? I = t.yellow : k.type === "hmr" ? I = t.magenta : k.type === "change" && (I = t.blue);
1160
+ const Z = k.message.substring(0, S - 12);
1161
+ z += `${t.dim}${k.timestamp}${t.reset} ${I}${Z}${t.reset}`;
1162
+ const se = S - k.timestamp.length - Z.length - 2;
1163
+ z += " ".repeat(Math.max(0, se));
1164
1164
  } else
1165
- G += " ".repeat(b - 2);
1166
- G += `${x}β”‚${t.reset}`, C.push(O.ESC.moveTo(r.row + 3 + U, r.col) + G);
1165
+ z += " ".repeat(S - 2);
1166
+ z += `${M}β”‚${t.reset}`, T.push(F.ESC.moveTo(i.row + 3 + U, i.col) + z);
1167
1167
  }
1168
- C.push(O.ESC.moveTo(r.row + 3 + this.visibleLogLines, r.col) + `${x}β””${"─".repeat(b - 2)}β”˜${t.reset}`), process.stdout.write(C.join(""));
1168
+ T.push(F.ESC.moveTo(i.row + 3 + this.visibleLogLines, i.col) + `${M}β””${"─".repeat(S - 2)}β”˜${t.reset}`), process.stdout.write(T.join(""));
1169
1169
  }
1170
1170
  fullRender() {
1171
- const e = O.C;
1172
- process.stdout.write(O.ESC.clearScreen + O.ESC.moveTo(1, 1));
1171
+ const e = F.C;
1172
+ process.stdout.write(F.ESC.clearScreen + F.ESC.moveTo(1, 1));
1173
1173
  const t = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - t.length) / 2);
1174
1174
  process.stdout.write(`${e.cyan}${"━".repeat(n)}${e.bold}${e.bgCyan}${e.black}${t}${e.reset}${e.cyan}${"━".repeat(this.cols - n - t.length)}${e.reset}`), this.updateHeader();
1175
- for (const r of this.components)
1176
- this.renderPanel(r.name);
1175
+ for (const i of this.components)
1176
+ this.renderPanel(i.name);
1177
1177
  this.renderFooter();
1178
1178
  }
1179
1179
  renderFooter() {
1180
- const e = O.C, t = this.rows - 1;
1180
+ const e = F.C, t = this.rows - 1;
1181
1181
  let n = `${e.gray}`;
1182
- n += `${e.green}●${e.gray} Ready `, n += `${e.yellow}⟳${e.gray} Building `, n += `${e.magenta}⚑${e.gray} HMR `, n += `${e.red}βœ–${e.gray} Error `, n += `${e.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${e.reset}`, process.stdout.write(O.ESC.moveTo(t, 1) + n);
1182
+ n += `${e.green}●${e.gray} Ready `, n += `${e.yellow}⟳${e.gray} Building `, n += `${e.magenta}⚑${e.gray} HMR `, n += `${e.red}βœ–${e.gray} Error `, n += `${e.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${e.reset}`, process.stdout.write(F.ESC.moveTo(t, 1) + n);
1183
1183
  }
1184
1184
  render() {
1185
1185
  this.needsFullRedraw = !0, this.queueUpdate("__full__");
1186
1186
  }
1187
1187
  clear() {
1188
- this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(O.ESC.clearScreen + O.ESC.moveTo(1, 1) + O.ESC.showCursor);
1188
+ this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(F.ESC.clearScreen + F.ESC.moveTo(1, 1) + F.ESC.showCursor);
1189
1189
  }
1190
1190
  };
1191
1191
  // ANSI escape codes
1192
- he(O, "ESC", {
1192
+ ye(F, "ESC", {
1193
1193
  moveTo: (e, t) => `\x1B[${e};${t}H`,
1194
1194
  hideCursor: "\x1B[?25l",
1195
1195
  showCursor: "\x1B[?25h",
1196
1196
  clearScreen: "\x1B[2J",
1197
1197
  clearLine: "\x1B[2K"
1198
1198
  }), // Colors
1199
- he(O, "C", {
1199
+ ye(F, "C", {
1200
1200
  reset: "\x1B[0m",
1201
1201
  bold: "\x1B[1m",
1202
1202
  dim: "\x1B[2m",
@@ -1211,7 +1211,7 @@ he(O, "C", {
1211
1211
  bgCyan: "\x1B[46m",
1212
1212
  black: "\x1B[30m"
1213
1213
  }), // Status configs
1214
- he(O, "STATUS", {
1214
+ ye(F, "STATUS", {
1215
1215
  initializing: { icon: "β—”", color: "yellow", label: "Initializing" },
1216
1216
  starting: { icon: "β—‘", color: "yellow", label: "Starting" },
1217
1217
  building: { icon: "⟳", color: "yellow", label: "Building" },
@@ -1224,124 +1224,124 @@ he(O, "STATUS", {
1224
1224
  warning: { icon: "⚠", color: "yellow", label: "Warning" },
1225
1225
  stopped: { icon: "β– ", color: "gray", label: "Stopped" }
1226
1226
  });
1227
- let je = O;
1228
- async function It(o) {
1229
- const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), r = o.map((p) => ({
1230
- name: p.name,
1231
- path: p.path,
1232
- id: p.componentId || ""
1233
- })), s = new je(r), d = [], w = (p) => {
1234
- const S = process.platform;
1235
- let g;
1236
- S === "darwin" ? g = `open "${p}"` : S === "win32" ? g = `start "" "${p}"` : g = `xdg-open "${p}"`, t(g, () => {
1227
+ let je = F;
1228
+ async function Nt(o) {
1229
+ const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), i = o.map((d) => ({
1230
+ name: d.name,
1231
+ path: d.path,
1232
+ id: d.componentId || ""
1233
+ })), s = new je(i), l = [], w = (d) => {
1234
+ const C = process.platform;
1235
+ let u;
1236
+ C === "darwin" ? u = `open "${d}"` : C === "win32" ? u = `start "" "${d}"` : u = `xdg-open "${d}"`, t(u, () => {
1237
1237
  });
1238
- }, $ = () => {
1238
+ }, v = () => {
1239
1239
  s.clear(), console.log(`
1240
- πŸ›‘ Shutting down all components...`), d.forEach((p) => {
1240
+ πŸ›‘ Shutting down all components...`), l.forEach((d) => {
1241
1241
  try {
1242
- p.kill("SIGTERM");
1242
+ d.kill("SIGTERM");
1243
1243
  } catch {
1244
1244
  }
1245
1245
  }), setTimeout(() => process.exit(0), 500);
1246
1246
  };
1247
- process.on("SIGINT", $), process.on("SIGTERM", $);
1247
+ process.on("SIGINT", v), process.on("SIGTERM", v);
1248
1248
  const m = process.argv[1];
1249
- for (let p = 0; p < o.length; p++) {
1250
- const S = o[p], g = S.name;
1251
- s.setStatus(g, "⏳ Starting..."), s.log(g, `Starting in ${S.path}`);
1252
- const b = e("node", [m, "dev"], {
1253
- cwd: n.default.resolve(S.path),
1249
+ for (let d = 0; d < o.length; d++) {
1250
+ const C = o[d], u = C.name;
1251
+ s.setStatus(u, "⏳ Starting..."), s.log(u, `Starting in ${C.path}`);
1252
+ const S = e("node", [m, "dev"], {
1253
+ cwd: n.default.resolve(C.path),
1254
1254
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1255
1255
  stdio: ["ignore", "pipe", "pipe"]
1256
1256
  });
1257
- d.push(b);
1258
- let x = "";
1259
- b.stdout.on("data", (C) => {
1260
- x += C.toString();
1261
- const L = x.split(`
1257
+ l.push(S);
1258
+ let M = "";
1259
+ S.stdout.on("data", (T) => {
1260
+ M += T.toString();
1261
+ const D = M.split(`
1262
1262
  `);
1263
- x = L.pop() || "";
1264
- for (const H of L) {
1265
- const f = H.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
- f && (f.includes("Registered component") || f.includes("Registered:") ? s.setStatus(g, "βœ… Ready") : f.includes("Building...") || f.includes("Running initial build") ? s.setStatus(g, "πŸ”¨ Building...") : f.includes("Build completed") || f.includes("Build succeeded") ? s.setStatus(g, "βœ… Ready") : f.includes("Build failed") ? s.setStatus(g, "❌ Build Error") : f.includes("File changed") ? (s.setStatus(g, "πŸ“ Changed"), setTimeout(() => s.setStatus(g, "βœ… Ready"), 1500)) : f.includes("Notifying") && f.includes("HMR") ? (s.setStatus(g, "πŸ”₯ HMR Update"), setTimeout(() => s.setStatus(g, "βœ… Ready"), 1e3)) : f.includes("HMR client connected") && (s.setStatus(g, "πŸ”₯ HMR Connected"), setTimeout(() => s.setStatus(g, "βœ… Ready"), 1e3)), !f.includes("Watching") && !f.includes("Press Ctrl+C") && !f.includes("Starting shared") && !f.includes("Management server") && !f.includes("Main server") && !f.includes("Access at:") && !f.includes("No build needed") && s.log(g, f));
1263
+ M = D.pop() || "";
1264
+ for (const P of D) {
1265
+ const x = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
+ x && (x.includes("Registered component") || x.includes("Registered:") ? s.setStatus(u, "βœ… Ready") : x.includes("Building...") || x.includes("Running initial build") ? s.setStatus(u, "πŸ”¨ Building...") : x.includes("Build completed") || x.includes("Build succeeded") ? s.setStatus(u, "βœ… Ready") : x.includes("Build failed") ? s.setStatus(u, "❌ Build Error") : x.includes("File changed") ? (s.setStatus(u, "πŸ“ Changed"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1500)) : x.includes("Notifying") && x.includes("HMR") ? (s.setStatus(u, "πŸ”₯ HMR Update"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)) : x.includes("HMR client connected") && (s.setStatus(u, "πŸ”₯ HMR Connected"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)), !x.includes("Watching") && !x.includes("Press Ctrl+C") && !x.includes("Starting shared") && !x.includes("Management server") && !x.includes("Main server") && !x.includes("Access at:") && !x.includes("No build needed") && s.log(u, x));
1267
1267
  }
1268
- }), b.stderr.on("data", (C) => {
1269
- const L = C.toString().split(`
1268
+ }), S.stderr.on("data", (T) => {
1269
+ const D = T.toString().split(`
1270
1270
  `);
1271
- for (const H of L) {
1272
- const f = H.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
- f && (s.log(g, `⚠️ ${f}`), s.setStatus(g, "⚠️ Warning"));
1271
+ for (const P of D) {
1272
+ const x = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
+ x && (s.log(u, `⚠️ ${x}`), s.setStatus(u, "⚠️ Warning"));
1274
1274
  }
1275
- }), b.on("exit", (C) => {
1276
- C !== 0 && C !== null && (s.setStatus(g, `❌ Exited (${C})`), s.log(g, `Process exited with code ${C}`));
1277
- }), p < o.length - 1 && await new Promise((C) => setTimeout(C, 500));
1275
+ }), S.on("exit", (T) => {
1276
+ T !== 0 && T !== null && (s.setStatus(u, `❌ Exited (${T})`), s.log(u, `Process exited with code ${T}`));
1277
+ }), d < o.length - 1 && await new Promise((T) => setTimeout(T, 500));
1278
1278
  }
1279
1279
  s.render(), setTimeout(() => {
1280
1280
  w("http://localhost:9292");
1281
1281
  }, 2e3);
1282
1282
  }
1283
- const Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1283
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1284
1284
  __proto__: null,
1285
- devCommand: Le,
1286
- monorepoDevCommand: It
1287
- }, Symbol.toStringTag, { value: "Module" })), Ne = ne.join(ht.homedir(), ".myop"), de = ne.join(Ne, "credentials.json");
1288
- function jt() {
1289
- D.existsSync(Ne) || D.mkdirSync(Ne, { recursive: !0, mode: 448 });
1285
+ devCommand: be,
1286
+ monorepoDevCommand: Nt
1287
+ }, Symbol.toStringTag, { value: "Module" })), Ne = H.join(vt.homedir(), ".myop"), pe = H.join(Ne, "credentials.json");
1288
+ function Lt() {
1289
+ R.existsSync(Ne) || R.mkdirSync(Ne, { recursive: !0, mode: 448 });
1290
1290
  }
1291
- function Ae() {
1291
+ function De() {
1292
1292
  try {
1293
- if (!D.existsSync(de))
1293
+ if (!R.existsSync(pe))
1294
1294
  return null;
1295
- const o = D.readFileSync(de, "utf8");
1295
+ const o = R.readFileSync(pe, "utf8");
1296
1296
  return JSON.parse(o);
1297
1297
  } catch (o) {
1298
1298
  return console.info("Failed to read credentials:", o.message), null;
1299
1299
  }
1300
1300
  }
1301
- function et(o) {
1302
- jt();
1301
+ function tt(o) {
1302
+ Lt();
1303
1303
  const e = {
1304
1304
  ...o,
1305
1305
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
1306
1306
  };
1307
- D.writeFileSync(de, JSON.stringify(e, null, 2), {
1307
+ R.writeFileSync(pe, JSON.stringify(e, null, 2), {
1308
1308
  mode: 384
1309
1309
  // Read/write for owner only
1310
1310
  });
1311
1311
  }
1312
- function tt() {
1312
+ function ot() {
1313
1313
  try {
1314
- return D.existsSync(de) && D.unlinkSync(de), !0;
1314
+ return R.existsSync(pe) && R.unlinkSync(pe), !0;
1315
1315
  } catch (o) {
1316
1316
  return console.error("Failed to clear credentials:", o.message), !1;
1317
1317
  }
1318
1318
  }
1319
- function Nt(o) {
1319
+ function At(o) {
1320
1320
  if (!o || !o.expiresAt)
1321
1321
  return !0;
1322
1322
  const e = 5 * 60 * 1e3, t = new Date(o.expiresAt).getTime();
1323
1323
  return Date.now() > t - e;
1324
1324
  }
1325
- function be() {
1326
- const o = Ae();
1325
+ function xe() {
1326
+ const o = De();
1327
1327
  return o ? {
1328
1328
  email: o.userEmail,
1329
1329
  userId: o.userId
1330
1330
  } : null;
1331
1331
  }
1332
- const re = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", we = 19284, He = `http://localhost:${we}/callback`, kt = "myop-cli";
1333
- function _t() {
1334
- return ke.randomBytes(32).toString("base64url");
1332
+ const ae = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, He = `http://localhost:${Se}/callback`, Dt = "myop-cli";
1333
+ function Ht() {
1334
+ return Le.randomBytes(32).toString("base64url");
1335
1335
  }
1336
- function Lt(o) {
1337
- return ke.createHash("sha256").update(o).digest("base64url");
1336
+ function Ut(o) {
1337
+ return Le.createHash("sha256").update(o).digest("base64url");
1338
1338
  }
1339
- async function At() {
1340
- const o = await fetch(`${re}/oauth/register`, {
1339
+ async function Jt() {
1340
+ const o = await fetch(`${ae}/oauth/register`, {
1341
1341
  method: "POST",
1342
1342
  headers: { "Content-Type": "application/json" },
1343
1343
  body: JSON.stringify({
1344
- client_name: kt,
1344
+ client_name: Dt,
1345
1345
  redirect_uris: [He],
1346
1346
  grant_types: ["authorization_code", "refresh_token"],
1347
1347
  response_types: ["code"]
@@ -1353,8 +1353,8 @@ async function At() {
1353
1353
  }
1354
1354
  return o.json();
1355
1355
  }
1356
- function ye(o, e, t, n = null) {
1357
- const r = {
1356
+ function we(o, e, t, n = null) {
1357
+ const i = {
1358
1358
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
1359
1359
  <circle cx="12" cy="12" r="10"/>
1360
1360
  <path d="M8 12l2.5 2.5L16 9"/>
@@ -1371,7 +1371,7 @@ function ye(o, e, t, n = null) {
1371
1371
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
1372
1372
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
1373
1373
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
1374
- }, { accent: d, glow: w } = s[o] || s.error;
1374
+ }, { accent: l, glow: w } = s[o] || s.error;
1375
1375
  return `<!DOCTYPE html>
1376
1376
  <html lang="en">
1377
1377
  <head>
@@ -1432,7 +1432,7 @@ function ye(o, e, t, n = null) {
1432
1432
  h1 {
1433
1433
  font-size: 20px;
1434
1434
  font-weight: 500;
1435
- color: ${d};
1435
+ color: ${l};
1436
1436
  margin-bottom: 12px;
1437
1437
  letter-spacing: -0.5px;
1438
1438
  }
@@ -1465,7 +1465,7 @@ function ye(o, e, t, n = null) {
1465
1465
  align-items: center;
1466
1466
  gap: 8px;
1467
1467
  background: ${w};
1468
- border: 1px solid ${d}33;
1468
+ border: 1px solid ${l}33;
1469
1469
  border-radius: 4px;
1470
1470
  padding: 10px 16px;
1471
1471
  font-size: 12px;
@@ -1502,7 +1502,7 @@ function ye(o, e, t, n = null) {
1502
1502
  <body>
1503
1503
  <div class="container">
1504
1504
  <div class="icon">
1505
- ${r[o] || r.error}
1505
+ ${i[o] || i.error}
1506
1506
  </div>
1507
1507
  <h1>${e}</h1>
1508
1508
  <p class="message">${t}</p>
@@ -1519,14 +1519,14 @@ function ye(o, e, t, n = null) {
1519
1519
  </body>
1520
1520
  </html>`;
1521
1521
  }
1522
- function Ht(o) {
1522
+ function Bt(o) {
1523
1523
  return new Promise((e, t) => {
1524
- const n = gt.createServer((r, s) => {
1525
- const d = new Ye(r.url, `http://localhost:${we}`);
1526
- if (d.pathname === "/callback") {
1527
- const w = d.searchParams.get("code"), $ = d.searchParams.get("state"), m = d.searchParams.get("error");
1524
+ const n = wt.createServer((i, s) => {
1525
+ const l = new Ke(i.url, `http://localhost:${Se}`);
1526
+ if (l.pathname === "/callback") {
1527
+ const w = l.searchParams.get("code"), v = l.searchParams.get("state"), m = l.searchParams.get("error");
1528
1528
  if (m) {
1529
- s.writeHead(200, { "Content-Type": "text/html" }), s.end(ye(
1529
+ s.writeHead(200, { "Content-Type": "text/html" }), s.end(we(
1530
1530
  "error",
1531
1531
  "Authentication Failed",
1532
1532
  "Unable to complete the authentication process.",
@@ -1534,8 +1534,8 @@ function Ht(o) {
1534
1534
  )), n.close(), t(new Error(`OAuth error: ${m}`));
1535
1535
  return;
1536
1536
  }
1537
- if ($ !== o) {
1538
- s.writeHead(400, { "Content-Type": "text/html" }), s.end(ye(
1537
+ if (v !== o) {
1538
+ s.writeHead(400, { "Content-Type": "text/html" }), s.end(we(
1539
1539
  "warning",
1540
1540
  "Security Error",
1541
1541
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
@@ -1544,7 +1544,7 @@ function Ht(o) {
1544
1544
  return;
1545
1545
  }
1546
1546
  if (!w) {
1547
- s.writeHead(400, { "Content-Type": "text/html" }), s.end(ye(
1547
+ s.writeHead(400, { "Content-Type": "text/html" }), s.end(we(
1548
1548
  "error",
1549
1549
  "Missing Authorization Code",
1550
1550
  "No authorization code was received from the server.",
@@ -1552,7 +1552,7 @@ function Ht(o) {
1552
1552
  )), n.close(), t(new Error("No authorization code"));
1553
1553
  return;
1554
1554
  }
1555
- s.writeHead(200, { "Content-Type": "text/html" }), s.end(ye(
1555
+ s.writeHead(200, { "Content-Type": "text/html" }), s.end(we(
1556
1556
  "success",
1557
1557
  "Authentication Successful",
1558
1558
  "You have been authenticated successfully. Return to the terminal to continue."
@@ -1560,18 +1560,18 @@ function Ht(o) {
1560
1560
  } else
1561
1561
  s.writeHead(404), s.end("Not found");
1562
1562
  });
1563
- n.listen(we, () => {
1564
- console.info(`OAuth callback server listening on port ${we}`);
1563
+ n.listen(Se, () => {
1564
+ console.info(`OAuth callback server listening on port ${Se}`);
1565
1565
  }), setTimeout(() => {
1566
1566
  n.close(), t(new Error("Authentication timed out"));
1567
1567
  }, 5 * 60 * 1e3);
1568
1568
  });
1569
1569
  }
1570
- async function Dt(o, e, t) {
1571
- const n = await fetch(`${re}/oauth/token`, {
1570
+ async function zt(o, e, t) {
1571
+ const n = await fetch(`${ae}/oauth/token`, {
1572
1572
  method: "POST",
1573
1573
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1574
- body: new Ke({
1574
+ body: new Qe({
1575
1575
  grant_type: "authorization_code",
1576
1576
  code: o,
1577
1577
  client_id: e,
@@ -1580,16 +1580,16 @@ async function Dt(o, e, t) {
1580
1580
  })
1581
1581
  });
1582
1582
  if (!n.ok) {
1583
- const r = await n.json();
1584
- throw new Error(r.error_description || r.error || "Token exchange failed");
1583
+ const i = await n.json();
1584
+ throw new Error(i.error_description || i.error || "Token exchange failed");
1585
1585
  }
1586
1586
  return n.json();
1587
1587
  }
1588
- async function Ut(o, e) {
1589
- const t = await fetch(`${re}/oauth/token`, {
1588
+ async function Wt(o, e) {
1589
+ const t = await fetch(`${ae}/oauth/token`, {
1590
1590
  method: "POST",
1591
1591
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1592
- body: new Ke({
1592
+ body: new Qe({
1593
1593
  grant_type: "refresh_token",
1594
1594
  refresh_token: o,
1595
1595
  client_id: e
@@ -1601,9 +1601,9 @@ async function Ut(o, e) {
1601
1601
  }
1602
1602
  return t.json();
1603
1603
  }
1604
- async function Bt(o) {
1605
- var r, s, d;
1606
- const e = await fetch(`${re}/mcp`, {
1604
+ async function Vt(o) {
1605
+ var i, s, l;
1606
+ const e = await fetch(`${ae}/mcp`, {
1607
1607
  method: "POST",
1608
1608
  headers: {
1609
1609
  "Content-Type": "application/json",
@@ -1624,57 +1624,57 @@ async function Bt(o) {
1624
1624
  const t = await e.json();
1625
1625
  if (t.error)
1626
1626
  throw new Error(t.error.message);
1627
- const n = (d = (s = (r = t.result) == null ? void 0 : r.content) == null ? void 0 : s[0]) == null ? void 0 : d.text;
1627
+ const n = (l = (s = (i = t.result) == null ? void 0 : i.content) == null ? void 0 : s[0]) == null ? void 0 : l.text;
1628
1628
  if (n)
1629
1629
  return JSON.parse(n);
1630
1630
  throw new Error("Invalid response from whoami");
1631
1631
  }
1632
- async function ce() {
1633
- const o = V("Starting authentication...").start();
1632
+ async function de() {
1633
+ const o = G("Starting authentication...").start();
1634
1634
  try {
1635
1635
  o.text = "Registering OAuth client...";
1636
- const t = (await At()).client_id, n = _t(), r = Lt(n), s = ke.randomBytes(16).toString("hex");
1636
+ const t = (await Jt()).client_id, n = Ht(), i = Ut(n), s = Le.randomBytes(16).toString("hex");
1637
1637
  o.text = "Waiting for authorization...";
1638
- const d = Ht(s), w = new Ye(`${re}/oauth/authorize`);
1639
- w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", t), w.searchParams.set("redirect_uri", He), w.searchParams.set("code_challenge", r), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", s), o.stop(), console.log(`
1638
+ const l = Bt(s), w = new Ke(`${ae}/oauth/authorize`);
1639
+ w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", t), w.searchParams.set("redirect_uri", He), w.searchParams.set("code_challenge", i), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", s), o.stop(), console.log(`
1640
1640
  🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
1641
- `), await ft(w.toString());
1642
- const $ = await d;
1641
+ `), await St(w.toString());
1642
+ const v = await l;
1643
1643
  o.start("Exchanging authorization code...");
1644
- const m = await Dt($, t, n);
1644
+ const m = await zt(v, t, n);
1645
1645
  o.text = "Getting user info...";
1646
- const p = await Bt(m.access_token), S = {
1646
+ const d = await Vt(m.access_token), C = {
1647
1647
  accessToken: m.access_token,
1648
1648
  refreshToken: m.refresh_token,
1649
1649
  expiresAt: new Date(Date.now() + m.expires_in * 1e3).toISOString(),
1650
1650
  clientId: t,
1651
- userId: p.userId,
1652
- userEmail: p.email
1651
+ userId: d.userId,
1652
+ userEmail: d.email
1653
1653
  };
1654
- return et(S), o.succeed(`Authenticated as ${p.email}`), S;
1654
+ return tt(C), o.succeed(`Authenticated as ${d.email}`), C;
1655
1655
  } catch (e) {
1656
1656
  throw o.fail(`Authentication failed: ${e.message}`), e;
1657
1657
  }
1658
1658
  }
1659
- async function ot() {
1660
- const o = Ae();
1659
+ async function nt() {
1660
+ const o = De();
1661
1661
  if (!o) {
1662
1662
  console.log("Not currently logged in.");
1663
1663
  return;
1664
1664
  }
1665
- tt(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1665
+ ot(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1666
1666
  }
1667
- async function Jt() {
1668
- let o = Ae();
1667
+ async function st() {
1668
+ let o = De();
1669
1669
  if (!o)
1670
1670
  return console.log(`Not logged in. Starting authentication...
1671
- `), await ce();
1672
- if (!Nt(o))
1671
+ `), await de();
1672
+ if (!At(o))
1673
1673
  return o;
1674
1674
  if (o.refreshToken) {
1675
- const e = V("Refreshing access token...").start();
1675
+ const e = G("Refreshing access token...").start();
1676
1676
  try {
1677
- const t = await Ut(
1677
+ const t = await Wt(
1678
1678
  o.refreshToken,
1679
1679
  o.clientId
1680
1680
  );
@@ -1683,116 +1683,116 @@ async function Jt() {
1683
1683
  accessToken: t.access_token,
1684
1684
  refreshToken: t.refresh_token,
1685
1685
  expiresAt: new Date(Date.now() + t.expires_in * 1e3).toISOString()
1686
- }, et(o), e.succeed("Token refreshed"), o;
1686
+ }, tt(o), e.succeed("Token refreshed"), o;
1687
1687
  } catch {
1688
- return e.warn("Token refresh failed, please log in again"), tt(), await ce();
1688
+ return e.warn("Token refresh failed, please log in again"), ot(), await de();
1689
1689
  }
1690
1690
  }
1691
1691
  return console.log(`Session expired. Please log in again.
1692
- `), await ce();
1692
+ `), await de();
1693
1693
  }
1694
- function zt() {
1695
- return re;
1694
+ function it() {
1695
+ return ae;
1696
1696
  }
1697
- const K = "@myop/cli", Ie = process.platform === "win32";
1698
- function Wt() {
1697
+ const X = "@myop/cli", ke = process.platform === "win32";
1698
+ function Gt() {
1699
1699
  try {
1700
- return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1700
+ return q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1701
1701
  } catch {
1702
1702
  return "https://registry.npmjs.org/";
1703
1703
  }
1704
1704
  }
1705
- function Vt() {
1705
+ function Yt() {
1706
1706
  try {
1707
- return Q("npm config get prefix", { encoding: "utf-8" }).trim();
1707
+ return q("npm config get prefix", { encoding: "utf-8" }).trim();
1708
1708
  } catch {
1709
1709
  return null;
1710
1710
  }
1711
1711
  }
1712
- async function Gt() {
1712
+ async function Kt() {
1713
1713
  try {
1714
- const o = Wt().replace(/\/$/, ""), e = await fetch(`${o}/${K}/latest`);
1714
+ const o = Gt().replace(/\/$/, ""), e = await fetch(`${o}/${X}/latest`);
1715
1715
  return e.ok ? (await e.json()).version : null;
1716
1716
  } catch {
1717
1717
  return null;
1718
1718
  }
1719
1719
  }
1720
- function Yt(o, e) {
1720
+ function Qt(o, e) {
1721
1721
  const t = o.split(".").map(Number), n = e.split(".").map(Number);
1722
- for (let r = 0; r < Math.max(t.length, n.length); r++) {
1723
- const s = t[r] || 0, d = n[r] || 0;
1724
- if (s > d) return 1;
1725
- if (s < d) return -1;
1722
+ for (let i = 0; i < Math.max(t.length, n.length); i++) {
1723
+ const s = t[i] || 0, l = n[i] || 0;
1724
+ if (s > l) return 1;
1725
+ if (s < l) return -1;
1726
1726
  }
1727
1727
  return 0;
1728
1728
  }
1729
- async function Kt(o) {
1730
- const e = V({
1729
+ async function Zt(o) {
1730
+ const e = G({
1731
1731
  text: "Checking for updates...",
1732
1732
  color: "cyan"
1733
- }).start(), t = await Gt();
1734
- if (e.stop(), !t || Yt(t, o) <= 0)
1733
+ }).start(), t = await Kt();
1734
+ if (e.stop(), !t || Qt(t, o) <= 0)
1735
1735
  return !1;
1736
1736
  console.log(`
1737
1737
  πŸ“¦ New version available: ${o} β†’ ${t}
1738
1738
  `);
1739
1739
  let n;
1740
1740
  try {
1741
- n = await Ge({
1741
+ n = await Ye({
1742
1742
  message: "Would you like to update now?",
1743
1743
  choices: [
1744
1744
  { name: "Yes, update now", value: !0 },
1745
1745
  { name: "No, continue with current version", value: !1 }
1746
1746
  ]
1747
1747
  });
1748
- } catch (r) {
1749
- throw r.name === "ExitPromptError" && (console.log(`
1748
+ } catch (i) {
1749
+ throw i.name === "ExitPromptError" && (console.log(`
1750
1750
 
1751
1751
  πŸ‘‹ Goodbye!
1752
- `), process.exit(0)), r;
1752
+ `), process.exit(0)), i;
1753
1753
  }
1754
1754
  if (n) {
1755
- const r = V({
1756
- text: `Updating ${K} to v${t}...`,
1755
+ const i = G({
1756
+ text: `Updating ${X} to v${t}...`,
1757
1757
  color: "green"
1758
- }).start(), s = `npm install -g ${K}@latest`, d = Vt();
1758
+ }).start(), s = `npm install -g ${X}@latest`, l = Yt();
1759
1759
  try {
1760
- Q(s, { stdio: "pipe" }), r.succeed(`Updated to v${t}`);
1760
+ q(s, { stdio: "pipe" }), i.succeed(`Updated to v${t}`);
1761
1761
  } catch {
1762
- r.stop(), console.log(`
1762
+ i.stop(), console.log(`
1763
1763
  πŸ” Elevated permissions required.
1764
1764
  `);
1765
1765
  try {
1766
- if (Ie) {
1767
- const p = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${K}@latest --prefix \\"${d}\\"` : `install -g ${K}@latest`}' -Verb RunAs -Wait`;
1768
- Q(`powershell -Command "${p}"`, { stdio: "inherit" });
1766
+ if (ke) {
1767
+ const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${l ? `install -g ${X}@latest --prefix \\"${l}\\"` : `install -g ${X}@latest`}' -Verb RunAs -Wait`;
1768
+ q(`powershell -Command "${d}"`, { stdio: "inherit" });
1769
1769
  } else {
1770
- const m = d ? `sudo npm install -g ${K}@latest --prefix "${d}"` : `sudo ${s}`;
1771
- Q(m, { stdio: "inherit" });
1770
+ const m = l ? `sudo npm install -g ${X}@latest --prefix "${l}"` : `sudo ${s}`;
1771
+ q(m, { stdio: "inherit" });
1772
1772
  }
1773
1773
  console.log(`
1774
1774
  βœ… Updated to v${t}`);
1775
1775
  } catch {
1776
1776
  console.log(`
1777
1777
  ❌ Update failed`);
1778
- const p = Ie ? `npm install -g ${K}@latest (run as Administrator)` : `sudo npm install -g ${K}@latest`;
1778
+ const d = ke ? `npm install -g ${X}@latest (run as Administrator)` : `sudo npm install -g ${X}@latest`;
1779
1779
  console.log(`
1780
- Please run manually: ${p}
1780
+ Please run manually: ${d}
1781
1781
  `), process.exit(1);
1782
1782
  }
1783
1783
  }
1784
1784
  let w = null;
1785
1785
  try {
1786
- let $;
1787
- d ? $ = Ie ? Ee(d, "node_modules") : Ee(d, "lib", "node_modules") : $ = Q("npm root -g", { encoding: "utf-8" }).trim();
1788
- const m = Ee($, K, "package.json"), p = ut(m, "utf-8");
1789
- w = JSON.parse(p).version;
1786
+ let v;
1787
+ l ? v = ke ? Oe(l, "node_modules") : Oe(l, "lib", "node_modules") : v = q("npm root -g", { encoding: "utf-8" }).trim();
1788
+ const m = Oe(v, X, "package.json"), d = yt(m, "utf-8");
1789
+ w = JSON.parse(d).version;
1790
1790
  } catch {
1791
1791
  }
1792
1792
  if (w === t)
1793
1793
  return console.log(`
1794
1794
  πŸ”„ Restarting...
1795
- `), mt(process.argv[0], process.argv.slice(1), {
1795
+ `), ht(process.argv[0], process.argv.slice(1), {
1796
1796
  stdio: "inherit",
1797
1797
  shell: !0
1798
1798
  }).on("close", (m) => {
@@ -1804,26 +1804,69 @@ Please run myop again to use the new version.
1804
1804
  }
1805
1805
  return !1;
1806
1806
  }
1807
- const Qt = (o) => new Promise((e) => setTimeout(e, o)), nt = (o = ".", e = 3, t = 0) => {
1807
+ const Xt = (o) => new Promise((e) => setTimeout(e, o)), qt = () => {
1808
+ let o = new URL(import.meta.url).pathname;
1809
+ process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1810
+ const e = H.dirname(o);
1811
+ return H.join(e, "skills");
1812
+ }, _e = (o, e) => {
1813
+ R.mkdirSync(e, { recursive: !0 });
1814
+ const t = R.readdirSync(o, { withFileTypes: !0 });
1815
+ for (const n of t) {
1816
+ const i = H.join(o, n.name), s = H.join(e, n.name);
1817
+ n.isDirectory() ? _e(i, s) : R.copyFileSync(i, s);
1818
+ }
1819
+ }, rt = (o) => {
1820
+ const e = qt();
1821
+ if (!R.existsSync(e))
1822
+ return console.info("Skills source directory not found, skipping skills installation"), !1;
1823
+ try {
1824
+ const t = H.join(o, ".agents", "skills");
1825
+ _e(e, t);
1826
+ const n = [".claude", ".cursor", ".gemini", ".junie", ".agent"], i = R.readdirSync(e, { withFileTypes: !0 }).filter((s) => s.isDirectory()).map((s) => s.name);
1827
+ for (const s of n) {
1828
+ const l = H.join(o, s, "skills");
1829
+ R.mkdirSync(l, { recursive: !0 });
1830
+ for (const w of i) {
1831
+ const v = H.join(l, w), m = H.join("..", "..", ".agents", "skills", w);
1832
+ try {
1833
+ R.rmSync(v, { recursive: !0, force: !0 });
1834
+ } catch {
1835
+ }
1836
+ try {
1837
+ R.symlinkSync(m, v, "dir");
1838
+ } catch {
1839
+ _e(
1840
+ H.join(t, w),
1841
+ v
1842
+ );
1843
+ }
1844
+ }
1845
+ }
1846
+ return !0;
1847
+ } catch (t) {
1848
+ return console.info("Failed to install skills:", t.message), !1;
1849
+ }
1850
+ }, at = (o = ".", e = 3, t = 0) => {
1808
1851
  const n = [];
1809
1852
  if (t > e) return n;
1810
1853
  try {
1811
- const r = D.readdirSync(o, { withFileTypes: !0 });
1812
- for (const s of r) {
1813
- const d = ne.join(o, s.name);
1854
+ const i = R.readdirSync(o, { withFileTypes: !0 });
1855
+ for (const s of i) {
1856
+ const l = H.join(o, s.name);
1814
1857
  if (s.isDirectory()) {
1815
1858
  if (s.name === "node_modules" || s.name === ".git" || s.name === "dist" || s.name.startsWith("."))
1816
1859
  continue;
1817
- n.push(...nt(d, e, t + 1));
1860
+ n.push(...at(l, e, t + 1));
1818
1861
  } else if (s.name === "myop.config.json")
1819
1862
  try {
1820
- const w = D.readFileSync(d, "utf-8"), $ = JSON.parse(w);
1863
+ const w = R.readFileSync(l, "utf-8"), v = JSON.parse(w);
1821
1864
  n.push({
1822
1865
  path: o,
1823
- configPath: d,
1824
- name: $.name || $.componentName || ne.basename(o),
1825
- componentId: $.componentId || null,
1826
- config: $
1866
+ configPath: l,
1867
+ name: v.name || v.componentName || H.basename(o),
1868
+ componentId: v.componentId || null,
1869
+ config: v
1827
1870
  });
1828
1871
  } catch {
1829
1872
  }
@@ -1833,7 +1876,7 @@ const Qt = (o) => new Promise((e) => setTimeout(e, o)), nt = (o = ".", e = 3, t
1833
1876
  return n;
1834
1877
  };
1835
1878
  y.executionPath = process.cwd();
1836
- const Se = (o = !1) => {
1879
+ const $e = (o = !1) => {
1837
1880
  const e = y.program.getOptionValue("verbose");
1838
1881
  e || (console.info = () => {
1839
1882
  }), console.info("πŸ“ verbose mode on"), y.options = {
@@ -1841,7 +1884,7 @@ const Se = (o = !1) => {
1841
1884
  verbose: e
1842
1885
  };
1843
1886
  try {
1844
- return y.myopConfig = wt(y.options.configPath), { configFound: !0 };
1887
+ return y.myopConfig = xt(y.options.configPath), { configFound: !0 };
1845
1888
  } catch (t) {
1846
1889
  if (o) {
1847
1890
  console.info(`
@@ -1851,7 +1894,7 @@ const Se = (o = !1) => {
1851
1894
  author: "@myop-cli",
1852
1895
  flows: []
1853
1896
  };
1854
- return _e(y.options.configPath, n), y.myopConfig = n, { configFound: !0 };
1897
+ return Ae(y.options.configPath, n), y.myopConfig = n, { configFound: !0 };
1855
1898
  } catch {
1856
1899
  return console.info("Error details :", t), { configFound: !1, error: t };
1857
1900
  }
@@ -1861,94 +1904,108 @@ const Se = (o = !1) => {
1861
1904
  };
1862
1905
  [
1863
1906
  new Fe(),
1864
- ...Mt
1907
+ ...Et
1865
1908
  ];
1866
- const Zt = "0.1.40";
1867
- y.program = new pt();
1868
- y.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(Zt);
1869
- y.program.addOption(new pe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1870
- y.program.addOption(new pe("-h, --help", "Show helpful information"));
1871
- y.program.addOption(new pe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1872
- y.program.addOption(new pe("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1873
- y.program.addOption(new pe("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1909
+ const eo = "0.1.42";
1910
+ y.program = new ft();
1911
+ y.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(eo);
1912
+ y.program.addOption(new me("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1913
+ y.program.addOption(new me("-h, --help", "Show helpful information"));
1914
+ y.program.addOption(new me("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1915
+ y.program.addOption(new me("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1916
+ y.program.addOption(new me("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1874
1917
  y.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, e) => {
1875
- Se(!0), console.info("adding ", o, e, y.options.configPath), o === "flow" && Ze._action(e), process.exit();
1918
+ $e(!0), console.info("adding ", o, e, y.options.configPath), o === "flow" && Xe._action(e), process.exit();
1876
1919
  });
1877
1920
  y.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, e) => {
1878
- Se(), console.info("removing ", o, e, y.options.configPath), o === "flow" && Xe._action(e), process.exit();
1921
+ $e(), console.info("removing ", o, e, y.options.configPath), o === "flow" && qe._action(e), process.exit();
1879
1922
  });
1880
1923
  y.program.command("install").description("Install Myop assets").action(async () => {
1881
- Se(), await Qe.action();
1924
+ $e(), await Ze.action();
1882
1925
  });
1883
1926
  y.program.command("login").description("Authenticate with Myop platform").action(async () => {
1884
1927
  try {
1885
- await ce();
1928
+ await de();
1886
1929
  } catch (o) {
1887
1930
  console.error("Login failed:", o.message), process.exit(1);
1888
1931
  }
1889
1932
  process.exit(0);
1890
1933
  });
1891
1934
  y.program.command("logout").description("Clear stored credentials").action(async () => {
1892
- await ot(), process.exit(0);
1935
+ await nt(), process.exit(0);
1893
1936
  });
1894
1937
  y.program.command("whoami").description("Show current authenticated user").action(async () => {
1895
- const o = be();
1938
+ const o = xe();
1896
1939
  o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1897
1940
  });
1898
1941
  y.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (o) => {
1899
- var g, b, x, C, L, H;
1900
- const e = y.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), r = await import("path");
1942
+ var M, T, D, P, x, j;
1943
+ const e = y.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), i = await import("path");
1901
1944
  let s = {};
1902
1945
  if (t.existsSync(e))
1903
1946
  try {
1904
- const f = t.readFileSync(e, "utf-8");
1905
- s = JSON.parse(f);
1906
- const P = s.name || s.componentName;
1907
- console.log(`πŸ“‹ Found config: ${P || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
1908
- } catch (f) {
1909
- console.error(`⚠️ Failed to parse ${e}:`, f.message);
1947
+ const b = t.readFileSync(e, "utf-8");
1948
+ s = JSON.parse(b);
1949
+ const f = s.name || s.componentName;
1950
+ console.log(`πŸ“‹ Found config: ${f || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
1951
+ } catch (b) {
1952
+ console.error(`⚠️ Failed to parse ${e}:`, b.message);
1910
1953
  }
1911
1954
  else
1912
1955
  console.log("⚠️ No myop.config.json found. A new component will be created.");
1913
- if (!o.skipBuild) {
1914
- const { exec: f } = await import("child_process");
1915
- let P = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
1916
- const E = (I = !1) => new Promise((_) => {
1917
- const te = V(I ? "Retrying build..." : "Building project...").start();
1918
- f("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (U, F, G) => {
1919
- if (!U) {
1920
- te.succeed("Build completed"), _(!0);
1956
+ let l = null, w = !1;
1957
+ try {
1958
+ const b = JSON.parse(t.readFileSync("package.json", "utf-8"));
1959
+ w = !!(b.scripts && b.scripts.build);
1960
+ } catch {
1961
+ }
1962
+ if (!w) {
1963
+ const b = t.readdirSync(".").filter(
1964
+ (f) => f.endsWith(".html") && !f.startsWith(".") && t.statSync(f).isFile()
1965
+ );
1966
+ b.length === 1 && (l = b[0]);
1967
+ }
1968
+ if (l)
1969
+ console.log(`πŸ“„ Single HTML file mode: ${l} (skipping build)`);
1970
+ else if (!o.skipBuild) {
1971
+ const { exec: b } = await import("child_process");
1972
+ let f = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
1973
+ const E = (B = !1) => new Promise((U) => {
1974
+ const k = G(B ? "Retrying build..." : "Building project...").start();
1975
+ b("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (z, I, Z) => {
1976
+ if (!z) {
1977
+ k.succeed("Build completed"), U(!0);
1921
1978
  return;
1922
1979
  }
1923
- if (te.fail("Build failed"), !P.hasTriedPlatformFix && !P.hasTriedInstall) {
1924
- const T = await qe(U, F, G, f, P);
1925
- if (P = { ...P, ...T }, T.handled) {
1980
+ if (k.fail("Build failed"), !f.hasTriedPlatformFix && !f.hasTriedInstall) {
1981
+ const se = await et(z, I, Z, b, f);
1982
+ if (f = { ...f, ...se }, se.handled) {
1926
1983
  const Y = await E(!0);
1927
- _(Y);
1984
+ U(Y);
1928
1985
  return;
1929
1986
  }
1930
1987
  }
1931
- console.error(U.message), _(!1);
1988
+ console.error(z.message), U(!1);
1932
1989
  });
1933
1990
  });
1934
1991
  await E() || process.exit(1);
1935
1992
  }
1936
- const d = "./dist/index.html";
1937
- t.existsSync(d) || (console.error("❌ Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1938
- let w;
1993
+ const v = l || "./dist/index.html";
1994
+ t.existsSync(v) || (console.error(`❌ Error: ${v} not found`), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1995
+ let m;
1939
1996
  try {
1940
- w = await Jt();
1941
- } catch (f) {
1942
- console.error("❌ Authentication failed:", f.message), process.exit(1);
1997
+ m = await st();
1998
+ } catch (b) {
1999
+ console.error("❌ Authentication failed:", b.message), process.exit(1);
1943
2000
  }
1944
- const $ = zt();
1945
- let m = V("Requesting upload URL...").start(), p;
2001
+ const d = it();
2002
+ let C = G("Requesting upload URL...").start(), u;
1946
2003
  try {
1947
- const f = await fetch(`${$}/mcp`, {
2004
+ const b = await fetch(`${d}/mcp`, {
1948
2005
  method: "POST",
1949
2006
  headers: {
1950
2007
  "Content-Type": "application/json",
1951
- Authorization: `Bearer ${w.accessToken}`
2008
+ Authorization: `Bearer ${m.accessToken}`
1952
2009
  },
1953
2010
  body: JSON.stringify({
1954
2011
  jsonrpc: "2.0",
@@ -1957,63 +2014,63 @@ y.program.command("sync").description("Build and upload component to Myop platfo
1957
2014
  params: {
1958
2015
  name: "upload_component",
1959
2016
  arguments: {
1960
- name: s.name || s.componentName || r.default.basename(process.cwd()),
2017
+ name: s.name || s.componentName || i.default.basename(process.cwd()),
1961
2018
  componentId: s.componentId || void 0,
1962
2019
  organization: s.organization || void 0
1963
2020
  }
1964
2021
  }
1965
2022
  })
1966
2023
  });
1967
- if (!f.ok)
1968
- throw new Error(`Server returned ${f.status}`);
1969
- const P = await f.json();
1970
- if (P.error)
1971
- throw new Error(P.error.message);
1972
- const E = (x = (b = (g = P.result) == null ? void 0 : g.content) == null ? void 0 : b[0]) == null ? void 0 : x.text;
1973
- if (p = JSON.parse(E), !p.success)
1974
- throw new Error(p.error);
1975
- m.succeed("Upload URL obtained");
1976
- } catch (f) {
1977
- m.fail("Failed to get upload URL"), console.error(" ", f.message), process.exit(1);
1978
- }
1979
- m = V("Uploading component...").start();
2024
+ if (!b.ok)
2025
+ throw new Error(`Server returned ${b.status}`);
2026
+ const f = await b.json();
2027
+ if (f.error)
2028
+ throw new Error(f.error.message);
2029
+ const E = (D = (T = (M = f.result) == null ? void 0 : M.content) == null ? void 0 : T[0]) == null ? void 0 : D.text;
2030
+ if (u = JSON.parse(E), !u.success)
2031
+ throw new Error(u.error);
2032
+ C.succeed("Upload URL obtained");
2033
+ } catch (b) {
2034
+ C.fail("Failed to get upload URL"), console.error(" ", b.message), process.exit(1);
2035
+ }
2036
+ C = G("Uploading component...").start();
1980
2037
  try {
1981
- const f = t.readFileSync(d, "utf-8");
1982
- let P;
1983
- const E = p.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2038
+ const b = t.readFileSync(v, "utf-8");
2039
+ let f;
2040
+ const E = u.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1984
2041
  if (E)
1985
- P = E[1];
2042
+ f = E[1];
1986
2043
  else {
1987
- const I = p.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1988
- if (I)
1989
- P = I[1];
2044
+ const B = u.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
2045
+ if (B)
2046
+ f = B[1];
1990
2047
  else
1991
- throw new Error("Could not parse presigned URL from: " + p.curlCommand);
2048
+ throw new Error("Could not parse presigned URL from: " + u.curlCommand);
1992
2049
  }
1993
- console.info("Uploading to:", P.substring(0, 100) + "...");
1994
- const M = await fetch(P, {
2050
+ console.info("Uploading to:", f.substring(0, 100) + "...");
2051
+ const _ = await fetch(f, {
1995
2052
  method: "PUT",
1996
2053
  headers: {
1997
2054
  "Content-Type": "text/html"
1998
2055
  },
1999
- body: f
2056
+ body: b
2000
2057
  });
2001
- if (!M.ok) {
2002
- const I = await M.text();
2003
- throw new Error(`Upload failed with status ${M.status}: ${I}`);
2058
+ if (!_.ok) {
2059
+ const B = await _.text();
2060
+ throw new Error(`Upload failed with status ${_.status}: ${B}`);
2004
2061
  }
2005
- m.succeed("Component uploaded");
2006
- } catch (f) {
2007
- m.fail("Upload failed"), console.error(" ", f.message), f.cause && console.error(" Cause:", f.cause), process.exit(1);
2062
+ C.succeed("Component uploaded");
2063
+ } catch (b) {
2064
+ C.fail("Upload failed"), console.error(" ", b.message), b.cause && console.error(" Cause:", b.cause), process.exit(1);
2008
2065
  }
2009
- m = V("Confirming upload...").start();
2066
+ C = G("Confirming upload...").start();
2010
2067
  let S;
2011
2068
  try {
2012
- const f = await fetch(`${$}/mcp`, {
2069
+ const b = await fetch(`${d}/mcp`, {
2013
2070
  method: "POST",
2014
2071
  headers: {
2015
2072
  "Content-Type": "application/json",
2016
- Authorization: `Bearer ${w.accessToken}`
2073
+ Authorization: `Bearer ${m.accessToken}`
2017
2074
  },
2018
2075
  body: JSON.stringify({
2019
2076
  jsonrpc: "2.0",
@@ -2022,50 +2079,329 @@ y.program.command("sync").description("Build and upload component to Myop platfo
2022
2079
  params: {
2023
2080
  name: "confirm_upload",
2024
2081
  arguments: {
2025
- uploadId: p.uploadId
2082
+ uploadId: u.uploadId
2026
2083
  }
2027
2084
  }
2028
2085
  })
2029
2086
  });
2030
- if (!f.ok)
2031
- throw new Error(`Server returned ${f.status}`);
2032
- const P = await f.json();
2033
- if (P.error)
2034
- throw new Error(P.error.message);
2035
- const E = (H = (L = (C = P.result) == null ? void 0 : C.content) == null ? void 0 : L[0]) == null ? void 0 : H.text;
2087
+ if (!b.ok)
2088
+ throw new Error(`Server returned ${b.status}`);
2089
+ const f = await b.json();
2090
+ if (f.error)
2091
+ throw new Error(f.error.message);
2092
+ const E = (j = (x = (P = f.result) == null ? void 0 : P.content) == null ? void 0 : x[0]) == null ? void 0 : j.text;
2036
2093
  if (S = JSON.parse(E), !S.success)
2037
2094
  throw new Error(S.error);
2038
- m.succeed("Upload confirmed");
2039
- } catch (f) {
2040
- m.fail("Confirmation failed"), console.error(" ", f.message), process.exit(1);
2095
+ C.succeed("Upload confirmed");
2096
+ } catch (b) {
2097
+ C.fail("Confirmation failed"), console.error(" ", b.message), process.exit(1);
2041
2098
  }
2042
2099
  if (S.isNewComponent || !s.componentId) {
2043
2100
  s.componentId = S.componentId, s.organization = S.orgId, s.name || (s.name = S.componentName);
2044
2101
  try {
2045
2102
  t.writeFileSync(e, JSON.stringify(s, null, 2)), console.log(`
2046
2103
  πŸ“ Updated ${e} with componentId`);
2047
- } catch (f) {
2104
+ } catch (b) {
2048
2105
  console.log(`
2049
- ⚠️ Could not update ${e}: ${f.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
2106
+ ⚠️ Could not update ${e}: ${b.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
2050
2107
  }
2051
2108
  }
2052
2109
  console.log(`
2053
2110
  βœ… Sync completed successfully!`), console.log(` Component: ${S.componentName}`), console.log(` Dashboard: ${S.dashboardUrl}`), process.exit(0);
2054
2111
  });
2055
- y.program.command("dev").description("Start development server with file watching").action(Le);
2056
- const Xt = () => {
2112
+ y.program.command("push").description("Upload component to Myop platform").action(async () => {
2113
+ var C, u, S, M, T, D;
2114
+ const o = y.program.getOptionValue("config") || "./myop.config.json";
2115
+ let e = {};
2116
+ if (R.existsSync(o))
2117
+ try {
2118
+ e = JSON.parse(R.readFileSync(o, "utf-8"));
2119
+ } catch (P) {
2120
+ console.error(`⚠️ Failed to parse ${o}:`, P.message);
2121
+ }
2122
+ const t = e.name || e.componentName || H.basename(process.cwd());
2123
+ console.log(`
2124
+ πŸ“‹ Component: ${t}`);
2125
+ let n;
2126
+ const i = R.readdirSync(".").filter(
2127
+ (P) => P.endsWith(".html") && !P.startsWith(".") && R.statSync(P).isFile()
2128
+ );
2129
+ i.length === 1 && !R.existsSync("./dist/index.html") ? n = i[0] : R.existsSync("./dist/index.html") ? n = "./dist/index.html" : i.length === 1 ? n = i[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));
2130
+ const s = R.readFileSync(n, "utf-8");
2131
+ console.log(` File: ${n} (${(s.length / 1024).toFixed(1)} KB)`);
2132
+ let l;
2133
+ try {
2134
+ l = await st();
2135
+ } catch (P) {
2136
+ console.error("❌ Authentication failed:", P.message), process.exit(1);
2137
+ }
2138
+ const w = it();
2139
+ let v = G("Uploading...").start(), m;
2140
+ try {
2141
+ const P = await fetch(`${w}/mcp`, {
2142
+ method: "POST",
2143
+ headers: {
2144
+ "Content-Type": "application/json",
2145
+ Authorization: `Bearer ${l.accessToken}`
2146
+ },
2147
+ body: JSON.stringify({
2148
+ jsonrpc: "2.0",
2149
+ id: 1,
2150
+ method: "tools/call",
2151
+ params: {
2152
+ name: "upload_component",
2153
+ arguments: {
2154
+ name: t,
2155
+ componentId: e.componentId && e.componentId !== "DEV" ? e.componentId : void 0,
2156
+ organization: e.organization || void 0
2157
+ }
2158
+ }
2159
+ })
2160
+ });
2161
+ if (!P.ok)
2162
+ throw new Error(`Server returned ${P.status}`);
2163
+ const x = await P.json();
2164
+ if (x.error)
2165
+ throw new Error(x.error.message);
2166
+ const j = (S = (u = (C = x.result) == null ? void 0 : C.content) == null ? void 0 : u[0]) == null ? void 0 : S.text;
2167
+ if (m = JSON.parse(j), !m.success)
2168
+ throw new Error(m.error);
2169
+ } catch (P) {
2170
+ v.fail("Failed to get upload URL"), console.error(" ", P.message), process.exit(1);
2171
+ }
2172
+ try {
2173
+ let P;
2174
+ const x = m.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2175
+ if (x)
2176
+ P = x[1];
2177
+ else {
2178
+ const b = m.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
2179
+ if (b)
2180
+ P = b[1];
2181
+ else
2182
+ throw new Error("Could not parse presigned URL");
2183
+ }
2184
+ const j = await fetch(P, {
2185
+ method: "PUT",
2186
+ headers: { "Content-Type": "text/html" },
2187
+ body: s
2188
+ });
2189
+ if (!j.ok) {
2190
+ const b = await j.text();
2191
+ throw new Error(`Upload failed: ${j.status} ${b}`);
2192
+ }
2193
+ } catch (P) {
2194
+ v.fail("Upload failed"), console.error(" ", P.message), process.exit(1);
2195
+ }
2196
+ let d;
2197
+ try {
2198
+ const P = await fetch(`${w}/mcp`, {
2199
+ method: "POST",
2200
+ headers: {
2201
+ "Content-Type": "application/json",
2202
+ Authorization: `Bearer ${l.accessToken}`
2203
+ },
2204
+ body: JSON.stringify({
2205
+ jsonrpc: "2.0",
2206
+ id: 2,
2207
+ method: "tools/call",
2208
+ params: {
2209
+ name: "confirm_upload",
2210
+ arguments: {
2211
+ uploadId: m.uploadId
2212
+ }
2213
+ }
2214
+ })
2215
+ });
2216
+ if (!P.ok)
2217
+ throw new Error(`Server returned ${P.status}`);
2218
+ const x = await P.json();
2219
+ if (x.error)
2220
+ throw new Error(x.error.message);
2221
+ const j = (D = (T = (M = x.result) == null ? void 0 : M.content) == null ? void 0 : T[0]) == null ? void 0 : D.text;
2222
+ if (d = JSON.parse(j), !d.success)
2223
+ throw new Error(d.error);
2224
+ v.succeed("Pushed successfully");
2225
+ } catch (P) {
2226
+ v.fail("Confirmation failed"), console.error(" ", P.message), process.exit(1);
2227
+ }
2228
+ if (d.isNewComponent || !e.componentId || e.componentId === "DEV") {
2229
+ e.componentId = d.componentId, e.organization = d.orgId, e.name || (e.name = d.componentName);
2230
+ try {
2231
+ R.writeFileSync(o, JSON.stringify(e, null, 2));
2232
+ } catch (P) {
2233
+ console.log(`⚠️ Could not update ${o}: ${P.message}`), console.log(` Add componentId: "${d.componentId}" manually`);
2234
+ }
2235
+ }
2236
+ console.log(`
2237
+ ${d.componentName}`), console.log(` ${d.dashboardUrl}
2238
+ `), process.exit(0);
2239
+ });
2240
+ y.program.command("create").description("Create a new Myop HTML component and start dev server").action(async () => {
2241
+ const { input: o } = await import("@inquirer/prompts"), e = await import("fs"), n = (await import("path")).default.basename(process.cwd());
2242
+ let i;
2243
+ try {
2244
+ i = await o({
2245
+ message: "Component name:",
2246
+ default: n
2247
+ });
2248
+ } catch (v) {
2249
+ throw v.name === "ExitPromptError" && (console.log(`
2250
+
2251
+ πŸ‘‹ Goodbye!
2252
+ `), process.exit(0)), v;
2253
+ }
2254
+ (e.existsSync("index.html") || e.existsSync("myop.config.json")) && (console.log(`
2255
+ ⚠️ index.html or myop.config.json already exists in this directory.`), console.log(" Use `myop dev` to start the dev server for an existing component.\n"), process.exit(1));
2256
+ const s = {
2257
+ name: i,
2258
+ componentId: "DEV",
2259
+ type: "html",
2260
+ author: "@myop-cli",
2261
+ HMR: !0
2262
+ };
2263
+ e.writeFileSync("myop.config.json", JSON.stringify(s, null, 2));
2264
+ const l = `<!DOCTYPE html>
2265
+ <html lang="en">
2266
+ <head>
2267
+ <meta charset="UTF-8">
2268
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2269
+ <meta name="myop:size" content='{"width":"100%","height":"100%"}'>
2270
+ <title>${i}</title>
2271
+ <script type="myop/types">
2272
+ // =========================================================================
2273
+ // MYOP COMPONENT TYPE DEFINITIONS
2274
+ // =========================================================================
2275
+
2276
+ /**
2277
+ * Data structure passed to myop_init_interface(data)
2278
+ */
2279
+ interface MyopInitData {
2280
+ title: string;
2281
+ description?: string;
2282
+ }
2283
+
2284
+ /**
2285
+ * Actions and payloads for myop_cta_handler(action, payload)
2286
+ */
2287
+ interface MyopCtaPayloads {
2288
+ 'button-clicked': { label: string };
2289
+ 'size-requested': {
2290
+ width?: number | null;
2291
+ height?: number | null;
2292
+ minWidth?: number | null;
2293
+ maxWidth?: number | null;
2294
+ minHeight?: number | null;
2295
+ maxHeight?: number | null;
2296
+ required?: boolean;
2297
+ };
2298
+ }
2299
+
2300
+ // =========================================================================
2301
+ // DO NOT EDIT BELOW - Standard Myop type declarations
2302
+ // =========================================================================
2303
+
2304
+ declare function myop_init_interface(): MyopInitData;
2305
+ declare function myop_init_interface(data: MyopInitData): void;
2306
+
2307
+ declare function myop_cta_handler<K extends keyof MyopCtaPayloads>(
2308
+ action: K,
2309
+ payload: MyopCtaPayloads[K]
2310
+ ): void;
2311
+ <\/script>
2312
+ <style>
2313
+ * {
2314
+ box-sizing: border-box;
2315
+ margin: 0;
2316
+ padding: 0;
2317
+ }
2318
+
2319
+ html, body {
2320
+ width: 100%;
2321
+ height: 100%;
2322
+ overflow: hidden;
2323
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
2324
+ color: #333;
2325
+ }
2326
+
2327
+ #app-root {
2328
+ width: 100%;
2329
+ height: 100%;
2330
+ display: flex;
2331
+ flex-direction: column;
2332
+ align-items: center;
2333
+ justify-content: center;
2334
+ padding: 24px;
2335
+ }
2336
+
2337
+ h1 {
2338
+ font-size: 24px;
2339
+ margin-bottom: 8px;
2340
+ color: #1a1a1a;
2341
+ }
2342
+
2343
+ p {
2344
+ color: #666;
2345
+ line-height: 1.5;
2346
+ }
2347
+ </style>
2348
+ </head>
2349
+ <body>
2350
+ <div id="app-root">
2351
+ <h1>${i}</h1>
2352
+ <p>Edit index.html to get started</p>
2353
+ </div>
2354
+
2355
+ <script>
2356
+ (function() {
2357
+ var currentState = {};
2358
+
2359
+ function render(data) {
2360
+ currentState = data;
2361
+ var root = document.getElementById('app-root');
2362
+ root.innerHTML =
2363
+ '<h1>' + (data.title || '') + '</h1>' +
2364
+ (data.description ? '<p>' + data.description + '</p>' : '');
2365
+ }
2366
+
2367
+ window.myop_init_interface = function(data) {
2368
+ if (!data) return currentState;
2369
+ render(data);
2370
+ };
2371
+
2372
+ window.myop_cta_handler = function(action_id, payload) {
2373
+ // Will be overridden by host application
2374
+ };
2375
+ })();
2376
+ <\/script>
2377
+
2378
+ <script id="myop_preview">
2379
+ window.myop_init_interface({
2380
+ title: '${i}',
2381
+ description: 'Edit index.html to get started'
2382
+ });
2383
+ <\/script>
2384
+ </body>
2385
+ </html>`;
2386
+ e.writeFileSync("index.html", l);
2387
+ const w = rt(process.cwd());
2388
+ console.log(`
2389
+ βœ… Created ${i}`), console.log(" index.html"), console.log(" myop.config.json"), w && console.log(" .agents/skills/ (AI agent skills)"), console.log(""), await be();
2390
+ });
2391
+ y.program.command("dev").description("Start development server with file watching").action(be);
2392
+ const to = () => {
2057
2393
  try {
2058
- Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2394
+ q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2059
2395
  } catch {
2060
2396
  return { gitNotInstalled: !0 };
2061
2397
  }
2062
2398
  try {
2063
- Q("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2399
+ q("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2064
2400
  } catch {
2065
2401
  return { notARepo: !0 };
2066
2402
  }
2067
2403
  try {
2068
- const o = Q("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
2404
+ const o = q("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
2069
2405
  encoding: "utf-8",
2070
2406
  stdio: ["pipe", "pipe", "pipe"]
2071
2407
  }).trim();
@@ -2076,22 +2412,22 @@ const Xt = () => {
2076
2412
  deletions: 0
2077
2413
  };
2078
2414
  const e = o.split(`
2079
- `), t = e[e.length - 1], n = t.match(/(\d+) insertion/), r = t.match(/(\d+) deletion/), s = t.match(/(\d+) file/);
2415
+ `), t = e[e.length - 1], n = t.match(/(\d+) insertion/), i = t.match(/(\d+) deletion/), s = t.match(/(\d+) file/);
2080
2416
  return {
2081
2417
  files: s ? parseInt(s[1]) : 0,
2082
2418
  insertions: n ? parseInt(n[1]) : 0,
2083
- deletions: r ? parseInt(r[1]) : 0
2419
+ deletions: i ? parseInt(i[1]) : 0
2084
2420
  };
2085
2421
  } catch {
2086
2422
  return null;
2087
2423
  }
2088
- }, oe = async (o = !1, e = !1) => {
2089
- var p, S, g;
2090
- const t = be(), n = !!(t != null && t.email), r = ((p = y.myopConfig) == null ? void 0 : p.name) || ((S = y.myopConfig) == null ? void 0 : S.componentName), s = (g = y.myopConfig) == null ? void 0 : g.componentId, d = Xt();
2424
+ }, ne = async (o = !1, e = !1) => {
2425
+ var d, C, u;
2426
+ const t = xe(), n = !!(t != null && t.email), i = ((d = y.myopConfig) == null ? void 0 : d.name) || ((C = y.myopConfig) == null ? void 0 : C.componentName), s = (u = y.myopConfig) == null ? void 0 : u.componentId, l = to();
2091
2427
  console.log(`
2092
2428
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Welcome to Myop CLI - Remote UI Made Easy β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2093
- `), o && r ? (console.log(` Component: ${r}`), s ? (console.log(` ID: ${s}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${s}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? t.email : "Not logged in"}`), d != null && d.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")) : d != null && d.notARepo ? console.log(" Changes: Not a git repository") : d && (d.insertions > 0 || d.deletions > 0) ? console.log(` Changes: ${d.files} file${d.files !== 1 ? "s" : ""} | \x1B[32m+${d.insertions}\x1B[0m \x1B[31m-${d.deletions}\x1B[0m`) : d && console.log(" Changes: No uncommitted changes"), console.log("");
2094
- const $ = [
2429
+ `), o && i ? (console.log(` Component: ${i}`), s ? (console.log(` ID: ${s}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${s}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? t.email : "Not logged in"}`), l != null && l.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")) : l != null && l.notARepo ? console.log(" Changes: Not a git repository") : l && (l.insertions > 0 || l.deletions > 0) ? console.log(` Changes: ${l.files} file${l.files !== 1 ? "s" : ""} | \x1B[32m+${l.insertions}\x1B[0m \x1B[31m-${l.deletions}\x1B[0m`) : l && console.log(" Changes: No uncommitted changes"), console.log("");
2430
+ const v = [
2095
2431
  {
2096
2432
  emoji: "πŸš€",
2097
2433
  label: "Initialize new component",
@@ -2101,25 +2437,25 @@ const Xt = () => {
2101
2437
  },
2102
2438
  {
2103
2439
  emoji: "πŸ› οΈ ",
2104
- label: r ? `Start dev mode for "${r}"` : "Start dev mode",
2440
+ label: i ? `Start dev mode for "${i}"` : "Start dev mode",
2105
2441
  value: "dev",
2106
2442
  help: "Starts dev server with HMR for instant preview of changes",
2107
2443
  disabled: o ? !1 : "(no config file)"
2108
2444
  },
2109
2445
  {
2110
2446
  emoji: "πŸ“¦",
2111
- label: r ? `Push "${r}"` : "Push component",
2447
+ label: i ? `Push "${i}"` : "Push component",
2112
2448
  value: "sync",
2113
2449
  help: "Builds project & uploads dist/index.html to Myop",
2114
2450
  disabled: o ? n ? !1 : "(login required)" : "(no config file)"
2115
2451
  }
2116
- ].map((b) => ({
2117
- name: e && !b.disabled ? `${b.emoji} ${b.label}
2118
- ${b.help}` : `${b.emoji} ${b.label}`,
2119
- value: b.value,
2120
- disabled: b.disabled
2452
+ ].map((S) => ({
2453
+ name: e && !S.disabled ? `${S.emoji} ${S.label}
2454
+ ${S.help}` : `${S.emoji} ${S.label}`,
2455
+ value: S.value,
2456
+ disabled: S.disabled
2121
2457
  }));
2122
- $.push(
2458
+ v.push(
2123
2459
  new Fe(),
2124
2460
  {
2125
2461
  name: e && n ? `πŸ”“ Logout (${t.email})
@@ -2139,116 +2475,116 @@ const Xt = () => {
2139
2475
  );
2140
2476
  let m;
2141
2477
  try {
2142
- m = await Ge({
2478
+ m = await Ye({
2143
2479
  message: "What would you like to do?",
2144
- choices: $
2480
+ choices: v
2145
2481
  });
2146
- } catch (b) {
2147
- throw b.name === "ExitPromptError" && (console.log(`
2482
+ } catch (S) {
2483
+ throw S.name === "ExitPromptError" && (console.log(`
2148
2484
 
2149
2485
  πŸ‘‹ Goodbye!
2150
- `), process.exit(0)), b;
2486
+ `), process.exit(0)), S;
2151
2487
  }
2152
2488
  switch (m) {
2153
2489
  case "init":
2154
- await oo();
2490
+ await io();
2155
2491
  break;
2156
2492
  case "sync":
2157
2493
  console.log(`
2158
2494
  Running sync...
2159
2495
  `);
2160
- const { execSync: b } = await import("child_process");
2496
+ const { execSync: S } = await import("child_process");
2161
2497
  try {
2162
- b("node " + process.argv[1] + " sync", { stdio: "inherit" });
2498
+ S("node " + process.argv[1] + " sync", { stdio: "inherit" });
2163
2499
  } catch {
2164
2500
  }
2165
- await oe(!0, e);
2501
+ await ne(!0, e);
2166
2502
  break;
2167
2503
  case "dev":
2168
- await Le();
2504
+ await be();
2169
2505
  break;
2170
2506
  case "login":
2171
2507
  try {
2172
- await ce(), console.log(`
2173
- `), await oe(o, e);
2174
- } catch (x) {
2175
- console.error("Login failed:", x.message), await oe(o, e);
2508
+ await de(), console.log(`
2509
+ `), await ne(o, e);
2510
+ } catch (M) {
2511
+ console.error("Login failed:", M.message), await ne(o, e);
2176
2512
  }
2177
2513
  break;
2178
2514
  case "logout":
2179
- await ot(), console.log(`
2180
- `), await oe(o, e);
2515
+ await nt(), console.log(`
2516
+ `), await ne(o, e);
2181
2517
  break;
2182
2518
  case "help":
2183
- await oe(o, !e);
2519
+ await ne(o, !e);
2184
2520
  break;
2185
2521
  case "exit":
2186
2522
  process.exit(0);
2187
2523
  }
2188
- }, ve = ".myop-monorepo.json", qt = () => {
2524
+ }, ve = ".myop-monorepo.json", oo = () => {
2189
2525
  try {
2190
- const o = D.readFileSync(ve, "utf-8");
2526
+ const o = R.readFileSync(ve, "utf-8");
2191
2527
  return JSON.parse(o);
2192
2528
  } catch {
2193
2529
  return null;
2194
2530
  }
2195
- }, eo = (o) => {
2531
+ }, no = (o) => {
2196
2532
  try {
2197
2533
  const e = {
2198
2534
  selectedComponents: o,
2199
2535
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2200
2536
  };
2201
- D.writeFileSync(ve, JSON.stringify(e, null, 2));
2537
+ R.writeFileSync(ve, JSON.stringify(e, null, 2));
2202
2538
  } catch {
2203
2539
  }
2204
- }, to = async () => {
2205
- const o = be(), e = !!(o != null && o.email);
2540
+ }, so = async () => {
2541
+ const o = xe(), e = !!(o != null && o.email);
2206
2542
  console.log(`
2207
2543
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Myop CLI - Monorepo Mode β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2208
2544
  `);
2209
- const t = V("Scanning for components...").start(), n = nt(".");
2545
+ const t = G("Scanning for components...").start(), n = at(".");
2210
2546
  t.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2211
2547
  `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2212
- const r = qt(), s = (r == null ? void 0 : r.selectedComponents) || [], d = s.length > 0;
2548
+ const i = oo(), s = (i == null ? void 0 : i.selectedComponents) || [], l = s.length > 0;
2213
2549
  console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
2214
- `), n.forEach((g, b) => {
2215
- const x = g.componentId ? "βœ…" : "βšͺ", C = g.componentId ? g.componentId.substring(0, 8) + "..." : "(not pushed)";
2216
- console.log(` ${x} ${g.name}`), console.log(` Path: ${g.path}`), console.log(` ID: ${C}`), console.log("");
2217
- }), console.log(` User: ${e ? o.email : "Not logged in"}`), d && console.log(` πŸ“‹ Using saved selection from ${ve}`), console.log("");
2218
- const { checkbox: w } = await import("@inquirer/prompts"), $ = n.map((g) => ({
2219
- name: `${g.name} (${g.path})`,
2220
- value: g.path,
2221
- checked: d ? s.includes(g.path) : !0
2550
+ `), n.forEach((u, S) => {
2551
+ const M = u.componentId ? "βœ…" : "βšͺ", T = u.componentId ? u.componentId.substring(0, 8) + "..." : "(not pushed)";
2552
+ console.log(` ${M} ${u.name}`), console.log(` Path: ${u.path}`), console.log(` ID: ${T}`), console.log("");
2553
+ }), console.log(` User: ${e ? o.email : "Not logged in"}`), l && console.log(` πŸ“‹ Using saved selection from ${ve}`), console.log("");
2554
+ const { checkbox: w } = await import("@inquirer/prompts"), v = n.map((u) => ({
2555
+ name: `${u.name} (${u.path})`,
2556
+ value: u.path,
2557
+ checked: l ? s.includes(u.path) : !0
2222
2558
  }));
2223
2559
  let m;
2224
2560
  try {
2225
2561
  m = await w({
2226
2562
  message: "Select components to start in dev mode:",
2227
- choices: $
2563
+ choices: v
2228
2564
  });
2229
- } catch (g) {
2230
- throw g.name === "ExitPromptError" && (console.log(`
2565
+ } catch (u) {
2566
+ throw u.name === "ExitPromptError" && (console.log(`
2231
2567
 
2232
2568
  πŸ‘‹ Goodbye!
2233
- `), process.exit(0)), g;
2569
+ `), process.exit(0)), u;
2234
2570
  }
2235
2571
  m.length === 0 && (console.log(`
2236
2572
  ⚠️ No components selected.
2237
- `), process.exit(0)), eo(m), console.log(`
2573
+ `), process.exit(0)), no(m), console.log(`
2238
2574
  πŸ’Ύ Selection saved to ${ve}`);
2239
- const p = n.filter((g) => m.includes(g.path));
2240
- console.log(`πŸš€ Starting dev mode for ${p.length} component${p.length > 1 ? "s" : ""}...
2575
+ const d = n.filter((u) => m.includes(u.path));
2576
+ console.log(`πŸš€ Starting dev mode for ${d.length} component${d.length > 1 ? "s" : ""}...
2241
2577
  `);
2242
- const { monorepoDevCommand: S } = await Promise.resolve().then(() => Ft);
2243
- await S(p);
2244
- }, oo = async () => {
2245
- const { input: o, select: e } = await import("@inquirer/prompts"), t = await import("fs"), r = (await import("path")).default.basename(process.cwd());
2246
- let s, d;
2578
+ const { monorepoDevCommand: C } = await Promise.resolve().then(() => _t);
2579
+ await C(d);
2580
+ }, io = async () => {
2581
+ const { input: o, select: e } = await import("@inquirer/prompts"), t = await import("fs"), n = await import("path"), i = n.default.basename(process.cwd());
2582
+ let s, l;
2247
2583
  try {
2248
2584
  s = await o({
2249
2585
  message: "Component name:",
2250
- default: r
2251
- }), d = await e({
2586
+ default: i
2587
+ }), l = await e({
2252
2588
  message: "Component type:",
2253
2589
  choices: [
2254
2590
  { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -2265,13 +2601,13 @@ Running sync...
2265
2601
  }
2266
2602
  const w = {
2267
2603
  name: s,
2268
- type: d,
2604
+ type: l,
2269
2605
  author: "@myop-cli",
2270
2606
  HMR: !0
2271
- }, $ = y.program.getOptionValue("config") || "./myop.config.json";
2607
+ }, v = y.program.getOptionValue("config") || "./myop.config.json";
2272
2608
  try {
2273
- t.writeFileSync($, JSON.stringify(w, null, 2)), console.log(`
2274
- βœ… Created ${$}`);
2609
+ t.writeFileSync(v, JSON.stringify(w, null, 2)), console.log(`
2610
+ βœ… Created ${v}`);
2275
2611
  const m = {
2276
2612
  name: s.toLowerCase().replace(/\s+/g, "-"),
2277
2613
  version: "1.0.0",
@@ -2364,7 +2700,7 @@ fs.writeFileSync('dist/index.html', html);
2364
2700
  console.log('βœ… Built dist/index.html');
2365
2701
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
2366
2702
  `), console.log("βœ… Created build.js");
2367
- const S = `<!DOCTYPE html>
2703
+ const C = `<!DOCTYPE html>
2368
2704
  <html lang="en">
2369
2705
  <head>
2370
2706
  <meta charset="UTF-8">
@@ -2381,8 +2717,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
2381
2717
  </body>
2382
2718
  </html>
2383
2719
  `;
2384
- t.writeFileSync("index.html", S), console.log("βœ… Created index.html");
2385
- const g = `// ${s} - Entry Point
2720
+ t.writeFileSync("index.html", C), console.log("βœ… Created index.html");
2721
+ const u = `// ${s} - Entry Point
2386
2722
  import { init } from './modules/app.js';
2387
2723
  import { setupMyopInterface } from './modules/myop.js';
2388
2724
 
@@ -2391,8 +2727,8 @@ document.addEventListener('DOMContentLoaded', () => {
2391
2727
  setupMyopInterface();
2392
2728
  });
2393
2729
  `;
2394
- t.writeFileSync("src/index.js", g), console.log("βœ… Created src/index.js");
2395
- const b = `// ${s} - Main Application Logic
2730
+ t.writeFileSync("src/index.js", u), console.log("βœ… Created src/index.js");
2731
+ const S = `// ${s} - Main Application Logic
2396
2732
 
2397
2733
  export function init() {
2398
2734
  console.log('${s} loaded');
@@ -2400,7 +2736,7 @@ export function init() {
2400
2736
  // Your component logic here
2401
2737
  }
2402
2738
  `;
2403
- t.writeFileSync("src/modules/app.js", b), console.log("βœ… Created src/modules/app.js"), t.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
2739
+ t.writeFileSync("src/modules/app.js", S), console.log("βœ… Created src/modules/app.js"), t.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
2404
2740
 
2405
2741
  export function setupMyopInterface() {
2406
2742
  // Called when host app sends data to this component
@@ -2416,12 +2752,12 @@ export function setupMyopInterface() {
2416
2752
  };
2417
2753
  }
2418
2754
  `), console.log("βœ… Created src/modules/myop.js");
2419
- const C = `/* ${s} - Styles Entry Point */
2755
+ const T = `/* ${s} - Styles Entry Point */
2420
2756
  /* Add your CSS imports here - they will be auto-bundled */
2421
2757
  @import './main.css';
2422
2758
  `;
2423
- t.writeFileSync("src/styles/index.css", C), console.log("βœ… Created src/styles/index.css");
2424
- const L = `/* ${s} - Main Styles */
2759
+ t.writeFileSync("src/styles/index.css", T), console.log("βœ… Created src/styles/index.css");
2760
+ const D = `/* ${s} - Main Styles */
2425
2761
 
2426
2762
  * {
2427
2763
  box-sizing: border-box;
@@ -2450,16 +2786,18 @@ p {
2450
2786
  line-height: 1.5;
2451
2787
  }
2452
2788
  `;
2453
- t.writeFileSync("src/styles/main.css", L), console.log("βœ… Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2789
+ t.writeFileSync("src/styles/main.css", D), console.log("βœ… Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2454
2790
  dist/
2455
2791
  .temp-entry.js
2456
2792
  .temp-styles.css
2457
2793
  .DS_Store
2458
2794
  `), console.log("βœ… Created .gitignore");
2459
- const f = await import("./index-DuEoKctW.js").then((E) => E.i), P = process.cwd();
2795
+ const x = rt(process.cwd());
2796
+ x && console.log("βœ… Installed AI agent skills");
2797
+ const j = await import("./index-DuEoKctW.js").then((f) => f.i), b = process.cwd();
2460
2798
  try {
2461
- await f.init({ fs: t, dir: P });
2462
- const E = [
2799
+ await j.init({ fs: t, dir: b });
2800
+ const f = [
2463
2801
  "myop.config.json",
2464
2802
  "package.json",
2465
2803
  "build.js",
@@ -2471,64 +2809,77 @@ dist/
2471
2809
  "src/styles/index.css",
2472
2810
  "src/styles/main.css"
2473
2811
  ];
2474
- for (const M of E)
2475
- await f.add({ fs: t, dir: P, filepath: M });
2476
- await f.commit({
2812
+ if (x) {
2813
+ const E = (_, B) => {
2814
+ try {
2815
+ const U = t.readdirSync(_, { withFileTypes: !0 });
2816
+ for (const k of U) {
2817
+ const z = n.join(_, k.name), I = n.join(B, k.name);
2818
+ k.isDirectory() ? E(z, I) : f.push(I);
2819
+ }
2820
+ } catch {
2821
+ }
2822
+ };
2823
+ E(".agents/skills", ".agents/skills");
2824
+ }
2825
+ for (const E of f)
2826
+ await j.add({ fs: t, dir: b, filepath: E });
2827
+ await j.commit({
2477
2828
  fs: t,
2478
- dir: P,
2829
+ dir: b,
2479
2830
  message: "init",
2480
2831
  author: { name: "myop-cli", email: "cli@myop.dev" }
2481
2832
  }), console.log("βœ… Initialized git repository");
2482
- } catch (E) {
2483
- console.log("⚠️ Failed to initialize git repository:", E.message);
2833
+ } catch (f) {
2834
+ console.log("⚠️ Failed to initialize git repository:", f.message);
2484
2835
  }
2485
2836
  console.log(`
2486
2837
  πŸ“¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
2487
- `), y.myopConfig = w, await oe(!0);
2838
+ `), y.myopConfig = w, await ne(!0);
2488
2839
  } catch (m) {
2489
2840
  console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
2490
2841
  }
2491
2842
  };
2492
2843
  y.program.command("default", { isDefault: !0 }).action(async () => {
2493
- if (y.program.getOptionValue("help") && (console.log(yt), process.exit()), y.program.getOptionValue("monorepo")) {
2494
- await to();
2844
+ if (y.program.getOptionValue("help") && (console.log(bt), process.exit()), y.program.getOptionValue("monorepo")) {
2845
+ await so();
2495
2846
  return;
2496
2847
  }
2497
2848
  if (y.program.getOptionValue("ci")) {
2498
- const w = await import("fs"), $ = y.program.getOptionValue("config") || "./myop.config.json", m = y.program.version(), p = be();
2499
- let S = { found: !1 };
2849
+ const w = await import("fs"), v = y.program.getOptionValue("config") || "./myop.config.json", m = y.program.version(), d = xe();
2850
+ let C = { found: !1 };
2500
2851
  try {
2501
- if (w.existsSync($)) {
2502
- const b = w.readFileSync($, "utf-8"), x = JSON.parse(b);
2503
- S = {
2852
+ if (w.existsSync(v)) {
2853
+ const S = w.readFileSync(v, "utf-8"), M = JSON.parse(S);
2854
+ C = {
2504
2855
  found: !0,
2505
- path: $,
2506
- name: x.name || x.componentName || null,
2507
- componentId: x.componentId || null,
2508
- organization: x.organization || null
2856
+ path: v,
2857
+ name: M.name || M.componentName || null,
2858
+ componentId: M.componentId || null,
2859
+ organization: M.organization || null
2509
2860
  };
2510
2861
  }
2511
- } catch (b) {
2512
- S = { found: !1, error: b.message };
2862
+ } catch (S) {
2863
+ C = { found: !1, error: S.message };
2513
2864
  }
2514
- const g = {
2865
+ const u = {
2515
2866
  version: m,
2516
- config: S,
2867
+ config: C,
2517
2868
  auth: {
2518
- loggedIn: !!(p != null && p.email),
2519
- email: (p == null ? void 0 : p.email) || null
2869
+ loggedIn: !!(d != null && d.email),
2870
+ email: (d == null ? void 0 : d.email) || null
2520
2871
  }
2521
2872
  };
2522
- console.log(JSON.stringify(g, null, 2)), process.exit(0);
2873
+ console.log(JSON.stringify(u, null, 2)), process.exit(0);
2523
2874
  }
2524
- let n = V({
2875
+ let n = G({
2525
2876
  text: "Loading Myop CLI...",
2526
2877
  color: "green"
2527
2878
  }).start();
2528
- const r = Se();
2529
- await Qt(500), n.stop();
2879
+ const i = $e();
2880
+ await Xt(500), n.stop();
2530
2881
  const s = y.program.version();
2531
- await Kt(s) || await oe(r.configFound);
2882
+ await Zt(s) || await ne(i.configFound);
2532
2883
  });
2533
2884
  y.program.parse(process.argv);
2534
2885
  y.program.opts();