fix(config): support additive config directories#32824
Open
totalolage wants to merge 2 commits into
Open
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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
Fixes #32825
Fixes #28658
Closes #26051
Type of change
What does this PR do?
Fixes a config resolution regression from the v1/v2 split: the old app config loader treated
OPENCODE_CONFIG_DIRas an extra config layer, but the v2/core path used it as a replacement for the XDG global config directory throughGlobal.config. That could make app-level config output show values that v2/core services, including references, did not see.This keeps
Global.configpinned to the real XDG global config path and models env-provided config directories as explicit additive layers instead.OPENCODE_CONFIG_DIRremains supported for compatibility.It also adds
OPENCODE_CONFIG_DIRSfor multiple extra config directories. The value is parsed likePATHwithpath.delimiter, trims entries, and ignores empty entries, so POSIX usesdirA:dirBand Windows usesdirA;dirB.Config order is now lowest to highest priority:
.opencodedirectoriesOPENCODE_CONFIG_DIRSentries from left to rightOPENCODE_CONFIG_DIRlast as the highest-priority legacy/custom overrideThe old app config path discovery, TUI config loader, v1 instruction service, and v2 instruction context now use the same extra directory ordering. That means
AGENTS.mdand relative configuredinstructionscan also come from custom config directories.Compared with #30821, this keeps the original XDG global config visible instead of replacing it, centralizes env directory parsing, preserves existing config loader behavior, and adds coverage for both old and v2 instruction paths.
How did you verify your code works?
bun test test/config/config.test.ts test/global.test.ts test/instruction-context.test.tsfrompackages/corebun test test/config/config.test.ts test/config/tui.test.ts test/session/instruction.test.tsfrompackages/opencodebun typecheckfrompackages/corebun typecheckfrompackages/opencodebun prettier --check packages/core/src/config.ts packages/core/src/flag/flag.ts packages/core/src/global.ts packages/core/src/instruction-context.ts packages/core/test/config/config.test.ts packages/core/test/global.test.ts packages/core/test/instruction-context.test.ts packages/opencode/src/config/config.ts packages/opencode/src/config/paths.ts packages/opencode/src/config/tui.ts packages/opencode/src/session/instruction.ts packages/opencode/test/config/config.test.ts packages/opencode/test/config/tui.test.ts packages/opencode/test/session/instruction.test.tsbun turbo typechecksuccessfullyScreenshots / recordings
N/A - non-UI change.
Checklist