diff options
| author | oribi <[email protected]> | 2025-10-28 18:50:09 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-28 11:50:09 -0500 |
| commit | eb398f1951764af812c7ef01f37f01da862a852a (patch) | |
| tree | 527ae6b6073263616149aa2de9fa7cf56a357c9a | |
| parent | 643c22d21fb438236ed9e218f085aad0c73ca8c1 (diff) | |
| download | opencode-eb398f1951764af812c7ef01f37f01da862a852a.tar.gz opencode-eb398f1951764af812c7ef01f37f01da862a852a.zip | |
add OPENCODE_CONFIG_DIR to allow loading a custom config directory (#3504)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
| -rw-r--r-- | packages/opencode/src/config/config.ts | 5 | ||||
| -rw-r--r-- | packages/opencode/src/flag/flag.ts | 1 | ||||
| -rw-r--r-- | packages/web/src/content/docs/config.mdx | 16 |
3 files changed, 22 insertions, 0 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 4c6003b9e..42d59226e 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -61,6 +61,11 @@ export namespace Config { )), ] + if (Flag.OPENCODE_CONFIG_DIR) { + directories.push(Flag.OPENCODE_CONFIG_DIR) + log.debug("loading config from OPENCODE_CONFIG_DIR", { path: Flag.OPENCODE_CONFIG_DIR }) + } + for (const dir of directories) { await assertValid(dir) installDependencies(dir) diff --git a/packages/opencode/src/flag/flag.ts b/packages/opencode/src/flag/flag.ts index 879aa758a..86ca07652 100644 --- a/packages/opencode/src/flag/flag.ts +++ b/packages/opencode/src/flag/flag.ts @@ -1,6 +1,7 @@ export namespace Flag { export const OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE") export const OPENCODE_CONFIG = process.env["OPENCODE_CONFIG"] + export const OPENCODE_CONFIG_DIR = process.env["OPENCODE_CONFIG_DIR"] export const OPENCODE_CONFIG_CONTENT = process.env["OPENCODE_CONFIG_CONTENT"] export const OPENCODE_DISABLE_AUTOUPDATE = truthy("OPENCODE_DISABLE_AUTOUPDATE") export const OPENCODE_DISABLE_PRUNE = truthy("OPENCODE_DISABLE_PRUNE") diff --git a/packages/web/src/content/docs/config.mdx b/packages/web/src/content/docs/config.mdx index f3b2a05a0..2a259ff37 100644 --- a/packages/web/src/content/docs/config.mdx +++ b/packages/web/src/content/docs/config.mdx @@ -61,6 +61,22 @@ opencode run "Hello world" --- +### Custom directory + +You can specify a custom config directory using the `OPENCODE_CONFIG_DIR` +environment variable. This directory will be searched for agents, commands, +modes, and plugins just like the standard `.opencode` directory, and should +follow the same structure. + +```bash +export OPENCODE_CONFIG_DIR=/path/to/my/config-directory +opencode run "Hello world" +``` + +Note: The custom directory is loaded after the global config and `.opencode` directories, so it can override their settings. + +--- + ## Schema The config file has a schema that's defined in [**`opencode.ai/config.json`**](https://opencode.ai/config.json). |
