@yolo-labs/yolo-cli 0.45.0 → 0.45.1

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/cli.js CHANGED
@@ -58,7 +58,7 @@ function printHelp() {
58
58
  ' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
59
59
  ' [--json] Pretty-print raw JSON instead of the table.',
60
60
  ' kanban export <tileId> [opts] Read a board out as a seed document (operator-only REST route).',
61
- ' [-o <file>] Write to <file>; refuses to overwrite. Default: stdout, for piping.',
61
+ ' [-o <file>|-] Write to <file> (refuses to overwrite; status line to stderr). `-` or omitted: stdout, for piping.',
62
62
  ' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
63
63
  ' kanban import <boardId> <file> Rebuild a board from a seed document (additive; never overwrites).',
64
64
  ' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
@@ -45,12 +45,17 @@ export async function runKanbanExport(options) {
45
45
  if (!resolved.ok)
46
46
  return resolved.failure;
47
47
  const { commonApiUrl, userToken, workspaceId } = resolved;
48
+ // `-o -` and `-o /dev/stdout` mean stdout. Resolve them here rather than
49
+ // writing to the path: the overwrite guard below would see /dev/stdout as an
50
+ // existing file and refuse, and even if it didn't, the status line would
51
+ // land in the same stream as the document.
52
+ const outFile = options.outFile && !isStdoutTarget(options.outFile) ? options.outFile : undefined;
48
53
  // Refuse an occupied destination BEFORE the request, not after. An export
49
54
  // is reached for when a workspace is already in trouble; spending the round
50
55
  // trip only to discard the one readable copy of the board would be the
51
56
  // wrong half of the operation to get right.
52
- if (options.outFile && fs.existsSync(options.outFile)) {
53
- return fail('usage', `refusing to overwrite existing file '${options.outFile}'; pick another path or remove it first`);
57
+ if (outFile && fs.existsSync(outFile)) {
58
+ return fail('usage', `refusing to overwrite existing file '${outFile}'; pick another path or remove it first`);
54
59
  }
55
60
  const path = `/workspaces/${encodeURIComponent(workspaceId)}/kanban/boards/${encodeURIComponent(options.tileId)}/seed`;
56
61
  let response;
@@ -68,23 +73,24 @@ export async function runKanbanExport(options) {
68
73
  status: response.status,
69
74
  });
70
75
  }
71
- if (!options.outFile) {
76
+ if (!outFile) {
72
77
  return { ok: true, output: body, raw: true, workspaceId };
73
78
  }
74
79
  const write = options.writeFileImpl ?? defaultWriteFileExclusive;
75
80
  try {
76
- write(options.outFile, body);
81
+ write(outFile, body);
77
82
  }
78
83
  catch (err) {
79
84
  if (isEexist(err)) {
80
- return fail('usage', `refusing to overwrite existing file '${options.outFile}'; pick another path or remove it first`);
85
+ return fail('usage', `refusing to overwrite existing file '${outFile}'; pick another path or remove it first`);
81
86
  }
82
- return fail('usage', `could not write '${options.outFile}': ${describeError(err)}`);
87
+ return fail('usage', `could not write '${outFile}': ${describeError(err)}`);
83
88
  }
84
89
  return {
85
90
  ok: true,
86
- output: `Wrote ${Buffer.byteLength(body, 'utf-8')} bytes to ${options.outFile}`,
91
+ output: `Wrote ${Buffer.byteLength(body, 'utf-8')} bytes to ${outFile}`,
87
92
  raw: false,
93
+ status: true,
88
94
  workspaceId,
89
95
  };
90
96
  }
@@ -143,6 +149,7 @@ export async function runKanbanImport(options) {
143
149
  ok: true,
144
150
  output: formatImportSummary(body, options.boardId),
145
151
  raw: false,
152
+ status: true,
146
153
  workspaceId,
147
154
  };
148
155
  }
@@ -235,14 +242,20 @@ function resolveContext(env, workspaceFlag) {
235
242
  return { ok: true, commonApiUrl, userToken, workspaceId };
236
243
  }
237
244
  // ─── CLI surface ──────────────────────────────────────────────────────────
