vibedgames 0.0.6 → 0.2.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.
@@ -1,20 +1,23 @@
1
1
  import { defineCommand } from "citty";
2
2
  const SUPPORTED = new Set(["bash", "zsh", "fish"]);
3
3
  const SUBCOMMANDS = [
4
+ "new",
4
5
  "init",
5
6
  "login",
6
7
  "logout",
7
8
  "deploy",
8
- "media",
9
+ "fork",
10
+ "generate",
11
+ "update",
9
12
  "completions",
10
13
  "whoami",
11
14
  ];
12
- const MEDIA_SUBCOMMANDS = ["run", "status", "models", "schema", "pricing", "docs", "upload"];
15
+ const GENERATE_SUBCOMMANDS = ["run", "status", "models", "schema", "pricing", "docs", "upload"];
13
16
  const COMMON_FLAGS = ["--help", "--version"];
14
- // CLI-level flags across the media subcommands. Model parameters are
15
- // arbitrary per fal endpoint and passed as `--<param>`, so they can't be
17
+ // CLI-level flags across the generate subcommands. Model parameters are
18
+ // arbitrary per model endpoint and passed as `--<param>`, so they can't be
16
19
  // enumerated here — these are just the stable, command-defined flags.
17
- const MEDIA_FLAGS = [
20
+ const GENERATE_FLAGS = [
18
21
  "--async",
19
22
  "--download",
20
23
  "--result",
@@ -47,12 +50,12 @@ _vg_completions() {
47
50
  fi
48
51
 
49
52
  case "$cmd" in
50
- media)
53
+ generate)
51
54
  if [[ $COMP_CWORD -eq 2 ]]; then
52
- COMPREPLY=( $(compgen -W "${MEDIA_SUBCOMMANDS.join(" ")} ${MEDIA_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
55
+ COMPREPLY=( $(compgen -W "${GENERATE_SUBCOMMANDS.join(" ")} ${GENERATE_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
53
56
  return
54
57
  fi
55
- COMPREPLY=( $(compgen -W "${MEDIA_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
58
+ COMPREPLY=( $(compgen -W "${GENERATE_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
56
59
  return
57
60
  ;;
58
61
  *)
@@ -67,10 +70,10 @@ complete -F _vg_completions vg
67
70
  function zshScript() {
68
71
  return `# vg completions for zsh. Source this file or place it on your fpath.
69
72
  _vg() {
70
- local -a subcmds media_subs media_flags common_flags
73
+ local -a subcmds generate_subs generate_flags common_flags
71
74
  subcmds=(${SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
72
- media_subs=(${MEDIA_SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
73
- media_flags=(${MEDIA_FLAGS.map((s) => `"${s}"`).join(" ")})
75
+ generate_subs=(${GENERATE_SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
76
+ generate_flags=(${GENERATE_FLAGS.map((s) => `"${s}"`).join(" ")})
74
77
  common_flags=(${COMMON_FLAGS.map((s) => `"${s}"`).join(" ")})
75
78
 
76
79
  if (( CURRENT == 2 )); then
@@ -78,12 +81,12 @@ _vg() {
78
81
  return
79
82
  fi
80
83
  case "\${words[2]}" in
81
- media)
84
+ generate)
82
85
  if (( CURRENT == 3 )); then
83
- _values "vg media subcommand" "\${media_subs[@]}" "\${media_flags[@]}" "\${common_flags[@]}"
86
+ _values "vg generate subcommand" "\${generate_subs[@]}" "\${generate_flags[@]}" "\${common_flags[@]}"
84
87
  return
85
88
  fi
86
- _values "vg media flag" "\${media_flags[@]}" "\${common_flags[@]}"
89
+ _values "vg generate flag" "\${generate_flags[@]}" "\${common_flags[@]}"
87
90
  ;;
88
91
  *)
89
92
  _values "vg flag" "\${common_flags[@]}"
@@ -100,17 +103,17 @@ function fishFlag(flag, condition) {
100
103
  return `complete -c vg -n '${condition}' ${opt} '${name}'`;
101
104
  }
102
105
  function fishScript() {
103
- const mediaFlagLines = [...MEDIA_FLAGS, ...COMMON_FLAGS].map((flag) => fishFlag(flag, "__fish_seen_subcommand_from media"));
106
+ const generateFlagLines = [...GENERATE_FLAGS, ...COMMON_FLAGS].map((flag) => fishFlag(flag, "__fish_seen_subcommand_from generate"));
104
107
  // For all other subcommands, only the common flags are meaningful.
105
- const otherSubcommands = SUBCOMMANDS.filter((s) => s !== "media");
108
+ const otherSubcommands = SUBCOMMANDS.filter((s) => s !== "generate");
106
109
  const otherFlagLines = COMMON_FLAGS.flatMap((flag) => otherSubcommands.map((sub) => fishFlag(flag, `__fish_seen_subcommand_from ${sub}`)));
107
110
  const topLevelFlagLines = COMMON_FLAGS.map((flag) => fishFlag(flag, "__fish_use_subcommand"));
108
111
  return `# vg completions for fish.
109
112
  complete -c vg -f
110
113
  complete -c vg -n '__fish_use_subcommand' -a '${SUBCOMMANDS.join(" ")}'
111
114
  ${topLevelFlagLines.join("\n")}
112
- ${MEDIA_SUBCOMMANDS.map((sub) => `complete -c vg -n '__fish_seen_subcommand_from media' -a '${sub}'`).join("\n")}
113
- ${mediaFlagLines.join("\n")}
115
+ ${GENERATE_SUBCOMMANDS.map((sub) => `complete -c vg -n '__fish_seen_subcommand_from generate' -a '${sub}'`).join("\n")}
116
+ ${generateFlagLines.join("\n")}
114
117
  ${otherFlagLines.join("\n")}
115
118
  `;
116
119
  }
@@ -0,0 +1 @@
1
+ export declare const generateCommand: import("citty").CommandDef<import("citty").ArgsDef>;
@@ -1,7 +1,7 @@
1
1
  import { defineCommand } from "citty";
2
2
  import consola from "consola";
3
3
  import { createClient } from "../lib/api.js";
4
- import { parseDownloadFlag, parseRunInput, readExplicitLocalFile, } from "../lib/media-args.js";
4
+ import { parseDownloadFlag, parseRunInput, readExplicitLocalFile } from "../lib/media-args.js";
5
5
  import { downloadMedia, extractMediaRefs } from "../lib/media-download.js";
6
6
  import { endpointPath, queueAppId, waitForCompletion } from "../lib/media-poll.js";
7
7
  import { uploadFile } from "../lib/media-upload.js";
@@ -33,7 +33,7 @@ function extractMediaUrls(result) {
33
33
  }
34
34
  // ---- run --------------------------------------------------------------------
35
35
  const runCommand = defineCommand({
36
- meta: { name: "run", description: "Run a fal model (waits for result by default)." },
36
+ meta: { name: "run", description: "Run a model (waits for result by default)." },
37
37
  args: {
38
38
  endpoint_id: {
39
39
  type: "positional",
@@ -57,25 +57,25 @@ const runCommand = defineCommand({
57
57
  // endpoint_id and any subcommand name in argv are no-ops.
58
58
  const finalInput = parseRunInput(rawArgs);
59
59
  const client = createClient();
60
- const submission = await client.media.forward.mutate({
60
+ const endpoint_id = args.endpoint_id;
61
+ const submission = await client.generate.forward.mutate({
61
62
  target: "queue",
62
63
  method: "POST",
63
- path: `/${endpointPath(args.endpoint_id)}`,
64
+ path: `/${endpointPath(endpoint_id)}`,
64
65
  body: finalInput,
65
66
  });
66
67
  const requestId = isRecord(submission) && typeof submission.request_id === "string"
67
68
  ? submission.request_id
68
69
  : null;
69
70
  if (!requestId) {
70
- throw new Error("fal queue submit did not return a request_id.");
71
+ throw new Error("queue submit did not return a request_id.");
71
72
  }
72
- const endpoint_id = args.endpoint_id;
73
73
  if (args.async) {
74
74
  const payload = {
75
75
  status: "submitted",
76
76
  endpoint_id,
77
77
  request_id: requestId,
78
- hint: `Check status: vg media status ${endpoint_id} ${requestId}`,
78
+ hint: `Check status: vg generate status ${endpoint_id} ${requestId}`,
79
79
  };
80
80
  if (isJsonOutput(args))
81
81
  writeJson(payload);
@@ -165,7 +165,7 @@ const statusCommand = defineCommand({
165
165
  : action === "result"
166
166
  ? `/${ep}/requests/${args.request_id}`
167
167
  : `/${ep}/requests/${args.request_id}/status`;
168
- const data = await client.media.forward.mutate({
168
+ const data = await client.generate.forward.mutate({
169
169
  target: "queue",
170
170
  method: action === "cancel" ? "PUT" : "GET",
171
171
  path,
@@ -221,7 +221,7 @@ const statusCommand = defineCommand({
221
221
  });
222
222
  // ---- models -----------------------------------------------------------------
223
223
  const modelsCommand = defineCommand({
224
- meta: { name: "models", description: "Search/list fal models." },
224
+ meta: { name: "models", description: "Search/list available models." },
225
225
  args: {
226
226
  query: { type: "positional", required: false, description: "Search query." },
227
227
  category: { type: "string", description: "Filter by category." },
@@ -256,7 +256,7 @@ const modelsCommand = defineCommand({
256
256
  if (expand.length > 0)
257
257
  query.expand = expand;
258
258
  const client = createClient();
259
- const data = await client.media.forward.mutate({
259
+ const data = await client.generate.forward.mutate({
260
260
  target: "platform",
261
261
  method: "GET",
262
262
  path: "/v1/models",
@@ -305,7 +305,7 @@ const schemaCommand = defineCommand({
305
305
  run: async ({ args }) => {
306
306
  const expand = args.format === "openapi" ? ["openapi-3.0"] : [];
307
307
  const client = createClient();
308
- const data = await client.media.forward.mutate({
308
+ const data = await client.generate.forward.mutate({
309
309
  target: "platform",
310
310
  method: "GET",
311
311
  path: "/v1/models",
@@ -327,7 +327,7 @@ const pricingCommand = defineCommand({
327
327
  },
328
328
  run: async ({ args }) => {
329
329
  const client = createClient();
330
- const data = await client.media.forward.mutate({
330
+ const data = await client.generate.forward.mutate({
331
331
  target: "platform",
332
332
  method: "GET",
333
333
  path: "/v1/models/pricing",
@@ -338,14 +338,14 @@ const pricingCommand = defineCommand({
338
338
  });
339
339
  // ---- docs -------------------------------------------------------------------
340
340
  const docsCommand = defineCommand({
341
- meta: { name: "docs", description: "Search fal documentation." },
341
+ meta: { name: "docs", description: "Search generative-model documentation." },
342
342
  args: {
343
343
  query: { type: "positional", required: true },
344
344
  json: { type: "boolean" },
345
345
  },
346
346
  run: async ({ args }) => {
347
347
  const client = createClient();
348
- const data = await client.media.forward.mutate({
348
+ const data = await client.generate.forward.mutate({
349
349
  target: "docs",
350
350
  method: "POST",
351
351
  path: "/docs/mcp",
@@ -363,7 +363,7 @@ const docsCommand = defineCommand({
363
363
  const uploadCommand = defineCommand({
364
364
  meta: {
365
365
  name: "upload",
366
- description: "Upload a local file to fal CDN. Returns a stable URL.",
366
+ description: "Upload a local file. Returns a stable hosted URL.",
367
367
  },
368
368
  args: {
369
369
  path: { type: "positional", required: true },
@@ -384,10 +384,10 @@ const uploadCommand = defineCommand({
384
384
  },
385
385
  });
386
386
  // ---- top-level --------------------------------------------------------------
387
- export const mediaCommand = defineCommand({
387
+ export const generateCommand = defineCommand({
388
388
  meta: {
389
- name: "media",
390
- description: "Generate, edit, and inspect media via fal.ai (mirrors the genmedia CLI surface).",
389
+ name: "generate",
390
+ description: "Generate, edit, and inspect images, video, and audio.",
391
391
  },
392
392
  subCommands: {
393
393
  run: runCommand,
@@ -1,18 +1,10 @@
1
1
  import { defineCommand } from "citty";
2
2
  import consola from "consola";
3
- import spawn from "cross-spawn";
3
+ import { run } from "../lib/run.js";
4
4
  const REPO = "kyh/vibedgames";
5
5
  const PKG = "vibedgames";
6
6
  const DEFAULT_AGENTS = "claude-code,cursor,codex";
7
7
  const description = "Install/update vibedgames skills and the vg CLI";
8
- const run = (cmd, args) => new Promise((resolve) => {
9
- const chunks = [];
10
- const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
11
- child.stdout?.on("data", (c) => chunks.push(c));
12
- child.stderr?.on("data", (c) => chunks.push(c));
13
- child.on("error", (err) => resolve({ code: 1, output: `${err.message}\n` }));
14
- child.on("close", (code) => resolve({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf8") }));
15
- });
16
8
  const skillsAddArgs = (agents, global, yes) => {
17
9
  const args = ["-y", "skills", "add", REPO];
18
10
  for (const agent of agents)
@@ -6,11 +6,7 @@ import { getBaseUrl, saveConfig } from "../lib/config.js";
6
6
  const POLL_INTERVAL_MS = 2_000;
7
7
  const MAX_POLLS = 150; // 5 min at 2s intervals
8
8
  function openBrowser(url) {
9
- const cmd = process.platform === "darwin"
10
- ? "open"
11
- : process.platform === "win32"
12
- ? "start"
13
- : "xdg-open";
9
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
14
10
  exec(`${cmd} "${url}"`);
15
11
  }
16
12
  function sleep(ms) {
@@ -1,4 +1,4 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
3
  import { defineCommand } from "citty";
4
4
  import consola from "consola";
@@ -22,6 +22,9 @@ const ENGINES = {
22
22
  repo: "pachoclo/vite-threejs-ts-template",
23
23
  label: "Three.js + Vite + TypeScript (community)",
24
24
  skill: "threejs",
25
+ postNotes: [
26
+ "The demo scene (src/scene.ts) wires lil-gui, stats.js and Drag/OrbitControls as a showcase — replace it with your game and drop the debug deps for production.",
27
+ ],
25
28
  },
26
29
  // React Three Fiber. Same author as the threejs preset — Vite + TS +
27
30
  // React 18 + R3F 8 + drei, with leva and r3f-perf wired up for debug.
@@ -130,7 +133,11 @@ export const newCommand = defineCommand({
130
133
  process.exit(1);
131
134
  }
132
135
  const preset = args.template
133
- ? { repo: args.template, label: `custom: ${args.template}`, skill: "deploy" }
136
+ ? {
137
+ repo: args.template,
138
+ label: `custom: ${args.template}`,
139
+ skill: "deploy",
140
+ }
134
141
  : ENGINES[args.engine];
135
142
  if (!preset) {
136
143
  consola.error(`Unknown engine: ${args.engine}. Use one of: ${Object.keys(ENGINES).join(", ")}.`);
@@ -158,7 +165,13 @@ export const newCommand = defineCommand({
158
165
  process.exit(1);
159
166
  }
160
167
  }
161
- // Post-process: name + vibedgames.json + README link to skills.
168
+ // Post-process: strip template-repo artifacts, then name + vibedgames.json
169
+ // + README link to skills.
170
+ if (!("inline" in preset)) {
171
+ cleanTemplateArtifacts(target);
172
+ ensureViteConfig(target);
173
+ ensureTypecheckScript(target);
174
+ }
162
175
  rewritePackageName(target, slug);
163
176
  writeVibedgamesJson(target, slug);
164
177
  writeReadme(target, slug, preset);
@@ -181,6 +194,51 @@ async function fetchTemplate(repo, target, force) {
181
194
  const emitter = tiged(repo, { force, verbose: false, mode: "tar" });
182
195
  await emitter.clone(target);
183
196
  }
197
+ /** Remove template-repo artifacts that never apply to a scaffolded game:
198
+ * the template's own lockfile (wrong for whatever package manager the user
199
+ * runs) and its CI workflows (reference the template repo, fail elsewhere). */
200
+ function cleanTemplateArtifacts(target) {
201
+ for (const f of ["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock"]) {
202
+ const p = resolve(target, f);
203
+ if (existsSync(p))
204
+ rmSync(p);
205
+ }
206
+ const gh = resolve(target, ".github");
207
+ if (existsSync(gh))
208
+ rmSync(gh, { recursive: true });
209
+ }
210
+ /** Some templates (threejs) ship no vite config at all, which means no
211
+ * relative `base` — write a minimal one so built asset URLs are relative
212
+ * and the bundle works wherever it's hosted. Never touches templates that
213
+ * bring their own config (phaser uses a vite/ config dir wired into its
214
+ * npm scripts). */
215
+ function ensureViteConfig(target) {
216
+ const hasConfig = ["vite.config.ts", "vite.config.js", "vite.config.mjs"].some((f) => existsSync(resolve(target, f))) || existsSync(resolve(target, "vite"));
217
+ if (hasConfig)
218
+ return;
219
+ writeFileSync(resolve(target, "vite.config.ts"), `import { defineConfig } from "vite";\n\nexport default defineConfig({\n base: "./",\n});\n`);
220
+ }
221
+ /** Agents lean on \`npm run typecheck\` to verify changes without a full
222
+ * build — add it when the template doesn't define one. */
223
+ function ensureTypecheckScript(target) {
224
+ const pkgPath = resolve(target, "package.json");
225
+ if (!existsSync(pkgPath))
226
+ return;
227
+ try {
228
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
229
+ const scripts = typeof pkg.scripts === "object" && pkg.scripts !== null
230
+ ? pkg.scripts
231
+ : {};
232
+ if (typeof scripts.typecheck === "string")
233
+ return;
234
+ scripts.typecheck = "tsc --noEmit";
235
+ pkg.scripts = scripts;
236
+ writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
237
+ }
238
+ catch {
239
+ // malformed package.json — rewritePackageName will warn about it
240
+ }
241
+ }
184
242
  function writeInlineTemplate(target, slug, force) {
185
243
  for (const file of NONE_FILES) {
186
244
  const path = resolve(target, file.path);
@@ -0,0 +1,13 @@
1
+ export declare const updateCommand: import("citty").CommandDef<{
2
+ readonly global: {
3
+ readonly type: "boolean";
4
+ readonly description: "Update skills installed in the user directory instead of the project";
5
+ readonly default: false;
6
+ readonly alias: "g";
7
+ };
8
+ readonly auto: {
9
+ readonly type: "boolean";
10
+ readonly description: "(internal) silent background mode: only update when npm has a newer version";
11
+ readonly default: false;
12
+ };
13
+ }>;
@@ -0,0 +1,68 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { defineCommand } from "citty";
3
+ import consola from "consola";
4
+ import { run } from "../lib/run.js";
5
+ import { fetchLatestVersion, isNewerVersion } from "../lib/update.js";
6
+ const PKG = "vibedgames";
7
+ const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
8
+ const skillsUpdateArgs = (global) => {
9
+ const args = ["-y", "skills", "update", "-y"];
10
+ if (global)
11
+ args.push("-g");
12
+ return args;
13
+ };
14
+ export const updateCommand = defineCommand({
15
+ meta: {
16
+ name: "update",
17
+ description: "Update the vg CLI and vibedgames skills to latest (runs automatically once a day; disable with VG_NO_AUTO_UPDATE=1)",
18
+ },
19
+ args: {
20
+ global: {
21
+ type: "boolean",
22
+ description: "Update skills installed in the user directory instead of the project",
23
+ default: false,
24
+ alias: "g",
25
+ },
26
+ auto: {
27
+ type: "boolean",
28
+ description: "(internal) silent background mode: only update when npm has a newer version",
29
+ default: false,
30
+ },
31
+ },
32
+ run: async ({ args }) => {
33
+ if (args.auto) {
34
+ const latest = await fetchLatestVersion();
35
+ if (!latest || !isNewerVersion(latest, pkg.version))
36
+ return;
37
+ await Promise.all([
38
+ run("npm", ["install", "-g", PKG]),
39
+ run("npx", skillsUpdateArgs(args.global)),
40
+ ]);
41
+ return;
42
+ }
43
+ consola.start("Updating the vg CLI and vibedgames skills...");
44
+ const [cli, skills] = await Promise.all([
45
+ run("npm", ["install", "-g", PKG]),
46
+ run("npx", skillsUpdateArgs(args.global)),
47
+ ]);
48
+ if (cli.code === 0) {
49
+ consola.success("vg CLI updated to latest");
50
+ }
51
+ else {
52
+ if (cli.output.trim())
53
+ consola.warn(cli.output.trim());
54
+ consola.warn(`Couldn't update the vg CLI (npm exit ${cli.code}). Update manually: npm install -g ${PKG}`);
55
+ }
56
+ if (skills.code === 0) {
57
+ consola.success("Skills updated to latest");
58
+ }
59
+ else {
60
+ if (skills.output.trim())
61
+ consola.warn(skills.output.trim());
62
+ consola.warn(`'skills update' exited with code ${skills.code}. If skills aren't installed here yet, run: vg init`);
63
+ }
64
+ if (cli.code !== 0 && skills.code !== 0) {
65
+ throw new Error("update failed for both the CLI and skills");
66
+ }
67
+ },
68
+ });
package/dist/index.js CHANGED
@@ -4,12 +4,14 @@ import { defineCommand, runMain } from "citty";
4
4
  import { completionsCommand } from "./commands/completions.js";
5
5
  import { deployCommand } from "./commands/deploy.js";
6
6
  import { forkCommand } from "./commands/fork.js";
7
+ import { generateCommand } from "./commands/generate.js";
7
8
  import { initCommand } from "./commands/init.js";
8
9
  import { loginCommand } from "./commands/login.js";
9
10
  import { logoutCommand } from "./commands/logout.js";
10
- import { mediaCommand } from "./commands/media.js";
11
11
  import { newCommand } from "./commands/new.js";
12
+ import { updateCommand } from "./commands/update.js";
12
13
  import { whoamiCommand } from "./commands/whoami.js";
14
+ import { maybeScheduleAutoUpdate } from "./lib/update.js";
13
15
  const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
14
16
  const main = defineCommand({
15
17
  meta: {
@@ -24,9 +26,16 @@ const main = defineCommand({
24
26
  logout: logoutCommand,
25
27
  deploy: deployCommand,
26
28
  fork: forkCommand,
27
- media: mediaCommand,
29
+ generate: generateCommand,
30
+ update: updateCommand,
28
31
  completions: completionsCommand,
29
32
  whoami: whoamiCommand,
30
33
  },
31
34
  });
35
+ // Skip for update/init (they already update) and completions (runs in shell
36
+ // startup — must stay side-effect free).
37
+ const subcommand = process.argv[2];
38
+ if (subcommand && !["update", "init", "completions"].includes(subcommand)) {
39
+ maybeScheduleAutoUpdate();
40
+ }
32
41
  runMain(main);
@@ -2,6 +2,7 @@ type Config = {
2
2
  token: string;
3
3
  baseUrl: string;
4
4
  };
5
+ export declare function getConfigDir(): string;
5
6
  export declare function getConfig(): Config | null;
6
7
  export declare function saveConfig(config: Config): void;
7
8
  export declare function clearConfig(): void;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
- function getConfigDir() {
4
+ export function getConfigDir() {
5
5
  const xdg = process.env.XDG_CONFIG_HOME;
6
6
  const base = xdg ?? join(homedir(), ".config");
7
7
  return join(base, "vg");
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Parse `--<key> value` pairs from argv into a JS object, JSON-decoding
3
3
  * values that look like JSON (true/false/null/numbers/objects/arrays) and
4
- * leaving everything else as a string. Mirrors genmedia's parse-value
5
- * behavior so skills targeting that surface produce the same input shapes.
4
+ * leaving everything else as a string. The parse-value behavior is stable
5
+ * so skills targeting this surface produce the same input shapes.
6
6
  *
7
7
  * Handles both `--key value` and the GNU-style `--key=value`. Without
8
8
  * `=` support, `--prompt=hello` would silently send the malformed key
9
- * `"prompt=hello"` to fal, and `--async=true` would slip past the
9
+ * `"prompt=hello"` upstream, and `--async=true` would slip past the
10
10
  * RUN_RESERVED_FLAGS guard as a bogus model param.
11
11
  */
12
12
  export declare function parseRunInput(argv: string[]): Record<string, unknown>;
@@ -17,7 +17,7 @@ export type LocalFile = {
17
17
  };
18
18
  /**
19
19
  * Probe a path the user explicitly asked us to read (e.g.
20
- * `vg media upload <path>`). Skips the path-shape heuristic so a bare
20
+ * `vg generate upload <path>`). Skips the path-shape heuristic so a bare
21
21
  * filename with a non-media extension — `model.glb`, `scene.fbx`,
22
22
  * `data.ply`, even `LICENSE` — still works.
23
23
  */
@@ -4,25 +4,19 @@ import { basename, extname, isAbsolute, join, resolve } from "node:path";
4
4
  // `--json`/`--help`/`--quiet` are global; `--async` switches the run path
5
5
  // in citty; `--download` takes an optional template. None of them should
6
6
  // leak through to fal as model parameters. `--logs` is intentionally NOT
7
- // here: it's a `vg media status` flag, not a `run` flag, so swallowing it
7
+ // here: it's a `vg generate status` flag, not a `run` flag, so swallowing it
8
8
  // would block users from passing a legitimate `logs` parameter to a
9
9
  // model endpoint.
10
- const RUN_RESERVED_FLAGS = new Set([
11
- "--json",
12
- "--help",
13
- "--quiet",
14
- "--async",
15
- "--download",
16
- ]);
10
+ const RUN_RESERVED_FLAGS = new Set(["--json", "--help", "--quiet", "--async", "--download"]);
17
11
  /**
18
12
  * Parse `--<key> value` pairs from argv into a JS object, JSON-decoding
19
13
  * values that look like JSON (true/false/null/numbers/objects/arrays) and
20
- * leaving everything else as a string. Mirrors genmedia's parse-value
21
- * behavior so skills targeting that surface produce the same input shapes.
14
+ * leaving everything else as a string. The parse-value behavior is stable
15
+ * so skills targeting this surface produce the same input shapes.
22
16
  *
23
17
  * Handles both `--key value` and the GNU-style `--key=value`. Without
24
18
  * `=` support, `--prompt=hello` would silently send the malformed key
25
- * `"prompt=hello"` to fal, and `--async=true` would slip past the
19
+ * `"prompt=hello"` upstream, and `--async=true` would slip past the
26
20
  * RUN_RESERVED_FLAGS guard as a bogus model param.
27
21
  */
28
22
  export function parseRunInput(argv) {
@@ -100,7 +94,7 @@ function parseValue(raw) {
100
94
  }
101
95
  /**
102
96
  * Probe a path the user explicitly asked us to read (e.g.
103
- * `vg media upload <path>`). Skips the path-shape heuristic so a bare
97
+ * `vg generate upload <path>`). Skips the path-shape heuristic so a bare
104
98
  * filename with a non-media extension — `model.glb`, `scene.fbx`,
105
99
  * `data.ply`, even `LICENSE` — still works.
106
100
  */
@@ -5,8 +5,23 @@ import { isRecord } from "./types.js";
5
5
  // response payloads where `content_type` is missing (some endpoints
6
6
  // omit it).
7
7
  const MEDIA_EXT = new Set([
8
- "png", "jpg", "jpeg", "webp", "gif", "bmp", "tif", "tiff", "avif",
9
- "mp4", "mov", "webm", "mp3", "wav", "ogg", "flac", "m4a",
8
+ "png",
9
+ "jpg",
10
+ "jpeg",
11
+ "webp",
12
+ "gif",
13
+ "bmp",
14
+ "tif",
15
+ "tiff",
16
+ "avif",
17
+ "mp4",
18
+ "mov",
19
+ "webm",
20
+ "mp3",
21
+ "wav",
22
+ "ogg",
23
+ "flac",
24
+ "m4a",
10
25
  ]);
11
26
  /**
12
27
  * Walk a fal result payload and pull out anything that looks like a media
@@ -131,7 +146,10 @@ export async function downloadMedia(opts) {
131
146
  // Handle both POSIX and Windows separators regardless of host OS so a
132
147
  // `..\\..\\evil` payload sent to a Linux client is still flattened.
133
148
  function sanitizeFilename(name) {
134
- const base = name.replace(/[\\/]+/g, "/").split("/").pop() ?? "";
149
+ const base = name
150
+ .replace(/[\\/]+/g, "/")
151
+ .split("/")
152
+ .pop() ?? "";
135
153
  if (!base || base === "." || base === "..")
136
154
  return null;
137
155
  return base;
@@ -9,7 +9,7 @@ type CompletedResult = {
9
9
  /**
10
10
  * Poll fal's queue from the client side until the job reaches a
11
11
  * terminal status, then fetch the result. The Worker isn't in the
12
- * loop — it's only along for each individual `media.forward` hop.
12
+ * loop — it's only along for each individual `generate.forward` hop.
13
13
  */
14
14
  export declare function waitForCompletion(client: Client, endpoint_id: string, request_id: string, opts: {
15
15
  quiet: boolean;
@@ -25,7 +25,7 @@ const POLL_TIMEOUT_MS = 30 * 60 * 1000;
25
25
  /**
26
26
  * Poll fal's queue from the client side until the job reaches a
27
27
  * terminal status, then fetch the result. The Worker isn't in the
28
- * loop — it's only along for each individual `media.forward` hop.
28
+ * loop — it's only along for each individual `generate.forward` hop.
29
29
  */
30
30
  export async function waitForCompletion(client, endpoint_id, request_id, opts) {
31
31
  const ep = queueAppId(endpoint_id);
@@ -33,11 +33,11 @@ export async function waitForCompletion(client, endpoint_id, request_id, opts) {
33
33
  let lastStatus;
34
34
  while (true) {
35
35
  if (Date.now() > deadline) {
36
- throw new Error(`fal job did not complete within ${POLL_TIMEOUT_MS}ms ` +
36
+ throw new Error(`Job did not complete within ${POLL_TIMEOUT_MS}ms ` +
37
37
  `(endpoint=${endpoint_id} request_id=${request_id}). ` +
38
- `Use \`vg media status ${endpoint_id} ${request_id} --result\` to check later.`);
38
+ `Use \`vg generate status ${endpoint_id} ${request_id} --result\` to check later.`);
39
39
  }
40
- const raw = await client.media.forward.mutate({
40
+ const raw = await client.generate.forward.mutate({
41
41
  target: "queue",
42
42
  method: "GET",
43
43
  path: `/${ep}/requests/${request_id}/status`,
@@ -54,11 +54,11 @@ export async function waitForCompletion(client, endpoint_id, request_id, opts) {
54
54
  break;
55
55
  if (upper === "FAILED" || upper === "CANCELLED") {
56
56
  const reason = pickErrorReason(raw);
57
- throw new Error(reason ? `fal job ${upper.toLowerCase()}: ${reason}` : `fal job ${upper.toLowerCase()}`);
57
+ throw new Error(reason ? `Job ${upper.toLowerCase()}: ${reason}` : `Job ${upper.toLowerCase()}`);
58
58
  }
59
59
  await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
60
60
  }
61
- const result = await client.media.forward.mutate({
61
+ const result = await client.generate.forward.mutate({
62
62
  target: "queue",
63
63
  method: "GET",
64
64
  path: `/${ep}/requests/${request_id}`,