vibedgames 0.0.2 → 0.0.4

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.
@@ -0,0 +1,7 @@
1
+ export declare const completionsCommand: import("citty").CommandDef<{
2
+ readonly shell: {
3
+ readonly type: "positional";
4
+ readonly description: "Shell to generate completions for: bash | zsh | fish";
5
+ readonly required: true;
6
+ };
7
+ }>;
@@ -0,0 +1,138 @@
1
+ import { defineCommand } from "citty";
2
+ const SUPPORTED = new Set(["bash", "zsh", "fish"]);
3
+ const SUBCOMMANDS = [
4
+ "init",
5
+ "login",
6
+ "logout",
7
+ "deploy",
8
+ "media",
9
+ "completions",
10
+ "whoami",
11
+ ];
12
+ const MEDIA_SUBCOMMANDS = ["run", "status", "models", "schema", "pricing", "docs", "upload"];
13
+ 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
16
+ // enumerated here — these are just the stable, command-defined flags.
17
+ const MEDIA_FLAGS = [
18
+ "--async",
19
+ "--download",
20
+ "--result",
21
+ "--cancel",
22
+ "--logs",
23
+ "--category",
24
+ "--status",
25
+ "--limit",
26
+ "--cursor",
27
+ "--endpoint_id",
28
+ "--expand",
29
+ "--format",
30
+ "--json",
31
+ "--quiet",
32
+ ];
33
+ function bashScript() {
34
+ return `# vg completions for bash. Source this file or write it to a file in your
35
+ # bash completion directory (e.g. /etc/bash_completion.d/vg).
36
+ _vg_completions() {
37
+ local cur prev cmd subcmd
38
+ COMPREPLY=()
39
+ cur="\${COMP_WORDS[COMP_CWORD]}"
40
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
41
+ cmd="\${COMP_WORDS[1]}"
42
+ subcmd="\${COMP_WORDS[2]}"
43
+
44
+ if [[ $COMP_CWORD -eq 1 ]]; then
45
+ COMPREPLY=( $(compgen -W "${SUBCOMMANDS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
46
+ return
47
+ fi
48
+
49
+ case "$cmd" in
50
+ media)
51
+ if [[ $COMP_CWORD -eq 2 ]]; then
52
+ COMPREPLY=( $(compgen -W "${MEDIA_SUBCOMMANDS.join(" ")} ${MEDIA_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
53
+ return
54
+ fi
55
+ COMPREPLY=( $(compgen -W "${MEDIA_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
56
+ return
57
+ ;;
58
+ *)
59
+ COMPREPLY=( $(compgen -W "${COMMON_FLAGS.join(" ")}" -- "$cur") )
60
+ return
61
+ ;;
62
+ esac
63
+ }
64
+ complete -F _vg_completions vg
65
+ `;
66
+ }
67
+ function zshScript() {
68
+ return `# vg completions for zsh. Source this file or place it on your fpath.
69
+ _vg() {
70
+ local -a subcmds media_subs media_flags common_flags
71
+ subcmds=(${SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
72
+ media_subs=(${MEDIA_SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
73
+ media_flags=(${MEDIA_FLAGS.map((s) => `"${s}"`).join(" ")})
74
+ common_flags=(${COMMON_FLAGS.map((s) => `"${s}"`).join(" ")})
75
+
76
+ if (( CURRENT == 2 )); then
77
+ _values "vg subcommand" "\${subcmds[@]}" "\${common_flags[@]}"
78
+ return
79
+ fi
80
+ case "\${words[2]}" in
81
+ media)
82
+ if (( CURRENT == 3 )); then
83
+ _values "vg media subcommand" "\${media_subs[@]}" "\${media_flags[@]}" "\${common_flags[@]}"
84
+ return
85
+ fi
86
+ _values "vg media flag" "\${media_flags[@]}" "\${common_flags[@]}"
87
+ ;;
88
+ *)
89
+ _values "vg flag" "\${common_flags[@]}"
90
+ ;;
91
+ esac
92
+ }
93
+ compdef _vg vg
94
+ `;
95
+ }
96
+ function fishFlag(flag, condition) {
97
+ const isShort = flag.startsWith("-") && !flag.startsWith("--");
98
+ const name = flag.replace(/^--?/, "");
99
+ const opt = isShort ? "-s" : "-l";
100
+ return `complete -c vg -n '${condition}' ${opt} '${name}'`;
101
+ }
102
+ function fishScript() {
103
+ const mediaFlagLines = [...MEDIA_FLAGS, ...COMMON_FLAGS].map((flag) => fishFlag(flag, "__fish_seen_subcommand_from media"));
104
+ // For all other subcommands, only the common flags are meaningful.
105
+ const otherSubcommands = SUBCOMMANDS.filter((s) => s !== "media");
106
+ const otherFlagLines = COMMON_FLAGS.flatMap((flag) => otherSubcommands.map((sub) => fishFlag(flag, `__fish_seen_subcommand_from ${sub}`)));
107
+ const topLevelFlagLines = COMMON_FLAGS.map((flag) => fishFlag(flag, "__fish_use_subcommand"));
108
+ return `# vg completions for fish.
109
+ complete -c vg -f
110
+ complete -c vg -n '__fish_use_subcommand' -a '${SUBCOMMANDS.join(" ")}'
111
+ ${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")}
114
+ ${otherFlagLines.join("\n")}
115
+ `;
116
+ }
117
+ export const completionsCommand = defineCommand({
118
+ meta: {
119
+ name: "completions",
120
+ description: "Print shell completions for vg. Pipe into your shell's completion dir.",
121
+ },
122
+ args: {
123
+ shell: {
124
+ type: "positional",
125
+ description: "Shell to generate completions for: bash | zsh | fish",
126
+ required: true,
127
+ },
128
+ },
129
+ run: ({ args }) => {
130
+ const shell = String(args.shell ?? "");
131
+ if (!SUPPORTED.has(shell)) {
132
+ process.stderr.write(`Unsupported shell "${shell}". Expected: ${Array.from(SUPPORTED).join(", ")}\n`);
133
+ process.exit(1);
134
+ }
135
+ const script = shell === "bash" ? bashScript() : shell === "zsh" ? zshScript() : fishScript();
136
+ process.stdout.write(script);
137
+ },
138
+ });
@@ -1,13 +1,13 @@
1
1
  export declare const deployCommand: import("citty").CommandDef<{
2
- dir: {
3
- type: "positional";
4
- description: string;
5
- required: false;
6
- default: string;
2
+ readonly dir: {
3
+ readonly type: "positional";
4
+ readonly description: "Directory to deploy";
5
+ readonly required: false;
6
+ readonly default: ".";
7
7
  };
8
- slug: {
9
- type: "string";
10
- description: string;
11
- required: false;
8
+ readonly slug: {
9
+ readonly type: "string";
10
+ readonly description: "Override the slug (bypasses vibedgames.json)";
11
+ readonly required: false;
12
12
  };
13
13
  }>;
@@ -44,6 +44,12 @@ export const deployCommand = defineCommand({
44
44
  config = { slug: args.slug, name: config?.name };
45
45
  }
46
46
  if (!config) {
47
+ if (!process.stdin.isTTY) {
48
+ consola.error("No slug specified and no vibedgames.json found.\n" +
49
+ " Pass --slug <name> when running without a TTY (e.g. in CI or from a coding agent).\n" +
50
+ " Example: vg deploy ./dist --slug my-game");
51
+ process.exit(1);
52
+ }
47
53
  const slug = await consola.prompt("Slug (e.g. pong):", { type: "text" });
48
54
  if (typeof slug !== "string" || !SLUG_RE.test(slug)) {
49
55
  consola.error("Invalid slug. Use lowercase letters, digits, hyphens.");
@@ -0,0 +1,20 @@
1
+ export declare const initCommand: import("citty").CommandDef<{
2
+ readonly agent: {
3
+ readonly type: "string";
4
+ readonly 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.";
5
+ readonly alias: "a";
6
+ readonly default: "claude-code,cursor,codex";
7
+ };
8
+ readonly global: {
9
+ readonly type: "boolean";
10
+ readonly description: "Install to user directory instead of project";
11
+ readonly default: false;
12
+ readonly alias: "g";
13
+ };
14
+ readonly yes: {
15
+ readonly type: "boolean";
16
+ readonly description: "Skip confirmation prompts";
17
+ readonly default: true;
18
+ readonly alias: "y";
19
+ };
20
+ }>;
@@ -0,0 +1,89 @@
1
+ import { defineCommand } from "citty";
2
+ import consola from "consola";
3
+ import spawn from "cross-spawn";
4
+ const REPO = "kyh/vibedgames";
5
+ const PKG = "vibedgames";
6
+ const DEFAULT_AGENTS = "claude-code,cursor,codex";
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
+ const skillsAddArgs = (agents, global, yes) => {
17
+ const args = ["-y", "skills", "add", REPO];
18
+ for (const agent of agents)
19
+ args.push("-a", agent);
20
+ if (global)
21
+ args.push("-g");
22
+ if (yes)
23
+ args.push("-y");
24
+ return args;
25
+ };
26
+ const skillsUpdateArgs = (global, yes) => {
27
+ const args = ["-y", "skills", "update"];
28
+ if (global)
29
+ args.push("-g");
30
+ if (yes)
31
+ args.push("-y");
32
+ return args;
33
+ };
34
+ export const initCommand = defineCommand({
35
+ meta: { name: "init", description },
36
+ args: {
37
+ agent: {
38
+ type: "string",
39
+ 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.",
40
+ alias: "a",
41
+ default: DEFAULT_AGENTS,
42
+ },
43
+ global: {
44
+ type: "boolean",
45
+ description: "Install to user directory instead of project",
46
+ default: false,
47
+ alias: "g",
48
+ },
49
+ yes: {
50
+ type: "boolean",
51
+ description: "Skip confirmation prompts",
52
+ default: true,
53
+ alias: "y",
54
+ },
55
+ },
56
+ run: async ({ args }) => {
57
+ const agents = args.agent
58
+ .split(",")
59
+ .map((s) => s.trim())
60
+ .filter(Boolean);
61
+ consola.start("Installing/updating vibedgames skills and the vg CLI...");
62
+ const [add, cli] = await Promise.all([
63
+ run("npx", skillsAddArgs(agents, args.global, args.yes)),
64
+ run("npm", ["install", "-g", PKG]),
65
+ ]);
66
+ if (add.code !== 0) {
67
+ if (add.output.trim())
68
+ consola.error(add.output.trim());
69
+ throw new Error(`skills add exited with code ${add.code}`);
70
+ }
71
+ consola.success(`Installed vibedgames skills for ${agents.join(", ")}`);
72
+ const update = await run("npx", skillsUpdateArgs(args.global, args.yes));
73
+ if (update.code !== 0) {
74
+ if (update.output.trim())
75
+ consola.warn(update.output.trim());
76
+ consola.warn(`'skills update' exited with code ${update.code}. Skills were just installed via 'add', so they should already be current.`);
77
+ }
78
+ else {
79
+ consola.success("Refreshed installed skills to latest");
80
+ }
81
+ if (cli.code !== 0) {
82
+ if (cli.output.trim())
83
+ consola.warn(cli.output.trim());
84
+ consola.warn(`Couldn't install the vg CLI globally (npm exit ${cli.code}). Install manually: npm install -g ${PKG}`);
85
+ return;
86
+ }
87
+ consola.success("Installed/updated vg CLI globally");
88
+ },
89
+ });
@@ -24,7 +24,7 @@ export const loginCommand = defineCommand({
24
24
  run: async () => {
25
25
  const baseUrl = getBaseUrl();
26
26
  const client = createPublicClient(baseUrl);
27
- const { code } = await client.cliAuth.create.mutate();
27
+ const { code } = await client.auth.cliInit.mutate();
28
28
  consola.box(`Code: ${code}`);
29
29
  consola.info("Opening browser to complete authentication...");
30
30
  const authUrl = `${baseUrl}/auth/cli?code=${code}`;
@@ -32,7 +32,7 @@ export const loginCommand = defineCommand({
32
32
  consola.start("Waiting for confirmation...");
33
33
  for (let i = 0; i < MAX_POLLS; i++) {
34
34
  await sleep(POLL_INTERVAL_MS);
35
- const result = await client.cliAuth.poll.query({ code });
35
+ const result = await client.auth.cliPoll.query({ code });
36
36
  if (result.status === "confirmed") {
37
37
  saveConfig({ token: result.token, baseUrl });
38
38
  consola.success("Logged in successfully");
@@ -0,0 +1 @@
1
+ export declare const mediaCommand: import("citty").CommandDef<import("citty").ArgsDef>;