@melra/cli 0.3.0-alpha.11 → 0.3.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +14 -7
  2. package/dist/activity.d.ts +26 -0
  3. package/dist/activity.d.ts.map +1 -0
  4. package/dist/activity.js +404 -0
  5. package/dist/activity.js.map +1 -0
  6. package/dist/approval-screen.d.ts +35 -0
  7. package/dist/approval-screen.d.ts.map +1 -0
  8. package/dist/approval-screen.js +130 -0
  9. package/dist/approval-screen.js.map +1 -0
  10. package/dist/client-status.d.ts +24 -0
  11. package/dist/client-status.d.ts.map +1 -0
  12. package/dist/client-status.js +273 -0
  13. package/dist/client-status.js.map +1 -0
  14. package/dist/clients.d.ts +32 -0
  15. package/dist/clients.d.ts.map +1 -0
  16. package/dist/clients.js +588 -0
  17. package/dist/clients.js.map +1 -0
  18. package/dist/conformance.d.ts +7 -0
  19. package/dist/conformance.d.ts.map +1 -1
  20. package/dist/conformance.js +134 -30
  21. package/dist/conformance.js.map +1 -1
  22. package/dist/demo-workflow.d.ts +46 -0
  23. package/dist/demo-workflow.d.ts.map +1 -0
  24. package/dist/demo-workflow.js +58 -0
  25. package/dist/demo-workflow.js.map +1 -0
  26. package/dist/environment.d.ts +15 -1
  27. package/dist/environment.d.ts.map +1 -1
  28. package/dist/environment.js +30 -4
  29. package/dist/environment.js.map +1 -1
  30. package/dist/human.d.ts +67 -0
  31. package/dist/human.d.ts.map +1 -0
  32. package/dist/human.js +266 -0
  33. package/dist/human.js.map +1 -0
  34. package/dist/index.js +432 -77
  35. package/dist/index.js.map +1 -1
  36. package/dist/isolation.d.ts +35 -0
  37. package/dist/isolation.d.ts.map +1 -0
  38. package/dist/isolation.js +66 -0
  39. package/dist/isolation.js.map +1 -0
  40. package/dist/jsonc.d.ts +24 -0
  41. package/dist/jsonc.d.ts.map +1 -0
  42. package/dist/jsonc.js +238 -0
  43. package/dist/jsonc.js.map +1 -0
  44. package/dist/output.d.ts +28 -0
  45. package/dist/output.d.ts.map +1 -0
  46. package/dist/output.js +84 -0
  47. package/dist/output.js.map +1 -0
  48. package/package.json +11 -10
