@yolo-labs/yolo-cli 0.34.0 → 0.36.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/cli.js CHANGED
@@ -754,7 +754,7 @@ function tileAppUsage(sub, message) {
754
754
  sign: 'Usage: yolo tileapp sign <manifest.json> --publisher <id> [--key <keyId>] [--stdout]\n',
755
755
  publish: 'Usage: yolo tileapp publish <manifest.json> --personal [--bundle-dir <dir>] [--context <dir>] [--dockerfile <f>] [--builder auto|podman|skopeo] (personal app)\n'
756
756
  + ' or: yolo tileapp publish <manifest.json> [--channel beta|stable] [--image-digest <d>] (marketplace)\n',
757
- validate: 'Usage: yolo tileapp validate <manifest.json> [--bundle-dir <dir>]\n',
757
+ validate: 'Usage: yolo tileapp validate <manifest.json> [--bundle-dir <dir>] [--personal]\n',
758
758
  dev: 'Usage: yolo tileapp dev <manifest.json> [--port N] [--host H] [--bundle-dir <dir>] [--deny]\n',
759
759
  install: 'Usage: yolo tileapp install <appId> --workspace <workspaceId> [--accept-optional <perm>]...\n',
760
760
  'add-tile': 'Usage: yolo tileapp add-tile <appId> --workspace <workspaceId> [--name <name>] [--version <v>]\n',
@@ -1044,6 +1044,7 @@ async function runTileAppValidateCmd(args) {
1044
1044
  const { runTileAppValidate, devExitCode } = await import('./tileapp-developer.js');
1045
1045
  let manifestPath;
1046
1046
  let bundleDir;
1047
+ let personal = false;
1047
1048
  for (let i = 0; i < args.length; i++) {
1048
1049
  const a = args[i];
1049
1050
  if (a === '--bundle-dir') {
@@ -1051,6 +1052,9 @@ async function runTileAppValidateCmd(args) {
1051
1052
  if (bundleDir === undefined)
1052
1053
  return tileAppUsage('validate', '--bundle-dir requires a value');
1053
1054
  }
1055
+ else if (a === '--personal') {
1056
+ personal = true;
1057
+ }
1054
1058
  else if (!a.startsWith('-') && !manifestPath)
1055
1059
  manifestPath = a;
1056
1060
  else
@@ -1058,7 +1062,7 @@ async function runTileAppValidateCmd(args) {
1058
1062
  }
1059
1063
  if (!manifestPath)
1060
1064
  return tileAppUsage('validate', 'a manifest path is required');
1061
- const result = runTileAppValidate({ manifestPath, bundleDir });
1065
+ const result = runTileAppValidate({ manifestPath, bundleDir, personal });
1062
1066
  if (result.ok) {
1063
1067
  process.stdout.write(`${result.output}\n`);
1064
1068
  return 0;
@@ -110,7 +110,11 @@ export function runTileAppValidate(opts) {
110
110
  const read = readManifestFile(opts.manifestPath);
111
111
  if (!read.ok)
112
112
  return { ok: false, kind: 'io', message: read.message };
113
- const v = validateManifest(read.manifest);
113
+ // A runtime personal app publishes an OCI archive and gets no R2 bundle, so
114
+ // only a PURE-UI personal manifest may use the `media/<file>` ref form.
115
+ const v = validateManifest(read.manifest, {
116
+ allowPlatformHostedScreenshots: !!opts.personal && !isRuntimeManifest(read.manifest),
117
+ });
114
118
  const errors = [...v.errors, ...publishGateErrors(read.manifest)];
115
119
  // A non-object manifest is fully reported by validateManifest; bail before the
116
120
  // bundle/runtime checks (which deref manifest fields) so we never crash on it.
@@ -156,19 +156,47 @@ export function runTileAppInit(opts) {
156
156
 
157
157
  const status = document.getElementById('status');
158
158
  if (status) status.textContent = 'Ready — edit app.js to build your app.';
159
+ `;
160
+ // Store screenshots live in `media/`. Scaffolding the directory (with a
161
+ // README, since an empty dir wouldn't survive and a dotfile is skipped by
162
+ // both the collector and the server) is what makes the feature discoverable
163
+ // — an author who never learns the folder exists ships a listing with no
164
+ // preview and no idea one was possible.
165
+ const mediaReadme = `# Store screenshots
166
+
167
+ Drop screenshots here, then reference them from tileapp.json:
168
+
169
+ "screenshots": ["media/01-main.webp"]
170
+
171
+ \`yolo tileapp publish tileapp.json --personal\` walks this directory and
172
+ uploads whatever is in it; the platform serves each file at
173
+ /v1/tileapps/<appId>/media/<file>.
174
+
175
+ format 1280x800 (16:10) webp, <= 400 KB each, 1-6 images, first is the hero
176
+ capture render at 2x and downscale — the store card crops to ~320px wide
177
+ content show the app doing its job on realistic data; an empty state or a
178
+ permission prompt is a wasted slot
179
+ budget bundles cap at 100 files / 3 MB total
180
+
181
+ An absolute https:// URL works too, and is the ONLY option for a runtime app
182
+ (it publishes an image, not a bundle, so it has nowhere to put these).
183
+
184
+ Check refs before publishing: yolo tileapp validate tileapp.json --personal
159
185
  `;
160
186
  try {
161
187
  fs.mkdirSync(dir, { recursive: false });
162
188
  fs.writeFileSync(path.join(dir, 'tileapp.json'), `${JSON.stringify(manifest, null, 2)}\n`);
163
189
  fs.writeFileSync(path.join(dir, 'index.html'), indexHtml);
164
190
  fs.writeFileSync(path.join(dir, 'app.js'), appJs);
191
+ fs.mkdirSync(path.join(dir, 'media'), { recursive: false });
192
+ fs.writeFileSync(path.join(dir, 'media', 'README.md'), mediaReadme);
165
193
  }
166
194
  catch (e) {
167
195
  return { ok: false, kind: 'io', message: `scaffold failed: ${e.message}` };
168
196
  }
169
197
  return {
170
198
  ok: true,
171
- output: `Created ${name}/ (tileapp.json + index.html + app.js)\n note: bundle CSP is \`script-src 'self'\` — keep JS in app.js (no inline <script>, no eval, no network)\n next: cd ${name} && yolo tileapp publish tileapp.json --personal`,
199
+ output: `Created ${name}/ (tileapp.json + index.html + app.js + media/)\n note: bundle CSP is \`script-src 'self'\` — keep JS in app.js (no inline <script>, no eval, no network)\n note: drop a 1280x800 webp in media/ and add \`"screenshots": ["media/01-main.webp"]\` to get a store preview (see media/README.md)\n next: cd ${name} && yolo tileapp publish tileapp.json --personal`,
172
200
  };
173
201
  }
174
202
  /** Recursively collect a bundle dir's files as upload entries. Skips VCS/dep
@@ -255,7 +283,9 @@ export async function runTileAppPublishPersonal(opts) {
255
283
  });
256
284
  }
257
285
  // Pure-UI path: strict schema lint (the server re-validates authoritatively).
258
- const v = validateManifest(read.manifest);
286
+ // This IS the path that gets an R2 bundle, so the `media/<file>` screenshot
287
+ // form is available to it — see ScreenshotRefOptions.
288
+ const v = validateManifest(read.manifest, { allowPlatformHostedScreenshots: true });
259
289
  if (v.errors.length > 0) {
260
290
  return { ok: false, kind: 'validation', message: `manifest invalid:\n - ${v.errors.join('\n - ')}` };
261
291
  }
@@ -15,6 +15,74 @@
15
15
  * confirmed authoritatively at publish — `validate` says so in its output.
16
16
  */
17
17
  const ID_RE = /^[a-z0-9][a-z0-9-]{1,63}$/;
18
+ // ── Store screenshots ───────────────────────────────────────────────────────
19
+ // Mirror of `common-api/src/types/tileapp-screenshots.ts`. The rules a
20
+ // publisher needs BEFORE uploading (count, ref form, extension) are checked
21
+ // here so `yolo tileapp validate` catches them offline; the dimension/content
22
+ // rules that need the image bytes are in
23
+ // `docs/TILEAPP_SCREENSHOT_GUIDELINES.md` and checked at review.
24
+ //
25
+ // 🚨 This file mirrors the server's PUBLISH-time validator
26
+ // (`validateManifestForPublish`), NOT its read-time one. The server splits the
27
+ // two on purpose: on the read path a validation failure SKIPS the app and it
28
+ // vanishes from the store, so `validateManifest` there checks structure only.
29
+ // The CLI is a publish lint, so strict is correct here — but don't "sync" the
30
+ // server's looser read-time rules back into this file.
31
+ const MAX_SCREENSHOTS = 6;
32
+ const SCREENSHOT_EXTENSIONS = ['.webp', '.png'];
33
+ const RELATIVE_SCREENSHOT_RE = /^media\/[a-z0-9][a-z0-9._-]*$/;
34
+ function hasAllowedScreenshotExt(pathname) {
35
+ const lower = pathname.toLowerCase();
36
+ return SCREENSHOT_EXTENSIONS.some((ext) => lower.endsWith(ext));
37
+ }
38
+ function validateScreenshotRef(ref, opts = {}) {
39
+ if (typeof ref !== 'string' || ref.length === 0)
40
+ return 'must be a non-empty string';
41
+ if (ref.length > 500)
42
+ return 'must be at most 500 characters';
43
+ if (/^https:\/\//i.test(ref)) {
44
+ let url;
45
+ try {
46
+ url = new URL(ref);
47
+ }
48
+ catch {
49
+ return `is not a valid URL: ${ref}`;
50
+ }
51
+ if (!hasAllowedScreenshotExt(url.pathname))
52
+ return `must end in ${SCREENSHOT_EXTENSIONS.join(' or ')}: ${ref}`;
53
+ return null;
54
+ }
55
+ // `media/<file>` is the PLATFORM-HOSTED form — valid only for a publishing
56
+ // path that actually has a store behind it (a pure-UI personal app's R2
57
+ // bundle). See ScreenshotRefOptions.
58
+ if (!opts.allowPlatformHostedScreenshots) {
59
+ return `must be an absolute https:// URL — the "media/<file>" form requires platform-hosted storage, which this publishing path does not have. Host the image and reference it by URL. Got: ${ref}`;
60
+ }
61
+ if (/^[a-z][a-z0-9+.-]*:/i.test(ref))
62
+ return `must be an https:// URL or a "media/<file>" path, got: ${ref}`;
63
+ if (!RELATIVE_SCREENSHOT_RE.test(ref)) {
64
+ return `relative refs must look like "media/<file>" with no subdirectories, got: ${ref}`;
65
+ }
66
+ if (!hasAllowedScreenshotExt(ref))
67
+ return `must end in ${SCREENSHOT_EXTENSIONS.join(' or ')}: ${ref}`;
68
+ return null;
69
+ }
70
+ function validateScreenshots(refs, opts = {}) {
71
+ if (refs === undefined)
72
+ return [];
73
+ if (!Array.isArray(refs))
74
+ return ['screenshots must be an array of strings when present'];
75
+ if (refs.length > MAX_SCREENSHOTS) {
76
+ return [`screenshots may list at most ${MAX_SCREENSHOTS} images (got ${refs.length})`];
77
+ }
78
+ const errors = [];
79
+ for (const ref of refs) {
80
+ const err = validateScreenshotRef(ref, opts);
81
+ if (err)
82
+ errors.push(`screenshots entry ${err}`);
83
+ }
84
+ return errors;
85
+ }
18
86
  const SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+].+)?$/;
19
87
  function isObj(v) {
20
88
  return typeof v === 'object' && v !== null && !Array.isArray(v);
@@ -79,7 +147,7 @@ export function parsePermissionShape(raw) {
79
147
  * (not fail-fast) so the author sees all problems at once — matching the
80
148
  * server. Returns `{ ok, errors }`.
81
149
  */
82
- export function validateManifest(raw) {
150
+ export function validateManifest(raw, opts = {}) {
83
151
  const errors = [];
84
152
  if (!isObj(raw))
85
153
  return { ok: false, errors: ['manifest is not an object'] };
@@ -174,9 +242,7 @@ export function validateManifest(raw) {
174
242
  }
175
243
  if (raw.category !== undefined && !isStr(raw.category))
176
244
  errors.push('category must be a string when present');
177
- if (raw.screenshots !== undefined && (!Array.isArray(raw.screenshots) || !raw.screenshots.every(isStr))) {
178
- errors.push('screenshots must be an array of strings when present');
179
- }
245
+ errors.push(...validateScreenshots(raw.screenshots, opts));
180
246
  if (raw.changelog !== undefined && !isStr(raw.changelog))
181
247
  errors.push('changelog must be a string when present');
182
248
  if (raw.featured !== undefined && typeof raw.featured !== 'boolean')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yolo-labs/yolo-cli",
3
- "version": "0.34.0",
4
- "description": "YOLO Studio substrate CLI — owns yolo plan/workspace/artifact substrate-tooling commands. Distinct from yolo-code (the agent CLI) and yolo-router (the LLM gateway client).",
3
+ "version": "0.36.0",
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",
7
7
  "bin": {