Repository navigation
fix(config): support additive config directories - #32824
totalolage wants to merge 2 commits into
Conversation
|
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. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
Requesting a reopen. This PR was closed by automated cleanup (30.5 days old, 0 reactions; both checks passed) — a mechanical criterion, not a review of the fix. The bug is still open (#32825) and still reproduced on 2.1.4, with recent reports from @hotzen, @diachkow, @Stainless2k, @cbrachem and @tslator; @totalolage authored both the issue and this PR. Its shape — Global.config pinned to XDG, env dirs additive, OPENCODE_CONFIG_DIRS parsed PATH-style, OPENCODE_CONFIG_DIR last — is still what the thread asks for. The branch is now 7,274 commits behind dev (f34ec09 vs 6b1bc48), 12 of 14 files no longer exist, and config loading moved to ConfigDiscovery, so it needs a port, not a merge. maintainerCanModify=false, so I'm not asking anyone to update the branch. If reopening is acceptable, I can port the diff to a fresh dev branch with full attribution to @totalolage, plus @tslator's skipped-source warning as a small follow-up. If you'd rather keep it closed, I'll respect that. |
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