@neta-art/cohub-cli 1.7.1 → 1.9.0

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/output.js CHANGED
@@ -35,6 +35,9 @@ export function table(rows, columns) {
35
35
  export function json(data) {
36
36
  console.log(JSON.stringify(data, null, 2));
37
37
  }
38
+ export function jsonRequested(opts) {
39
+ return Boolean(opts?.json || process.argv.includes("--json"));
40
+ }
38
41
  export function ok(msg) {
39
42
  console.log(`\n ✓ ${msg}\n`);
40
43
  }
@@ -70,6 +73,18 @@ function debugErrorMetaFromBody(body) {
70
73
  items.push(`traceId: ${errorBody.traceId}`);
71
74
  return items;
72
75
  }
76
+ function fetchFailureDetail(e) {
77
+ if (!(e instanceof Error) || e.message !== "fetch failed")
78
+ return null;
79
+ const cause = e.cause;
80
+ const code = typeof cause?.code === "string" ? cause.code : null;
81
+ const hostname = typeof cause?.hostname === "string" ? cause.hostname : null;
82
+ const message = typeof cause?.message === "string" ? cause.message : null;
83
+ const parts = [code, hostname && `host: ${hostname}`, message].filter(Boolean);
84
+ return parts.length > 0
85
+ ? `Network request failed (${parts.join(" · ")}). Check DNS/proxy/firewall settings and try again.`
86
+ : "Network request failed. Check DNS/proxy/firewall settings and try again.";
87
+ }
73
88
  export function handleHttp(e) {
74
89
  if (e instanceof Error && e.name === "AuthRequiredError") {
75
90
  return error("not authenticated", "run `cohub auth login`");
@@ -77,32 +92,38 @@ export function handleHttp(e) {
77
92
  const status = e.status;
78
93
  const body = e.body;
79
94
  const message = errorMessageFromBody(body) ?? (e instanceof Error ? e.message : String(e));
95
+ const fetchDetail = fetchFailureDetail(e);
80
96
  const detailParts = [];
81
97
  if (process.env.COHUB_DEBUG_ERRORS) {
82
98
  if (status)
83
99
  detailParts.push(`HTTP ${status}`);
84
100
  detailParts.push(...debugErrorMetaFromBody(body));
85
101
  }
86
- error(message, detailParts.length > 0 ? detailParts.join(" · ") : undefined);
102
+ error(message, detailParts.length > 0 ? detailParts.join(" · ") : fetchDetail ?? undefined);
87
103
  }
88
104
  // -- Spinner -----------------------------------------------------------------
89
105
  export function spinner() {
90
106
  let interval = null;
91
107
  const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
92
108
  let i = 0;
109
+ let currentMsg = "";
93
110
  return {
94
111
  start(msg) {
112
+ currentMsg = msg;
95
113
  if (process.env.CI || !process.stderr.isTTY) {
96
- process.stderr.write(` ${msg}...\n`);
114
+ process.stderr.write(` ${currentMsg}...\n`);
97
115
  return;
98
116
  }
99
- process.stderr.write(` ${msg} `);
117
+ process.stderr.write(` ${currentMsg} `);
100
118
  interval = setInterval(() => {
101
119
  process.stderr.clearLine?.(0);
102
120
  process.stderr.cursorTo?.(0);
103
- process.stderr.write(` ${frames[i++ % frames.length] ?? ""} ${msg} `);
121
+ process.stderr.write(` ${frames[i++ % frames.length] ?? ""} ${currentMsg} `);
104
122
  }, 80);
105
123
  },
124
+ update(msg) {
125
+ currentMsg = msg;
126
+ },
106
127
  stop(msg) {
107
128
  if (interval)
108
129
  clearInterval(interval);
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function resolveSpace(program: Command): string;
package/dist/space.js ADDED
@@ -0,0 +1,14 @@
1
+ import { error } from "./output.js";
2
+ export function resolveSpace(program) {
3
+ let current = program;
4
+ while (current) {
5
+ const opts = current.opts();
6
+ if (typeof opts.space === "string" && opts.space.trim())
7
+ return opts.space.trim();
8
+ current = current.parent ?? null;
9
+ }
10
+ const envSpace = process.env.COHUB_SPACE_ID?.trim();
11
+ if (envSpace)
12
+ return envSpace;
13
+ return error("Missing required space", "Add -s, --space <id> or set COHUB_SPACE_ID.");
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "1.7.1",
3
+ "version": "1.9.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -13,9 +13,10 @@
13
13
  "README.md"
14
14
  ],
15
15
  "dependencies": {
16
+ "@neta-art/generation": "^0.1.2",
16
17
  "commander": "^13.1.0",
17
18
  "sharp": "^0.34.5",
18
- "@neta-art/cohub": "1.15.1"
19
+ "@neta-art/cohub": "1.16.1"
19
20
  },
20
21
  "publishConfig": {
21
22
  "access": "public"