vibedgames 0.6.3 → 0.8.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 (140) hide show
  1. package/README.md +14 -9
  2. package/dist/THIRD_PARTY_NOTICES.txt +383 -0
  3. package/dist/chunk-2QBYTIMH.js +511 -0
  4. package/dist/chunk-6FZPPUQH.js +107 -0
  5. package/dist/chunk-AZGENOOR.js +22 -0
  6. package/dist/chunk-CAKBGDCY.js +47 -0
  7. package/dist/chunk-CU7UY5YJ.js +1108 -0
  8. package/dist/chunk-CZPKN32Z.js +257 -0
  9. package/dist/chunk-FL6IFBUF.js +22 -0
  10. package/dist/chunk-FNYBZNW2.js +165 -0
  11. package/dist/chunk-GUF6ADBF.js +273 -0
  12. package/dist/chunk-H4NBRFBY.js +79 -0
  13. package/dist/chunk-HASKWB6B.js +111 -0
  14. package/dist/chunk-I6O4HIDY.js +1063 -0
  15. package/dist/chunk-IO6OM6WM.js +466 -0
  16. package/dist/chunk-J6PKNPI2.js +26 -0
  17. package/dist/chunk-JT2AU24K.js +759 -0
  18. package/dist/chunk-K5SC6SXO.js +172 -0
  19. package/dist/chunk-MBXCVCC4.js +478 -0
  20. package/dist/chunk-PEUP4MZR.js +59 -0
  21. package/dist/chunk-PQDBCZRT.js +2017 -0
  22. package/dist/chunk-RIGKOLNN.js +1360 -0
  23. package/dist/chunk-RNBUX5VF.js +68 -0
  24. package/dist/chunk-RYFO3ZPO.js +71 -0
  25. package/dist/chunk-RZ4DIJQW.js +68 -0
  26. package/dist/chunk-SAANBZ25.js +118 -0
  27. package/dist/chunk-TMK6V5FV.js +395 -0
  28. package/dist/chunk-TYVYWBY6.js +69 -0
  29. package/dist/chunk-VFFOT7KD.js +2980 -0
  30. package/dist/chunk-W5XP4ZVU.js +159 -0
  31. package/dist/chunk-X4ZABSCN.js +415 -0
  32. package/dist/chunk-XDC7QGOF.js +32 -0
  33. package/dist/chunk-XK5RZQMX.js +1780 -0
  34. package/dist/chunk-Y552BNFZ.js +41 -0
  35. package/dist/chunk-Z4Z24FWO.js +39 -0
  36. package/dist/chunk-ZI6PKVXG.js +64 -0
  37. package/dist/chunk-ZYCSYJWX.js +87 -0
  38. package/dist/index.js +67 -60
  39. package/package.json +13 -16
  40. package/templates/none/_gitignore +3 -0
  41. package/templates/none/index.html +29 -0
  42. package/templates/none/package.json +16 -0
  43. package/templates/none/src/main.ts +16 -0
  44. package/templates/none/tsconfig.json +18 -0
  45. package/templates/none/vite.config.ts +8 -0
  46. package/templates/phaser/_gitignore +3 -0
  47. package/templates/phaser/index.html +24 -0
  48. package/templates/phaser/package.json +19 -0
  49. package/templates/phaser/src/main.ts +16 -0
  50. package/templates/phaser/src/scenes/game-scene.ts +65 -0
  51. package/templates/phaser/tsconfig.json +18 -0
  52. package/templates/phaser/vite.config.ts +8 -0
  53. package/templates/react-r3f/_gitignore +3 -0
  54. package/templates/react-r3f/index.html +24 -0
  55. package/templates/react-r3f/package.json +27 -0
  56. package/templates/react-r3f/src/app.tsx +33 -0
  57. package/templates/react-r3f/src/main.tsx +15 -0
  58. package/templates/react-r3f/tsconfig.json +19 -0
  59. package/templates/react-r3f/vite.config.ts +10 -0
  60. package/templates/threejs/_gitignore +3 -0
  61. package/templates/threejs/index.html +36 -0
  62. package/templates/threejs/package.json +20 -0
  63. package/templates/threejs/src/main.ts +44 -0
  64. package/templates/threejs/tsconfig.json +18 -0
  65. package/templates/threejs/vite.config.ts +8 -0
  66. package/dist/commands/completions.d.ts +0 -7
  67. package/dist/commands/completions.js +0 -145
  68. package/dist/commands/credits.d.ts +0 -10
  69. package/dist/commands/credits.js +0 -136
  70. package/dist/commands/deploy.d.ts +0 -26
  71. package/dist/commands/deploy.js +0 -257
  72. package/dist/commands/factory.d.ts +0 -3
  73. package/dist/commands/factory.js +0 -73
  74. package/dist/commands/fork.d.ts +0 -29
  75. package/dist/commands/fork.js +0 -124
  76. package/dist/commands/generate.d.ts +0 -1
  77. package/dist/commands/generate.js +0 -565
  78. package/dist/commands/init.d.ts +0 -20
  79. package/dist/commands/init.js +0 -105
  80. package/dist/commands/login.d.ts +0 -1
  81. package/dist/commands/login.js +0 -45
  82. package/dist/commands/logout.d.ts +0 -1
  83. package/dist/commands/logout.js +0 -13
  84. package/dist/commands/new.d.ts +0 -26
  85. package/dist/commands/new.js +0 -318
  86. package/dist/commands/playtest-run.d.ts +0 -66
  87. package/dist/commands/playtest-run.js +0 -268
  88. package/dist/commands/playtest.d.ts +0 -76
  89. package/dist/commands/playtest.js +0 -372
  90. package/dist/commands/update.d.ts +0 -13
  91. package/dist/commands/update.js +0 -82
  92. package/dist/commands/whoami.d.ts +0 -10
  93. package/dist/commands/whoami.js +0 -44
  94. package/dist/index.d.ts +0 -2
  95. package/dist/lib/api.d.ts +0 -18
  96. package/dist/lib/api.js +0 -27
  97. package/dist/lib/archive.d.ts +0 -17
  98. package/dist/lib/archive.js +0 -228
  99. package/dist/lib/codex.d.ts +0 -117
  100. package/dist/lib/codex.js +0 -426
  101. package/dist/lib/config-file.d.ts +0 -16
  102. package/dist/lib/config-file.js +0 -54
  103. package/dist/lib/config.d.ts +0 -11
  104. package/dist/lib/config.js +0 -54
  105. package/dist/lib/manifest.d.ts +0 -10
  106. package/dist/lib/manifest.js +0 -91
  107. package/dist/lib/media-args.d.ts +0 -30
  108. package/dist/lib/media-args.js +0 -219
  109. package/dist/lib/media-download.d.ts +0 -37
  110. package/dist/lib/media-download.js +0 -268
  111. package/dist/lib/media-poll.d.ts +0 -18
  112. package/dist/lib/media-poll.js +0 -86
  113. package/dist/lib/media-upload.d.ts +0 -12
  114. package/dist/lib/media-upload.js +0 -52
  115. package/dist/lib/output.d.ts +0 -68
  116. package/dist/lib/output.js +0 -102
  117. package/dist/lib/package-manager.d.ts +0 -25
  118. package/dist/lib/package-manager.js +0 -77
  119. package/dist/lib/playtest/agent.d.ts +0 -192
  120. package/dist/lib/playtest/agent.js +0 -652
  121. package/dist/lib/playtest/browser.d.ts +0 -109
  122. package/dist/lib/playtest/browser.js +0 -219
  123. package/dist/lib/playtest/controls.d.ts +0 -47
  124. package/dist/lib/playtest/controls.js +0 -218
  125. package/dist/lib/playtest/errors.d.ts +0 -9
  126. package/dist/lib/playtest/errors.js +0 -12
  127. package/dist/lib/playtest/keys.d.ts +0 -41
  128. package/dist/lib/playtest/keys.js +0 -157
  129. package/dist/lib/playtest/run.d.ts +0 -195
  130. package/dist/lib/playtest/run.js +0 -409
  131. package/dist/lib/run.d.ts +0 -19
  132. package/dist/lib/run.js +0 -23
  133. package/dist/lib/strict-args.d.ts +0 -27
  134. package/dist/lib/strict-args.js +0 -78
  135. package/dist/lib/types.d.ts +0 -16
  136. package/dist/lib/types.js +0 -10
  137. package/dist/lib/update.d.ts +0 -10
  138. package/dist/lib/update.js +0 -110
  139. package/dist/lib/upload.d.ts +0 -16
  140. package/dist/lib/upload.js +0 -41
