Skip to content

fix(config): support additive config directories#32824

Open
totalolage wants to merge 2 commits into
anomalyco:devfrom
totalolage:config-dirs
Open

fix(config): support additive config directories#32824
totalolage wants to merge 2 commits into
anomalyco:devfrom
totalolage:config-dirs

Conversation

@totalolage

@totalolage totalolage commented Jun 18, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #32825
Fixes #28658
Closes #26051

Type of change

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

What does this PR do?

Fixes a config resolution regression from the v1/v2 split: the old app config loader treated OPENCODE_CONFIG_DIR as an extra config layer, but the v2/core path used it as a replacement for the XDG global config directory through Global.config. That could make app-level config output show values that v2/core services, including references, did not see.

This keeps Global.config pinned to the real XDG global config path and models env-provided config directories as explicit additive layers instead. OPENCODE_CONFIG_DIR remains supported for compatibility.

It also adds OPENCODE_CONFIG_DIRS for multiple extra config directories. The value is parsed like PATH with path.delimiter, trims entries, and ignores empty entries, so POSIX uses dirA:dirB and Windows uses dirA;dirB.

Config order is now lowest to highest priority:

  1. XDG global config
  2. project config files
  3. discovered .opencode directories
  4. OPENCODE_CONFIG_DIRS entries from left to right
  5. OPENCODE_CONFIG_DIR last as the highest-priority legacy/custom override

The 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.md and relative configured instructions can 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.ts from packages/core
  • bun test test/config/config.test.ts test/config/tui.test.ts test/session/instruction.test.ts from packages/opencode
  • bun typecheck from packages/core
  • bun typecheck from packages/opencode
  • bun 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.ts
  • Pre-push hook ran bun turbo typecheck successfully

Screenshots / recordings

N/A - non-UI change.

Checklist

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

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

1 participant