[PR #6663] fix: merge instructions arrays across config files #12027

Closed
opened 2026-02-16 18:16:57 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6663

State: closed
Merged: Yes


The instructions config array was being replaced instead of merged when combining global and project configs. This meant global instructions (e.g. from ~/.config/opencode/opencode.json) were lost when a project had its own instructions array.

this PR:

  • renames mergeConfigWithPlugins to mergeConfigConcatArrays to reflect its broader purpose
  • adds instructions array merging alongside the existing plugin array handling
  • adds tests for instructions merging and deduplication

The plugin array already had this fix (PR #4724), but instructions was missed.

Paths are deduplicated by their raw string value, not their resolved location. Resolving paths at merge time isn't feasible since globs need filesystem access and project context isn't fully established yet.

Config location instructions value Resolves to
~/.config/opencode/opencode.json ["INSTRUCTIONS.md"] Looks in project dir (not global config dir)
~/.config/opencode/opencode.json ["~/.config/opencode/INSTRUCTIONS.md"] Correctly resolves to global file
./opencode.json ["INSTRUCTIONS.md"] Looks in project dir

Users should use absolute or ~/ paths in global config to ensure they resolve correctly.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6663 **State:** closed **Merged:** Yes --- The `instructions` config array was being replaced instead of merged when combining global and project configs. This meant global instructions (e.g. from `~/.config/opencode/opencode.json`) were lost when a project had its own `instructions` array. this PR: - renames `mergeConfigWithPlugins` to `mergeConfigConcatArrays` to reflect its broader purpose - adds `instructions` array merging alongside the existing `plugin` array handling - adds tests for instructions merging and deduplication The `plugin` array already had this fix (PR #4724), but `instructions` was missed. Paths are deduplicated by their **raw string value**, not their resolved location. Resolving paths at merge time isn't feasible since globs need filesystem access and project context isn't fully established yet. | Config location | `instructions` value | Resolves to | |-----------------|---------------------|-------------| | `~/.config/opencode/opencode.json` | `["INSTRUCTIONS.md"]` | Looks in **project dir** (not global config dir) | | `~/.config/opencode/opencode.json` | `["~/.config/opencode/INSTRUCTIONS.md"]` | Correctly resolves to global file | | `./opencode.json` | `["INSTRUCTIONS.md"]` | Looks in project dir | Users should use absolute or `~/` paths in global config to ensure they resolve correctly.
yindo added the pull-request label 2026-02-16 18:16:57 -05:00
yindo closed this issue 2026-02-16 18:16:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12027