@@ -1,228 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, } from "node:fs";
3
- import path from "node:path";
4
- import ignore from "ignore";
5
- import { create as tarCreate, extract as tarExtract } from "tar";
6
- import { isJsonObject, isJsonString } from "./types.js";
7
- /**
8
- * Patterns ALWAYS excluded from a source archive, regardless of .gitignore —
9
- * build output, VCS internals, and (critically) secrets. Source upload is a
10
- * publish: anything left in the folder becomes forkable by anyone.
11
- */
12
- const HARD_EXCLUDES = [
13
- "node_modules",
14
- ".git",
15
- "dist",
16
- "build",
17
- ".next",
18
- ".turbo",
19
- ".cache",
20
- ".vercel",
21
- ".wrangler",
22
- "coverage",
23
- ".DS_Store",
24
- "*.log",
25
- // secrets — never ship these
26
- ".env",
27
- ".env.*",
28
- "*.pem",
29
- "*.key",
30
- "*.p12",
31
- "*.pfx",
32
- "id_rsa",
33
- "id_dsa",
34
- "id_ecdsa",
35
- "id_ed25519",
36
- ".npmrc",
37
- ".git-credentials",
38
- // archives (avoid bundling our own output)
39
- "*.tgz",
40
- "*.tar.gz",
41
- ];
42
- /**
43
- * Build the exclusion predicate. HARD_EXCLUDES live in their OWN matcher,
44
- * checked independently of the user's .gitignore/.vibedgamesignore — so a
45
- * negation like `!.env` in a user ignore file can NOT un-exclude a secret.
46
- * A path is excluded if EITHER matcher says so.
47
- */
48
- const buildIgnorer = (root) => {
49
- const hard = ignore().add(HARD_EXCLUDES);
50
- const user = ignore();
51
- for (const name of [".gitignore", ".vibedgamesignore"]) {
52
- const p = path.join(root, name);
53
- if (existsSync(p)) {
54
- user.add(readFileSync(p, "utf-8"));
55
- }
56
- }
57
- return (rel) => hard.ignores(rel) || user.ignores(rel);
58
- };
59
- /** Walk `root`, returning posix relative paths of files not ignored. Ignored
60
- * directories are pruned (not descended into) for speed. */
61
- const collectFiles = (root, ignored) => {
62
- const out = [];
63
- const walk = (dir) => {
64
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
65
- const abs = path.join(dir, entry.name);
66
- const rel = path.relative(root, abs).split(path.sep).join("/");
67
- if (!rel) {
68
- continue;
69
- }
70
- // `ignore` matches dirs via a trailing slash; test both forms.
71
- if (entry.isDirectory()) {
72
- if (ignored(`${rel}/`) || ignored(rel)) {
73
- continue;
74
- }
75
- walk(abs);
76
- }
77
- else if (entry.isFile()) {
78
- if (ignored(rel)) {
79
- continue;
80
- }
81
- out.push(rel);
82
- }
83
- }
84
- };
85
- walk(root);
86
- return out.toSorted();
87
- };
88
- /** Version of an installed dependency, searching node_modules up the tree. */
89
- const installedVersion = (root, name) => {
90
- let dir = root;
91
- while (true) {
92
- const p = path.join(dir, "node_modules", name, "package.json");
93
- if (existsSync(p)) {
94
- try {
95
- const pkg = JSON.parse(readFileSync(p, "utf-8"));
96
- const v = isJsonObject(pkg) ? pkg.version : undefined;
97
- if (isJsonString(v)) {
98
- return v;
99
- }
100
- }
101
- catch {
102
- /* fall through to parent */
103
- }
104
- }
105
- const parent = path.dirname(dir);
106
- if (parent === dir) {
107
- return null;
108
- }
109
- dir = parent;
110
- }
111
- };
112
- const resolveSpec = (root, name, spec) => {
113
- if (spec.startsWith("workspace:")) {
114
- const range = spec.slice("workspace:".length);
115
- // Explicit range (e.g. workspace:^1.2.3) — keep the literal range.
116
- if (/\d/u.test(range)) {
117
- return range;
118
- }
119
- const v = installedVersion(root, name);
120
- if (!v) {
121
- return null;
122
- }
123
- if (range === "~") {
124
- return `~${v}`;
125
- }
126
- if (range === "*") {
127
- return v;
128
- // exact pin
129
- }
130
- // "" or "^"
131
- return `^${v}`;
132
- }
133
- // catalog: / catalog:<name> — resolve to the installed version, caret-pinned.
134
- const v = installedVersion(root, name);
135
- return v ? `^${v}` : null;
136
- };
137
- const DEP_FIELDS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
138
- /**
139
- * Rewrite `workspace:` / `catalog:` dep specs in package.json to the concrete
140
- * versions currently installed in node_modules — mirroring what `pnpm publish`
141
- * does — so the forked project installs from npm. Returns the rewritten JSON
142
- * string, or null if there's nothing to change (the common standalone case).
143
- */
144
- const rewriteWorkspaceProtocols = (root) => {
145
- let pkg;
146
- try {
147
- pkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf-8"));
148
- }
149
- catch {
150
- return null;
151
- }
152
- if (!isJsonObject(pkg)) {
153
- return null;
154
- }
155
- let changed = false;
156
- for (const field of DEP_FIELDS) {
157
- const deps = pkg[field];
158
- if (!isJsonObject(deps)) {
159
- continue;
160
- }
161
- for (const [name, spec] of Object.entries(deps)) {
162
- if (!isJsonString(spec)) {
163
- continue;
164
- }
165
- if (!spec.startsWith("workspace:") && !spec.startsWith("catalog:")) {
166
- continue;
167
- }
168
- const resolved = resolveSpec(root, name, spec);
169
- if (resolved && resolved !== spec) {
170
- deps[name] = resolved;
171
- changed = true;
172
- }
173
- }
174
- }
175
- return changed ? `${JSON.stringify(pkg, null, 2)}\n` : null;
176
- };
177
- /**
178
- * Create a gzipped tar of `root`'s source (respecting .gitignore +
179
- * HARD_EXCLUDES) at a temp path. Returns the archive path, its sha256, byte
180
- * size, and the list of included files.
181
- */
182
- export const packSource = async (root, tmpDir) => {
183
- const ignored = buildIgnorer(root);
184
- const files = collectFiles(root, ignored);
185
- if (files.length === 0) {
186
- throw new Error("No source files to archive (everything was ignored?).");
187
- }
188
- mkdirSync(tmpDir, { recursive: true });
189
- // If package.json uses pnpm-only protocols (workspace:/catalog:), a forked
190
- // copy wouldn't `npm install` standalone. Rewrite them to concrete installed
191
- // versions in the ARCHIVED package.json only (disk untouched) by staging the
192
- // file list into a temp dir. No protocols → no staging (fast path).
193
- const rewritten = files.includes("package.json") ? rewriteWorkspaceProtocols(root) : null;
194
- let cwd = root;
195
- let stage = null;
196
- if (rewritten) {
197
- stage = mkdtempSync(path.join(tmpDir, "stage-"));
198
- for (const f of files) {
199
- const dest = path.join(stage, f);
200
- mkdirSync(path.dirname(dest), { recursive: true });
201
- copyFileSync(path.join(root, f), dest);
202
- }
203
- writeFileSync(path.join(stage, "package.json"), rewritten);
204
- cwd = stage;
205
- }
206
- const tarball = path.join(tmpDir, `vg-source-${process.pid}-${files.length}.tgz`);
207
- try {
208
- await tarCreate({ cwd, file: tarball, gzip: true, portable: true }, files);
209
- }
210
- finally {
211
- if (stage) {
212
- rmSync(stage, { force: true, recursive: true });
213
- }
214
- }
215
- const buf = readFileSync(tarball);
216
- return {
217
- bytes: statSync(tarball).size,
218
- files,
219
- path: tarball,
220
- sha256: createHash("sha256").update(buf).digest("hex"),
221
- };
222
- };
223
- /** Extract a gzipped tar into `destDir` (created if needed). tar strips
224
- * leading slashes and rejects `..` paths, so extraction stays inside dest. */
225
- export const extractSource = async (archivePath, destDir) => {
226
- mkdirSync(destDir, { recursive: true });
227
- await tarExtract({ cwd: destDir, file: archivePath });
228
- };
@@ -1,117 +0,0 @@
1
- import type { JsonObject } from "./types.js";
2
- export type Provider = "vibedgames" | "codex";
3
- /**
4
- * Expected, user-facing failure of the codex provider. Carries a clean
5
- * message plus any output Codex itself emitted, so the caller can present
6
- * it directly instead of dumping a stack trace. `notInstalled` flags the
7
- * "`codex` binary missing" case so callers can suggest a fallback.
8
- */
9
- export declare class CodexError extends Error {
10
- readonly notInstalled: boolean;
11
- readonly output: string;
12
- constructor(message: string, opts?: {
13
- notInstalled?: boolean;
14
- output?: string;
15
- });
16
- }
17
- /**
18
- * Resolve an explicitly named provider from the `--provider` flag, falling
19
- * back to the `VG_GENERATE_PROVIDER` env var and finally the vibedgames
20
- * default. Unknown values throw so a typo (`--provider coddex`) fails
21
- * loudly instead of silently hitting the paid backend. `chooseProvider`
22
- * layers the automatic Codex routing on top of this.
23
- */
24
- export declare const resolveProvider: (flag?: string) => Provider;
25
- /** The OpenAI image family — the models a signed-in Codex plan serves itself. */
26
- export declare const isOpenAiImageEndpoint: (endpointId: string) => boolean;
27
- /**
28
- * The `codex` binary this machine would run: `VG_CODEX_BIN` when set (and
29
- * present), else the first `codex` on PATH. Null when there is none — the
30
- * signal that keeps automatic routing on the vibedgames runner.
31
- */
32
- export declare const findCodexBinary: (env?: NodeJS.ProcessEnv) => string | null;
33
- export interface CodexInput {
34
- prompt: string;
35
- count: number;
36
- sizeHint?: string;
37
- /** Raw reference values from the input; may be local paths or URLs. */
38
- referenceCandidates: string[];
39
- }
40
- /**
41
- * Pull the fields Codex can act on out of the parsed `run` input. Pure:
42
- * no filesystem access, so the reference values are returned verbatim and
43
- * resolved to local files later.
44
- */
45
- export declare const parseCodexInput: (input: JsonObject) => CodexInput;
46
- export interface AutoRouteContext {
47
- endpointId: string;
48
- async: boolean;
49
- input: JsonObject;
50
- codexInstalled: boolean;
51
- }
52
- export interface ProviderChoice {
53
- provider: Provider;
54
- /** True when nothing named the provider and Codex was picked for it. */
55
- auto: boolean;
56
- }
57
- /**
58
- * Pick the backend for one `run`. An explicit `--provider` or
59
- * `VG_GENERATE_PROVIDER` always wins. Left unset, an OpenAI image endpoint
60
- * goes to a locally installed Codex CLI — the same model family on the
61
- * user's own plan, nothing billed to vibedgames — whenever Codex can honour
62
- * the request (synchronous, local references only). Everything else stays
63
- * on the vibedgames runner, so video/audio and non-OpenAI image models are
64
- * unaffected by having Codex installed.
65
- */
66
- export declare const chooseProvider: (flag: string | undefined, ctx: AutoRouteContext) => ProviderChoice;
67
- /**
68
- * Build the natural-language instruction handed to `codex exec`. We pin
69
- * exact output filenames and the working directory so the generated
70
- * files land somewhere we can deterministically collect them.
71
- */
72
- export declare const buildCodexPrompt: (input: CodexInput, filenames: string[], hasReferences: boolean) => string;
73
- /**
74
- * Choose the on-disk destination for a collected Codex output, mirroring
75
- * the `--download` template semantics used for the vibedgames path
76
- * ({index}, {ext}, {request_id} placeholders; bare path treated as a
77
- * directory or a literal file by extension).
78
- */
79
- export declare const renderLocalTarget: (template: string | undefined, index: number, ext: string, requestId: string, count: number) => string;
80
- interface CodexRun {
81
- requestId: string;
82
- prompt: string;
83
- /** Absolute paths to the images Codex produced, in a stable order. */
84
- rawFiles: string[];
85
- /**
86
- * Reference inputs that were dropped because they weren't local files
87
- * (Codex can only attach on-disk references). Surfaced to the caller so
88
- * it isn't silently lost — especially under --json, where a warning to
89
- * a suppressed logger would vanish.
90
- */
91
- ignoredReferences: string[];
92
- }
93
- /**
94
- * Delegate image generation to the local `codex` CLI. Runs
95
- * `codex exec` in an isolated temp workspace, then collects the produced
96
- * images from that workspace (and, as a fallback, from Codex's default
97
- * `generated_images` store). Throws with actionable guidance when Codex
98
- * is missing, fails, or produces nothing.
99
- */
100
- /** The `codex exec` argv for one image run. */
101
- export declare const codexExecArgs: (workDir: string, references: string[], prompt: string) => string[];
102
- export declare const generateImagesWithCodex: (opts: {
103
- input: JsonObject;
104
- }) => Promise<CodexRun>;
105
- /**
106
- * Copy Codex's raw outputs to their final destinations per the
107
- * `--download` template (or default cwd naming). Returns the written
108
- * paths and any per-file failures.
109
- */
110
- export declare const placeCodexOutputs: (rawFiles: string[], template: string | undefined, requestId: string) => {
111
- downloaded: string[];
112
- failed: {
113
- url: string;
114
- error: string;
115
- }[];
116
- };
117
- export {};