Class: AgentSettings::Adapters::Opencode
- Inherits:
-
Object
- Object
- AgentSettings::Adapters::Opencode
- Defined in:
- lib/agent_settings/adapters/opencode.rb
Overview
Adapter for OpenCode agent configuration.
OpenCode stores configuration in JSON files:
- Global: ~/.config/opencode/opencode.json (user-level config)
- Project: opencode.json (discovered by walking up from project directory)
OpenCode supports multiple environment variable overrides:
- OPENCODE_CONFIG: Direct path to config file
- OPENCODE_CONFIG_DIR: Directory containing opencode.json
- OPENCODE_CONFIG_CONTENT: Inline JSON config content
The project config uses discovery - it walks up from the provided directory looking for opencode.json, similar to how git finds .git.
Instance Method Summary collapse
-
#env_overrides(dir:, env:, trusted:) ⇒ Array<EnvOverride>
Get environment variable overrides for OpenCode.
-
#layers(dir:, env:, trusted:) ⇒ Array<Location>
Get all config layers for OpenCode.
-
#warnings ⇒ Array<String>
Get warnings for OpenCode configuration.
Instance Method Details
#env_overrides(dir:, env:, trusted:) ⇒ Array<EnvOverride>
Get environment variable overrides for OpenCode.
Checks for three environment variables:
- OPENCODE_CONFIG: Path to config file (active if file exists)
- OPENCODE_CONFIG_DIR: Directory containing opencode.json
- OPENCODE_CONFIG_CONTENT: Inline JSON (always active if set)
50 51 52 |
# File 'lib/agent_settings/adapters/opencode.rb', line 50 def env_overrides(dir:, env:, trusted:) # rubocop:disable Lint/UnusedMethodArgument build_env_overrides(env) end |
#layers(dir:, env:, trusted:) ⇒ Array<Location>
Get all config layers for OpenCode.
Returns an array of Location objects for global and project configs. Project config is discovered by walking up the directory tree from the provided dir.
35 36 37 |
# File 'lib/agent_settings/adapters/opencode.rb', line 35 def layers(dir:, env:, trusted:) # rubocop:disable Lint/UnusedMethodArgument build_layers(dir) end |
#warnings ⇒ Array<String>
Get warnings for OpenCode configuration.
OpenCode doesn't produce any warnings currently.
59 |
# File 'lib/agent_settings/adapters/opencode.rb', line 59 def warnings(*) = [] |