Description
Currently the config is loaded from a static polira.config.ts file in the project root. Users should be able to configure Polira more flexibly — either by loading config dynamically from multiple sources or via a dedicated CLI command to initialize/update their config.
Config Precedence (highest to lowest)
- CLI flags (e.g.
--mode, --size, --save) — per-invocation overrides, already partially exists
- Environment variables (
POLIRA_* prefix) — useful for CI/CD and Docker
- Config file (
polira.config.ts) — project-level settings, already works
- Defaults (
DEFAULT_CONFIG + zod .default() values) — zero-config baseline
Environment Variable Mapping
Flat POLIRA_* naming convention maps to nested config paths:
POLIRA_AI_TEXT_MODEL=gpt-4o-mini → ai.textModel
POLIRA_AI_IMAGE_MODEL=dall-e-3 → ai.imageModel
POLIRA_IMAGE_SIZE=1024x1024 → image.size
POLIRA_IMAGE_STYLE="watercolor" → image.style
POLIRA_STORAGE_PROVIDER=cloudinary → storage.provider
POLIRA_WRITING_MODE=strong → writing.defaultMode
POLIRA_MARKDOWN_COVER_FIELD=heroImage → markdown.coverField
Note: credential env vars (OPENAI_API_KEY, CLOUDINARY_*) stay as-is — they're secrets, not config. POLIRA_* vars are for behavioral settings only.
CLI Flags
Already partially exists (--mode, --size, --save, --upload). These overrides are applied per-command in each action handler. The gap is that they're applied inconsistently and not all config fields have corresponding flags.
Tasks
Files
src/core/config.ts — config loading logic, env var parsing, multi-source merge
src/cli/commands/config.ts — new CLI command (init, set, show)
src/cli/index.ts — register new command
src/cli/commands/*.ts — standardize flag override pattern
Description
Currently the config is loaded from a static
polira.config.tsfile in the project root. Users should be able to configure Polira more flexibly — either by loading config dynamically from multiple sources or via a dedicated CLI command to initialize/update their config.Config Precedence (highest to lowest)
--mode,--size,--save) — per-invocation overrides, already partially existsPOLIRA_*prefix) — useful for CI/CD and Dockerpolira.config.ts) — project-level settings, already worksDEFAULT_CONFIG+ zod.default()values) — zero-config baselineEnvironment Variable Mapping
Flat
POLIRA_*naming convention maps to nested config paths:Note: credential env vars (
OPENAI_API_KEY,CLOUDINARY_*) stay as-is — they're secrets, not config.POLIRA_*vars are for behavioral settings only.CLI Flags
Already partially exists (
--mode,--size,--save,--upload). These overrides are applied per-command in each action handler. The gap is that they're applied inconsistently and not all config fields have corresponding flags.Tasks
POLIRA_*environment variable support toloadConfig()with deep-merge over config filepolira config initcommand to interactively scaffold a config filepolira config set <key> <value>command to update individual config valuespolira config showcommand to display the fully resolved config (all layers merged)~/.config/polira/config.tsas fallback (before defaults, after project config)polira.config.ts)Files
src/core/config.ts— config loading logic, env var parsing, multi-source mergesrc/cli/commands/config.ts— new CLI command (init,set,show)src/cli/index.ts— register new commandsrc/cli/commands/*.ts— standardize flag override pattern