Repository navigation
Conversation
…config loading When embedding OpenCode in a service (e.g. via `opencode serve`), the host application typically provides all configuration through `OPENCODE_CONFIG_CONTENT`. Loading global config files from `~/.config/opencode/` can cause unexpected behavior by merging unrelated user-level settings. This adds `OPENCODE_DISABLE_GLOBAL_CONFIG` environment variable that, when set to `1` or `true`, makes `loadGlobal()` return an empty config object, skipping all files under the global config directory (`config.json`, `opencode.json`, `opencode.jsonc`). This flag only affects global config — project-level `.opencode/` directories, `OPENCODE_CONFIG`, and `OPENCODE_CONFIG_CONTENT` continue to load normally.
…ories When OPENCODE_DISABLE_GLOBAL_CONFIG is set, exclude Global.Path.config (~/.config/opencode/) from the directories list. This prevents scanning global agents, skills, commands, and plugins when global config is disabled.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Found a potential duplicate: PR #20784: "feat(sdk): add settingSources to control which config sources are loaded" Why it's related: This PR also addresses controlling which configuration sources are loaded. It provides a |
|
Hey! Just wanted to bump this — I have a use case where I'm shipping a repo with a self-contained The implementation here looks correct and minimal. The CI failure appears to be a flaky Windows e2e test ( Would be great to see this merged! Could someone re-run the CI or merge if the flaky test is a known issue? Thanks! |
…nfig # Conflicts: # packages/opencode/src/config/config.ts # packages/opencode/src/config/paths.ts # packages/opencode/src/flag/flag.ts
Hi @carstenrntn, Thanks for the bump! I've rebased and restarted the tests. Fingers crossed (and praying to the CI gods) that it passes and gets accepted soon! 🤞 |
|
Hey there, |
|
Hello maintainers, |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #21264
Type of change
What does this PR do?
When embedding OpenCode via
opencode servein a host application (e.g. Electron app), all config is provided throughOPENCODE_CONFIG_CONTENT. But global config files and directories from~/.config/opencode/still get loaded and merged, which caninterfere with the intended configuration.
This adds
OPENCODE_DISABLE_GLOBAL_CONFIGenv var. When set to1:loadGlobal()inconfig.tsreturns{}early, skippingconfig.json/opencode.json/opencode.jsoncunder~/.config/opencode/ConfigPaths.directories()inpaths.tsexcludesGlobal.Path.configfrom the returned list, so global agents, skills, commands,and plugins are also not scanned
Project-level
.opencode/directories,OPENCODE_CONFIG, andOPENCODE_CONFIG_CONTENTare not affected. Follows the existingOPENCODE_DISABLE_*naming convention.How did you verify your code works?
OPENCODE_DISABLE_GLOBAL_CONFIG=1+OPENCODE_CONFIG_CONTENTand ranopencode serve— global config loading logs(
service=config path=~/.config/opencode/...) no longer appear, onlyloaded custom config from OPENCODE_CONFIG_CONTENT.opencode/agents/and.opencode/skills/still load correctly with the flag setScreenshots / recordings
N/A — no UI changes, env var only.
Checklist