Repository navigation
fix(core): keep OPENCODE_CONFIG_DIR additive for global AGENTS.md - #47468
Open
minutechreview wants to merge 1 commit into
Open
minutechreview wants to merge 1 commit into
minutechreview wants to merge 1 commit into
Conversation
Setting OPENCODE_CONFIG_DIR made both the session-level and system-context instruction loaders (session/instruction.ts and core/instruction-context.ts) stop checking the real XDG global config dir for AGENTS.md, since both built their global lookup path from Global.Service's `config` field, which resolves to `OPENCODE_CONFIG_DIR ?? Global.Path.config` and therefore fully replaces the static default instead of adding to it. This matches ConfigPaths.directories() reading Global.Path.config directly, but the instruction loaders never did the same. Add Global.configDirs(config), which returns the override first (so it still wins when it defines its own AGENTS.md) followed by the real static default when they differ, and use it from both loaders instead of duplicating the logic. Closes anomalyco#28658, anomalyco#32825
This was referenced Sep 5, 2026
|
this needs to be merged asap please! |
Author
|
@hotzen #47468 fixes this. It builds the global config and |
This was referenced Sep 27, 2026
|
so how do we get the maintainer's attention |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #28658, #32825
Type of change
What does this PR do?
OPENCODE_CONFIG_DIRis meant to add a second config location, not replace the global one. It does add correctly for agents/commands/skills, becauseConfigPaths.directories()always includesGlobal.Path.config(the static XDG path) regardless of the flag. But the globalAGENTS.mdlookup insession/instruction.tsand the equivalent lookup incore/instruction-context.tsboth build their path fromGlobal.Service'sconfigproperty, which isFlag.OPENCODE_CONFIG_DIR ?? Global.Path.config— so once you set the env var,~/.config/opencode/AGENTS.mdis never checked again.I added
Global.configDirs(config)inpackages/core/src/global.ts, which returns[config, Global.Path.config](override first so it still wins if it defines its own AGENTS.md, deduped when they're the same value), and pointed both loaders at it instead of duplicating the logic. First-match-wins order is preserved in both call sites.How did you verify your code works?
Global.configDirsand for the extractedglobalInstructionFileshelper insession/instruction.tsthat assert the override is checked, the real default is still checked when the override doesn't have the file, override still wins when both exist, and no duplicate path when they're the same.core/test/instruction-context.test.tsthat writes an AGENTS.md to the real global config dir, pointsOPENCODE_CONFIG_DIRat an unrelated empty dir, and confirms the global file still loads.git stash) and pass against the fix.bun testforpackages/core(1101 tests) andpackages/opencode(3599 tests): all passing.bun turbo typecheckfor both packages: clean.oxlinton all changed files: no new warnings (3 pre-existing unrelated unused-import warnings ininstruction.tsare unchanged fromdev).Checklist