feat(config): support opencode.local.json for project-local config overrides#17234
Open
webrgp wants to merge 1 commit intoanomalyco:devfrom
Open
feat(config): support opencode.local.json for project-local config overrides#17234webrgp wants to merge 1 commit intoanomalyco:devfrom
webrgp wants to merge 1 commit intoanomalyco:devfrom
Conversation
…errides Adds opencode.local.json and opencode.local.jsonc as a new config layer between project config and .opencode directories. Intended to be gitignored for machine-specific settings like API keys or model preferences without modifying the shared project config.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #17232
Type of change
What does this PR do?
Adds
opencode.local.jsonandopencode.local.jsoncas a new config layer for machine-specific overrides that can be safely gitignored. This gives users a clean way to keep secrets (API keys, custom endpoints) or machine-specific settings out of version control without modifying the sharedopencode.json.The local config files slot between project config and
.opencodedirectories in the precedence order:.well-known/opencode~/.config/opencode/opencode.jsonOPENCODE_CONFIGopencode.json(committed)opencode.local.json(NEW — gitignored).opencodedirectoriesOPENCODE_CONFIG_CONTENTImplementation reuses the existing
ConfigPaths.projectFiles()helper parameterized with"opencode.local"— this naturally discovers both.jsonand.jsoncvariants using the sameFilesystem.findUpwalk-up logic, so no changes to path resolution were needed. Loading is gated by the sameOPENCODE_DISABLE_PROJECT_CONFIGflag as regular project config.Changes:
packages/opencode/src/config/config.ts— 4 lines to load local config files after project config, updated precedence commentpackages/opencode/test/config/config.test.ts— 7 tests covering JSON/JSONC loading, precedence over project config,.opencode/overrides local, disabled-by-flag, array merging, and loading when gitignoredpackages/web/src/content/docs/config.mdx— updated precedence list and added "Local overrides" section with examplesHow did you verify your code works?
Added 7 unit tests in
packages/opencode/test/config/config.test.tsunder adescribe("opencode.local.json")block. All tests pass locally viabun testfrompackages/opencode. Existing tests remain green (one pre-existing failure inpermission config preserves key orderis unrelated).Screenshots / recordings
N/A — no UI changes.
Checklist