Class: AgentSettings::AgentConfigPath

Inherits:
Data
  • Object
show all
Defined in:
lib/agent_settings/agent_config_path.rb

Overview

The complete result of resolving an agent's config location.

AgentConfigPath is the primary return value from resolve and contains all information about where an agent's configuration is located, including:

  • The effective (active) config location
  • Global and project-specific locations
  • All config layers organized by precedence
  • Environment variable overrides detected
  • Any warnings (e.g., untrusted project)

The effective location is determined by checking in order:

  1. Active environment variable overrides (highest precedence)
  2. First existing layer in precedence order
  3. First layer if none exist

Examples:

result = AgentSettings.resolve(:claude, dir: Dir.pwd)
result.effective.path     #=> "/Users/me/.claude/settings.json"
result.effective.exists?  #=> true
result.global             #=> Location for global config
result.project            #=> Location for project config
result.custom_config?     #=> false (no env override active)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agentSymbol (readonly)

the agent this config path is for

Returns:

  • (Symbol)

    the current value of agent



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def agent
  @agent
end

#effectiveLocation? (readonly)

the currently active config location

Returns:

  • (Location, nil)

    the current value of effective



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def effective
  @effective
end

#env_overridesArray<EnvOverride> (readonly)

detected environment variable overrides

Returns:

  • (Array<EnvOverride>)

    the current value of env_overrides



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def env_overrides
  @env_overrides
end

#globalLocation? (readonly)

the global (user) config location

Returns:

  • (Location, nil)

    the current value of global



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def global
  @global
end

#layersArray<Location> (readonly)

all config locations in precedence order

Returns:

  • (Array<Location>)

    the current value of layers



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def layers
  @layers
end

#projectLocation? (readonly)

the project-level config location

Returns:

  • (Location, nil)

    the current value of project



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def project
  @project
end

#warningsArray<String> (readonly)

any warnings about the configuration

Returns:

  • (Array<String>)

    the current value of warnings



36
37
38
# File 'lib/agent_settings/agent_config_path.rb', line 36

def warnings
  @warnings
end

Instance Method Details

#custom_config?Boolean

Check if a custom config is being used via environment variable.

Returns true if any environment variable override is active, meaning the agent is using a config location different from the default file-based locations.

Examples:

env = { "OPENCODE_CONFIG" => "/custom/config.json" }
result = AgentSettings.resolve(:opencode, dir: Dir.pwd, env: env)
result.custom_config?  #=> true (if /custom/config.json exists)

Returns:

  • (Boolean)

    true if an environment override is active



49
# File 'lib/agent_settings/agent_config_path.rb', line 49

def custom_config? = env_overrides.any?(&:active?)