@asteroidai/cli 1.8.204 → 1.9.2

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/asteroid.js CHANGED
@@ -57,7 +57,7 @@ function columns(rows) {
57
57
  const scalarKeys = [];
58
58
  for (const row of rows) {
59
59
  for (const [key, value2] of Object.entries(row)) {
60
- if (isScalar(value2) && !HIDDEN.test(key) && !scalarKeys.includes(key))
60
+ if (isScalar(value2) && !HIDDEN.test(key.split(".").at(-1) ?? key) && !scalarKeys.includes(key))
61
61
  scalarKeys.push(key);
62
62
  }
63
63
  }
@@ -70,8 +70,21 @@ function columns(rows) {
70
70
  function style(format, value2, options) {
71
71
  return options.styled ? styleText(format, value2, { validateStream: false }) : value2;
72
72
  }
73
- function table(rows, options = {}) {
74
- if (rows.length === 0) return "No results.";
73
+ function flatten(row) {
74
+ const flat = {};
75
+ for (const [key, value2] of Object.entries(row)) {
76
+ if (!isObject(value2)) {
77
+ flat[key] = value2;
78
+ continue;
79
+ }
80
+ for (const [inner, v] of Object.entries(value2))
81
+ flat[`${key}.${inner}`] = v;
82
+ }
83
+ return flat;
84
+ }
85
+ function table(input, options = {}) {
86
+ if (input.length === 0) return "No results.";
87
+ const rows = input.map(flatten);
75
88
  const keys = columns(rows);
76
89
  if (keys.length === 0) return rows.map((row) => text(row)).join("\n");
77
90
  const cells = rows.map((row) => keys.map((key) => cell(row[key])));
@@ -108,6 +121,10 @@ ${indent(table(v, options))}`;
108
121
  if (Array.isArray(v) && v.length > 0 && v.every(isScalar)) {
109
122
  return `${label(key)} ${v.map(text).join(`
110
123
  ${" ".repeat(width + 2)}`)}`;
124
+ }
125
+ if (isObject(v) && Object.keys(v).length > 0) {
126
+ return `${style("bold", key, options)}:
127
+ ${indent(record(v, options))}`;
111
128
  }
112
129
  return `${label(key)} ${isScalar(v) ? text(v) : summary(v)}`;
113
130
  }).join("\n");
@@ -5312,7 +5329,7 @@ var ApiError = class extends Error {
5312
5329
  status;
5313
5330
  body;
5314
5331
  };
5315
- var VERSION = "1.8.204";
5332
+ var VERSION = "1.9.2";
5316
5333
  function problem(status, body, fallback) {
5317
5334
  if (body && typeof body === "object") {
5318
5335
  const record2 = body;
package/dist/core.js CHANGED
@@ -4569,7 +4569,7 @@ function columns(rows) {
4569
4569
  const scalarKeys = [];
4570
4570
  for (const row of rows) {
4571
4571
  for (const [key, value2] of Object.entries(row)) {
4572
- if (isScalar(value2) && !HIDDEN.test(key) && !scalarKeys.includes(key))
4572
+ if (isScalar(value2) && !HIDDEN.test(key.split(".").at(-1) ?? key) && !scalarKeys.includes(key))
4573
4573
  scalarKeys.push(key);
4574
4574
  }
4575
4575
  }
@@ -4582,8 +4582,21 @@ function columns(rows) {
4582
4582
  function style(format, value2, options) {
4583
4583
  return options.styled ? styleText(format, value2, { validateStream: false }) : value2;
4584
4584
  }
4585
- function table(rows, options = {}) {
4586
- if (rows.length === 0) return "No results.";
4585
+ function flatten(row) {
4586
+ const flat = {};
4587
+ for (const [key, value2] of Object.entries(row)) {
4588
+ if (!isObject(value2)) {
4589
+ flat[key] = value2;
4590
+ continue;
4591
+ }
4592
+ for (const [inner, v] of Object.entries(value2))
4593
+ flat[`${key}.${inner}`] = v;
4594
+ }
4595
+ return flat;
4596
+ }
4597
+ function table(input, options = {}) {
4598
+ if (input.length === 0) return "No results.";
4599
+ const rows = input.map(flatten);
4587
4600
  const keys = columns(rows);
4588
4601
  if (keys.length === 0) return rows.map((row) => text(row)).join("\n");
4589
4602
  const cells = rows.map((row) => keys.map((key) => cell(row[key])));
@@ -4620,6 +4633,10 @@ ${indent(table(v, options))}`;
4620
4633
  if (Array.isArray(v) && v.length > 0 && v.every(isScalar)) {
4621
4634
  return `${label(key)} ${v.map(text).join(`
4622
4635
  ${" ".repeat(width + 2)}`)}`;
4636
+ }
4637
+ if (isObject(v) && Object.keys(v).length > 0) {
4638
+ return `${style("bold", key, options)}:
4639
+ ${indent(record(v, options))}`;
4623
4640
  }
4624
4641
  return `${label(key)} ${isScalar(v) ? text(v) : summary(v)}`;
4625
4642
  }).join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteroidai/cli",
3
- "version": "1.8.204",
3
+ "version": "1.9.2",
4
4
  "description": "The asteroid command-line interface for the Asteroid platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,4 +23,30 @@ describe("render", () => {
23
23
  expect(render(rows)).not.toContain("┌");
24
24
  expect(render(rows, { styled: true })).toContain("┌");
25
25
  });
