vibedgames 0.4.0 → 0.5.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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/credits.js +7 -18
  3. package/dist/commands/deploy.d.ts +8 -0
  4. package/dist/commands/deploy.js +58 -31
  5. package/dist/commands/fork.js +30 -24
  6. package/dist/commands/generate.js +69 -45
  7. package/dist/commands/init.js +29 -24
  8. package/dist/commands/login.js +2 -2
  9. package/dist/commands/new.d.ts +1 -1
  10. package/dist/commands/new.js +82 -62
  11. package/dist/commands/playtest.d.ts +12 -0
  12. package/dist/commands/playtest.js +36 -2
  13. package/dist/commands/update.js +19 -14
  14. package/dist/commands/whoami.d.ts +10 -1
  15. package/dist/commands/whoami.js +12 -5
  16. package/dist/index.js +2 -0
  17. package/dist/lib/api.d.ts +16 -4
  18. package/dist/lib/api.js +22 -28
  19. package/dist/lib/archive.js +8 -4
  20. package/dist/lib/codex.d.ts +3 -2
  21. package/dist/lib/codex.js +8 -7
  22. package/dist/lib/config-file.js +6 -5
  23. package/dist/lib/config.js +11 -1
  24. package/dist/lib/manifest.js +3 -3
  25. package/dist/lib/media-args.d.ts +4 -2
  26. package/dist/lib/media-args.js +6 -5
  27. package/dist/lib/media-download.d.ts +6 -1
  28. package/dist/lib/media-download.js +54 -10
  29. package/dist/lib/media-poll.d.ts +3 -2
  30. package/dist/lib/media-poll.js +11 -10
  31. package/dist/lib/media-upload.d.ts +1 -1
  32. package/dist/lib/media-upload.js +5 -4
  33. package/dist/lib/output.d.ts +12 -4
  34. package/dist/lib/output.js +11 -3
  35. package/dist/lib/package-manager.js +1 -1
  36. package/dist/lib/run.d.ts +9 -1
  37. package/dist/lib/run.js +8 -3
  38. package/dist/lib/strict-args.d.ts +27 -0
  39. package/dist/lib/strict-args.js +68 -0
  40. package/dist/lib/types.d.ts +16 -2
  41. package/dist/lib/types.js +12 -3
  42. package/dist/lib/update.js +8 -5
  43. package/package.json +16 -17
  44. package/LICENSE +0 -21
package/README.md CHANGED
@@ -64,7 +64,7 @@ of failing with a bare exit code.
64
64
  installed as a platform-specific optional package on first use — the CLI itself
65
65
  carries none of it.
66
66
 
67
- `vg generate` calls the `generate.forward` tRPC proc — the server holds the
67
+ `vg generate` calls the `generate.forward` proc — the server holds the
68
68
  provider API key, so generation works for any logged-in user with no local keys.
69
69
 
70
70
  ## Using with a coding agent
@@ -1,8 +1,10 @@
1
1
  import { defineCommand } from "citty";
2
2
  import consola from "consola";
3
- import { createClient } from "../lib/api.js";
3
+ import { authErrorCode, createClient } from "../lib/api.js";
4
4
  import { getToken } from "../lib/config.js";
5
5
  import { outputArgs, writeStructured } from "../lib/output.js";
6
+ import { assertKnownFlags } from "../lib/strict-args.js";
7
+ const creditsArgs = { ...outputArgs };
6
8
  const MICRO_PER_USD = 1_000_000;
7
9
  const SUB_CENT_MICRO = MICRO_PER_USD / 100;
8
10
  const MAX_ENTRIES_SHOWN = 15;
@@ -51,27 +53,14 @@ function formatWhen(date, now) {
51
53
  opts.year = "numeric";
52
54
  return date.toLocaleDateString("en-US", opts);
53
55
  }
