Skip to content

fix(config): correct directory config precedence so project overrides global#19376

Closed
MoerAI wants to merge 1 commit intoanomalyco:devfrom
MoerAI:fix/config-precedence-order-19296
Closed

fix(config): correct directory config precedence so project overrides global#19376
MoerAI wants to merge 1 commit intoanomalyco:devfrom
MoerAI:fix/config-precedence-order-19296

Conversation

@MoerAI
Copy link

@MoerAI MoerAI commented Mar 27, 2026

Summary

  • Fix config precedence order so project .opencode directory configs properly override home ~/.opencode directory configs
  • This restores the documented behavior where project configs take priority over global defaults

Problem

The ConfigPaths.directories() function returned directories in this order:

  1. ~/.config/opencode (global XDG config)
  2. Project .opencode dirs (loaded first)
  3. Home ~/.opencode dir (loaded last — overrides project!)

Since configs are merged sequentially with later values overriding earlier ones, the home ~/.opencode config incorrectly took precedence over the project .opencode config. This contradicts the documented precedence order.

Fix

Swap the order so home ~/.opencode is loaded before project .opencode:

  1. ~/.config/opencode (global XDG config)
  2. Home ~/.opencode dir (loaded first — serves as base)
  3. Project .opencode dirs (loaded last — overrides home)

This matches the documented precedence where project configs override global defaults.

Reproduction

As described in the issue:

  • Global restricted + local unrestricted → Before: asks for permission (wrong). After: allows (correct)
  • Global unrestricted + local restricted → Before: no permission required (wrong). After: asks for permission (correct)

Closes #19296

… global

The directories() function loaded home ~/.opencode configs AFTER project
.opencode configs, giving global config higher precedence than project
config. This contradicts the documented precedence order where project
configs should override global defaults.

Swap the order so home .opencode is merged first (as a base), then
project .opencode is merged on top, giving project config the higher
precedence as documented.

Closes anomalyco#19296
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 27, 2026
@github-actions
Copy link
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 27, 2026
@github-actions github-actions bot closed this Mar 27, 2026
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.

Global configuration supersedes local configuration

2 participants