vibedgames 0.5.0 → 0.6.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/LICENSE +21 -0
- 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 +43 -33
- package/dist/commands/deploy.d.ts +10 -10
- package/dist/commands/deploy.js +155 -139
- 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 +51 -46
- package/dist/commands/generate.js +318 -264
- package/dist/commands/init.d.ts +8 -8
- package/dist/commands/init.js +31 -24
- package/dist/commands/login.js +12 -12
- package/dist/commands/logout.js +2 -2
- package/dist/commands/new.d.ts +16 -16
- package/dist/commands/new.js +153 -142
- package/dist/commands/playtest-run.d.ts +62 -0
- package/dist/commands/playtest-run.js +258 -0
- package/dist/commands/playtest.d.ts +41 -6
- package/dist/commands/playtest.js +114 -101
- package/dist/commands/update.d.ts +7 -7
- package/dist/commands/update.js +20 -17
- package/dist/commands/whoami.d.ts +5 -5
- package/dist/commands/whoami.js +8 -7
- package/dist/index.js +21 -11
- package/dist/lib/api.d.ts +4 -4
- package/dist/lib/api.js +6 -12
- package/dist/lib/archive.d.ts +4 -4
- package/dist/lib/archive.js +121 -104
- package/dist/lib/codex.d.ts +45 -15
- package/dist/lib/codex.js +175 -106
- package/dist/lib/config-file.d.ts +6 -6
- package/dist/lib/config-file.js +28 -26
- package/dist/lib/config.d.ts +8 -8
- package/dist/lib/config.js +31 -33
- package/dist/lib/manifest.d.ts +3 -3
- package/dist/lib/manifest.js +42 -38
- package/dist/lib/media-args.d.ts +7 -7
- package/dist/lib/media-args.js +113 -95
- package/dist/lib/media-download.d.ts +9 -9
- package/dist/lib/media-download.js +148 -134
- package/dist/lib/media-poll.d.ts +8 -8
- package/dist/lib/media-poll.js +32 -27
- package/dist/lib/media-upload.d.ts +2 -2
- package/dist/lib/media-upload.js +27 -27
- package/dist/lib/output.d.ts +27 -12
- package/dist/lib/output.js +26 -26
- package/dist/lib/package-manager.d.ts +3 -3
- package/dist/lib/package-manager.js +27 -22
- package/dist/lib/playtest/agent.d.ts +188 -0
- package/dist/lib/playtest/agent.js +610 -0
- package/dist/lib/playtest/browser.d.ts +109 -0
- package/dist/lib/playtest/browser.js +219 -0
- package/dist/lib/playtest/controls.d.ts +47 -0
- package/dist/lib/playtest/controls.js +218 -0
- package/dist/lib/playtest/errors.d.ts +9 -0
- package/dist/lib/playtest/errors.js +12 -0
- package/dist/lib/playtest/keys.d.ts +41 -0
- package/dist/lib/playtest/keys.js +157 -0
- package/dist/lib/playtest/run.d.ts +193 -0
- package/dist/lib/playtest/run.js +408 -0
- 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 +28 -18
- package/dist/lib/types.d.ts +5 -5
- package/dist/lib/types.js +9 -12
- package/dist/lib/update.d.ts +4 -4
- package/dist/lib/update.js +41 -32
- package/dist/lib/upload.d.ts +4 -4
- package/dist/lib/upload.js +14 -9
- package/package.json +16 -16
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Kaiyu Hsu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
|
-
import consola from "consola";
|
|
2
|
+
import { consola } from "consola";
|
|
3
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";
|
|
@@ -10,55 +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";
|
|
62
|
+
}
|
|
54
63
|
return date.toLocaleDateString("en-US", opts);
|
|
55
|
-
}
|
|
64
|
+
};
|
|
56
65
|
export const creditsCommand = defineCommand({
|
|
66
|
+
args: creditsArgs,
|
|
57
67
|
meta: {
|
|
58
|
-
name: "credits",
|
|
59
68
|
description: "Show your credit balance and recent usage.",
|
|
69
|
+
name: "credits",
|
|
60
70
|
},
|
|
61
|
-
args: creditsArgs,
|
|
62
71
|
run: async ({ args, rawArgs }) => {
|
|
63
72
|
assertKnownFlags(rawArgs, creditsArgs);
|
|
64
73
|
const token = getToken();
|
|
@@ -73,17 +82,18 @@ export const creditsCommand = defineCommand({
|
|
|
73
82
|
balance_micro: balanceMicro,
|
|
74
83
|
balance_usd: balanceMicro / MICRO_PER_USD,
|
|
75
84
|
entries: entries.map((e) => ({
|
|
76
|
-
|
|
85
|
+
created_at: e.createdAt.toISOString(),
|
|
77
86
|
delta_micro: e.deltaMicro,
|
|
78
|
-
kind: e.kind,
|
|
79
|
-
request_id: e.requestId,
|
|
80
87
|
endpoint_id: e.endpointId,
|
|
88
|
+
id: e.id,
|
|
89
|
+
kind: e.kind,
|
|
81
90
|
note: e.note,
|
|
82
|
-
|
|
91
|
+
request_id: e.requestId,
|
|
83
92
|
})),
|
|
84
93
|
};
|
|
85
|
-
if (writeStructured(payload, args))
|
|
94
|
+
if (writeStructured(payload, args)) {
|
|
86
95
|
return;
|
|
96
|
+
}
|
|
87
97
|
consola.log(`Balance: ${formatUsd(balanceMicro)}`);
|
|
88
98
|
if (entries.length === 0) {
|
|
89
99
|
consola.log("No activity yet.");
|
|
@@ -92,8 +102,8 @@ export const creditsCommand = defineCommand({
|
|
|
92
102
|
const now = new Date();
|
|
93
103
|
const rows = entries.slice(0, MAX_ENTRIES_SHOWN).map((e) => ({
|
|
94
104
|
amount: formatSignedUsd(e.deltaMicro),
|
|
95
|
-
label: kindLabel(e.kind, e.deltaMicro),
|
|
96
105
|
endpoint: e.endpointId ?? "",
|
|
106
|
+
label: kindLabel(e.kind, e.deltaMicro),
|
|
97
107
|
when: formatWhen(e.createdAt, now),
|
|
98
108
|
}));
|
|
99
109
|
const amountWidth = Math.max(...rows.map((r) => r.amount.length));
|
|
@@ -110,15 +120,15 @@ export const creditsCommand = defineCommand({
|
|
|
110
120
|
consola.log(line.trimEnd());
|
|
111
121
|
}
|
|
112
122
|
}
|
|
113
|
-
catch (
|
|
123
|
+
catch (error) {
|
|
114
124
|
// Only an auth error means "log in"; surface network/server failures as
|
|
115
125
|
// themselves so they aren't mistaken for a bad credential.
|
|
116
|
-
const code = authErrorCode(
|
|
126
|
+
const code = authErrorCode(error);
|
|
117
127
|
if (code === "UNAUTHORIZED" || code === "FORBIDDEN") {
|
|
118
128
|
consola.warn("Not authenticated. Run `vg login`, or check your VG_TOKEN / API key.");
|
|
119
129
|
}
|
|
120
130
|
else {
|
|
121
|
-
consola.error(`Failed to fetch credits: ${
|
|
131
|
+
consola.error(`Failed to fetch credits: ${error instanceof Error ? error.message : String(error)}`);
|
|
122
132
|
}
|
|
123
133
|
process.exit(1);
|
|
124
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
|
}>;
|