@yolo-labs/yolo-cli 0.43.0 → 0.44.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/README.md +51 -42
- package/dist/artifact-get.js +2 -9
- package/dist/cli.js +24 -126
- package/dist/deploy-client.js +10 -20
- package/dist/deploy-config.js +2 -3
- package/dist/exit.js +34 -0
- package/dist/kanban-cli.js +352 -0
- package/dist/preview.js +145 -0
- package/dist/tileapp-oci-assembler.js +2 -2
- package/dist/tileapp-validator.js +6 -0
- package/dist/work-client.js +11 -60
- package/package.json +4 -7
- package/dist/canonicalizer.js +0 -208
- package/dist/lockfile.js +0 -203
- package/dist/plan-frontmatter.schema.json +0 -191
- package/dist/plan-validate.js +0 -270
- package/dist/revision.js +0 -43
- package/dist/run-list.js +0 -148
- package/dist/webapp-url.js +0 -61
package/README.md
CHANGED
|
@@ -1,57 +1,66 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @yolo-labs/yolo-cli
|
|
2
2
|
|
|
3
|
-
The `yolo`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
- **`yolo-code`** — YOLO Studio's built-in coding agent CLI (separate package).
|
|
7
|
-
- **`yolo-router`** — the LLM gateway client (separate package).
|
|
8
|
-
|
|
9
|
-
## Status
|
|
10
|
-
|
|
11
|
-
Phase 8a Group 9 scaffold. v1 ships only `yolo --version` and
|
|
12
|
-
`yolo context` (resolves and prints the container ambient session
|
|
13
|
-
context). Plan import/export lands in Phase 8c.
|
|
14
|
-
|
|
15
|
-
## Usage (in-container)
|
|
3
|
+
The `yolo` CLI provides workspace context, artifact reads, personal app development
|
|
4
|
+
and publishing, and hosting commands. Run `yolo --help` for all commands.
|
|
16
5
|
|
|
17
6
|
```sh
|
|
18
|
-
yolo --version
|
|
19
7
|
yolo context
|
|
8
|
+
yolo artifact list
|
|
9
|
+
yolo tileapp init my-app
|
|
10
|
+
yolo deploy --dry-run
|
|
20
11
|
```
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
Authenticated commands require `SESSION_ID`, `YOLO_COMMON_API_URL` (or
|
|
14
|
+
`YOLO_API_URL`), and a user access JWT. The CLI reads the rotated token at
|
|
15
|
+
`~/.config/yolo/token`, falling back to `YOLO_API_TOKEN`. The session record
|
|
16
|
+
supplies the workspace identity.
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
Artifact commands mint a scoped delegated token through
|
|
19
|
+
`POST /internal/mcp/tokens`; hosting commands authenticate with the user JWT.
|
|
20
|
+
Offline commands such as app scaffolding, validation, and local serving do not
|
|
21
|
+
require authentication.
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
Build and test locally:
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
lane-runner / service callers. **No longer required in user shells**
|
|
38
|
-
and intentionally excluded from the sandbox env.
|
|
25
|
+
```sh
|
|
26
|
+
npm ci
|
|
27
|
+
npm test
|
|
28
|
+
node dist/cli.js --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This standalone package is installed in Studio containers through
|
|
32
|
+
`containers/sandboxes/yolo-main/Dockerfile`.
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
endpoint (`POST /internal/mcp/tokens`) with `agentId: 'substrate-cli'`
|
|
42
|
-
and a capped scope set, authenticating with the user JWT
|
|
43
|
-
(`Authorization: Bearer`) when available, falling back to
|
|
44
|
-
`X-Internal-Auth` otherwise. It then calls `/internal/work/*` REST
|
|
45
|
-
routes with the delegated bearer (which is the capability — the
|
|
46
|
-
service header is no longer required by `requireMcpAuth`).
|
|
34
|
+
## Managed branch previews
|
|
47
35
|
|
|
48
|
-
|
|
36
|
+
Inside a Studio workspace, create a persistent preview of a repository branch:
|
|
49
37
|
|
|
50
38
|
```sh
|
|
51
|
-
|
|
52
|
-
npm run build
|
|
53
|
-
|
|
39
|
+
yolo preview create --name 'Latest main' --branch main --cwd web \
|
|
40
|
+
--setup 'npm ci' --build 'npm run build' \
|
|
41
|
+
--command 'npm start -- --hostname "$HOST" --port "$PORT"'
|
|
42
|
+
yolo preview status
|
|
43
|
+
yolo preview status <tile-id> --json
|
|
44
|
+
yolo preview logs <tile-id> --tail 100
|
|
45
|
+
yolo preview stop <tile-id>
|
|
54
46
|
```
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
Choose commands appropriate to your app; the example assumes its start script
|
|
49
|
+
accepts `--hostname` and `--port`. Single-quote commands to preserve `$PORT` and
|
|
50
|
+
`$HOST` for the service. It uses isolated checkouts, checks candidate health, and
|
|
51
|
+
switches the tile's stable port only after a successful build and start. Failed
|
|
52
|
+
updates keep the last working version. The required runtime must already be
|
|
53
|
+
installed; this service targets stateless HTTP apps, not database migrations.
|
|
54
|
+
|
|
55
|
+
The session resolves the authoritative workspace. Preview operations use delegated
|
|
56
|
+
capabilities; no manual credentials or workspace ID are needed. `create` returns
|
|
57
|
+
the tile ID and starts asynchronously. Use `status` for progress, and reuse
|
|
58
|
+
`--request-id <stable-id>` if retrying creation after an uncertain response.
|
|
59
|
+
`status` without an ID lists managed branch previews only. `stop` retains the tile
|
|
60
|
+
and configuration in Studio, removes its running service, and prevents startup on
|
|
61
|
+
page reload. Click **Start** in the tile to resume. Logs are bounded and in-memory;
|
|
62
|
+
stopping the service discards them. All commands accept `--json`.
|
|
63
|
+
|
|
64
|
+
`yolo preview --help` lists polling, timeout, port and health-check options. New CLI,
|
|
65
|
+
API, agent-registry scopes and container-api versions must be deployed together;
|
|
66
|
+
older deployments return an error rather than run a different preview mode.
|
package/dist/artifact-get.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Returns the latest version by default; `--version <n>` pins to a
|
|
5
5
|
* specific version. Default summary renders metadata only (key,
|
|
6
|
-
* version, type, producer,
|
|
6
|
+
* version, type, producer, contentLength, createdAt).
|
|
7
7
|
* `--content` flag emits ONLY the artifact content body to stdout
|
|
8
8
|
* (suitable for piping). `--json` emits the full record including
|
|
9
9
|
* content.
|
|
@@ -81,8 +81,7 @@ export async function runArtifactGet(options) {
|
|
|
81
81
|
// ─── Output formatting ────────────────────────────────────────────────────
|
|
82
82
|
/**
|
|
83
83
|
* Header with metadata — no content body. The producer block tells
|
|
84
|
-
* the operator who emitted the artifact (agent + tile)
|
|
85
|
-
* fingerprint for cross-run identity.
|
|
84
|
+
* the operator who emitted the artifact (agent + tile).
|
|
86
85
|
*/
|
|
87
86
|
export function formatSummary(artifact, workspaceId) {
|
|
88
87
|
const lines = [];
|
|
@@ -90,12 +89,6 @@ export function formatSummary(artifact, workspaceId) {
|
|
|
90
89
|
lines.push(` type: ${artifact.artifactType}`);
|
|
91
90
|
lines.push(` contentLength: ${artifact.contentLength}`);
|
|
92
91
|
lines.push(` producedBy: ${artifact.producedByAgentId}${artifact.producedByTileId ? ` (tile ${artifact.producedByTileId})` : ''}`);
|
|
93
|
-
if (artifact.producerType)
|
|
94
|
-
lines.push(` producerType: ${artifact.producerType}`);
|
|
95
|
-
if (artifact.producerId)
|
|
96
|
-
lines.push(` producerId: ${artifact.producerId}`);
|
|
97
|
-
if (artifact.fingerprint)
|
|
98
|
-
lines.push(` fingerprint: ${artifact.fingerprint}`);
|
|
99
92
|
if (artifact.refPath)
|
|
100
93
|
lines.push(` refPath: ${artifact.refPath}`);
|
|
101
94
|
lines.push(` createdAt: ${artifact.createdAt}`);
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* `yolo` — YOLO Studio
|
|
4
|
-
*
|
|
5
|
-
* Owns substrate-tooling subcommands (plan import/export/validate;
|
|
6
|
-
* future: workspace, artifact). v1 ships only `yolo --version` and
|
|
7
|
-
* `yolo context`; full plan import/export lands in Phase 8c.
|
|
8
|
-
*
|
|
9
|
-
* NOT the agent CLI. The agent CLI is `yolo-code`. NOT the LLM router
|
|
10
|
-
* client. The LLM router client is `yolo-router`.
|
|
3
|
+
* `yolo` — YOLO Studio workspace, artifact, app and hosting CLI.
|
|
11
4
|
*
|
|
12
5
|
* Auth contract (AUTH_AND_ONBOARDING Slice 0 — user-JWT-only):
|
|
13
6
|
* `SESSION_ID` + `YOLO_COMMON_API_URL` + a USER ACCESS JWT, resolved by
|
|
@@ -20,8 +13,6 @@
|
|
|
20
13
|
* binding is derived from the session record, not from env or args.
|
|
21
14
|
*/
|
|
22
15
|
import { readSessionContext, formatContext, ContextResolutionError } from './context.js';
|
|
23
|
-
import { validatePlanFile, formatErrors } from './plan-validate.js';
|
|
24
|
-
import { runRunList, exitCodeForFailure as runListExitCode, } from './run-list.js';
|
|
25
16
|
import { runArtifactGet, exitCodeForFailure as artifactGetExitCode, } from './artifact-get.js';
|
|
26
17
|
import { runArtifactList, exitCodeForFailure as artifactListExitCode, } from './artifact-list.js';
|
|
27
18
|
import { runTileAppSign, runTileAppPublish, exitCodeForFailure as tileAppExitCode, } from './tileapp-publisher.js';
|
|
@@ -37,6 +28,7 @@ import { runTileAppSign, runTileAppPublish, exitCodeForFailure as tileAppExitCod
|
|
|
37
28
|
// `../package.json` relative path resolves correctly both during
|
|
38
29
|
// tests (src/) and in production (dist/).
|
|
39
30
|
import { createRequire } from 'module';
|
|
31
|
+
import { exitAfterFlush } from './exit.js';
|
|
40
32
|
const PKG_VERSION = createRequire(import.meta.url)('../package.json').version;
|
|
41
33
|
/**
|
|
42
34
|
* Serialize an orchestration result for `--json` output. Strips the
|
|
@@ -55,11 +47,6 @@ function printHelp() {
|
|
|
55
47
|
'',
|
|
56
48
|
'Commands:',
|
|
57
49
|
' context Print resolved session/workspace/API context.',
|
|
58
|
-
' plan validate <file> Validate a .yolo/plans/<slug>.md plan file (offline).',
|
|
59
|
-
' run list [opts] List Plan Runs in the current workspace (work.list_runs).',
|
|
60
|
-
' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
|
|
61
|
-
' [--state <pending|running|paused|...>] Server-side executionState filter.',
|
|
62
|
-
' [--json] Pretty-print raw JSON instead of the table.',
|
|
63
50
|
' artifact get <key> [opts] Read a workspace artifact (work.get_artifact).',
|
|
64
51
|
' [--version <n>] Pin to a specific version. Default: latest.',
|
|
65
52
|
' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
|
|
@@ -70,6 +57,11 @@ function printHelp() {
|
|
|
70
57
|
' [--limit <n>] Cap result count (1-500, default 100).',
|
|
71
58
|
' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
|
|
72
59
|
' [--json] Pretty-print raw JSON instead of the table.',
|
|
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.',
|
|
62
|
+
' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
|
|
63
|
+
' kanban import <boardId> <file> Rebuild a board from a seed document (additive; never overwrites).',
|
|
64
|
+
' [--workspace <wsId>] Sanity-check the workspace bound to this session.',
|
|
73
65
|
' tileapp init <name> Scaffold a personal app (./<name>/tileapp.json + index.html).',
|
|
74
66
|
' tileapp validate <manifest> [opts] Offline lint: manifest schema + bundle layout (no auth).',
|
|
75
67
|
' tileapp media push <manifest> [--dir d] Upload store screenshots (additive — leaves the rest of the bundle alone).',
|
|
@@ -100,7 +92,8 @@ function printHelp() {
|
|
|
100
92
|
' mcp scopes [opts] Show mintable vs not-mintable MCP scopes for this session (pure read).',
|
|
101
93
|
' [--agent <agentId>] Agent identity to inspect (default: substrate-cli).',
|
|
102
94
|
' [--json] Emit {agentId, allowed, denied} as JSON.',
|
|
103
|
-
'
|
|
95
|
+
' preview <create|status|logs|stop> [opts] Manage branch-following previews.',
|
|
96
|
+
' serve <dir> [opts] Static file server.',
|
|
104
97
|
' [--port <n>] Port (default: $PORT, else 3000).',
|
|
105
98
|
' [--host <h>] Bind host (default: 0.0.0.0).',
|
|
106
99
|
' [--spa] Serve index.html for unmatched routes (SPA mode).',
|
|
@@ -112,7 +105,7 @@ function printHelp() {
|
|
|
112
105
|
' deploy status [--json] Project + release status (incl. pending approvals).',
|
|
113
106
|
' deploy logs [--tail] [--since <dur>] Recent logs; --tail streams NDJSON.',
|
|
114
107
|
' deploy rollback [releaseId] [--json] Repoint the project to a previous release.',
|
|
115
|
-
' --version Print
|
|
108
|
+
' --version Print CLI version.',
|
|
116
109
|
' --help Print this help.',
|
|
117
110
|
'',
|
|
118
111
|
'Distinct from:',
|
|
@@ -121,30 +114,6 @@ function printHelp() {
|
|
|
121
114
|
'',
|
|
122
115
|
].join('\n'));
|
|
123
116
|
}
|
|
124
|
-
function runPlanValidate(args) {
|
|
125
|
-
const file = args[0];
|
|
126
|
-
if (!file) {
|
|
127
|
-
process.stderr.write('yolo: plan validate requires a file path\n');
|
|
128
|
-
process.stderr.write('Usage: yolo plan validate <file>\n');
|
|
129
|
-
return 64; // EX_USAGE
|
|
130
|
-
}
|
|
131
|
-
let result;
|
|
132
|
-
try {
|
|
133
|
-
result = validatePlanFile(file);
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
137
|
-
process.stderr.write(`yolo: cannot read plan file '${file}': ${msg}\n`);
|
|
138
|
-
return 64;
|
|
139
|
-
}
|
|
140
|
-
if (result.ok) {
|
|
141
|
-
process.stdout.write(`OK: ${file} is canonical and schema-valid (planId=${result.planId}, ${result.bytes} bytes)\n`);
|
|
142
|
-
return 0;
|
|
143
|
-
}
|
|
144
|
-
process.stderr.write(`FAIL: ${file}\n`);
|
|
145
|
-
process.stderr.write(`${formatErrors(result.errors)}\n`);
|
|
146
|
-
return 1;
|
|
147
|
-
}
|
|
148
117
|
function tileAppUsage(sub, message) {
|
|
149
118
|
process.stderr.write(`yolo tileapp ${sub}: ${message}\n`);
|
|
150
119
|
const usage = {
|
|
@@ -169,7 +138,7 @@ async function runTileAppInstallCmd(args) {
|
|
|
169
138
|
const a = args[i];
|
|
170
139
|
// A following flag must never be consumed as a value (`--workspace
|
|
171
140
|
// --accept-optional=x`), so reject empty values and `--`-leading values —
|
|
172
|
-
//
|
|
141
|
+
// Reject flags in value positions.
|
|
173
142
|
if (a === '--workspace') {
|
|
174
143
|
const v = args[++i];
|
|
175
144
|
if (!v || v.startsWith('--'))
|
|
@@ -540,61 +509,6 @@ async function runTileAppDevCmd(args) {
|
|
|
540
509
|
}
|
|
541
510
|
return runTileAppDev({ manifestPath, port, host, bundleDir, allow });
|
|
542
511
|
}
|
|
543
|
-
function parseRunListArgs(args) {
|
|
544
|
-
let workspaceFlag;
|
|
545
|
-
let stateFilter;
|
|
546
|
-
let jsonOutput = false;
|
|
547
|
-
for (let i = 0; i < args.length; i++) {
|
|
548
|
-
const a = args[i];
|
|
549
|
-
if (a === '--workspace') {
|
|
550
|
-
const v = args[++i];
|
|
551
|
-
if (!v || v.startsWith('--'))
|
|
552
|
-
return { ok: false, message: '--workspace requires a value' };
|
|
553
|
-
workspaceFlag = v;
|
|
554
|
-
}
|
|
555
|
-
else if (a.startsWith('--workspace=')) {
|
|
556
|
-
workspaceFlag = a.slice('--workspace='.length);
|
|
557
|
-
}
|
|
558
|
-
else if (a === '--state') {
|
|
559
|
-
const v = args[++i];
|
|
560
|
-
if (!v || v.startsWith('--'))
|
|
561
|
-
return { ok: false, message: '--state requires a value' };
|
|
562
|
-
stateFilter = v;
|
|
563
|
-
}
|
|
564
|
-
else if (a.startsWith('--state=')) {
|
|
565
|
-
stateFilter = a.slice('--state='.length);
|
|
566
|
-
}
|
|
567
|
-
else if (a === '--json') {
|
|
568
|
-
jsonOutput = true;
|
|
569
|
-
}
|
|
570
|
-
else if (a.startsWith('--')) {
|
|
571
|
-
return { ok: false, message: `unknown option: ${a}` };
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
574
|
-
return { ok: false, message: `unexpected positional argument: ${a}` };
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return { ok: true, workspaceFlag, stateFilter, jsonOutput };
|
|
578
|
-
}
|
|
579
|
-
async function runRunListCmd(args) {
|
|
580
|
-
const parsed = parseRunListArgs(args);
|
|
581
|
-
if (!parsed.ok) {
|
|
582
|
-
process.stderr.write(`yolo: run list: ${parsed.message}\n`);
|
|
583
|
-
process.stderr.write('Usage: yolo run list [--workspace <wsId>] [--state <pending|running|paused|succeeded|failed|cancelled|superseded>] [--json]\n');
|
|
584
|
-
return 64;
|
|
585
|
-
}
|
|
586
|
-
const result = await runRunList({
|
|
587
|
-
workspaceFlag: parsed.workspaceFlag,
|
|
588
|
-
stateFilter: parsed.stateFilter,
|
|
589
|
-
outputFormat: parsed.jsonOutput ? 'json' : 'summary',
|
|
590
|
-
});
|
|
591
|
-
if (result.ok) {
|
|
592
|
-
process.stdout.write(`${result.output}\n`);
|
|
593
|
-
return 0;
|
|
594
|
-
}
|
|
595
|
-
process.stderr.write(`FAIL [${result.kind}]: ${result.message}\n`);
|
|
596
|
-
return runListExitCode(result.kind);
|
|
597
|
-
}
|
|
598
512
|
function parseArtifactGetArgs(args) {
|
|
599
513
|
let key;
|
|
600
514
|
let version;
|
|
@@ -781,32 +695,6 @@ async function main(argv) {
|
|
|
781
695
|
throw err;
|
|
782
696
|
}
|
|
783
697
|
}
|
|
784
|
-
if (cmd === 'plan') {
|
|
785
|
-
const sub = args[1];
|
|
786
|
-
if (sub === 'validate') {
|
|
787
|
-
return runPlanValidate(args.slice(2));
|
|
788
|
-
}
|
|
789
|
-
if (!sub) {
|
|
790
|
-
process.stderr.write('yolo: plan requires a subcommand (validate)\n');
|
|
791
|
-
return 64;
|
|
792
|
-
}
|
|
793
|
-
process.stderr.write(`yolo: unknown plan subcommand '${sub}'\n`);
|
|
794
|
-
process.stderr.write('Subcommands: validate\n');
|
|
795
|
-
return 64;
|
|
796
|
-
}
|
|
797
|
-
if (cmd === 'run') {
|
|
798
|
-
const sub = args[1];
|
|
799
|
-
if (sub === 'list') {
|
|
800
|
-
return runRunListCmd(args.slice(2));
|
|
801
|
-
}
|
|
802
|
-
if (!sub) {
|
|
803
|
-
process.stderr.write('yolo: run requires a subcommand (list)\n');
|
|
804
|
-
return 64;
|
|
805
|
-
}
|
|
806
|
-
process.stderr.write(`yolo: unknown run subcommand '${sub}'\n`);
|
|
807
|
-
process.stderr.write('Subcommands: list\n');
|
|
808
|
-
return 64;
|
|
809
|
-
}
|
|
810
698
|
if (cmd === 'artifact') {
|
|
811
699
|
const sub = args[1];
|
|
812
700
|
if (sub === 'get') {
|
|
@@ -849,6 +737,10 @@ async function main(argv) {
|
|
|
849
737
|
process.stderr.write('Subcommands: init, validate, dev, sign, publish, media, install, add-tile\n');
|
|
850
738
|
return 64;
|
|
851
739
|
}
|
|
740
|
+
if (cmd === 'kanban') {
|
|
741
|
+
const { runKanbanCmd } = await import('./kanban-cli.js');
|
|
742
|
+
return runKanbanCmd(args.slice(1));
|
|
743
|
+
}
|
|
852
744
|
if (cmd === 'mcp') {
|
|
853
745
|
const sub = args[1];
|
|
854
746
|
if (sub === 'scopes')
|
|
@@ -861,13 +753,17 @@ async function main(argv) {
|
|
|
861
753
|
process.stderr.write('Subcommands: scopes\n');
|
|
862
754
|
return 64;
|
|
863
755
|
}
|
|
756
|
+
if (cmd === 'preview') {
|
|
757
|
+
const { runPreviewCmd } = await import('./preview.js');
|
|
758
|
+
return runPreviewCmd(args.slice(1));
|
|
759
|
+
}
|
|
864
760
|
if (cmd === 'serve') {
|
|
865
761
|
const { runServeCmd } = await import('./serve.js');
|
|
866
762
|
return runServeCmd(args.slice(1));
|
|
867
763
|
}
|
|
868
764
|
if (cmd === 'deploy') {
|
|
869
765
|
// Lazy-load (serve precedent) so the deploy stack — incl. esbuild via
|
|
870
|
-
// deploy-bundle
|
|
766
|
+
// deploy-bundle is loaded only for hosting commands.
|
|
871
767
|
const { runDeployCmd } = await import('./deploy-cli.js');
|
|
872
768
|
return runDeployCmd(args.slice(1));
|
|
873
769
|
}
|
|
@@ -875,7 +771,9 @@ async function main(argv) {
|
|
|
875
771
|
printHelp();
|
|
876
772
|
return 64; // EX_USAGE
|
|
877
773
|
}
|
|
878
|
-
|
|
774
|
+
// Never `process.exit()` straight after writing: output to a pipe is async and
|
|
775
|
+
// would be cut at the 64 KiB pipe buffer (see ./exit.ts).
|
|
776
|
+
main(process.argv).then((code) => exitAfterFlush(code), (err) => {
|
|
879
777
|
process.stderr.write(`yolo: unexpected error: ${err?.message ?? err}\n`);
|
|
880
|
-
|
|
778
|
+
exitAfterFlush(1);
|
|
881
779
|
});
|
package/dist/deploy-client.js
CHANGED
|
@@ -93,21 +93,11 @@ export async function uploadAssetBucket(ctx, projectId, shipId, files) {
|
|
|
93
93
|
* | 410 upload-expired (ship session lapsed → rerun)
|
|
94
94
|
*/
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* forward them and the server stamps release PROVENANCE — letting an auditor
|
|
99
|
-
* walk a live URL back to the run that shipped it. These are CLIENT-ASSERTED
|
|
100
|
-
* over the user JWT (NOT cryptographically bound like the MCP token path), so
|
|
101
|
-
* the server records them as `source: 'cli-env'`: unverified audit metadata,
|
|
102
|
-
* never authorizing. Omitted entirely for an interactive `yolo deploy` run
|
|
103
|
-
* outside a lane (none of the vars set).
|
|
96
|
+
* Caller-reported session provenance for hosting audit metadata.
|
|
97
|
+
* This header never authorizes a deployment or rollback.
|
|
104
98
|
*/
|
|
105
|
-
export function
|
|
99
|
+
export function sessionContextHeaders(env) {
|
|
106
100
|
const headers = {};
|
|
107
|
-
if (env.YOLO_RUN_PLAN_ID)
|
|
108
|
-
headers['X-Yolo-Run-Plan-Id'] = env.YOLO_RUN_PLAN_ID;
|
|
109
|
-
if (env.YOLO_RUN_STEP_RUN_ID)
|
|
110
|
-
headers['X-Yolo-Run-Step-Run-Id'] = env.YOLO_RUN_STEP_RUN_ID;
|
|
111
101
|
if (env.SESSION_ID)
|
|
112
102
|
headers['X-Yolo-Session-Id'] = env.SESSION_ID;
|
|
113
103
|
return headers;
|
|
@@ -127,14 +117,14 @@ export async function finalizeShip(ctx, projectId, shipId, modules = [], sourceM
|
|
|
127
117
|
if (!fetchImpl)
|
|
128
118
|
return noFetchFailure();
|
|
129
119
|
const url = `${stripTrailingSlash(ctx.commonApiUrl)}/v1/deploy/projects/${enc(projectId)}/ship/${enc(shipId)}/finalize`;
|
|
130
|
-
//
|
|
131
|
-
const
|
|
120
|
+
// Optional session provenance for the hosting audit record.
|
|
121
|
+
const requestHeaders = sessionContextHeaders(ctx.env);
|
|
132
122
|
// Resume-after-grant: the pending-store rerun redeems the operator's grant
|
|
133
123
|
// explicitly (x-approval-id → approvalNonce server-side), which yields crisp
|
|
134
124
|
// approval-pending/-denied/-expired outcomes instead of the nonce-less
|
|
135
125
|
// retry-redeem's blended ones.
|
|
136
126
|
if (opts.approvalId)
|
|
137
|
-
|
|
127
|
+
requestHeaders['x-approval-id'] = opts.approvalId;
|
|
138
128
|
let response;
|
|
139
129
|
try {
|
|
140
130
|
if (modules.length > 0) {
|
|
@@ -150,14 +140,14 @@ export async function finalizeShip(ctx, projectId, shipId, modules = [], sourceM
|
|
|
150
140
|
// No explicit Content-Type — fetch sets the multipart boundary itself.
|
|
151
141
|
response = await fetchImpl(url, {
|
|
152
142
|
method: 'POST',
|
|
153
|
-
headers: { Authorization: `Bearer ${token}`, ...
|
|
143
|
+
headers: { Authorization: `Bearer ${token}`, ...requestHeaders },
|
|
154
144
|
body: form,
|
|
155
145
|
});
|
|
156
146
|
}
|
|
157
147
|
else {
|
|
158
148
|
response = await fetchImpl(url, {
|
|
159
149
|
method: 'POST',
|
|
160
|
-
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', ...
|
|
150
|
+
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', ...requestHeaders },
|
|
161
151
|
body: JSON.stringify({}),
|
|
162
152
|
});
|
|
163
153
|
}
|
|
@@ -238,12 +228,12 @@ export async function listProjects(ctx) {
|
|
|
238
228
|
}
|
|
239
229
|
/** POST /v1/deploy/projects/:id/rollback */
|
|
240
230
|
export async function rollbackProject(ctx, projectId, request = {}) {
|
|
241
|
-
// Rollback is a prod re-activation — forward
|
|
231
|
+
// Rollback is a prod re-activation — forward session context so the server can
|
|
242
232
|
// stamp `rollback.provenance` (same audit basis as a ship's finalize leg).
|
|
243
233
|
return jsonLeg(ctx, `/deploy/projects/${enc(projectId)}/rollback`, {
|
|
244
234
|
method: 'POST',
|
|
245
235
|
jsonBody: request,
|
|
246
|
-
headers:
|
|
236
|
+
headers: sessionContextHeaders(ctx.env),
|
|
247
237
|
});
|
|
248
238
|
}
|
|
249
239
|
/** POST /v1/deploy/projects/:id/unpublish — take a live project offline (reversible). */
|
package/dist/deploy-config.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* is the session JWT; `projectId` is non-secret and ownership-checked
|
|
10
10
|
* server-side on every call.
|
|
11
11
|
*
|
|
12
|
-
* Canonical write shape
|
|
12
|
+
* Canonical write shape:
|
|
13
13
|
* - JSON, 2-space indent, single trailing `\n`.
|
|
14
14
|
* - Fixed key order per the spec example: $version, projectId, slug,
|
|
15
15
|
* type, build{command,outputDir}, worker{entry,assetsDir},
|
|
@@ -305,8 +305,7 @@ function collectUnknownKeyWarnings(obj) {
|
|
|
305
305
|
/**
|
|
306
306
|
* Reorder to the spec's fixed key order, omitting absent optionals.
|
|
307
307
|
* Binding entries keep `kind`, `binding` first; extra hint keys follow
|
|
308
|
-
*
|
|
309
|
-
* free-form maps). Pure — does not mutate input.
|
|
308
|
+
* in lexicographic order. Pure — does not mutate input.
|
|
310
309
|
*/
|
|
311
310
|
function canonicalize(config) {
|
|
312
311
|
const out = { $version: 1 };
|
package/dist/exit.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit only after stdout and stderr have flushed.
|
|
3
|
+
*
|
|
4
|
+
* When stdout is a pipe (`yolo kanban export <tile> | jq`), Node writes to it
|
|
5
|
+
* asynchronously, and `process.exit()` drops whatever the kernel pipe buffer
|
|
6
|
+
* (64 KiB on Linux) has not accepted yet: a large export arrived as exactly
|
|
7
|
+
* 65,536 bytes of truncated JSON, with exit status 0. A file or TTY is written
|
|
8
|
+
* synchronously, which is why `-o <file>` was unaffected.
|
|
9
|
+
*
|
|
10
|
+
* A zero-length write's callback runs after every earlier write on that
|
|
11
|
+
* stream has been handed to the OS, so exiting from both callbacks loses
|
|
12
|
+
* nothing. The explicit exit is kept (rather than just setting exitCode)
|
|
13
|
+
* because some commands can leave handles open that would otherwise keep the
|
|
14
|
+
* process alive.
|
|
15
|
+
*/
|
|
16
|
+
export function exitAfterFlush(code, streams = [process.stdout, process.stderr], exit = (c) => process.exit(c)) {
|
|
17
|
+
process.exitCode = code;
|
|
18
|
+
let pending = streams.length;
|
|
19
|
+
if (pending === 0) {
|
|
20
|
+
exit(code);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const settle = () => { if (--pending === 0)
|
|
24
|
+
exit(code); };
|
|
25
|
+
for (const stream of streams) {
|
|
26
|
+
// A destroyed or errored stream (e.g. the reader closed the pipe) never
|
|
27
|
+
// calls back; treat it as flushed rather than hanging the process.
|
|
28
|
+
if (stream.destroyed || !stream.writable) {
|
|
29
|
+
settle();
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
stream.write('', settle);
|
|
33
|
+
}
|
|
34
|
+
}
|