@miosa/cli 1.0.5 → 1.0.6

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.
@@ -0,0 +1,138 @@
1
+ /**
2
+ * MIOSA CLI render vocabulary.
3
+ *
4
+ * Single source of truth for the visible look-and-feel: banner, status
5
+ * icons, key/value panels, hint blocks, error envelopes, and elapsed
6
+ * timing. Every command should compose its output from these primitives
7
+ * so the brand stays consistent.
8
+ *
9
+ * Design rules:
10
+ * - One accent color (cyan) for the brand.
11
+ * - Semantic colors for status (green/yellow/red/dim).
12
+ * - Never print colors when not a TTY (CI, pipes) — chalk handles
13
+ * this automatically via FORCE_COLOR=0 / NO_COLOR; we just call it.
14
+ * - Plain ASCII only. No unicode that breaks in cmd.exe / Putty.
15
+ * - Every "section" the user sees should fit inside one of these
16
+ * primitives; the command does NOT reach for raw `console.log` +
17
+ * ad-hoc chalk except for the body of a tool result.
18
+ */
19
+ import chalk from "chalk";
20
+ // ── Status icons ──────────────────────────────────────────────────────────
21
+ // Plain ASCII so they render everywhere. Colors applied via chalk.
22
+ export const icon = {
23
+ ok: chalk.green("✓"),
24
+ fail: chalk.red("✗"),
25
+ warn: chalk.yellow("⚠"),
26
+ info: chalk.cyan("›"),
27
+ bullet: chalk.dim("•"),
28
+ arrow: chalk.dim("→"),
29
+ pending: chalk.yellow("·"),
30
+ };
31
+ // ── Brand banner ──────────────────────────────────────────────────────────
32
+ /**
33
+ * Single-line MIOSA banner used at the top of lifecycle commands
34
+ * (login / logout / mcp install). Compact and unobtrusive.
35
+ *
36
+ * ▮▮▮ MIOSA ▮▮▮ v1.0.4
37
+ */
38
+ export function banner(opts = {}) {
39
+ const bar = chalk.cyan("▮▮▮");
40
+ const wordmark = chalk.bold("MIOSA");
41
+ const version = opts.version ? chalk.dim(` v${opts.version}`) : "";
42
+ const subtitle = opts.subtitle ? chalk.dim(` ${opts.subtitle}`) : "";
43
+ return `${bar} ${wordmark} ${bar}${version}${subtitle}`;
44
+ }
45
+ /**
46
+ * Render a list of key/value rows with aligned columns. Used for the
47
+ * "✓ Authenticated ClinicIQ · Pro plan" output blocks.
48
+ */
49
+ export function kvPanel(rows) {
50
+ if (rows.length === 0)
51
+ return "";
52
+ const labelWidth = Math.max(...rows.map((r) => r.label.length));
53
+ return rows
54
+ .map((r) => {
55
+ const lead = r.icon ? `${r.icon} ` : " ";
56
+ const label = chalk.bold(r.label.padEnd(labelWidth));
57
+ return ` ${lead}${label} ${r.value}`;
58
+ })
59
+ .join("\n");
60
+ }
61
+ // ── Hint block ────────────────────────────────────────────────────────────
62
+ /**
63
+ * Suggest what the user can do next. Rendered as:
64
+ *
65
+ * → Next: miosa computers list
66
+ * miosa mcp install
67
+ */
68
+ export function hintBlock(label, commands) {
69
+ if (commands.length === 0)
70
+ return "";
71
+ const head = ` ${chalk.dim("→")} ${chalk.bold(label)}`;
72
+ const pad = " ".repeat(label.length + 5); // align with first command
73
+ const lines = commands.map((c, i) => i === 0 ? `${head} ${chalk.cyan(c)}` : ` ${pad}${chalk.cyan(c)}`);
74
+ return lines.join("\n");
75
+ }
76
+ /**
77
+ * Format an error in the brand's red envelope. Use this in the catch
78
+ * block of every command instead of bare `console.error`.
79
+ */
80
+ export function errorEnvelope(env) {
81
+ const lines = [];
82
+ lines.push(` ${chalk.red("✗")} ${chalk.bold.red(env.title)}`);
83
+ if (env.body)
84
+ lines.push(` ${chalk.dim(env.body)}`);
85
+ if (env.suggest && env.suggest.length > 0) {
86
+ lines.push("");
87
+ lines.push(` ${chalk.dim("→")} ${chalk.bold("Try")}`);
88
+ for (const s of env.suggest)
89
+ lines.push(` ${chalk.cyan(s)}`);
90
+ }
91
+ if (env.withDebugHint) {
92
+ lines.push("");
93
+ lines.push(` ${chalk.dim("Run with MIOSA_DEBUG=1 for the full stack trace.")}`);
94
+ }
95
+ return lines.join("\n");
96
+ }
97
+ // ── Elapsed timer ─────────────────────────────────────────────────────────
98
+ /**
99
+ * Wrap an async block and append a "Took 1.2s" line on success.
100
+ * On error, re-throws so the caller can format its own envelope.
101
+ */
102
+ export async function withElapsed(fn) {
103
+ const start = Date.now();
104
+ const result = await fn();
105
+ const ms = Date.now() - start;
106
+ return { result, elapsed: formatDuration(ms) };
107
+ }
108
+ export function formatDuration(ms) {
109
+ if (ms < 1000)
110
+ return `${ms}ms`;
111
+ if (ms < 10_000)
112
+ return `${(ms / 1000).toFixed(1)}s`;
113
+ if (ms < 60_000)
114
+ return `${Math.round(ms / 1000)}s`;
115
+ const m = Math.floor(ms / 60_000);
116
+ const s = Math.round((ms % 60_000) / 1000);
117
+ return `${m}m ${s}s`;
118
+ }
119
+ // ── Composition helpers ──────────────────────────────────────────────────
120
+ /** Insert a blank line. Cheap readability tool. */
121
+ export const blank = () => console.log();
122
+ /** Print the banner — convenience over `console.log(banner(...))`. */
123
+ export function printBanner(opts = {}) {
124
+ console.log();
125
+ console.log(` ${banner(opts)}`);
126
+ console.log();
127
+ }
128
+ /** Print the elapsed line in dim text below a successful command. */
129
+ export function printElapsed(elapsed) {
130
+ console.log();
131
+ console.log(` ${chalk.dim(`Took ${elapsed}`)}`);
132
+ }
133
+ /** Print a section header (dim small-caps). */
134
+ export function sectionHeader(label) {
135
+ console.log();
136
+ console.log(` ${chalk.dim.bold(label.toUpperCase())}`);
137
+ }
138
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/ui/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,6EAA6E;AAC7E,mEAAmE;AAEnE,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;IACvB,IAAI,EAA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AC,EAAE,CAAC,CAAC;AAC1D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miosa/cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "MIOSA platform CLI — projects, sandboxes, deploys, databases, more",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,14 +38,17 @@
38
38
  "dependencies": {
39
39
  "chalk": "^5.3.0",
40
40
  "commander": "^12.1.0",
41
+ "ink": "^7.0.3",
41
42
  "inquirer": "^9.3.7",
42
43
  "ora": "^8.1.1",
44
+ "react": "^19.2.6",
43
45
  "undici": "^6.19.7",
44
46
  "ws": "^8.18.0"
45
47
  },
46
48
  "devDependencies": {
47
49
  "@types/inquirer": "^9.0.8",
48
50
  "@types/node": "^20.17.9",
51
+ "@types/react": "^19.2.15",
49
52
  "@types/ws": "^8.5.13",
50
53
  "tsx": "^4.19.2",
51
54
  "typescript": "^5.7.2",