Class: SkillBench::Config

Inherits:
Object
  • Object
show all
Extended by:
FacadeReaders, FacadeWriters
Defined in:
lib/skill_bench/config.rb,
lib/skill_bench/config/store.rb,
lib/skill_bench/config/applier.rb,
lib/skill_bench/config/defaults.rb,
lib/skill_bench/config/json_loader.rb,
lib/skill_bench/config/env_overrides.rb,
lib/skill_bench/config/facade_readers.rb,
lib/skill_bench/config/facade_writers.rb

Overview

Centralized configuration for the SkillBench system. Supports hierarchical loading: Defaults < Home JSON < Local JSON < ENV Variables.

Defined Under Namespace

Modules: FacadeReaders, FacadeWriters Classes: Applier, Defaults, EnvOverrides, JsonLoader, Store

Constant Summary collapse

CONFIG_FILENAME =

File name used for local and home evaluator configuration.

'skill-bench.json'

Constants included from FacadeWriters

FacadeWriters::PROVIDER_SETTINGS

Class Method Summary collapse

Methods included from FacadeWriters

allowed_commands=, current_llm_provider=, llm_providers_config=, max_execution_time=, set_provider_api_key, set_provider_api_version, set_provider_base_url, set_provider_endpoint, set_provider_location, set_provider_model, set_provider_project_id

Methods included from FacadeReaders

allowed_commands, api_key, base_url, current_llm_provider, for_provider, llm_providers_config, max_execution_time, model

Class Method Details

.allowed_commandsArray<String>?

Returns allowed commands from configuration.

Returns:

  • (Array<String>, nil)

    List of allowed commands



92
93
94
# File 'lib/skill_bench/config.rb', line 92

def allowed_commands
  store.allowed_commands
end

.api_keyString?

Returns API key from configuration.

Returns:

  • (String, nil)

    API key



128
129
130
# File 'lib/skill_bench/config.rb', line 128

def api_key
  store.api_key
end

.applyHash

Applies configuration from the store.

Returns:

  • (Hash)

    applied configuration



41
42
43
# File 'lib/skill_bench/config.rb', line 41

def apply
  Config::Applier.call(store.to_h)
end

.current_llm_providerSymbol

Returns the current LLM provider name.

Returns:

  • (Symbol)

    Current provider name



106
107
108
# File 'lib/skill_bench/config.rb', line 106

def current_llm_provider
  store.current_llm_provider || :openai
end

.current_llm_provider=(provider) ⇒ void

This method returns an undefined value.

Sets the current LLM provider.

Parameters:

  • provider (Symbol)

    Provider name



114
115
116
# File 'lib/skill_bench/config.rb', line 114

def current_llm_provider=(provider)
  store.assign_current_llm_provider(provider)
end

.defaultsHash

Returns the default configuration.

Returns:

  • (Hash)

    default configuration hash



34
35
36
# File 'lib/skill_bench/config.rb', line 34

def defaults
  Config::Defaults.call
end

.env_overridesHash

Returns configuration overrides from environment variables.

Returns:

  • (Hash)

    environment-based overrides



65
66
67
# File 'lib/skill_bench/config.rb', line 65

def env_overrides
  Config::EnvOverrides.call
end

.llm_providers_configHash

Returns LLM providers configuration.

Returns:

  • (Hash)

    Providers configuration



121
122
123
# File 'lib/skill_bench/config.rb', line 121

def llm_providers_config
  store.llm_providers_config || {}
end

.load_from_file(path) ⇒ Hash

Loads configuration from a JSON file.

Parameters:

  • path (String)

    Path to JSON file

Returns:

  • (Hash)

    loaded configuration



49
50
51
# File 'lib/skill_bench/config.rb', line 49

def load_from_file(path)
  Config::JsonLoader.call(path)
end

.max_execution_timeInteger

Returns max execution time from configuration.

Returns:

  • (Integer)

    Maximum execution time in seconds



99
100
101
# File 'lib/skill_bench/config.rb', line 99

def max_execution_time
  store.max_execution_time || 30
end

.modelString?

Returns model from configuration.

Returns:

  • (String, nil)

    Model name



135
136
137
# File 'lib/skill_bench/config.rb', line 135

def model
  store.model
end

.resetvoid

This method returns an undefined value.

Resets and reloads configuration from all sources. Pipeline: Defaults → Home JSON → Local JSON → ENV overrides.



73
74
75
76
77
78
79
# File 'lib/skill_bench/config.rb', line 73

def reset
  @store = Config::Store.new
  apply_defaults
  apply_json_config(home_config_path)
  apply_json_config(Pathname.new(Dir.pwd).join(CONFIG_FILENAME))
  apply_env_overrides
end

.save_to_file(path, config) ⇒ void

This method returns an undefined value.

Saves configuration to a JSON file.

Parameters:

  • path (String)

    Path to JSON file

  • config (Hash)

    Configuration to save



58
59
60
# File 'lib/skill_bench/config.rb', line 58

def save_to_file(path, config)
  Config::FacadeWriters.save_to_file(path, config)
end

.setup {|config| ... } ⇒ void

This method returns an undefined value.

Sets up configuration with a block.

Yield Parameters:

  • config (Config::Store)

    Configuration store for modification



85
86
87
# File 'lib/skill_bench/config.rb', line 85

def setup
  yield store
end

.storeConfig::Store

Returns the mutable configuration store behind the facade. Lazily initializes configuration on first access.

Returns:



27
28
29
# File 'lib/skill_bench/config.rb', line 27

def store
  @store ||= Config::Store.new
end