You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.opencode/ config precedence is inverted in nested directories #21307
When .opencode/opencode.json (or .jsonc) exists in multiple nested directories, the parent directory wins instead of the child.
This is the opposite of how plain opencode.json files behave and opposite of the documented "local overrides global" precedence model.
Root cause: ConfigPaths.directories uses Filesystem.up, which yields directories child-first.
The merge loop in loadInstanceState applies mergeDeep(result, next) where the later-processed entry wins.
So the last parent always overrides the child.
Plain opencode.json files (not in .opencode/) don't have this problem: Filesystem.findUp is called with { rootFirst: true }, which reverses the list before merging.
Plugins
MCP context7, no plugins
OpenCode version
1.3.7
Steps to reproduce
Create configs in .opencode/ for parent and child.
This issue might be a duplicate of existing issues. Please check:
Global configuration supersedes local configuration #19296: Global configuration supersedes local configuration — describes the same config precedence inversion where global/parent config overrides project/child config, likely sharing the same root cause in the merge logic
Comment for Issue #21307 (.opencode/ config precedence inverted)
This is a significant bug that affects monorepo workflows where different subdirectories need different configurations. The current behavior breaks the expected "local overrides global" model.
Activity
github-actions commentedon Apr 7, 2026
This issue might be a duplicate of existing issues. Please check:
.opencode/directoriesQuantumEdu commentedon Apr 10, 2026
Comment for Issue #21307 (.opencode/ config precedence inverted)
This is a significant bug that affects monorepo workflows where different subdirectories need different configurations. The current behavior breaks the expected "local overrides global" model.
Additional Impact Areas
Beyond the reported issue, this bug affects:
Monorepo subprojects:
Feature-specific overrides:
Environment-specific configs (if using directory-based env separation):
Suggested Testing
Add regression tests for:
.opencode/and root-level configs.jsoncvs.jsonfile handlingTemporary Workaround
Until fixed, users can work around this by:
opencode.jsoninstead of.opencode/opencode.json.opencode/directoriesThe fix is critical for projects that rely on hierarchical configuration for different parts of the codebase.
fix(config): load ~/.opencode before project dirs so project config wins
fix(config): load ~/.opencode before project dirs so project config wins
github-actions commentedon Jul 6, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.