@gobi-ai/cli 0.9.3 → 0.9.5

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.
@@ -4,12 +4,12 @@
4
4
  "name": "gobi-ai"
5
5
  },
6
6
  "description": "Claude Code plugin for the Gobi collaborative knowledge platform CLI",
7
- "version": "0.9.2",
7
+ "version": "0.9.4",
8
8
  "plugins": [
9
9
  {
10
10
  "name": "gobi",
11
11
  "description": "Manage the Gobi collaborative knowledge platform from the command line. Search and ask brains, publish brain documents, create threads, manage sessions, generate images and videos.",
12
- "version": "0.9.2",
12
+ "version": "0.9.4",
13
13
  "author": {
14
14
  "name": "gobi-ai"
15
15
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gobi",
3
3
  "description": "Manage the Gobi collaborative knowledge platform from the command line",
4
- "version": "0.9.2",
4
+ "version": "0.9.4",
5
5
  "author": {
6
6
  "name": "gobi-ai"
7
7
  },
@@ -253,7 +253,9 @@ export function registerMediaCommand(program) {
253
253
  .option("--seed <seed>", "Random seed for reproducibility")
254
254
  .option("--reference-media-id <referenceMediaId>", "Reference image media ID")
255
255
  .option("--wait", "Poll until generation completes")
256
+ .option("-o, --output <path>", "Download image to this path when done (implies --wait)")
256
257
  .action(async (opts) => {
258
+ const shouldWait = opts.wait || !!opts.output;
257
259
  const name = opts.name || opts.prompt.slice(0, 50).replace(/[^a-zA-Z0-9-_ ]/g, "").trim().replace(/\s+/g, "-");
258
260
  const body = {
259
261
  prompt: opts.prompt,
@@ -272,7 +274,7 @@ export function registerMediaCommand(program) {
272
274
  const resp = (await apiPost("/media-gen/images/generate", body));
273
275
  let data = unwrapResp(resp);
274
276
  const jobId = data.jobId || data.id;
275
- if (opts.wait && jobId) {
277
+ if (shouldWait && jobId) {
276
278
  console.log(`Image job ${jobId} queued — polling for completion…`);
277
279
  data = await pollStatus(`/media-gen/images/${jobId}`, [
278
280
  "completed",
@@ -281,6 +283,31 @@ export function registerMediaCommand(program) {
281
283
  "inference_failed",
282
284
  ]);
283
285
  }
286
+ // Download image to file if -o specified
287
+ if (opts.output && data) {
288
+ const id = data.jobId || data.id;
289
+ if (id) {
290
+ const token = await getValidToken();
291
+ const url = `${BASE_URL}/media-gen/images/${id}/download`;
292
+ const res = await fetch(url, {
293
+ headers: { Authorization: `Bearer ${token}` },
294
+ });
295
+ if (res.ok) {
296
+ const { writeFile, mkdir } = await import("fs/promises");
297
+ const { dirname } = await import("path");
298
+ const buffer = Buffer.from(await res.arrayBuffer());
299
+ await mkdir(dirname(opts.output), { recursive: true });
300
+ await writeFile(opts.output, buffer);
301
+ const contentType = res.headers.get("content-type") || "image/png";
302
+ if (isJsonMode(media)) {
303
+ jsonOut({ ...data, filename: opts.output, contentType, size: buffer.length });
304
+ return;
305
+ }
306
+ console.log(`Image saved to ${opts.output} (${buffer.length} bytes)`);
307
+ return;
308
+ }
309
+ }
310
+ }
284
311
  if (isJsonMode(media)) {
285
312
  jsonOut(data);
286
313
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobi-ai/cli",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "CLI client for the Gobi collaborative knowledge platform",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,24 +27,30 @@ gobi --json media image-generate --prompt "a sunset over mountains"
27
27
 
28
28
  ## Typical Workflow (Image Generation)
29
29
 
30
- Always follow this two-step flow — generate, then download to vault:
30
+ Single command — generate and download in one step:
31
31
 
32
32
  ```bash
33
- # Step 1: Generate (use --wait to poll until complete)
34
- gobi --json media image-generate --prompt "a sunset over mountains" --wait
35
- # → returns JSON with jobId
33
+ gobi --json media image-generate --prompt "<PROMPT>" -o media/<NAME>.png
34
+ ```
35
+
36
+ Replace `<NAME>` with a short descriptive slug derived from the prompt (e.g., `happy-family`, `sunset-mountains`).
37
+
38
+ The `-o` flag implies `--wait` and downloads the image when done.
36
39
 
37
- # Step 2: Download to vault media/ folder
38
- gobi --json media image-download <jobId> -o media/<name>.png
40
+ **IMPORTANT: After downloading, show the image using Obsidian wiki-link syntax EXACTLY like this:**
41
+
42
+ ```
43
+ ![[media/<NAME>.png]]
39
44
  ```
40
45
 
41
- Then show the result as an embedded vault link: `![[media/<name>.png]]`
46
+ Do NOT use markdown image syntax `![](...)` or `gobi://` URLs. Always use `![[media/<NAME>.png]]`.
42
47
 
43
48
  ### Key rules
49
+ - Replace `<NAME>` with a descriptive slug — NEVER use example names like `sunset.png` literally.
44
50
  - `--name` is **optional** — auto-derived from prompt if omitted.
45
- - `--wait` avoids needing a separate `image-status` call.
46
- - Always download with `-o media/<name>.png` pick a short descriptive name (e.g., `happy-family.png`).
47
- - `image-status` takes a **positional** jobId (NOT `--job-id`): `gobi media image-status <jobId>`
51
+ - Do NOT use the `downloadUrl` from the response — it is a frontend path, not a direct download link.
52
+ - `image-download` takes a **positional** jobId (NOT `--job-id`): `gobi media image-download <jobId>`
53
+ - The `jobId` (or `id`) field is what you pass to `image-download` / `image-status` — NOT `mediaId`.
48
54
 
49
55
  ## Available Commands
50
56
 
@@ -152,6 +152,7 @@ Options:
152
152
  --seed <seed> Random seed for reproducibility
153
153
  --reference-media-id <referenceMediaId> Reference image media ID
154
154
  --wait Poll until generation completes
155
+ -o, --output <path> Download image to this path when done (implies --wait)
155
156
  -h, --help display help for command
156
157
  ```
157
158
 
@@ -206,8 +207,8 @@ Usage: gobi media image-download [options] <jobId>
206
207
  Download a generated image.
207
208
 
208
209
  Options:
209
- --wait Poll until generation completes before downloading
210
- --type <type> Image type (image, thumbnail, asset)
211
- -o, --output <path> Output file path (default: {jobId}.{ext} in current directory)
212
- -h, --help display help for command
210
+ --wait Poll until generation completes before downloading
211
+ --type <type> Image type (image, thumbnail, asset)
212
+ -o, --output <path> Output file path (default: {jobId}.{ext} in current directory)
213
+ -h, --help display help for command
213
214
  ```