238
- const EXPORT_USAGE = 'Usage: yolo kanban export <tileId> [-o <file>] [--workspace <wsId>]\n';
245
+ const EXPORT_USAGE = [
246
+ 'Usage: yolo kanban export <tileId> [-o <file>|-] [--workspace <wsId>]',
247
+ '',
248
+ ' -o <file> Write the document to <file> (refuses to overwrite); the status line goes to stderr.',
249
+ ' -o - Write the document to stdout (the default). /dev/stdout works the same.',
250
+ '',
251
+ ].join('\n');
239
252
  const IMPORT_USAGE = 'Usage: yolo kanban import <boardId> <file> [--workspace <wsId>]\n';
240
253
  const MODELS_USAGE = 'Usage: yolo kanban models [--json] [--workspace <wsId>]\n';
241
254
  const KANBAN_USAGE = [
242
255
  'Usage: yolo kanban <subcommand>',
243
256
  '',
244
257
  'Subcommands:',
245
- ' export <tileId> [-o <file>] Write a board\'s seed document to a file or stdout',
258
+ ' export <tileId> [-o <file>|-] Write a board\'s seed document to a file or stdout',
246
259
  ' import <boardId> <file> Create cards on a board from a seed document',
247
260
  ' models [--json] List the model ids a card can be pinned to',
248
261
  '',
@@ -351,7 +364,7 @@ export function parseKanbanImportArgs(args) {
351
364
  return { ok: true, boardId: positional[0], file: positional[1], workspaceFlag };
352
365
  }
353
366
  /** `args` is everything after `kanban`. */
354
- export async function runKanbanCmd(args) {
367
+ export async function runKanbanCmd(args, deps = {}) {
355
368
  const sub = args[0];
356
369
  if (isHelp(sub)) {
357
370
  process.stdout.write(KANBAN_USAGE);
@@ -370,7 +383,7 @@ export async function runKanbanCmd(args) {
370
383
  process.stderr.write(MODELS_USAGE);
371
384
  return 64;
372
385
  }
373
- return report(await runKanbanModels({ json: parsed.json, workspaceFlag: parsed.workspaceFlag }));
386
+ return report(await runKanbanModels({ json: parsed.json, workspaceFlag: parsed.workspaceFlag, ...deps }));
374
387
  }
375
388
  if (sub === 'export') {
376
389
  const parsed = parseKanbanExportArgs(args.slice(1));
@@ -383,6 +396,7 @@ export async function runKanbanCmd(args) {
383
396
  tileId: parsed.tileId,
384
397
  outFile: parsed.outFile,
385
398
  workspaceFlag: parsed.workspaceFlag,
399
+ ...deps,
386
400
  }));
387
401
  }
388
402
  if (sub === 'import') {
@@ -396,6 +410,7 @@ export async function runKanbanCmd(args) {
396
410
  boardId: parsed.boardId,
397
411
  file: parsed.file,
398
412
  workspaceFlag: parsed.workspaceFlag,
413
+ ...deps,
399
414
  }));
400
415
  }
401
416
  process.stderr.write(sub ? `yolo: unknown kanban subcommand '${sub}'\n` : 'yolo: kanban requires a subcommand\n');
@@ -405,8 +420,12 @@ export async function runKanbanCmd(args) {
405
420
  function report(result) {
406
421
  if (result.ok) {
407
422
  // `raw` output is the document: no trailing newline, so a redirect or a
408
- // pipe gets the same bytes `-o` would have written.
409
- process.stdout.write(result.raw ? result.output : `${result.output}\n`);
423
+ // pipe gets the same bytes `-o` would have written. A status line is for
424
+ // the human, so it stays out of stdout.
425
+ if (result.status)
426
+ process.stderr.write(`${result.output}\n`);
427
+ else
428
+ process.stdout.write(result.raw ? result.output : `${result.output}\n`);
410
429
  return 0;
411
430
  }
412
431
  process.stderr.write(`FAIL [${result.kind}]: ${result.message}\n`);
@@ -427,6 +446,10 @@ async function safeReadText(response) {
427
446
  return '<no body>';
428
447
  }
429
448
  }
449
+ /** Destinations that mean "the document goes to stdout", not a file. */
450
+ function isStdoutTarget(filePath) {
451
+ return filePath === '-' || filePath === '/dev/stdout' || filePath === '/dev/fd/1';
452
+ }
430
453
  function isEexist(err) {
431
454
  return typeof err === 'object' && err !== null && err.code === 'EEXIST';
432
455
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-labs/yolo-cli",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "description": "YOLO Studio CLI for workspace context, artifacts, personal apps and hosting.",
5
5
  "license": "MIT",
6
6
  "repository": {