Feat: Decouple Model Definitions using Host config Hook#4
Open
dragon-Elec wants to merge 2 commits into
Open
Conversation
Feat: Decouple Model Definitions using Host config Hook
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.
Feat: Decouple Model Definitions using Host
configHookThis PR implements a solution to decouple model definitions from the user's primary
opencode.jsonconfiguration file, reducing configuration bloat and resolving maintenance issues discussed in #134.The Hook Mechanism
By targeting OpenCode's runtime
configlifecycle hook, which executes prior to provider validation and client instantiation, the plugin dynamically injects model catalogs directly into OpenCode's configuration memory.This enables:
opencode.json.What's Changed
~/.config/opencode/antigravity-models.json(c).opencode/antigravity-models.json(c)modelsmapping block inantigravity.json.Built-in defaults->Decoupled JSON/JSONC overrides->Main opencode.json overridesThis ensures any existing model declarations inside
opencode.jsoncontinue to override all other definitions, ensuring zero disruption for existing users.Why Backwards Compatibility Matters (Fail-Safe Architecture)
Because OpenCode's
configlifecycle hook is currently undocumented, there is a risk that a future upstream OpenCode release could deprecate or alter it.To mitigate this, we maintain full backwards compatibility with static definitions in
opencode.json:opencode.json(or using theopencode auth loginmodel setup flow). OpenCode will parse them natively.opencode.jsondefinitions last, we guarantee that any static config file settings override the dynamic injection, leaving the user in complete control.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Decouples model definitions from the main OpenCode config by injecting them during the host
confighook. This reducesopencode.jsonbloat and enables zero‑config model updates.~/.config/opencode/antigravity-models.json(c)and./.opencode/antigravity-models.json(c)(JSON/JSONC supported).opencode.jsonoverrides (backward compatible).whitelistto all merged model IDs.modelsin the plugin config schema to carry injected definitions.Written for commit fe739e8. Summary will update on new commits.