@yolo-labs/yolo-cli 0.44.1 → 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 +3 -1
- package/dist/kanban-cli.js +138 -18
- package/dist/tileapp-personal.js +3 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -58,10 +58,12 @@ 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
|
|
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.',
|
|
65
|
+
' kanban models List the model ids a card can be pinned to, and whether each can run now.',
|
|
66
|
+
' [--json] [--workspace <wsId>] Raw JSON instead of the table; sanity-check the workspace.',
|
|
65
67
|
' git doctor [opts] Diagnose why git (not gh) can\'t authenticate to github.com.',
|
|
66
68
|
' [--fix] Repair what is safe to (store file, helpers, remote URL), then re-check.',
|
|
67
69
|
' [--offline] [--remote <name>] [--json] Skip network checks; remote to probe (default: origin); JSON output.',
|
package/dist/kanban-cli.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `yolo kanban export` / `yolo kanban import` — move a board seed document
|
|
3
|
-
* between a workspace and a file, with no model in the loop.
|
|
3
|
+
* between a workspace and a file, with no model in the loop. Plus
|
|
4
|
+
* `yolo kanban models`, the pinnable model ids (`studio.kanban_list_models`
|
|
5
|
+
* from a shell, on the same user-token surface).
|
|
4
6
|
*
|
|
5
7
|
* A board lives in Mongo, scoped to a workspace that can wedge. The seed
|
|
6
8
|
* document (`common-api/src/services/kanban-board-seed.ts`) is the only copy
|
|
@@ -43,12 +45,17 @@ export async function runKanbanExport(options) {
|
|
|
43
45
|
if (!resolved.ok)
|
|
44
46
|
return resolved.failure;
|
|
45
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;
|
|
46
53
|
// Refuse an occupied destination BEFORE the request, not after. An export
|
|
47
54
|
// is reached for when a workspace is already in trouble; spending the round
|
|
48
55
|
// trip only to discard the one readable copy of the board would be the
|
|
49
56
|
// wrong half of the operation to get right.
|
|
50
|
-
if (
|
|
51
|
-
return fail('usage', `refusing to overwrite existing file '${
|
|
57
|
+
if (outFile && fs.existsSync(outFile)) {
|
|
58
|
+
return fail('usage', `refusing to overwrite existing file '${outFile}'; pick another path or remove it first`);
|
|
52
59
|
}
|
|
53
60
|
const path = `/workspaces/${encodeURIComponent(workspaceId)}/kanban/boards/${encodeURIComponent(options.tileId)}/seed`;
|
|
54
61
|
let response;
|
|
@@ -66,23 +73,24 @@ export async function runKanbanExport(options) {
|
|
|
66
73
|
status: response.status,
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
|
-
if (!
|
|
76
|
+
if (!outFile) {
|
|
70
77
|
return { ok: true, output: body, raw: true, workspaceId };
|
|
71
78
|
}
|
|
72
79
|
const write = options.writeFileImpl ?? defaultWriteFileExclusive;
|
|
73
80
|
try {
|
|
74
|
-
write(
|
|
81
|
+
write(outFile, body);
|
|
75
82
|
}
|
|
76
83
|
catch (err) {
|
|
77
84
|
if (isEexist(err)) {
|
|
78
|
-
return fail('usage', `refusing to overwrite existing file '${
|
|
85
|
+
return fail('usage', `refusing to overwrite existing file '${outFile}'; pick another path or remove it first`);
|
|
79
86
|
}
|
|
80
|
-
return fail('usage', `could not write '${
|
|
87
|
+
return fail('usage', `could not write '${outFile}': ${describeError(err)}`);
|
|
81
88
|
}
|
|
82
89
|
return {
|
|
83
90
|
ok: true,
|
|
84
|
-
output: `Wrote ${Buffer.byteLength(body, 'utf-8')} bytes to ${
|
|
91
|
+
output: `Wrote ${Buffer.byteLength(body, 'utf-8')} bytes to ${outFile}`,
|
|
85
92
|
raw: false,
|
|
93
|
+
status: true,
|
|
86
94
|
workspaceId,
|
|
87
95
|
};
|
|
88
96
|
}
|
|
@@ -141,9 +149,48 @@ export async function runKanbanImport(options) {
|
|
|
141
149
|
ok: true,
|
|
142
150
|
output: formatImportSummary(body, options.boardId),
|
|
143
151
|
raw: false,
|
|
152
|
+
status: true,
|
|
144
153
|
workspaceId,
|
|
145
154
|
};
|
|
146
155
|
}
|
|
156
|
+
export async function runKanbanModels(options = {}) {
|
|
157
|
+
const env = options.env ?? process.env;
|
|
158
|
+
const resolved = resolveContext(env, options.workspaceFlag);
|
|
159
|
+
if (!resolved.ok)
|
|
160
|
+
return resolved.failure;
|
|
161
|
+
const { commonApiUrl, userToken, workspaceId } = resolved;
|
|
162
|
+
let response;
|
|
163
|
+
try {
|
|
164
|
+
response = await userRouteRequest({ commonApiUrl, userToken, fetchImpl: options.fetchImpl }, `/workspaces/${encodeURIComponent(workspaceId)}/kanban/models`, { method: 'GET' });
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
return fail('http', `kanban.models.list failed: ${describeError(err)}`);
|
|
168
|
+
}
|
|
169
|
+
const body = await safeReadText(response);
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
return fail('http', `kanban.models.list failed: HTTP ${response.status} — ${body}`, { status: response.status });
|
|
172
|
+
}
|
|
173
|
+
if (options.json)
|
|
174
|
+
return { ok: true, output: body, raw: true, workspaceId };
|
|
175
|
+
return { ok: true, output: formatModels(body), raw: false, workspaceId };
|
|
176
|
+
}
|
|
177
|
+
/** One id per line — the value `model` takes — then whether it can run now and why not. */
|
|
178
|
+
export function formatModels(body) {
|
|
179
|
+
let models;
|
|
180
|
+
try {
|
|
181
|
+
models = JSON.parse(body).models ?? [];
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return body;
|
|
185
|
+
}
|
|
186
|
+
if (models.length === 0)
|
|
187
|
+
return 'No models are discovered for this workspace right now.';
|
|
188
|
+
const idCol = Math.max(...models.map((m) => m.id.length));
|
|
189
|
+
return models.map((m) => {
|
|
190
|
+
const state = m.available ? 'available' : `unavailable${m.unavailableReason ? ` — ${m.unavailableReason}` : ''}`;
|
|
191
|
+
return `${m.id.padEnd(idCol)} ${m.isDefault ? 'default ' : ' '}${state}`;
|
|
192
|
+
}).join('\n');
|
|
193
|
+
}
|
|
147
194
|
/**
|
|
148
195
|
* `key → cardId`, one per line, under a count. That map is what a caller
|
|
149
196
|
* needs to say anything at all about the board it just rebuilt, and it is
|
|
@@ -195,8 +242,56 @@ function resolveContext(env, workspaceFlag) {
|
|
|
195
242
|
return { ok: true, commonApiUrl, userToken, workspaceId };
|
|
196
243
|
}
|
|
197
244
|
// ─── CLI surface ──────────────────────────────────────────────────────────
|
|
198
|
-
const EXPORT_USAGE =
|
|
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');
|
|
199
252
|
const IMPORT_USAGE = 'Usage: yolo kanban import <boardId> <file> [--workspace <wsId>]\n';
|
|
253
|
+
const MODELS_USAGE = 'Usage: yolo kanban models [--json] [--workspace <wsId>]\n';
|
|
254
|
+
const KANBAN_USAGE = [
|
|
255
|
+
'Usage: yolo kanban <subcommand>',
|
|
256
|
+
'',
|
|
257
|
+
'Subcommands:',
|
|
258
|
+
' export <tileId> [-o <file>|-] Write a board\'s seed document to a file or stdout',
|
|
259
|
+
' import <boardId> <file> Create cards on a board from a seed document',
|
|
260
|
+
' models [--json] List the model ids a card can be pinned to',
|
|
261
|
+
'',
|
|
262
|
+
'Every subcommand takes --workspace <wsId> (defaults to this session\'s workspace).',
|
|
263
|
+
'',
|
|
264
|
+
].join('\n');
|
|
265
|
+
const isHelp = (a) => a === '--help' || a === '-h' || a === 'help';
|
|
266
|
+
export function parseKanbanModelsArgs(args) {
|
|
267
|
+
let json = false;
|
|
268
|
+
let workspaceFlag;
|
|
269
|
+
for (let i = 0; i < args.length; i++) {
|
|
270
|
+
const a = args[i];
|
|
271
|
+
if (a === '--json') {
|
|
272
|
+
json = true;
|
|
273
|
+
}
|
|
274
|
+
else if (a === '--workspace') {
|
|
275
|
+
const v = args[++i];
|
|
276
|
+
if (!v || v.startsWith('--'))
|
|
277
|
+
return { ok: false, message: '--workspace requires a value' };
|
|
278
|
+
workspaceFlag = v;
|
|
279
|
+
}
|
|
280
|
+
else if (a.startsWith('--workspace=')) {
|
|
281
|
+
const v = a.slice('--workspace='.length);
|
|
282
|
+
if (!v)
|
|
283
|
+
return { ok: false, message: '--workspace requires a value' };
|
|
284
|
+
workspaceFlag = v;
|
|
285
|
+
}
|
|
286
|
+
else if (a.startsWith('-')) {
|
|
287
|
+
return { ok: false, message: `unknown option: ${a}` };
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
return { ok: false, message: `unexpected positional argument: ${a}` };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return { ok: true, json, workspaceFlag };
|
|
294
|
+
}
|
|
200
295
|
export function parseKanbanExportArgs(args) {
|
|
201
296
|
let tileId;
|
|
202
297
|
let outFile;
|
|
@@ -269,8 +364,27 @@ export function parseKanbanImportArgs(args) {
|
|
|
269
364
|
return { ok: true, boardId: positional[0], file: positional[1], workspaceFlag };
|
|
270
365
|
}
|
|
271
366
|
/** `args` is everything after `kanban`. */
|
|
272
|
-
export async function runKanbanCmd(args) {
|
|
367
|
+
export async function runKanbanCmd(args, deps = {}) {
|
|
273
368
|
const sub = args[0];
|
|
369
|
+
if (isHelp(sub)) {
|
|
370
|
+
process.stdout.write(KANBAN_USAGE);
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
// `yolo kanban <sub> --help` prints that subcommand's usage rather than failing its parse.
|
|
374
|
+
const subUsage = sub === 'export' ? EXPORT_USAGE : sub === 'import' ? IMPORT_USAGE : sub === 'models' ? MODELS_USAGE : null;
|
|
375
|
+
if (subUsage && args.slice(1).some((a) => a === '--help' || a === '-h')) {
|
|
376
|
+
process.stdout.write(subUsage);
|
|
377
|
+
return 0;
|
|
378
|
+
}
|
|
379
|
+
if (sub === 'models') {
|
|
380
|
+
const parsed = parseKanbanModelsArgs(args.slice(1));
|
|
381
|
+
if (!parsed.ok) {
|
|
382
|
+
process.stderr.write(`yolo: kanban models: ${parsed.message}\n`);
|
|
383
|
+
process.stderr.write(MODELS_USAGE);
|
|
384
|
+
return 64;
|
|
385
|
+
}
|
|
386
|
+
return report(await runKanbanModels({ json: parsed.json, workspaceFlag: parsed.workspaceFlag, ...deps }));
|
|
387
|
+
}
|
|
274
388
|
if (sub === 'export') {
|
|
275
389
|
const parsed = parseKanbanExportArgs(args.slice(1));
|
|
276
390
|
if (!parsed.ok) {
|
|
@@ -282,6 +396,7 @@ export async function runKanbanCmd(args) {
|
|
|
282
396
|
tileId: parsed.tileId,
|
|
283
397
|
outFile: parsed.outFile,
|
|
284
398
|
workspaceFlag: parsed.workspaceFlag,
|
|
399
|
+
...deps,
|
|
285
400
|
}));
|
|
286
401
|
}
|
|
287
402
|
if (sub === 'import') {
|
|
@@ -295,21 +410,22 @@ export async function runKanbanCmd(args) {
|
|
|
295
410
|
boardId: parsed.boardId,
|
|
296
411
|
file: parsed.file,
|
|
297
412
|
workspaceFlag: parsed.workspaceFlag,
|
|
413
|
+
...deps,
|
|
298
414
|
}));
|
|
299
415
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return 64;
|
|
303
|
-
}
|
|
304
|
-
process.stderr.write(`yolo: unknown kanban subcommand '${sub}'\n`);
|
|
305
|
-
process.stderr.write('Subcommands: export, import\n');
|
|
416
|
+
process.stderr.write(sub ? `yolo: unknown kanban subcommand '${sub}'\n` : 'yolo: kanban requires a subcommand\n');
|
|
417
|
+
process.stderr.write(KANBAN_USAGE);
|
|
306
418
|
return 64;
|
|
307
419
|
}
|
|
308
420
|
function report(result) {
|
|
309
421
|
if (result.ok) {
|
|
310
422
|
// `raw` output is the document: no trailing newline, so a redirect or a
|
|
311
|
-
// pipe gets the same bytes `-o` would have written.
|
|
312
|
-
|
|
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`);
|
|
313
429
|
return 0;
|
|
314
430
|
}
|
|
315
431
|
process.stderr.write(`FAIL [${result.kind}]: ${result.message}\n`);
|
|
@@ -330,6 +446,10 @@ async function safeReadText(response) {
|
|
|
330
446
|
return '<no body>';
|
|
331
447
|
}
|
|
332
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
|
+
}
|
|
333
453
|
function isEexist(err) {
|
|
334
454
|
return typeof err === 'object' && err !== null && err.code === 'EEXIST';
|
|
335
455
|
}
|
package/dist/tileapp-personal.js
CHANGED
|
@@ -148,8 +148,9 @@ export function runTileAppInit(opts) {
|
|
|
148
148
|
// calculator/grapher), write a real parser here (tokenizer → shunting-yard →
|
|
149
149
|
// RPN eval) rather than reaching for eval. Keep everything self-contained.
|
|
150
150
|
//
|
|
151
|
-
// To call HOST capabilities (LLM, MCP tools, files), vendor @
|
|
152
|
-
// browser build
|
|
151
|
+
// To call HOST capabilities (LLM, MCP tools, files), vendor @yolo-labs/app-sdk's
|
|
152
|
+
// browser build (npm i @yolo-labs/app-sdk, then copy its dist/) into
|
|
153
|
+
// ./vendor/app-sdk/ and request matching permissions in
|
|
153
154
|
// tileapp.json (permissions.required / optional):
|
|
154
155
|
// import { createTileApp } from './vendor/app-sdk/index.js';
|
|
155
156
|
// const app = createTileApp();
|