Class: AgentSettings::EnvOverride

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

Overview

Represents an environment variable that overrides config location.

Agents can use environment variables to override their default config locations. EnvOverride captures information about these variables, including their name, value, the resulting config path, and whether the override is active (i.e., the target file exists).

Supported environment variables by agent:

  • Claude: CLAUDE_CONFIG_DIR
  • OpenCode: OPENCODE_CONFIG, OPENCODE_CONFIG_DIR, OPENCODE_CONFIG_CONTENT
  • Codex: CODEX_HOME

Examples:

override = EnvOverride.new(
  agent: :claude,
  name: 'CLAUDE_CONFIG_DIR',
  value: '/custom/config',
  path: '/custom/config/settings.json',
  exists: true,
  active: true,
  note: 'Config directory override'
)
override.active?  #=> true

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#activeBoolean (readonly)

whether this override is in effect (file exists)

Returns:

  • the current value of active



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def active
  @active
end

#agentSymbol (readonly)

the agent this override applies to

Returns:

  • the current value of agent



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def agent
  @agent
end

#existsBoolean (readonly)

whether the config file exists at this path

Returns:

  • the current value of exists



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def exists
  @exists
end

#nameString (readonly)

the environment variable name (e.g., 'CLAUDE_CONFIG_DIR')

Returns:

  • the current value of name



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def name
  @name
end

#noteString (readonly)

description of what this override does

Returns:

  • the current value of note



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def note
  @note
end

#pathString (readonly)

the resulting config file path

Returns:

  • the current value of path



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def path
  @path
end

#valueString (readonly)

the value of the environment variable

Returns:

  • the current value of value



35
36
37
# File 'lib/agent_settings/env_override.rb', line 35

def value
  @value
end

Instance Method Details

#active?Boolean

Returns whether this override is in effect.

Returns:

  • whether this override is in effect



40
# File 'lib/agent_settings/env_override.rb', line 40

def active? = active

#exists?Boolean

Returns whether the config file exists at this path.

Returns:

  • whether the config file exists at this path



37
# File 'lib/agent_settings/env_override.rb', line 37

def exists? = exists

#to_locationLocation

Convert this override to a Location object.

When an environment override is active, it becomes the effective config location. This method converts the override to a Location with scope :env.

Returns:

  • a Location representing this override



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/agent_settings/env_override.rb', line 49

def to_location
  Location.new(
    agent: agent,
    scope: :env,
    source: name,
    path: path,
    exists: exists,
    active: active,
    note: note
  )
end