vibedgames 0.6.1 → 0.6.2

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.
@@ -97,6 +97,8 @@ interface CodexRun {
97
97
  * `generated_images` store). Throws with actionable guidance when Codex
98
98
  * is missing, fails, or produces nothing.
99
99
  */
100
+ /** The `codex exec` argv for one image run. */
101
+ export declare const codexExecArgs: (workDir: string, references: string[], prompt: string) => string[];
100
102
  export declare const generateImagesWithCodex: (opts: {
101
103
  input: JsonObject;
102
104
  }) => Promise<CodexRun>;
package/dist/lib/codex.js CHANGED
@@ -179,7 +179,10 @@ export const buildCodexPrompt = (input, filenames, hasReferences) => {
179
179
  `Prompt: ${input.prompt}`,
180
180
  ];
181
181
  if (input.sizeHint) {
182
- lines.push(`Size: ${input.sizeHint}.`);
182
+ // A target, not a contract: the generator picks from a few fixed sizes, and
183
+ // asked for an exact one Codex stops to request permission to resize —
184
+ // which the no-code rule below forbids, so the run ends with no file.
185
+ lines.push(`Size: aim for ${input.sizeHint}. Use the closest size the generator offers and save that as-is — never resize, crop or ask about it.`);
183
186
  }
184
187
  lines.push(`Save the output as PNG into the current working directory using exactly ` +
185
188
  `these filenames: ${filenames.join(", ")}.`, `Do not read, create, or modify any other files, and do not write or run code. $imagegen`);
@@ -214,28 +217,29 @@ export const renderLocalTarget = (template, index, ext, requestId, count) => {
214
217
  return path.resolve(template, `codex-image-${index}.${ext}`);
215
218
  };
216
219
  const codexHome = () => process.env.CODEX_HOME ?? path.join(homedir(), ".codex");
217
- const listImages = (dir) => {
218
- let names;
220
+ /**
221
+ * Image files under `dir`, one level of subdirectories included: Codex files
222
+ * its generated images per session (`generated_images/<session>/<id>.png`),
223
+ * so a flat listing of the store never sees them.
224
+ */
225
+ const listImages = (dir, depth = 1) => {
226
+ let entries;
219
227
  try {
220
- names = readdirSync(dir);
228
+ entries = readdirSync(dir, { withFileTypes: true });
221
229
  }
222
230
  catch {
223
231
  return [];
224
232
  }
225
233
  const out = [];
226
- for (const name of names) {
227
- const ext = path.extname(name).slice(1).toLowerCase();
228
- if (!IMAGE_EXT.has(ext)) {
229
- continue;
230
- }
231
- const full = path.join(dir, name);
232
- try {
233
- if (statSync(full).isFile()) {
234
- out.push(full);
234
+ for (const entry of entries) {
235
+ const full = path.join(dir, entry.name);
236
+ if (entry.isDirectory()) {
237
+ if (depth > 0) {
238
+ out.push(...listImages(full, depth - 1));
235
239
  }
236
240
  }
237
- catch {
238
- // Raced away between readdir and stat; skip.
241
+ else if (entry.isFile() && IMAGE_EXT.has(path.extname(entry.name).slice(1).toLowerCase())) {
242
+ out.push(full);
239
243
  }
240
244
  }
241
245
  return out.toSorted();
@@ -298,6 +302,20 @@ new Promise((resolve) => {
298
302
  * `generated_images` store). Throws with actionable guidance when Codex
299
303
  * is missing, fails, or produces nothing.
300
304
  */
305
+ /** The `codex exec` argv for one image run. */
306
+ export const codexExecArgs = (workDir, references, prompt) => [
307
+ "exec",
308
+ "--skip-git-repo-check",
309
+ "-s",
310
+ "workspace-write",
311
+ "-C",
312
+ workDir,
313
+ ...references.flatMap((r) => ["-i", r]),
314
+ // `-i` is variadic (`--image <FILE>...`): without the separator it
315
+ // swallows the prompt as one more image and codex waits on stdin for one.
316
+ "--",
317
+ prompt,
318
+ ];
301
319
  export const generateImagesWithCodex = async (opts) => {
302
320
  const parsed = parseCodexInput(opts.input);
303
321
  if (!parsed.prompt) {
@@ -322,16 +340,7 @@ export const generateImagesWithCodex = async (opts) => {
322
340
  const filenames = Array.from({ length: parsed.count }, (_, i) => `output-${i}.png`);
323
341
  const prompt = buildCodexPrompt(parsed, filenames, references.length > 0);
324
342
  const bin = process.env.VG_CODEX_BIN ?? "codex";
325
- const args = [
326
- "exec",
327
- "--skip-git-repo-check",
328
- "-s",
329
- "workspace-write",
330
- "-C",
331
- workDir,
332
- ...references.flatMap((r) => ["-i", r]),
333
- prompt,
334
- ];
343
+ const args = codexExecArgs(workDir, references, prompt);
335
344
  // Snapshot Codex's default image store so we can tell which files this
336
345
  // run produced if the model saves there instead of the workspace.
337
346
  const storeDir = path.join(codexHome(), "generated_images");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibedgames",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "vg": "./dist/index.js"