package/dist/output.js ADDED
@@ -0,0 +1,84 @@
1
+ // Copyright 2026 XAGI Labs Private Limited
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Terminal output for people, without changing it for programs.
4
+ //
5
+ // The CLI's contract with scripts, tests, and MCP clients is JSON on stdout,
6
+ // and that has to stay byte-for-byte what it was. A person at a terminal gets
7
+ // a readable report instead, decided by one rule: stdout is a TTY and `--json`
8
+ // was not passed. Anything piped or captured never sees a single ANSI byte.
9
+ import { printable } from "./approval-screen.js";
10
+ /** A readable report for this invocation, rather than JSON. */
11
+ export function isHuman(args, stream = process.stdout) {
12
+ return !args.includes("--json") && stream.isTTY === true;
13
+ }
14
+ // https://no-color.org: a non-empty NO_COLOR turns colour off whatever else is
15
+ // set. FORCE_COLOR follows Node's own reading ("0"/"false" off, anything else
16
+ // on). Checked here rather than through `tty.WriteStream.hasColors()`, which
17
+ // answers the same but prints a process warning when both are set.
18
+ function colorEnabled() {
19
+ const { NO_COLOR, FORCE_COLOR, TERM } = process.env;
20
+ if (NO_COLOR !== undefined && NO_COLOR !== "")
21
+ return false;
22
+ if (FORCE_COLOR !== undefined)
23
+ return FORCE_COLOR !== "0" && FORCE_COLOR !== "false";
24
+ return process.stdout.isTTY === true && TERM !== "dumb";
25
+ }
26
+ // Read per call, not once at load, so a test can change the environment. An
27
+ // empty string stays empty, so a blank table cell leaves no trailing codes.
28
+ const sgr = (open, close) => (text) => text !== "" && colorEnabled() ? `\u001b[${open}m${text}\u001b[${close}m` : text;
29
+ export const paint = {
30
+ ok: sgr(32, 39),
31
+ warn: sgr(33, 39),
32
+ fail: sgr(31, 39),
33
+ dim: sgr(2, 22),
34
+ bold: sgr(1, 22),
35
+ };
36
+ // The legacy Windows console renders ✓ ⚠ ✗ as boxes. Windows Terminal (which
37
+ // sets WT_SESSION) and VS Code's terminal do not, so only the old one gets ASCII.
38
+ function unicode() {
39
+ return (process.platform !== "win32" ||
40
+ process.env.WT_SESSION !== undefined ||
41
+ process.env.TERM_PROGRAM === "vscode");
42
+ }
43
+ /** The coloured status symbol: ✓ ⚠ ✗, or [ok] [warn] [fail] where those would not render. */
44
+ export function mark(status) {
45
+ const [symbol, ascii, color] = status === "pass"
46
+ ? ["✓", "[ok]", paint.ok]
47
+ : status === "warn"
48
+ ? ["⚠", "[warn]", paint.warn]
49
+ : ["✗", "[fail]", paint.fail];
50
+ return color(unicode() ? symbol : ascii);
51
+ }
52
+ // Colour codes take no columns on screen, so alignment measures without them.
53
+ const width = (text) => text.replace(/\u001b\[[0-9;]*m/g, "").length;
54
+ /**
55
+ * Rows as aligned columns, one line per row. Every column but the last is
56
+ * padded to its widest cell, so a two-column table is a key/value list.
57
+ */
58
+ export function table(rows, options = {}) {
59
+ const widths = [];
60
+ for (const row of rows) {
61
+ row.forEach((cell, column) => {
62
+ widths[column] = Math.max(widths[column] ?? 0, width(cell));
63
+ });
64
+ }
65
+ const indent = " ".repeat(options.indent ?? 0);
66
+ return rows
67
+ .map((row) => indent +
68
+ row
69
+ .map((cell, column) => column === row.length - 1
70
+ ? cell
71
+ : cell + " ".repeat((widths[column] ?? 0) - width(cell)))
72
+ .join(" ")
73
+ .trimEnd())
74
+ .join("\n");
75
+ }
76
+ /**
77
+ * The one place a command decides between its JSON and its human report. The
78
+ * JSON branch is exactly what the CLI has always written, so a script cannot
79
+ * tell this function exists.
80
+ */
81
+ export function printJsonOrHuman(value, renderHuman, args) {
82
+ process.stdout.write(isHuman(args) ? `${renderHuman(value)}\n` : `${printable(JSON.stringify(value, null, 2), true)}\n`);
83
+ }
84
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,sCAAsC;AAEtC,gEAAgE;AAChE,EAAE;AACF,6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M,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACX,MAAM;QACN,GAAG;aACA,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CACpB,MAAM,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC;YACvB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAC3D;aACA,IAAI,CAAC,IAAI,CAAC;aACV,OAAO,EAAE,CACb;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAQ,EACR,WAAiC,EACjC,IAAuB;IAEvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CACnG,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@melra/cli",
3
- "version": "0.3.0-alpha.11",
3
+ "version": "0.3.0-alpha.13",
4
4
  "description": "MELRA autonomy kernel and command-line interface.",
5
+ "mcpName": "io.github.xagi-lab/melra",
5
6
  "license": "Apache-2.0",
6
7
  "repository": {
7
8
  "type": "git",
@@ -25,14 +26,14 @@
25
26
  "README.md"
26
27
  ],
27
28
  "dependencies": {
28
- "@modelcontextprotocol/sdk": "1.30.0",
29
- "@melra/browser-runtime": "0.3.0-alpha.11",
30
- "@melra/computer-runtime": "0.3.0-alpha.11",
31
- "@melra/policy-core": "0.3.0-alpha.11",
32
- "@melra/runtime-core": "0.3.0-alpha.11",
33
- "@melra/protocol": "0.3.0-alpha.11",
34
- "@melra/storage-sqlite": "0.3.0-alpha.11",
35
- "@melra/server": "0.3.0-alpha.11"
29
+ "@modelcontextprotocol/sdk": "1.32.1",
30
+ "@melra/browser-runtime": "0.3.0-alpha.13",
31
+ "@melra/computer-runtime": "0.3.0-alpha.13",
32
+ "@melra/protocol": "0.3.0-alpha.13",
33
+ "@melra/runtime-core": "0.3.0-alpha.13",
34
+ "@melra/server": "0.3.0-alpha.13",
35
+ "@melra/policy-core": "0.3.0-alpha.13",
36
+ "@melra/storage-sqlite": "0.3.0-alpha.13"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "tsc -p tsconfig.json && chmod +x dist/bin.js dist/index.js",
@@ -41,6 +42,6 @@
41
42
  "start": "tsx src/index.ts",
42
43
  "pack:check": "npm pack --dry-run",
43
44
  "test": "vitest run --testTimeout=20000",
44
- "typecheck": "tsc -p tsconfig.json --noEmit"
45
+ "typecheck": "tsc -p tsconfig.test.json"
45
46
  }
46
47
  }