26
+
27
+ it("prints nested objects in full, not as cut JSON", () => {
28
+ const out = render({
29
+ workflow: { id: "3cfc3c1d-e38d-4132-a5ee-8847136d491d", name: "Nebula" },
30
+ version: { version: 3, isPublished: true },
31
+ });
32
+ expect(out).toContain("3cfc3c1d-e38d-4132-a5ee-8847136d491d");
33
+ expect(out).toMatch(/workflow:\n {2}id +3cfc3c1d/);
34
+ expect(out).not.toContain("…");
35
+ });
36
+
37
+ it("flattens one level of nested fields into table columns", () => {
38
+ const out = render([
39
+ { date: "2026-10-09", outcomes: { success: 3, failure: 1 } },
40
+ ]);
41
+ expect(out).toContain("OUTCOMES.SUCCESS");
42
+ expect(out).toMatch(/2026-10-09 +3 +1/);
43
+ });
44
+
45
+ it("hides nested fields that are hidden at the top level", () => {
46
+ const out = render([
47
+ { id: "1", execution: { agentId: "a-1", status: "failed" } },
48
+ ]);
49
+ expect(out).toContain("EXECUTION.STATUS");
50
+ expect(out).not.toContain("AGENTID");
51
+ });
26
52
  });
package/src/output.ts CHANGED
@@ -59,7 +59,11 @@ function columns(rows: Row[]): string[] {
59
59
  const scalarKeys: string[] = [];
60
60
  for (const row of rows) {
61
61
  for (const [key, value] of Object.entries(row)) {
62
- if (isScalar(value) && !HIDDEN.test(key) && !scalarKeys.includes(key))
62
+ if (
63
+ isScalar(value) &&
64
+ !HIDDEN.test(key.split(".").at(-1) ?? key) &&
65
+ !scalarKeys.includes(key)
66
+ )
63
67
  scalarKeys.push(key);
64
68
  }
65
69
  }
@@ -80,8 +84,22 @@ function style(
80
84
  : value;
81
85
  }
82
86
 
83
- export function table(rows: Row[], options: RenderOptions = {}): string {
84
- if (rows.length === 0) return "No results.";
87
+ function flatten(row: Row): Row {
88
+ const flat: Row = {};
89
+ for (const [key, value] of Object.entries(row)) {
90
+ if (!isObject(value)) {
91
+ flat[key] = value;
92
+ continue;
93
+ }
94
+ for (const [inner, v] of Object.entries(value as Row))
95
+ flat[`${key}.${inner}`] = v;
96
+ }
97
+ return flat;
98
+ }
99
+
100
+ export function table(input: Row[], options: RenderOptions = {}): string {
101
+ if (input.length === 0) return "No results.";
102
+ const rows = input.map(flatten);
85
103
  const keys = columns(rows);
86
104
  if (keys.length === 0) return rows.map((row) => text(row)).join("\n");
87
105
  const cells = rows.map((row) => keys.map((key) => cell(row[key])));
@@ -124,6 +142,9 @@ function record(value: Row, options: RenderOptions): string {
124
142
  if (Array.isArray(v) && v.length > 0 && v.every(isScalar)) {
125
143
  return `${label(key)} ${v.map(text).join(`\n${" ".repeat(width + 2)}`)}`;
126
144
  }
145
+ if (isObject(v) && Object.keys(v as Row).length > 0) {
146
+ return `${style("bold", key, options)}:\n${indent(record(v as Row, options))}`;
147
+ }
127
148
  return `${label(key)} ${isScalar(v) ? text(v) : summary(v)}`;
128
149
  })
129
150
  .join("\n");