feat(cli,config): add config file, providers/models listing, and help command - #10
Open
lorecanc wants to merge 1 commit into
Open
feat(cli,config): add config file, providers/models listing, and help command#10lorecanc wants to merge 1 commit into
lorecanc wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ergonomics and discoverability:
~/.config/opencode-usage/config.toml($XDG_CONFIG_HOMEaware) with[defaults](days/weeks/months,by,sort) and[insights] preferred_modelsthat 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 fromopencode models(cached per run), so they always match your actual setup.providersmarks connected providers (*, fromauth.json);modelssupports--provider(repeatable),--id(bare model IDs as stored in the DB), and--jsonfor both.help—opencode-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 viatomllib(stdlib, Python 3.11+; the project requires 3.10+, so this keeps>=3.10compatibility by importingtomllibdirectly — note: if you want to support 3.10 strictly, we can switch totomlifor <3.11)src/opencode_usage/cli.py: help/providers/models subcommands, config defaults applied in_cmd_run/_cmd_insights, epilogssrc/opencode_usage/models.py: picker honorspreferred_modelsfrom configtests/test_config.py: new — loading, precedence, malformed filestests/test_cli.py,tests/test_models.py: new testsREADME.md: documentedVerification
uv run pytest tests/— 385 passeduvx ruff check .anduvx ruff format --check .— cleanNote
tomllibrequires Python 3.11+. The project declares>=3.10; if 3.10 support matters, happy to usetomliwith a fallback import instead.