Skip to content

feat: add ~/.voipirc.json config file support#5

Open
dean-harel wants to merge 1 commit into
pithings:mainfrom
dean-harel:feat/voipirc-config
Open

feat: add ~/.voipirc.json config file support#5
dean-harel wants to merge 1 commit into
pithings:mainfrom
dean-harel:feat/voipirc-config

Conversation

@dean-harel

@dean-harel dean-harel commented Apr 29, 2026

Copy link
Copy Markdown

Closes #4

Implements persistent configuration via JSON files so users don't have to pass --provider, --voice, --lang, and --rate on every invocation.

Config file locations (precedence order)

  1. $PWD/.voipirc.json β€” project-local override
  2. $HOME/.voipirc.json β€” user global (primary)
  3. $XDG_CONFIG_HOME/voipi/config.json β€” XDG compliant
  4. $HOME/.config/voipi/config.json β€” XDG fallback

Schema

All fields optional. Unknown keys are ignored. Malformed JSON warns to stderr and falls back to the next path.

{
  "provider": "edge-tts",
  "voice": "en-US-GuyNeural",
  "lang": "en",
  "rate": 1.2
}

Precedence (highest to lowest)

  • Method options (speak({ voice: "X" }))
  • Constructor options (new VoiPi({ providers: [...] }))
  • CLI flags (--voice, --provider, etc.)
  • Config file (~/.voipirc.json)
  • Hardcoded defaults (auto chain, provider defaults)

Changes

  • src/_config.ts β€” config discovery and loading
  • src/voipi.ts β€” merge config defaults into speak / save / synthesize; use config provider when no constructor options given
  • src/cli/index.ts β€” add --show-config flag; mention config file in --help
  • test/config.test.ts β€” vitest coverage for loading, precedence, malformed JSON fallback, and VoiPi integration
  • test/voipi.test.ts β€” mock loadConfig to stay deterministic
  • README.md & packages/pi/README.md β€” document config file usage

Notes

  • Config is read once per VoiPi construction (not module scope), so Pi's /reload and long-running processes pick up changes without module cache issues.
  • No config get/set/list subcommands β€” users edit the JSON file manually (per issue scope).
  • No per-provider internals leaked in config.
  • No hot-reload/watch β€” restart process to pick up changes.

- Load defaults from .voipirc.json / XDG config paths
- Config provider overrides auto-detection chain
- Config voice/lang/rate merged as speak/save/synthesize defaults
- Add --show-config CLI flag
- Add tests for config loading and precedence
@vercel

vercel Bot commented Apr 29, 2026

Copy link
Copy Markdown

@dean-harel is attempting to deploy a commit to the pi0 Team on Vercel.

A member of the Team first needs to authorize it.

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.

Feature Request: Persistent configuration file (~/.voipirc.json)

1 participant