vibedgames 0.4.1 → 0.5.1
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 +1 -1
- package/dist/commands/completions.d.ts +1 -1
- package/dist/commands/completions.js +21 -20
- package/dist/commands/credits.d.ts +5 -5
- package/dist/commands/credits.js +45 -47
- package/dist/commands/deploy.d.ts +10 -10
- package/dist/commands/deploy.js +157 -137
- package/dist/commands/factory.d.ts +1 -1
- package/dist/commands/factory.js +18 -15
- package/dist/commands/fork.d.ts +14 -14
- package/dist/commands/fork.js +53 -45
- package/dist/commands/generate.js +343 -286
- package/dist/commands/init.d.ts +8 -8
- package/dist/commands/init.js +31 -24
- package/dist/commands/login.js +14 -14
- package/dist/commands/logout.js +2 -2
- package/dist/commands/new.d.ts +16 -16
- package/dist/commands/new.js +191 -165
- package/dist/commands/playtest.d.ts +5 -5
- package/dist/commands/playtest.js +103 -97
- package/dist/commands/update.d.ts +7 -7
- package/dist/commands/update.js +22 -17
- package/dist/commands/whoami.d.ts +5 -5
- package/dist/commands/whoami.js +11 -10
- package/dist/index.js +12 -10
- package/dist/lib/api.d.ts +16 -4
- package/dist/lib/api.js +20 -32
- package/dist/lib/archive.d.ts +4 -4
- package/dist/lib/archive.js +123 -102
- package/dist/lib/codex.d.ts +46 -15
- package/dist/lib/codex.js +178 -108
- package/dist/lib/config-file.d.ts +6 -6
- package/dist/lib/config-file.js +33 -30
- package/dist/lib/config.d.ts +8 -8
- package/dist/lib/config.js +38 -30
- package/dist/lib/manifest.d.ts +3 -3
- package/dist/lib/manifest.js +44 -40
- package/dist/lib/media-args.d.ts +8 -6
- package/dist/lib/media-args.js +113 -94
- package/dist/lib/media-download.d.ts +9 -8
- package/dist/lib/media-download.js +158 -144
- package/dist/lib/media-poll.d.ts +8 -7
- package/dist/lib/media-poll.js +38 -32
- package/dist/lib/media-upload.d.ts +1 -1
- package/dist/lib/media-upload.js +30 -29
- package/dist/lib/output.d.ts +34 -11
- package/dist/lib/output.js +28 -20
- package/dist/lib/package-manager.d.ts +3 -3
- package/dist/lib/package-manager.js +27 -22
- package/dist/lib/run.d.ts +4 -4
- package/dist/lib/run.js +7 -4
- package/dist/lib/strict-args.d.ts +4 -4
- package/dist/lib/strict-args.js +29 -19
- package/dist/lib/types.d.ts +16 -2
- package/dist/lib/types.js +10 -4
- package/dist/lib/update.d.ts +4 -4
- package/dist/lib/update.js +47 -35
- package/dist/lib/upload.d.ts +4 -4
- package/dist/lib/upload.js +14 -9
- package/package.json +7 -8
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`
|
|
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,7 +1,7 @@
|
|
|
1
1
|
export declare const completionsCommand: import("citty").CommandDef<{
|
|
2
2
|
readonly shell: {
|
|
3
|
-
readonly type: "positional";
|
|
4
3
|
readonly description: "Shell to generate completions for: bash | zsh | fish";
|
|
5
4
|
readonly required: true;
|
|
5
|
+
readonly type: "positional";
|
|
6
6
|
};
|
|
7
7
|
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
2
|
const SUPPORTED = new Set(["bash", "zsh", "fish"]);
|
|
3
|
+
const isShell = (value) => SUPPORTED.has(value);
|
|
3
4
|
const SUBCOMMANDS = [
|
|
4
5
|
"new",
|
|
5
6
|
"init",
|
|
@@ -36,8 +37,7 @@ const GENERATE_FLAGS = [
|
|
|
36
37
|
"--json",
|
|
37
38
|
"--quiet",
|
|
38
39
|
];
|
|
39
|
-
|
|
40
|
-
return `# vg completions for bash. Source this file or write it to a file in your
|
|
40
|
+
const bashScript = () => `# vg completions for bash. Source this file or write it to a file in your
|
|
41
41
|
# bash completion directory (e.g. /etc/bash_completion.d/vg).
|
|
42
42
|
_vg_completions() {
|
|
43
43
|
local cur prev cmd subcmd
|
|
@@ -69,9 +69,7 @@ _vg_completions() {
|
|
|
69
69
|
}
|
|
70
70
|
complete -F _vg_completions vg
|
|
71
71
|
`;
|
|
72
|
-
|
|
73
|
-
function zshScript() {
|
|
74
|
-
return `# vg completions for zsh. Source this file or place it on your fpath.
|
|
72
|
+
const zshScript = () => `# vg completions for zsh. Source this file or place it on your fpath.
|
|
75
73
|
_vg() {
|
|
76
74
|
local -a subcmds generate_subs generate_flags common_flags
|
|
77
75
|
subcmds=(${SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
|
|
@@ -98,14 +96,13 @@ _vg() {
|
|
|
98
96
|
}
|
|
99
97
|
compdef _vg vg
|
|
100
98
|
`;
|
|
101
|
-
|
|
102
|
-
function fishFlag(flag, condition) {
|
|
99
|
+
const fishFlag = (flag, condition) => {
|
|
103
100
|
const isShort = flag.startsWith("-") && !flag.startsWith("--");
|
|
104
|
-
const name = flag.replace(
|
|
101
|
+
const name = flag.replace(/^--?/u, "");
|
|
105
102
|
const opt = isShort ? "-s" : "-l";
|
|
106
103
|
return `complete -c vg -n '${condition}' ${opt} '${name}'`;
|
|
107
|
-
}
|
|
108
|
-
|
|
104
|
+
};
|
|
105
|
+
const fishScript = () => {
|
|
109
106
|
const generateFlagLines = [...GENERATE_FLAGS, ...COMMON_FLAGS].map((flag) => fishFlag(flag, "__fish_seen_subcommand_from generate"));
|
|
110
107
|
// For all other subcommands, only the common flags are meaningful.
|
|
111
108
|
const otherSubcommands = SUBCOMMANDS.filter((s) => s !== "generate");
|
|
@@ -119,26 +116,30 @@ ${GENERATE_SUBCOMMANDS.map((sub) => `complete -c vg -n '__fish_seen_subcommand_f
|
|
|
119
116
|
${generateFlagLines.join("\n")}
|
|
120
117
|
${otherFlagLines.join("\n")}
|
|
121
118
|
`;
|
|
122
|
-
}
|
|
119
|
+
};
|
|
123
120
|
export const completionsCommand = defineCommand({
|
|
124
|
-
meta: {
|
|
125
|
-
name: "completions",
|
|
126
|
-
description: "Print shell completions for vg. Pipe into your shell's completion dir.",
|
|
127
|
-
},
|
|
128
121
|
args: {
|
|
129
122
|
shell: {
|
|
130
|
-
type: "positional",
|
|
131
123
|
description: "Shell to generate completions for: bash | zsh | fish",
|
|
132
124
|
required: true,
|
|
125
|
+
type: "positional",
|
|
133
126
|
},
|
|
134
127
|
},
|
|
128
|
+
meta: {
|
|
129
|
+
description: "Print shell completions for vg. Pipe into your shell's completion dir.",
|
|
130
|
+
name: "completions",
|
|
131
|
+
},
|
|
135
132
|
run: ({ args }) => {
|
|
136
133
|
const shell = String(args.shell ?? "");
|
|
137
|
-
if (!
|
|
138
|
-
process.stderr.write(`Unsupported shell "${shell}". Expected: ${
|
|
134
|
+
if (!isShell(shell)) {
|
|
135
|
+
process.stderr.write(`Unsupported shell "${shell}". Expected: ${[...SUPPORTED].join(", ")}\n`);
|
|
139
136
|
process.exit(1);
|
|
140
137
|
}
|
|
141
|
-
const
|
|
142
|
-
|
|
138
|
+
const scripts = {
|
|
139
|
+
bash: bashScript,
|
|
140
|
+
fish: fishScript,
|
|
141
|
+
zsh: zshScript,
|
|
142
|
+
};
|
|
143
|
+
process.stdout.write(scripts[shell]());
|
|
143
144
|
},
|
|
144
145
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const creditsCommand: import("citty").CommandDef<{
|
|
2
|
-
readonly json: {
|
|
3
|
-
readonly type: "boolean";
|
|
4
|
-
readonly description: "Print structured JSON to stdout.";
|
|
5
|
-
};
|
|
6
2
|
readonly field: {
|
|
7
|
-
readonly type: "string";
|
|
8
3
|
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.";
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
};
|
|
6
|
+
readonly json: {
|
|
7
|
+
readonly description: "Print structured JSON to stdout.";
|
|
8
|
+
readonly type: "boolean";
|
|
9
9
|
};
|
|
10
10
|
}>;
|
package/dist/commands/credits.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
|
-
import consola from "consola";
|
|
3
|
-
import { createClient } from "../lib/api.js";
|
|
2
|
+
import { consola } from "consola";
|
|
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
6
|
import { assertKnownFlags } from "../lib/strict-args.js";
|
|
@@ -10,67 +10,64 @@ const SUB_CENT_MICRO = MICRO_PER_USD / 100;
|
|
|
10
10
|
const MAX_ENTRIES_SHOWN = 15;
|
|
11
11
|
// Dollars from integer micro-USD. Two decimals normally; four when the
|
|
12
12
|
// magnitude is sub-cent so small generation charges don't render as $0.00.
|
|
13
|
-
|
|
13
|
+
const formatUsd = (micro) => {
|
|
14
14
|
const abs = Math.abs(micro);
|
|
15
15
|
const decimals = abs > 0 && abs < SUB_CENT_MICRO ? 4 : 2;
|
|
16
16
|
const base = `$${(abs / MICRO_PER_USD).toFixed(decimals)}`;
|
|
17
17
|
return micro < 0 ? `-${base}` : base;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
function kindLabel(kind, deltaMicro) {
|
|
18
|
+
};
|
|
19
|
+
const formatSignedUsd = (micro) => micro < 0 ? formatUsd(micro) : `+${formatUsd(micro)}`;
|
|
20
|
+
const kindLabel = (kind, deltaMicro) => {
|
|
23
21
|
switch (kind) {
|
|
24
|
-
case "signup_grant":
|
|
22
|
+
case "signup_grant": {
|
|
25
23
|
return "Welcome credits";
|
|
26
|
-
|
|
24
|
+
}
|
|
25
|
+
case "admin_grant": {
|
|
27
26
|
return deltaMicro < 0 ? "Adjustment" : "Credit grant";
|
|
28
|
-
|
|
27
|
+
}
|
|
28
|
+
case "generation_hold": {
|
|
29
29
|
return "Generation";
|
|
30
|
-
|
|
30
|
+
}
|
|
31
|
+
case "generation_settle": {
|
|
31
32
|
return "Usage adjustment";
|
|
32
|
-
|
|
33
|
+
}
|
|
34
|
+
case "generation_release": {
|
|
33
35
|
return "Refund — failed generation";
|
|
34
|
-
|
|
36
|
+
}
|
|
37
|
+
default: {
|
|
35
38
|
return kind;
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
|
-
}
|
|
41
|
+
};
|
|
38
42
|
// Relative for the last week, short date beyond that.
|
|
39
|
-
|
|
43
|
+
const formatWhen = (date, now) => {
|
|
40
44
|
const minutes = Math.floor((now.getTime() - date.getTime()) / 60_000);
|
|
41
|
-
if (minutes < 1)
|
|
45
|
+
if (minutes < 1) {
|
|
42
46
|
return "just now";
|
|
43
|
-
|
|
47
|
+
}
|
|
48
|
+
if (minutes < 60) {
|
|
44
49
|
return `${minutes}m ago`;
|
|
50
|
+
}
|
|
45
51
|
const hours = Math.floor(minutes / 60);
|
|
46
|
-
if (hours < 24)
|
|
52
|
+
if (hours < 24) {
|
|
47
53
|
return `${hours}h ago`;
|
|
54
|
+
}
|
|
48
55
|
const days = Math.floor(hours / 24);
|
|
49
|
-
if (days < 7)
|
|
56
|
+
if (days < 7) {
|
|
50
57
|
return `${days}d ago`;
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
}
|
|
59
|
+
const opts = { day: "numeric", month: "short" };
|
|
60
|
+
if (date.getFullYear() !== now.getFullYear()) {
|
|
53
61
|
opts.year = "numeric";
|
|
54
|
-
return date.toLocaleDateString("en-US", opts);
|
|
55
|
-
}
|
|
56
|
-
function authErrorCode(err) {
|
|
57
|
-
if (typeof err === "object" && err !== null && "data" in err) {
|
|
58
|
-
const data = err.data;
|
|
59
|
-
if (typeof data === "object" &&
|
|
60
|
-
data !== null &&
|
|
61
|
-
"code" in data &&
|
|
62
|
-
typeof data.code === "string") {
|
|
63
|
-
return data.code;
|
|
64
|
-
}
|
|
65
62
|
}
|
|
66
|
-
return
|
|
67
|
-
}
|
|
63
|
+
return date.toLocaleDateString("en-US", opts);
|
|
64
|
+
};
|
|
68
65
|
export const creditsCommand = defineCommand({
|
|
66
|
+
args: creditsArgs,
|
|
69
67
|
meta: {
|
|
70
|
-
name: "credits",
|
|
71
68
|
description: "Show your credit balance and recent usage.",
|
|
69
|
+
name: "credits",
|
|
72
70
|
},
|
|
73
|
-
args: creditsArgs,
|
|
74
71
|
run: async ({ args, rawArgs }) => {
|
|
75
72
|
assertKnownFlags(rawArgs, creditsArgs);
|
|
76
73
|
const token = getToken();
|
|
@@ -80,22 +77,23 @@ export const creditsCommand = defineCommand({
|
|
|
80
77
|
}
|
|
81
78
|
const client = createClient();
|
|
82
79
|
try {
|
|
83
|
-
const { balanceMicro, entries } = await client.credits.me
|
|
80
|
+
const { balanceMicro, entries } = await client.credits.me();
|
|
84
81
|
const payload = {
|
|
85
82
|
balance_micro: balanceMicro,
|
|
86
83
|
balance_usd: balanceMicro / MICRO_PER_USD,
|
|
87
84
|
entries: entries.map((e) => ({
|
|
88
|
-
|
|
85
|
+
created_at: e.createdAt.toISOString(),
|
|
89
86
|
delta_micro: e.deltaMicro,
|
|
90
|
-
kind: e.kind,
|
|
91
|
-
request_id: e.requestId,
|
|
92
87
|
endpoint_id: e.endpointId,
|
|
88
|
+
id: e.id,
|
|
89
|
+
kind: e.kind,
|
|
93
90
|
note: e.note,
|
|
94
|
-
|
|
91
|
+
request_id: e.requestId,
|
|
95
92
|
})),
|
|
96
93
|
};
|
|
97
|
-
if (writeStructured(payload, args))
|
|
94
|
+
if (writeStructured(payload, args)) {
|
|
98
95
|
return;
|
|
96
|
+
}
|
|
99
97
|
consola.log(`Balance: ${formatUsd(balanceMicro)}`);
|
|
100
98
|
if (entries.length === 0) {
|
|
101
99
|
consola.log("No activity yet.");
|
|
@@ -104,8 +102,8 @@ export const creditsCommand = defineCommand({
|
|
|
104
102
|
const now = new Date();
|
|
105
103
|
const rows = entries.slice(0, MAX_ENTRIES_SHOWN).map((e) => ({
|
|
106
104
|
amount: formatSignedUsd(e.deltaMicro),
|
|
107
|
-
label: kindLabel(e.kind, e.deltaMicro),
|
|
108
105
|
endpoint: e.endpointId ?? "",
|
|
106
|
+
label: kindLabel(e.kind, e.deltaMicro),
|
|
109
107
|
when: formatWhen(e.createdAt, now),
|
|
110
108
|
}));
|
|
111
109
|
const amountWidth = Math.max(...rows.map((r) => r.amount.length));
|
|
@@ -122,15 +120,15 @@ export const creditsCommand = defineCommand({
|
|
|
122
120
|
consola.log(line.trimEnd());
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
|
-
catch (
|
|
123
|
+
catch (error) {
|
|
126
124
|
// Only an auth error means "log in"; surface network/server failures as
|
|
127
125
|
// themselves so they aren't mistaken for a bad credential.
|
|
128
|
-
const code = authErrorCode(
|
|
126
|
+
const code = authErrorCode(error);
|
|
129
127
|
if (code === "UNAUTHORIZED" || code === "FORBIDDEN") {
|
|
130
128
|
consola.warn("Not authenticated. Run `vg login`, or check your VG_TOKEN / API key.");
|
|
131
129
|
}
|
|
132
130
|
else {
|
|
133
|
-
consola.error(`Failed to fetch credits: ${
|
|
131
|
+
consola.error(`Failed to fetch credits: ${error instanceof Error ? error.message : String(error)}`);
|
|
134
132
|
}
|
|
135
133
|
process.exit(1);
|
|
136
134
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
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
2
|
readonly field: {
|
|
7
|
-
readonly type: "string";
|
|
8
3
|
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.";
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
};
|
|
6
|
+
readonly json: {
|
|
7
|
+
readonly description: "Print structured JSON to stdout.";
|
|
8
|
+
readonly type: "boolean";
|
|
9
9
|
};
|
|
10
10
|
readonly dir: {
|
|
11
|
-
readonly
|
|
11
|
+
readonly default: ".";
|
|
12
12
|
readonly description: "Directory to deploy";
|
|
13
13
|
readonly required: false;
|
|
14
|
-
readonly
|
|
14
|
+
readonly type: "positional";
|
|
15
15
|
};
|
|
16
16
|
readonly slug: {
|
|
17
|
-
readonly type: "string";
|
|
18
17
|
readonly description: "Override the slug (bypasses vibedgames.json)";
|
|
19
18
|
readonly required: false;
|
|
19
|
+
readonly type: "string";
|
|
20
20
|
};
|
|
21
21
|
readonly source: {
|
|
22
|
-
readonly type: "boolean";
|
|
23
|
-
readonly description: "Also upload a forkable source archive, letting anyone logged in fork the project.";
|
|
24
22
|
readonly default: false;
|
|
23
|
+
readonly description: "Also upload a forkable source archive, letting anyone logged in fork the project.";
|
|
24
|
+
readonly type: "boolean";
|
|
25
25
|
};
|
|
26
26
|
}>;
|