Skip to content

feat: smart file naming and default output directory#51

Open
ctate wants to merge 3 commits into
mainfrom
ctate/smart-file-naming
Open

feat: smart file naming and default output directory#51
ctate wants to merge 3 commits into
mainfrom
ctate/smart-file-naming

Conversation

@ctate
Copy link
Copy Markdown
Collaborator

@ctate ctate commented May 4, 2026

Summary

  • Save generations to ~/.ai-cli/generations/ by default instead of the current working directory
  • Derive filenames from the prompt with a 4-char random hex suffix (e.g. a-sunset-a3f2.png) — parallel-safe, no filesystem scanning
  • -o flag and AI_CLI_OUTPUT_DIR env var continue to override the default
  • When stdin-only (no text prompt), falls back to output-<hex>.<ext>

Save generations to ~/.ai-cli/generations/ by default instead of
cluttering the current working directory. Filenames are now derived
from the prompt with a random hex suffix (e.g. a-sunset-a3f2.png)
for parallel-safe, descriptive naming. The -o flag and AI_CLI_OUTPUT_DIR
env var continue to override the default.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-cli Ready Ready Preview, Comment May 4, 2026 5:01pm

@vercel vercel Bot requested a deployment to Preview May 4, 2026 16:07 Abandoned
@vercel vercel Bot requested a deployment to Preview May 4, 2026 16:07 Abandoned
Comment thread packages/ai-cli/src/lib/output.ts Outdated
…ode normalization

- Fall back to "output" slug when prompt contains only special characters
- Add existsSync retry loop to avoid filename collisions (keeps 4 hex chars)
- Restore per-job index in multi-job filenames (e.g. a-sunset-abcd-1.png)
- Inject index before extension when -o <file> is used with multiple jobs
- Normalize unicode via NFD decomposition to preserve accented characters
Replace existsSync check-then-write with atomic writeFileSync wx flag
to prevent race conditions between concurrent processes. Add 7
integration tests covering explicit dir/file output, index insertion,
collision retry, stdout piping, and string data handling.
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.

1 participant