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, skill_sources

Class Method Details

.allowed_commandsArray<String>?

Returns allowed commands from configuration.

Returns:

  • (Array<String>, nil)

    List of allowed commands



94
95
96
# File 'lib/skill_bench/config.rb', line 94

def allowed_commands
  store.allowed_commands
end

.api_keyString?

Returns API key from configuration.

Returns:

  • (String, nil)

    API key



137
138
139
# File 'lib/skill_bench/config.rb', line 137

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



108
109
110
# File 'lib/skill_bench/config.rb', line 108

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



116
117
118
# File 'lib/skill_bench/config.rb', line 116

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



123
124
125
# File 'lib/skill_bench/config.rb', line 123

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



101
102
103
# File 'lib/skill_bench/config.rb', line 101

def max_execution_time
  store.max_execution_time || 30
end

.modelString?

Returns model from configuration.

Returns:

  • (String, nil)

    Model name



144
145
146
# File 'lib/skill_bench/config.rb', line 144

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
80
81
# File 'lib/skill_bench/config.rb', line 73

def reset
  @store = Config::Store.new
  apply_defaults
  apply_json_config(home_config_path)
  local_path = Pathname.new(Dir.pwd).join(CONFIG_FILENAME)
  is_workspace_file = File.exist?(File.join(Dir.pwd, 'ruby-skill-bench.gemspec'))
  apply_json_config(local_path) unless defined?(Minitest) && is_workspace_file
  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



87
88
89
# File 'lib/skill_bench/config.rb', line 87

def setup
  yield store
end

.skill_sourcesHash?

Returns skill sources mapping.

Returns:

  • (Hash, nil)

    skill source name → directory path



130
131
132
# File 'lib/skill_bench/config.rb', line 130

def skill_sources
  store.skill_sources || {}
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