54
- function authErrorCode(err) {
55
- if (typeof err === "object" && err !== null && "data" in err) {
56
- const data = err.data;
57
- if (typeof data === "object" &&
58
- data !== null &&
59
- "code" in data &&
60
- typeof data.code === "string") {
61
- return data.code;
62
- }
63
- }
64
- return null;
65
- }
66
56
  export const creditsCommand = defineCommand({
67
57
  meta: {
68
58
  name: "credits",
69
59
  description: "Show your credit balance and recent usage.",
70
60
  },
71
- args: {
72
- ...outputArgs,
73
- },
74
- run: async ({ args }) => {
61
+ args: creditsArgs,
62
+ run: async ({ args, rawArgs }) => {
63
+ assertKnownFlags(rawArgs, creditsArgs);
75
64
  const token = getToken();
76
65
  if (!token) {
77
66
  consola.warn("Not logged in. Run `vg login` to authenticate.");
@@ -79,7 +68,7 @@ export const creditsCommand = defineCommand({
79
68
  }
80
69
  const client = createClient();
81
70
  try {
82
- const { balanceMicro, entries } = await client.credits.me.query();
71
+ const { balanceMicro, entries } = await client.credits.me();
83
72
  const payload = {
84
73
  balance_micro: balanceMicro,
85
74
  balance_usd: balanceMicro / MICRO_PER_USD,
@@ -1,4 +1,12 @@
1
1
  export declare const deployCommand: import("citty").CommandDef<{
2
+ readonly json: {
3
+ readonly type: "boolean";
4
+ readonly description: "Print structured JSON to stdout.";
5
+ };
6
+ readonly field: {
7
+ readonly type: "string";
8
+ readonly description: "Print a single value from the JSON result, e.g. --field request_id or --field images[0].url. Prints scalars bare for shell capture.";
9
+ };
2
10
  readonly dir: {
3
11
  readonly type: "positional";
4
12
  readonly description: "Directory to deploy";
@@ -7,31 +7,41 @@ import { createClient } from "../lib/api.js";
7
7
  import { packSource } from "../lib/archive.js";
8
8
  import { findProjectRoot, projectConfigPath, readProjectConfig, writeProjectConfig, SLUG_RE, } from "../lib/config-file.js";
9
9
  import { buildManifest } from "../lib/manifest.js";
10
+ import { isJsonOutput, outputArgs, writeStructured } from "../lib/output.js";
11
+ import { assertKnownFlags } from "../lib/strict-args.js";
12
+ import { isJsonString } from "../lib/types.js";
10
13
  import { uploadAll } from "../lib/upload.js";
14
+ const deployArgs = {
15
+ dir: {
16
+ type: "positional",
17
+ description: "Directory to deploy",
18
+ required: false,
19
+ default: ".",
20
+ },
21
+ slug: {
22
+ type: "string",
23
+ description: "Override the slug (bypasses vibedgames.json)",
24
+ required: false,
25
+ },
26
+ source: {
27
+ type: "boolean",
28
+ description: "Also upload a forkable source archive, letting anyone logged in fork the project.",
29
+ default: false,
30
+ },
31
+ ...outputArgs,
32
+ };
11
33
  export const deployCommand = defineCommand({
12
34
  meta: {
13
35
  name: "deploy",
14
36
  description: "Deploy a game to vibedgames",
15
37
  },
16
- args: {
17
- dir: {
18
- type: "positional",
19
- description: "Directory to deploy",
20
- required: false,
21
- default: ".",
22
- },
23
- slug: {
24
- type: "string",
25
- description: "Override the slug (bypasses vibedgames.json)",
26
- required: false,
27
- },
28
- source: {
29
- type: "boolean",
30
- description: "Also upload a forkable source archive, letting anyone logged in fork the project.",
31
- default: false,
32
- },
33
- },
34
- run: async ({ args }) => {
38
+ args: deployArgs,
39
+ run: async ({ args, rawArgs }) => {
40
+ assertKnownFlags(rawArgs, deployArgs);
41
+ // Progress narration shares stdout with the payload, so it has to go quiet
42
+ // whenever stdout is the result rather than a story about it.
43
+ const structured = isJsonOutput(args) || Boolean(args.field);
44
+ const say = structured ? () => { } : (message) => consola.info(message);
35
45
  const dir = resolve(args.dir);
36
46
  if (!existsSync(dir)) {
37
47
  consola.error(`Directory does not exist: ${dir}`);
@@ -47,7 +57,7 @@ export const deployCommand = defineCommand({
47
57
  for (const name of ["dist", "build", "out"]) {
48
58
  if (existsSync(join(dir, name, "index.html"))) {
49
59
  deployDir = join(dir, name);
50
- consola.info(`Project root detected — deploying its build output ${name}/ instead.`);
60
+ say(`Project root detected — deploying its build output ${name}/ instead.`);
51
61
  break;
52
62
  }
53
63
  }
@@ -75,18 +85,21 @@ export const deployCommand = defineCommand({
75
85
  " Example: vg deploy ./dist --slug my-game");
76
86
  process.exit(1);
77
87
  }
88
+ // isJsonString: consola.prompt is typed to resolve a string but can
89
+ // resolve a cancel sentinel at runtime, and a symbol would throw
90
+ // inside RegExp.test.
78
91
  const slug = await consola.prompt("Slug (e.g. pong):", { type: "text" });
79
- if (typeof slug !== "string" || !SLUG_RE.test(slug)) {
92
+ if (!isJsonString(slug) || !SLUG_RE.test(slug)) {
80
93
  consola.error("Invalid slug. Use lowercase letters, digits, hyphens.");
81
94
  process.exit(1);
82
95
  }
83
96
  const name = await consola.prompt("Name (optional):", { type: "text" });
84
97
  config = {
85
98
  slug,
86
- name: typeof name === "string" && name.length > 0 ? name : undefined,
99
+ name: isJsonString(name) && name.length > 0 ? name : undefined,
87
100
  };
88
101
  writeProjectConfig(dir, config);
89
- consola.info(`Wrote ${projectConfigPath(dir)}`);
102
+ say(`Wrote ${projectConfigPath(dir)}`);
90
103
  }
91
104
  if (!SLUG_RE.test(config.slug)) {
92
105
  consola.error(`Invalid slug in vibedgames.json: ${config.slug}`);
@@ -104,7 +117,7 @@ export const deployCommand = defineCommand({
104
117
  process.exit(1);
105
118
  }
106
119
  const totalBytes = manifest.reduce((acc, f) => acc + f.size, 0);
107
- consola.info(`Deploying ${config.slug}: ${manifest.length} files, ${formatBytes(totalBytes)}`);
120
+ say(`Deploying ${config.slug}: ${manifest.length} files, ${formatBytes(totalBytes)}`);
108
121
  // ---- Pack forkable source (opt-in: source is a publish, --source) -------
109
122
  let sourceArchive = null;
110
123
  if (args.source) {
@@ -115,7 +128,7 @@ export const deployCommand = defineCommand({
115
128
  else {
116
129
  try {
117
130
  sourceArchive = await packSource(root, join(tmpdir(), "vibedgames"));
118
- consola.info(`Source: ${sourceArchive.files.length} files, ${formatBytes(sourceArchive.bytes)} — forkable via \`vg fork ${config.slug}\``);
131
+ say(`Source: ${sourceArchive.files.length} files, ${formatBytes(sourceArchive.bytes)} — forkable via \`vg fork ${config.slug}\``);
119
132
  }
120
133
  catch (err) {
121
134
  consola.error(`Source archive failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -128,7 +141,7 @@ export const deployCommand = defineCommand({
128
141
  const started = Date.now();
129
142
  let created;
130
143
  try {
131
- created = await client.deploy.create.mutate({
144
+ created = await client.deploy.create({
132
145
  slug: config.slug,
133
146
  name: config.name,
134
147
  files: manifest.map((f) => ({
@@ -149,14 +162,15 @@ export const deployCommand = defineCommand({
149
162
  process.exit(1);
150
163
  }
151
164
  // ---- Upload to R2 -------------------------------------------------------
152
- consola.start(`Uploading ${created.uploads.length} files`);
165
+ if (!structured)
166
+ consola.start(`Uploading ${created.uploads.length} files`);
153
167
  try {
154
168
  await uploadAll({
155
169
  files: manifest,
156
170
  uploads: created.uploads,
157
171
  onProgress: (done, total) => {
158
172
  if (done === total || done % 10 === 0) {
159
- consola.info(`Uploaded ${done}/${total}`);
173
+ say(`Uploaded ${done}/${total}`);
160
174
  }
161
175
  },
162
176
  });
@@ -192,7 +206,7 @@ export const deployCommand = defineCommand({
192
206
  // ---- Finalize -----------------------------------------------------------
193
207
  let finalized;
194
208
  try {
195
- finalized = await client.deploy.finalize.mutate({
209
+ finalized = await client.deploy.finalize({
196
210
  deploymentId: created.deploymentId,
197
211
  });
198
212
  }
@@ -200,8 +214,21 @@ export const deployCommand = defineCommand({
200
214
  consola.error(err instanceof Error ? err.message : String(err));
201
215
  process.exit(1);
202
216
  }
203
- const elapsed = ((Date.now() - started) / 1000).toFixed(1);
204
- consola.success(`Deployed ${config.slug} in ${elapsed}s`);
217
+ const elapsedMs = Date.now() - started;
218
+ if (writeStructured({
219
+ slug: config.slug,
220
+ url: finalized.url,
221
+ deployment_id: created.deploymentId,
222
+ files: manifest.length,
223
+ bytes: totalBytes,
224
+ source: sourceArchive
225
+ ? { files: sourceArchive.files.length, bytes: sourceArchive.bytes }
226
+ : null,
227
+ elapsed_ms: elapsedMs,
228
+ }, args)) {
229
+ return;
230
+ }
231
+ consola.success(`Deployed ${config.slug} in ${(elapsedMs / 1000).toFixed(1)}s`);
205
232
  consola.log(` ${finalized.url}`);
206
233
  },
207
234
  });
@@ -7,34 +7,38 @@ import { createClient } from "../lib/api.js";
7
7
  import { extractSource } from "../lib/archive.js";
8
8
  import { SLUG_RE } from "../lib/config-file.js";
9
9
  import { isJsonOutput, outputArgs, writeStructured } from "../lib/output.js";
10
+ import { assertKnownFlags } from "../lib/strict-args.js";
11
+ import { isJsonObject } from "../lib/types.js";
12
+ const forkArgs = {
13
+ slug: {
14
+ type: "positional",
15
+ description: "Slug of the project to fork (e.g. bomberman).",
16
+ required: true,
17
+ },
18
+ target: {
19
+ type: "positional",
20
+ description: "New slug + directory for the fork. Defaults to <slug>-fork.",
21
+ required: false,
22
+ },
23
+ name: {
24
+ type: "string",
25
+ description: "Display name for the fork (defaults to the target slug).",
26
+ },
27
+ force: {
28
+ type: "boolean",
29
+ description: "Overwrite the target directory if it exists.",
30
+ default: false,
31
+ },
32
+ ...outputArgs,
33
+ };
10
34
  export const forkCommand = defineCommand({
11
35
  meta: {
12
36
  name: "fork",
13
37
  description: "Fork another project's source so you can build on it. Downloads the source a project shipped with `vg deploy`, extracts it locally, and rewrites it to a new slug.",
14
38
  },
15
- args: {
16
- slug: {
17
- type: "positional",
18
- description: "Slug of the project to fork (e.g. bomberman).",
19
- required: true,
20
- },
21
- target: {
22
- type: "positional",
23
- description: "New slug + directory for the fork. Defaults to <slug>-fork.",
24
- required: false,
25
- },
26
- name: {
27
- type: "string",
28
- description: "Display name for the fork (defaults to the target slug).",
29
- },
30
- force: {
31
- type: "boolean",
32
- description: "Overwrite the target directory if it exists.",
33
- default: false,
34
- },
35
- ...outputArgs,
36
- },
37
- run: async ({ args }) => {
39
+ args: forkArgs,
40
+ run: async ({ args, rawArgs }) => {
41
+ assertKnownFlags(rawArgs, forkArgs);
38
42
  const source = args.slug.trim().toLowerCase();
39
43
  const target = (args.target ?? `${source}-fork`).trim().toLowerCase();
40
44
  if (!SLUG_RE.test(target)) {
@@ -57,7 +61,7 @@ export const forkCommand = defineCommand({
57
61
  consola.start(`Forking ${source}`);
58
62
  let src;
59
63
  try {
60
- src = await client.deploy.getSource.query({ slug: source });
64
+ src = await client.deploy.getSource({ slug: source });
61
65
  }
62
66
  catch (err) {
63
67
  consola.error(err instanceof Error ? err.message : String(err));
@@ -101,6 +105,8 @@ function rewritePackageName(dir, slug) {
101
105
  return;
102
106
  try {
103
107
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
108
+ if (!isJsonObject(pkg))
109
+ throw new Error("package.json is not a JSON object");
104
110
  pkg.name = slug;
105
111
  delete pkg.repository;
106
112
  delete pkg.bugs;
@@ -1,26 +1,25 @@
1
1
  import { defineCommand } from "citty";
2
2
  import consola from "consola";
3
- import { createClient } from "../lib/api.js";
3
+ import { createClient, forwardJson } from "../lib/api.js";
4
4
  import { CodexError, generateImagesWithCodex, placeCodexOutputs, resolveProvider, } from "../lib/codex.js";
5
- import { parseDownloadFlag, parseRunInput, readExplicitLocalFile } from "../lib/media-args.js";
5
+ import { parseDownloadFlag, parseRunInput, readExplicitLocalFile, } from "../lib/media-args.js";
6
6
  import { downloadMedia, extractMediaRefs } from "../lib/media-download.js";
7
7
  import { endpointPath, queueAppId, waitForCompletion } from "../lib/media-poll.js";
8
8
  import { uploadFile } from "../lib/media-upload.js";
9
9
  import { isJsonOutput, outputArgs, writeJson, writeStructured } from "../lib/output.js";
10
- import { isRecord } from "../lib/types.js";
11
- // Action-specific fields for the status-command payload. `result` wraps
12
- // the raw fal payload under `result:` so fal's own keys can't clobber
13
- // our top-level (action / endpoint_id / request_id). `status` cherry-
14
- // picks known fields for the same reason.
10
+ import { isJsonNumber, isJsonObject, isJsonString, } from "../lib/types.js";
15
11
  function buildActionFields(action, data) {
16
12
  if (action === "result")
17
13
  return { result: data };
18
- if (action === "status" && isRecord(data)) {
19
- return {
20
- status: typeof data.status === "string" ? data.status : undefined,
21
- queue_position: typeof data.queue_position === "number" ? data.queue_position : undefined,
22
- logs: data.logs,
23
- };
14
+ if (action === "status" && isJsonObject(data)) {
15
+ const fields = {};
16
+ if (isJsonString(data.status))
17
+ fields.status = data.status;
18
+ if (isJsonNumber(data.queue_position))
19
+ fields.queue_position = data.queue_position;
20
+ if (data.logs !== undefined)
21
+ fields.logs = data.logs;
22
+ return fields;
24
23
  }
25
24
  return {};
26
25
  }
@@ -71,13 +70,13 @@ const runCommand = defineCommand({
71
70
  return;
72
71
  }
73
72
  const client = createClient();
74
- const submission = await client.generate.forward.mutate({
73
+ const submission = await forwardJson(client, {
75
74
  target: "queue",
76
75
  method: "POST",
77
76
  path: `/${endpointPath(endpoint_id)}`,
78
77
  body: finalInput,
79
78
  });
80
- const requestId = isRecord(submission) && typeof submission.request_id === "string"
79
+ const requestId = isJsonObject(submission) && isJsonString(submission.request_id)
81
80
  ? submission.request_id
82
81
  : null;
83
82
  if (!requestId) {
@@ -113,11 +112,15 @@ const runCommand = defineCommand({
113
112
  endpoint_id,
114
113
  request_id: completed.request_id,
115
114
  result: completed.result,
116
- ...(downloaded ? { downloaded_files: downloaded.downloaded } : {}),
117
- ...(downloaded && downloaded.failed.length > 0
118
- ? { download_failures: downloaded.failed }
119
- : {}),
120
115
  };
116
+ if (downloaded) {
117
+ payload.downloaded_files = downloaded.downloaded;
118
+ if (downloaded.failed.length > 0)
119
+ payload.download_failures = downloaded.failed;
120
+ if (downloaded.mislabeled.length > 0) {
121
+ payload.download_format_mismatches = downloaded.mislabeled;
122
+ }
123
+ }
121
124
  if (!writeStructured(payload, args)) {
122
125
  consola.success(`Run completed (${completed.request_id})`);
123
126
  if (downloaded) {
@@ -125,6 +128,7 @@ const runCommand = defineCommand({
125
128
  consola.log(` ${path}`);
126
129
  for (const f of downloaded.failed)
127
130
  consola.warn(` failed: ${f.url} (${f.error})`);
131
+ warnMislabeled(downloaded.mislabeled);
128
132
  }
129
133
  if (!downloaded?.downloaded.length) {
130
134
  for (const url of extractMediaUrls(completed.result))
@@ -136,6 +140,19 @@ const runCommand = defineCommand({
136
140
  }
137
141
  },
138
142
  });
143
+ /**
144
+ * A downloaded file whose extension does not match the bytes inside it.
145
+ *
146
+ * The model, not the CLI, picks the output format, so asking for `board.png`
147
+ * from an endpoint that returns JPEG produces a `.png` full of JPEG. The next
148
+ * tool in the pipeline reports "bad signature" with no hint of where it came
149
+ * from, so name it here while the cause is still on screen.
150
+ */
151
+ function warnMislabeled(mislabeled) {
152
+ for (const m of mislabeled) {
153
+ consola.warn(` ${m.path} holds ${m.actual.toUpperCase()} data, not what its extension says`);
154
+ }
155
+ }
139
156
  // Delegate image generation to the local Codex CLI instead of the
140
157
  // vibedgames model runner. Produces local files directly (Codex writes
141
158
  // to disk), so there's no queue, no request polling, and no vibedgames
@@ -180,9 +197,11 @@ async function runViaCodex(opts) {
180
197
  request_id: requestId,
181
198
  result: { provider: "codex", prompt, images: downloaded.map((path) => ({ path })) },
182
199
  downloaded_files: downloaded,
183
- ...(failed.length > 0 ? { download_failures: failed } : {}),
184
- ...(ignoredReferences.length > 0 ? { ignored_references: ignoredReferences } : {}),
185
200
  };
201
+ if (failed.length > 0)
202
+ payload.download_failures = failed;
203
+ if (ignoredReferences.length > 0)
204
+ payload.ignored_references = ignoredReferences;
186
205
  if (!writeStructured(payload, args)) {
187
206
  consola.success(`Codex generated ${downloaded.length} image(s) (${requestId})`);
188
207
  for (const path of downloaded)
@@ -230,7 +249,7 @@ const statusCommand = defineCommand({
230
249
  : action === "result"
231
250
  ? `/${ep}/requests/${args.request_id}`
232
251
  : `/${ep}/requests/${args.request_id}/status`;
233
- const data = await client.generate.forward.mutate({
252
+ const data = await forwardJson(client, {
234
253
  target: "queue",
235
254
  method: action === "cancel" ? "PUT" : "GET",
236
255
  path,
@@ -245,12 +264,12 @@ const statusCommand = defineCommand({
245
264
  for (let attempt = 0; attempt < 3; attempt++) {
246
265
  await new Promise((resolve) => setTimeout(resolve, 1_000));
247
266
  try {
248
- const poll = await client.generate.forward.mutate({
267
+ const poll = await forwardJson(client, {
249
268
  target: "queue",
250
269
  method: "GET",
251
270
  path: statusPath,
252
271
  });
253
- const status = isRecord(poll) && typeof poll.status === "string" ? poll.status.toUpperCase() : "";
272
+ const status = isJsonObject(poll) && isJsonString(poll.status) ? poll.status.toUpperCase() : "";
254
273
  if (["CANCELLED", "FAILED", "COMPLETED"].includes(status))
255
274
  break;
256
275
  }
@@ -268,22 +287,25 @@ const statusCommand = defineCommand({
268
287
  requestId: args.request_id,
269
288
  });
270
289
  }
271
- const actionFields = buildActionFields(action, data);
272
290
  const payload = {
273
291
  action,
274
292
  endpoint_id: args.endpoint_id,
275
293
  request_id: args.request_id,
276
- ...actionFields,
277
- ...(downloaded ? { downloaded_files: downloaded.downloaded } : {}),
278
- ...(downloaded && downloaded.failed.length > 0
279
- ? { download_failures: downloaded.failed }
280
- : {}),
294
+ ...buildActionFields(action, data),
281
295
  };
296
+ if (downloaded) {
297
+ payload.downloaded_files = downloaded.downloaded;
298
+ if (downloaded.failed.length > 0)
299
+ payload.download_failures = downloaded.failed;
300
+ if (downloaded.mislabeled.length > 0) {
301
+ payload.download_format_mismatches = downloaded.mislabeled;
302
+ }
303
+ }
282
304
  if (!writeStructured(payload, args)) {
283
305
  if (action === "status") {
284
- const status = isRecord(data) && typeof data.status === "string" ? data.status : "?";
306
+ const status = isJsonObject(data) && isJsonString(data.status) ? data.status : "?";
285
307
  consola.log(`status: ${status}`);
286
- if (isRecord(data) && typeof data.queue_position === "number") {
308
+ if (isJsonObject(data) && isJsonNumber(data.queue_position)) {
287
309
  consola.log(`queue_position: ${data.queue_position}`);
288
310
  }
289
311
  }
@@ -294,6 +316,7 @@ const statusCommand = defineCommand({
294
316
  consola.log(` ${p}`);
295
317
  for (const f of downloaded.failed)
296
318
  consola.warn(` failed: ${f.url} (${f.error})`);
319
+ warnMislabeled(downloaded.mislabeled);
297
320
  }
298
321
  if (action === "result" && !downloaded?.downloaded.length) {
299
322
  for (const url of extractMediaUrls(data))
@@ -343,7 +366,7 @@ const modelsCommand = defineCommand({
343
366
  if (expand.length > 0)
344
367
  query.expand = expand;
345
368
  const client = createClient();
346
- const data = await client.generate.forward.mutate({
369
+ const data = await forwardJson(client, {
347
370
  target: "platform",
348
371
  method: "GET",
349
372
  path: "/v1/models",
@@ -362,12 +385,12 @@ function splitList(value) {
362
385
  .filter(Boolean);
363
386
  }
364
387
  function printModels(data) {
365
- const models = isRecord(data) && Array.isArray(data.models) ? data.models : [];
388
+ const models = isJsonObject(data) && Array.isArray(data.models) ? data.models : [];
366
389
  for (const m of models) {
367
- if (!isRecord(m))
390
+ if (!isJsonObject(m))
368
391
  continue;
369
392
  const id = String(m.endpoint_id ?? "?");
370
- const meta = isRecord(m.metadata) ? m.metadata : {};
393
+ const meta = isJsonObject(m.metadata) ? m.metadata : {};
371
394
  const tags = [];
372
395
  if (meta.category)
373
396
  tags.push(String(meta.category));
@@ -375,7 +398,7 @@ function printModels(data) {
375
398
  tags.push(String(meta.status));
376
399
  consola.log(`${id}${tags.length > 0 ? ` [${tags.join(", ")}]` : ""}`);
377
400
  }
378
- if (isRecord(data) && data.next_cursor) {
401
+ if (isJsonObject(data) && data.next_cursor) {
379
402
  consola.log(`\nnext_cursor: ${String(data.next_cursor)}`);
380
403
  }
381
404
  }
@@ -390,15 +413,16 @@ const schemaCommand = defineCommand({
390
413
  run: async ({ args }) => {
391
414
  const expand = args.format === "openapi" ? ["openapi-3.0"] : [];
392
415
  const client = createClient();
393
- const data = await client.generate.forward.mutate({
416
+ const query = {};
417
+ query.endpoint_id = args.endpoint_id;
418
+ query.limit = "1";
419
+ if (expand.length > 0)
420
+ query.expand = expand;
421
+ const data = await forwardJson(client, {
394
422
  target: "platform",
395
423
  method: "GET",
396
424
  path: "/v1/models",
397
- query: {
398
- endpoint_id: args.endpoint_id,
399
- limit: "1",
400
- ...(expand.length > 0 ? { expand } : {}),
401
- },
425
+ query,
402
426
  });
403
427
  if (!writeStructured(data, args))
404
428
  writeJson(data);
@@ -413,7 +437,7 @@ const pricingCommand = defineCommand({
413
437
  },
414
438
  run: async ({ args }) => {
415
439
  const client = createClient();
416
- const data = await client.generate.forward.mutate({
440
+ const data = await forwardJson(client, {
417
441
  target: "platform",
418
442
  method: "GET",
419
443
  path: "/v1/models/pricing",
@@ -432,7 +456,7 @@ const docsCommand = defineCommand({
432
456
  },
433
457
  run: async ({ args }) => {
434
458
  const client = createClient();
435
- const data = await client.generate.forward.mutate({
459
+ const data = await forwardJson(client, {
436
460
  target: "docs",
437
461
  method: "POST",
438
462
  path: "/docs/mcp",
@@ -3,6 +3,7 @@ import { defineCommand } from "citty";
3
3
  import consola from "consola";
4
4
  import { detectPackageManager, globalInstallArgs, globalInstallCommand, PKG_NAME, } from "../lib/package-manager.js";
5
5
  import { isMissingCommand, run } from "../lib/run.js";
6
+ import { assertKnownFlags } from "../lib/strict-args.js";
6
7
  const REPO = "kyh/vibedgames";
7
8
  const DEFAULT_AGENTS = "claude-code,cursor,codex";
8
9
  const description = "Install/update vibedgames skills and the vg CLI";
@@ -24,29 +25,31 @@ const skillsUpdateArgs = (global, yes) => {
24
25
  args.push("-y");
25
26
  return args;
26
27
  };
28
+ const initArgs = {
29
+ agent: {
30
+ type: "string",
31
+ description: "Comma-separated target agents. Default installs for Claude Code, Cursor, and Codex (symlinked from a shared .agents/skills/ dir). Pass '*' for every supported agent.",
32
+ alias: "a",
33
+ default: DEFAULT_AGENTS,
34
+ },
35
+ global: {
36
+ type: "boolean",
37
+ description: "Install to user directory instead of project",
38
+ default: false,
39
+ alias: "g",
40
+ },
41
+ yes: {
42
+ type: "boolean",
43
+ description: "Skip confirmation prompts",
44
+ default: true,
45
+ alias: "y",
46
+ },
47
+ };
27
48
  export const initCommand = defineCommand({
28
49
  meta: { name: "init", description },
29
- args: {
30
- agent: {
31
- type: "string",
32
- description: "Comma-separated target agents. Default installs for Claude Code, Cursor, and Codex (symlinked from a shared .agents/skills/ dir). Pass '*' for every supported agent.",
33
- alias: "a",
34
- default: DEFAULT_AGENTS,
35
- },
36
- global: {
37
- type: "boolean",
38
- description: "Install to user directory instead of project",
39
- default: false,
40
- alias: "g",
41
- },
42
- yes: {
43
- type: "boolean",
44
- description: "Skip confirmation prompts",
45
- default: true,
46
- alias: "y",
47
- },
48
- },
49
- run: async ({ args }) => {
50
+ args: initArgs,
51
+ run: async ({ args, rawArgs }) => {
52
+ assertKnownFlags(rawArgs, initArgs);
50
53
  const agents = args.agent
51
54
  .split(",")
52
55
  .map((s) => s.trim())
@@ -55,9 +58,9 @@ export const initCommand = defineCommand({
55
58
  // different manager writes a second copy into a prefix the shell may not
56
59
  // even be looking at, so `vg --version` would not move.
57
60
  const manager = detectPackageManager(fileURLToPath(import.meta.url));
58
- consola.start("Installing/updating vibedgames skills and the vg CLI...");
61
+ consola.start("Installing/updating vibedgames skills and the vg CLI (this takes a few minutes — `skills` fetches the repo once per skill)...");
59
62
  const [add, cli] = await Promise.all([
60
- run("npx", skillsAddArgs(agents, args.global, args.yes)),
63
+ run("npx", skillsAddArgs(agents, args.global, args.yes), { stream: true }),
61
64
  run(manager, globalInstallArgs(manager)),
62
65
  ]);
63
66
  if (add.code !== 0) {
@@ -71,7 +74,9 @@ export const initCommand = defineCommand({
71
74
  throw new Error(`skills add exited with code ${add.code}`);
72
75
  }
73
76
  consola.success(`Installed vibedgames skills for ${agents.join(", ")}`);
74
- const update = await run("npx", skillsUpdateArgs(args.global, args.yes));
77
+ const update = await run("npx", skillsUpdateArgs(args.global, args.yes), {
78
+ stream: true,
79
+ });
75
80
  if (update.code !== 0) {
76
81
  if (update.output.trim())
77
82
  consola.warn(update.output.trim());