Skip to content

Fix CLI error double-wrapping, config read side effect, and stale flag docs - #34

Merged
betomoedano merged 3 commits into
mainfrom
cursor/routine-bug-fixes-9214
Jul 16, 2026
Merged

Fix CLI error double-wrapping, config read side effect, and stale flag docs#34
betomoedano merged 3 commits into
mainfrom
cursor/routine-bug-fixes-9214

Conversation

@betomoedano

@betomoedano betomoedano commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Routine bug-scan pass over the codebase. Fixes several small but real bugs; no behavior additions.

Updated after main merged the feature-graphic command (#30): conflicts resolved, and the same two bug patterns found in the icon command were also present in the new feature-graphic command, so they're fixed there too.

Bug fixes

  • Double-wrapped error messages (src/commands/icon.ts, src/commands/feature-graphic.ts): every this.error(...) inside run() throws an oclif CLIError that was caught by the outer catch and re-wrapped as Failed to generate icon: <original red message>. For example, snapai icon -p x --model banana -n 2 printed a nested, double-styled message. The catch now re-throws CLIErrors as-is and only wraps unexpected errors (API failures, save failures).

    Before:

    ›   Error: Failed to generate icon: Banana normal only supports -n 1
    

    After:

    ›   Error: Banana normal only supports -n 1
    
  • Config file created on read (src/services/config.ts): getConfig() called fs.ensureFile(), so read-only commands like snapai config --show (or any generation using env-var keys) created an empty ~/.snapai/config.json as a side effect. Reads now check pathExists instead.

  • Preview/generation validation mismatch (src/commands/icon.ts, src/commands/feature-graphic.ts): --prompt-only skipped validation that generation mode performs. For icon, --model banana-2 -q high --prompt-only previewed fine but failed when actually generating. For feature-graphic, the preview skipped all provider-specific checks (-n limits and --quality resolution). Previews now run the same validation.

  • Broken npm script (package.json): removed test:icon-batch, which points at scripts/test-icon-batch.sh — neither the script nor the scripts/ directory exists in the repo.

  • Missing webpack externals (webpack.config.js): @google/genai and mime were missing from externals, so pnpm run bundle inlined them while every other runtime dependency stayed external.

Cleanup

  • Removed dead ternary rawPrompt ? prompt : prompt in src/services/openai.ts.
  • Fixed stale (GPT-Image-1 only) help text on --background / --output-format / --moderation; these apply to all OpenAI models (with a note that gpt-image-2 rejects transparent).
  • Fixed a misleading comment in the config command (no-flag invocation shows config, not help).

Verification

  • Merged latest main (including feat: Add feature-graphic command for Google Play Store banners #30) into this branch; pnpm run build, pnpm run lint, and pnpm run bundle all pass.
  • Manually verified with the built CLI:
    • icon --model banana -n 2 and fg --model banana -n 3 --prompt-only → single clean error (no double wrapping); runtime errors (e.g. missing API key) still get the Failed to generate ...: prefix.
    • config --show with no ~/.snapai → no file/directory created; config --openai-api-key ... still persists correctly.
    • --model banana-2 -q high --prompt-only now fails the same way generation mode does; normal --prompt-only previews (icon and feature-graphic, incl. --app-name/--style) unchanged.

Related open work (not duplicated here)

Open in Web Open in Cursor 

…g docs

- icon: re-throw oclif CLIErrors instead of re-wrapping them as
  'Failed to generate icon: ...' (validation errors printed twice-nested)
- icon: validate --quality for banana-2 in --prompt-only so the preview
  matches generation-mode behavior
- icon: fix stale '(GPT-Image-1 only)' flag descriptions that apply to
  all OpenAI models
- config service: don't create an empty ~/.snapai/config.json as a side
  effect of read-only commands like 'snapai config --show'
- openai service: remove dead 'rawPrompt ? prompt : prompt' ternary
- package.json: remove broken test:icon-batch script (script file does
  not exist in the repo)
- webpack: add @google/genai and mime to externals like the other
  runtime dependencies

Co-authored-by: Beto <betomoedano@users.noreply.github.com>
@betomoedano
betomoedano marked this pull request as ready for review July 16, 2026 00:28
cursoragent and others added 2 commits July 16, 2026 00:33
…xes-9214

# Conflicts:
#	src/commands/icon.ts

Co-authored-by: Beto <betomoedano@users.noreply.github.com>
- re-throw oclif CLIErrors instead of double-wrapping them as
  'Failed to generate feature graphic: ...' (same bug as icon command)
- validate provider-specific constraints (-n limits, --quality) in
  --prompt-only mode so the preview matches generation behavior

Co-authored-by: Beto <betomoedano@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants