@melra/cli 0.3.0-alpha.10 → 0.3.0-alpha.12

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 (43) hide show
  1. package/README.md +11 -6
  2. package/dist/activity.d.ts +26 -0
  3. package/dist/activity.d.ts.map +1 -0
  4. package/dist/activity.js +401 -0
  5. package/dist/activity.js.map +1 -0
  6. package/dist/client-status.d.ts +24 -0
  7. package/dist/client-status.d.ts.map +1 -0
  8. package/dist/client-status.js +273 -0
  9. package/dist/client-status.js.map +1 -0
  10. package/dist/clients.d.ts +32 -0
  11. package/dist/clients.d.ts.map +1 -0
  12. package/dist/clients.js +584 -0
  13. package/dist/clients.js.map +1 -0
  14. package/dist/conformance.d.ts.map +1 -1
  15. package/dist/conformance.js +47 -7
  16. package/dist/conformance.js.map +1 -1
  17. package/dist/demo-workflow.d.ts +46 -0
  18. package/dist/demo-workflow.d.ts.map +1 -0
  19. package/dist/demo-workflow.js +58 -0
  20. package/dist/demo-workflow.js.map +1 -0
  21. package/dist/environment.d.ts +5 -1
  22. package/dist/environment.d.ts.map +1 -1
  23. package/dist/environment.js +15 -1
  24. package/dist/environment.js.map +1 -1
  25. package/dist/human.d.ts +67 -0
  26. package/dist/human.d.ts.map +1 -0
  27. package/dist/human.js +257 -0
  28. package/dist/human.js.map +1 -0
  29. package/dist/index.js +316 -72
  30. package/dist/index.js.map +1 -1
  31. package/dist/isolation.d.ts +35 -0
  32. package/dist/isolation.d.ts.map +1 -0
  33. package/dist/isolation.js +66 -0
  34. package/dist/isolation.js.map +1 -0
  35. package/dist/jsonc.d.ts +24 -0
  36. package/dist/jsonc.d.ts.map +1 -0
  37. package/dist/jsonc.js +238 -0
  38. package/dist/jsonc.js.map +1 -0
  39. package/dist/output.d.ts +28 -0
  40. package/dist/output.d.ts.map +1 -0
  41. package/dist/output.js +77 -0
  42. package/dist/output.js.map +1 -0
  43. package/package.json +10 -9
