Skip to content

feat(cli,config): add config file, providers/models listing, and help command - #10

Open
lorecanc wants to merge 1 commit into
rchardx:mainfrom
lorecanc:feat/config-and-commands
Open

feat(cli,config): add config file, providers/models listing, and help command#10
lorecanc wants to merge 1 commit into
rchardx:mainfrom
lorecanc:feat/config-and-commands

Conversation

@lorecanc

@lorecanc lorecanc commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Ergonomics and discoverability:

  • Config file — optional ~/.config/opencode-usage/config.toml ($XDG_CONFIG_HOME aware) with [defaults] (days/weeks/months, by, sort) and [insights] preferred_models that orders the interactive model picker. Precedence: CLI flags > config > built-in defaults. Missing/malformed files silently fall back to defaults.
  • providers / models — list IDs sourced from opencode models (cached per run), so they always match your actual setup. providers marks connected providers (*, from auth.json); models supports --provider (repeatable), --id (bare model IDs as stored in the DB), and --json for both.
  • helpopencode-usage help [run|insights|providers|models], plus exhaustive English epilogs on every parser covering config, filters, output modes, and examples.

Changes

  • src/opencode_usage/config.py: new — TOML loading via tomllib (stdlib, Python 3.11+; the project requires 3.10+, so this keeps >=3.10 compatibility by importing tomllib directly — note: if you want to support 3.10 strictly, we can switch to tomli for <3.11)
  • src/opencode_usage/cli.py: help/providers/models subcommands, config defaults applied in _cmd_run/_cmd_insights, epilogs
  • src/opencode_usage/models.py: picker honors preferred_models from config
  • tests/test_config.py: new — loading, precedence, malformed files
  • tests/test_cli.py, tests/test_models.py: new tests
  • README.md: documented

Verification

  • uv run pytest tests/ — 385 passed
  • uvx ruff check . and uvx ruff format --check . — clean

Note

tomllib requires Python 3.11+. The project declares >=3.10; if 3.10 support matters, happy to use tomli with a fallback import instead.

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