Skip to content

fix: correct .opencode/ config directory precedence#21405

Open
claygeo wants to merge 1 commit intoanomalyco:devfrom
claygeo:fix/opencode-config-precedence
Open

fix: correct .opencode/ config directory precedence#21405
claygeo wants to merge 1 commit intoanomalyco:devfrom
claygeo:fix/opencode-config-precedence

Conversation

@claygeo
Copy link
Copy Markdown

@claygeo claygeo commented Apr 8, 2026

Issue for this PR

Closes #21307

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

ConfigPaths.directories() uses Filesystem.up() to collect .opencode/ config dirs from child to parent. These get fed into mergeDeep where later entries win. Since up() yields child-first, the parent dir ends up last in the array and wins the merge. That's backwards.

The fix: .reverse() the array so parent comes first, child comes last. Child config wins the merge, which is the expected behavior. This matches how projectFiles already handles the same precedence problem using { rootFirst: true }.

How did you verify your code works?

Added a test that creates nested .opencode/ dirs (parent with username: "parent-wins", child with username: "child-should-win"), loads config from the child dir, and asserts child wins.

All 76 config tests pass including the new one: bun test packages/opencode/test/config/config.test.ts

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Reverse the project .opencode/ directory list so child directories
override parent directories during config merge, matching the behavior
of plain opencode.json files which already use rootFirst ordering.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.opencode/ config precedence is inverted in nested directories

1 participant