package/dist/output.js ADDED
@@ -0,0 +1,77 @@
1
+ // Copyright 2026 XAGI Labs Private Limited
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /** A readable report for this invocation, rather than JSON. */
4
+ export function isHuman(args, stream = process.stdout) {
5
+ return !args.includes("--json") && stream.isTTY === true;
6
+ }
7
+ // https://no-color.org: a non-empty NO_COLOR turns colour off whatever else is
8
+ // set. FORCE_COLOR follows Node's own reading ("0"/"false" off, anything else
9
+ // on). Checked here rather than through `tty.WriteStream.hasColors()`, which
10
+ // answers the same but prints a process warning when both are set.
11
+ function colorEnabled() {
12
+ const { NO_COLOR, FORCE_COLOR, TERM } = process.env;
13
+ if (NO_COLOR !== undefined && NO_COLOR !== "")
14
+ return false;
15
+ if (FORCE_COLOR !== undefined)
16
+ return FORCE_COLOR !== "0" && FORCE_COLOR !== "false";
17
+ return process.stdout.isTTY === true && TERM !== "dumb";
18
+ }
19
+ // Read per call, not once at load, so a test can change the environment. An
20
+ // empty string stays empty, so a blank table cell leaves no trailing codes.
21
+ const sgr = (open, close) => (text) => text !== "" && colorEnabled() ? `\u001b[${open}m${text}\u001b[${close}m` : text;
22
+ export const paint = {
23
+ ok: sgr(32, 39),
24
+ warn: sgr(33, 39),
25
+ fail: sgr(31, 39),
26
+ dim: sgr(2, 22),
27
+ bold: sgr(1, 22),
28
+ };
29
+ // The legacy Windows console renders ✓ ⚠ ✗ as boxes. Windows Terminal (which
30
+ // sets WT_SESSION) and VS Code's terminal do not, so only the old one gets ASCII.
31
+ function unicode() {
32
+ return (process.platform !== "win32" ||
33
+ process.env.WT_SESSION !== undefined ||
34
+ process.env.TERM_PROGRAM === "vscode");
35
+ }
36
+ /** The coloured status symbol: ✓ ⚠ ✗, or [ok] [warn] [fail] where those would not render. */
37
+ export function mark(status) {
38
+ const [symbol, ascii, color] = status === "pass"
39
+ ? ["✓", "[ok]", paint.ok]
40
+ : status === "warn"
41
+ ? ["⚠", "[warn]", paint.warn]
42
+ : ["✗", "[fail]", paint.fail];
43
+ return color(unicode() ? symbol : ascii);
44
+ }
45
+ // Colour codes take no columns on screen, so alignment measures without them.
46
+ const width = (text) => text.replace(/\u001b\[[0-9;]*m/g, "").length;
47
+ /**
48
+ * Rows as aligned columns, one line per row. Every column but the last is
49
+ * padded to its widest cell, so a two-column table is a key/value list.
50
+ */
51
+ export function table(rows, options = {}) {
52
+ const widths = [];
53
+ for (const row of rows) {
54
+ row.forEach((cell, column) => {
55
+ widths[column] = Math.max(widths[column] ?? 0, width(cell));
56
+ });
57
+ }
58
+ const indent = " ".repeat(options.indent ?? 0);
59
+ return rows
60
+ .map((row) => indent +
61
+ row
62
+ .map((cell, column) => column === row.length - 1
63
+ ? cell
64
+ : cell + " ".repeat((widths[column] ?? 0) - width(cell)))
65
+ .join(" ")
66
+ .trimEnd())
67
+ .join("\n");
68
+ }
69
+ /**
70
+ * The one place a command decides between its JSON and its human report. The
71
+ * JSON branch is exactly what the CLI has always written, so a script cannot
72
+ * tell this function exists.
73
+ */
74
+ export function printJsonOrHuman(value, renderHuman, args) {
75
+ process.stdout.write(isHuman(args) ? `${renderHuman(value)}\n` : `${JSON.stringify(value, null, 2)}\n`);
76
+ }
77
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,sCAAsC;AAWtC,+DAA+D;AAC/D,MAAM,UAAU,OAAO,CACrB,IAAuB,EACvB,SAA8B,OAAO,CAAC,MAAM;IAE5C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;AAC3D,CAAC;AAED,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,mEAAmE;AACnE,SAAS,YAAY;IACnB,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IACpD,IAAI,QAAQ,KAAK,SAAS,IAA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AAK,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,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAClF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melra/cli",
3
- "version": "0.3.0-alpha.10",
3
+ "version": "0.3.0-alpha.12",
4
4
  "description": "MELRA autonomy kernel and command-line interface.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,13 +25,14 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
- "@modelcontextprotocol/sdk": "1.30.0",
29
- "@melra/browser-runtime": "0.3.0-alpha.10",
30
- "@melra/computer-runtime": "0.3.0-alpha.10",
31
- "@melra/policy-core": "0.3.0-alpha.10",
32
- "@melra/protocol": "0.3.0-alpha.10",
33
- "@melra/server": "0.3.0-alpha.10",
34
- "@melra/storage-sqlite": "0.3.0-alpha.10"
28
+ "@modelcontextprotocol/sdk": "1.32.1",
29
+ "@melra/browser-runtime": "0.3.0-alpha.12",
30
+ "@melra/computer-runtime": "0.3.0-alpha.12",
31
+ "@melra/policy-core": "0.3.0-alpha.12",
32
+ "@melra/runtime-core": "0.3.0-alpha.12",
33
+ "@melra/server": "0.3.0-alpha.12",
34
+ "@melra/protocol": "0.3.0-alpha.12",
35
+ "@melra/storage-sqlite": "0.3.0-alpha.12"
35
36
  },
36
37
  "scripts": {
37
38
  "build": "tsc -p tsconfig.json && chmod +x dist/bin.js dist/index.js",
@@ -40,6 +41,6 @@
40
41
  "start": "tsx src/index.ts",
41
42
  "pack:check": "npm pack --dry-run",
42
43
  "test": "vitest run --testTimeout=20000",
43
- "typecheck": "tsc -p tsconfig.json --noEmit"
44
+ "typecheck": "tsc -p tsconfig.test.json"
44
45
  }
45
46
  }