@yolo-labs/yolo-cli 0.38.1 → 0.39.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/deploy-cli.js +88 -4
- package/package.json +1 -1
package/dist/deploy-cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (docs/MANAGED_HOSTING_CLI_SPEC.md §1).
|
|
4
4
|
*
|
|
5
5
|
* yolo deploy [--env <staging|prod>] [--dry-run] [--json] ← bare = ship
|
|
6
|
-
* yolo deploy init [--slug <slug>] [--type <static|worker>] [--json]
|
|
6
|
+
* yolo deploy init [--slug <slug>] [--type <static|worker>] [--parent <id|slug>] [--json]
|
|
7
7
|
* yolo deploy status [--json]
|
|
8
8
|
* yolo deploy logs [--tail] [--since <dur>] [--json]
|
|
9
9
|
* yolo deploy rollback [releaseId] [--json]
|
|
@@ -41,7 +41,7 @@ import { runDeployDev } from './deploy-dev.js';
|
|
|
41
41
|
import { defaultReadFile } from './auth-context.js';
|
|
42
42
|
const USAGE = [
|
|
43
43
|
'Usage: yolo deploy [--env <staging|prod>] [--dry-run] [--json]',
|
|
44
|
-
' yolo deploy init [--slug <slug>] [--type <static|worker>] [--json]',
|
|
44
|
+
' yolo deploy init [--slug <slug>] [--type <static|worker>] [--parent <id|slug>] [--json]',
|
|
45
45
|
' yolo deploy link (--project-id <id> | --slug <slug>) [--type <static|worker>]',
|
|
46
46
|
' yolo deploy validate [--json]',
|
|
47
47
|
' yolo deploy doctor [--json]',
|
|
@@ -193,6 +193,7 @@ async function runShipCmd(args, deps, io) {
|
|
|
193
193
|
export function parseInitArgs(args) {
|
|
194
194
|
let slug;
|
|
195
195
|
let type;
|
|
196
|
+
let parentProjectId;
|
|
196
197
|
let jsonOutput = false;
|
|
197
198
|
for (let i = 0; i < args.length; i++) {
|
|
198
199
|
const a = args[i];
|
|
@@ -216,6 +217,15 @@ export function parseInitArgs(args) {
|
|
|
216
217
|
return { ok: false, message: `--type must be 'static' or 'worker' (got '${v}')` };
|
|
217
218
|
type = v;
|
|
218
219
|
}
|
|
220
|
+
else if (a === '--parent') {
|
|
221
|
+
const v = args[++i];
|
|
222
|
+
if (!v || v.startsWith('--'))
|
|
223
|
+
return { ok: false, message: '--parent requires a project id' };
|
|
224
|
+
parentProjectId = v;
|
|
225
|
+
}
|
|
226
|
+
else if (a.startsWith('--parent=')) {
|
|
227
|
+
parentProjectId = a.slice('--parent='.length);
|
|
228
|
+
}
|
|
219
229
|
else if (a.startsWith('--type=')) {
|
|
220
230
|
const v = a.slice('--type='.length);
|
|
221
231
|
if (v !== 'static' && v !== 'worker')
|
|
@@ -229,7 +239,10 @@ export function parseInitArgs(args) {
|
|
|
229
239
|
return { ok: false, message: `unexpected positional argument: ${a}` };
|
|
230
240
|
}
|
|
231
241
|
}
|
|
232
|
-
|
|
242
|
+
if (parentProjectId !== undefined && parentProjectId.length === 0) {
|
|
243
|
+
return { ok: false, message: '--parent requires a project id or slug' };
|
|
244
|
+
}
|
|
245
|
+
return { ok: true, slug, type, parentProjectId, jsonOutput };
|
|
233
246
|
}
|
|
234
247
|
async function runInitCmd(args, deps, io) {
|
|
235
248
|
const parsed = parseInitArgs(args);
|
|
@@ -260,6 +273,27 @@ async function runInitCmd(args, deps, io) {
|
|
|
260
273
|
return exitCodeForFailure(readResult.kind);
|
|
261
274
|
}
|
|
262
275
|
const existing = readResult.config;
|
|
276
|
+
if (existing?.projectId && parsed.parentProjectId) {
|
|
277
|
+
// 🚨 `--parent` on an ALREADY-LINKED directory would otherwise report
|
|
278
|
+
// `already-linked` and exit 0, having silently ignored the flag — the same
|
|
279
|
+
// false-success the slug-reconciliation guard below exists to prevent.
|
|
280
|
+
// Parent links are create-only, so there is nothing `init` can do here.
|
|
281
|
+
const message = 'this directory is already linked to a project; --parent only applies when creating one';
|
|
282
|
+
// JSON mode keeps stderr EMPTY — automation treats it as diagnostics, and
|
|
283
|
+
// the init contract is a clean stream split.
|
|
284
|
+
if (parsed.jsonOutput) {
|
|
285
|
+
io.out(`${formatJsonResult({ status: 'failed', message })}\n`);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
io.err(`FAIL: ${message}.\n`
|
|
289
|
+
// Only advice that actually works: parent links are create-only and
|
|
290
|
+
// there is no re-parent route or console control, so the recovery is
|
|
291
|
+
// to create the child as a NEW project.
|
|
292
|
+
+ ' Nesting is set at creation. Create the child in its own directory with\n'
|
|
293
|
+
+ ' `yolo deploy init --parent <id|slug>`, or from the Hosting console\'s New project dialog.\n');
|
|
294
|
+
}
|
|
295
|
+
return 1;
|
|
296
|
+
}
|
|
263
297
|
if (existing?.projectId) {
|
|
264
298
|
// Idempotent: a committed link means future sessions ship to the SAME
|
|
265
299
|
// project instead of forking a new slug — never silently re-create.
|
|
@@ -282,6 +316,42 @@ async function runInitCmd(args, deps, io) {
|
|
|
282
316
|
io.err(`${formatFail({ kind: 'auth', message: auth.message })}\n`);
|
|
283
317
|
return 78;
|
|
284
318
|
}
|
|
319
|
+
// Resolve `--parent` when given as a SLUG rather than an id. A CLI-only user
|
|
320
|
+
// has no way to discover an opaque 24-hex id (there is no `deploy list`
|
|
321
|
+
// subcommand), but slugs are the handle they already use everywhere else —
|
|
322
|
+
// so accept either and look the slug up through the same owned-projects
|
|
323
|
+
// helper `link` uses (codex P2).
|
|
324
|
+
let resolvedParentId = parsed.parentProjectId;
|
|
325
|
+
if (resolvedParentId) {
|
|
326
|
+
// SLUG FIRST, then id. A slug may legally be 24 hex characters, so a
|
|
327
|
+
// shape test alone is ambiguous; looking the slug up first resolves both
|
|
328
|
+
// forms with one call and gives slugs precedence — which is the form a
|
|
329
|
+
// human typed on purpose.
|
|
330
|
+
const parentLookup = await findOwnedProjectBySlug(deps, auth.context, resolvedParentId);
|
|
331
|
+
if (!parentLookup.ok) {
|
|
332
|
+
// A list failure (auth/network) is NOT "not found" — surface the real
|
|
333
|
+
// error and its exit code, matching how `link` treats the same helper.
|
|
334
|
+
if (parsed.jsonOutput)
|
|
335
|
+
io.out(`${formatJsonResult(parentLookup)}\n`);
|
|
336
|
+
else
|
|
337
|
+
io.err(`${formatFail(parentLookup)}\n`);
|
|
338
|
+
return exitCodeForFailure(parentLookup.kind);
|
|
339
|
+
}
|
|
340
|
+
const bySlug = parentLookup.project ? resolveProjectId(parentLookup.project) : undefined;
|
|
341
|
+
if (bySlug) {
|
|
342
|
+
resolvedParentId = bySlug;
|
|
343
|
+
}
|
|
344
|
+
else if (!/^[a-f0-9]{24}$/i.test(resolvedParentId)) {
|
|
345
|
+
const message = `no project of yours matches parent '${resolvedParentId}' — pass its slug or 24-hex id`;
|
|
346
|
+
if (parsed.jsonOutput)
|
|
347
|
+
io.out(`${formatJsonResult({ status: 'failed', message })}\n`);
|
|
348
|
+
else
|
|
349
|
+
io.err(`FAIL: ${message}\n`);
|
|
350
|
+
return 1;
|
|
351
|
+
}
|
|
352
|
+
// Else: not a slug of ours, but id-shaped — pass through and let the
|
|
353
|
+
// server's ownership-asserted read be the authority.
|
|
354
|
+
}
|
|
285
355
|
const create = deps.createProjectImpl ?? createProject;
|
|
286
356
|
const created = await create(auth.context, {
|
|
287
357
|
name: parsed.slug ?? path.basename(cwd),
|
|
@@ -291,6 +361,9 @@ async function runInitCmd(args, deps, io) {
|
|
|
291
361
|
// (and therefore to VibeAssist event watchers). Local CLI use remains
|
|
292
362
|
// unchanged because the field is optional.
|
|
293
363
|
...(deps.env?.WORKSPACE_ID ? { workspaceId: deps.env.WORKSPACE_ID } : {}),
|
|
364
|
+
// Nesting S4 — passed straight through; the server verifies ownership,
|
|
365
|
+
// depth and parent state. Not written to `.yolo/deploy.json`.
|
|
366
|
+
...(resolvedParentId ? { parentProjectId: resolvedParentId } : {}),
|
|
294
367
|
});
|
|
295
368
|
if (!created.ok) {
|
|
296
369
|
// create-or-LINK: a `slug-taken` on a slug the caller ALREADY OWNS means a
|
|
@@ -308,7 +381,18 @@ async function runInitCmd(args, deps, io) {
|
|
|
308
381
|
const lookup = await findOwnedProjectBySlug(deps, auth.context, takenSlug);
|
|
309
382
|
const owned = lookup.ok ? lookup.project : undefined;
|
|
310
383
|
const projectId = owned ? resolveProjectId(owned) : undefined;
|
|
311
|
-
|
|
384
|
+
// 🚨 Do NOT reconcile into a project that is not already under the
|
|
385
|
+
// requested parent (codex P2). Parent links are CREATE-ONLY server
|
|
386
|
+
// side, so linking here would report a successful nesting that never
|
|
387
|
+
// happened — the caller believes the family exists and it does not.
|
|
388
|
+
// Fall through to the plain slug-taken refusal instead.
|
|
389
|
+
// Case-normalized: `--parent` accepts either case (the regex is /i) but
|
|
390
|
+
// the API serializes an ObjectId lowercase, so a raw compare would
|
|
391
|
+
// report a mismatch for the very same parent (codex P2).
|
|
392
|
+
const parentMismatch = parsed.parentProjectId !== undefined
|
|
393
|
+
&& str(owned?.parentProjectId)?.toLowerCase()
|
|
394
|
+
!== resolvedParentId?.toLowerCase();
|
|
395
|
+
if (projectId && !parentMismatch) {
|
|
312
396
|
return writeLinkFile(cwd, writeConfig, io, {
|
|
313
397
|
projectId,
|
|
314
398
|
slug: str(owned.slug) ?? takenSlug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolo-labs/yolo-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "YOLO Studio substrate CLI \u2014 owns yolo plan/workspace/artifact substrate-tooling commands. Distinct from yolo-code (the agent CLI) and yolo-router (the LLM gateway client).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|