Class: Aidp::Setup::InMemoryConfigManager
- Inherits:
-
Object
- Object
- Aidp::Setup::InMemoryConfigManager
- Defined in:
- lib/aidp/setup/in_memory_config_manager.rb
Overview
ConfigManager-compatible wrapper for in-memory wizard configuration.
This class provides the same interface as Harness::ConfigManager but reads from the wizard's in-memory @config hash instead of from disk. This enables ProviderFactory to work during the wizard before the config file is written.
Instance Attribute Summary collapse
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
Instance Method Summary collapse
-
#all_providers(_options = {}) ⇒ Object
Get all provider configurations.
-
#circuit_breaker_config(_options = {}) ⇒ Object
Get circuit breaker configuration.
-
#config(_options = {}) ⇒ Object
Get complete configuration (returns a copy to prevent mutation).
-
#config_summary ⇒ Object
Get configuration summary.
-
#config_valid? ⇒ Boolean
Check if configuration is valid.
-
#default_provider(_options = {}) ⇒ Object
Get default provider.
-
#fallback_providers(_options = {}) ⇒ Object
Get fallback providers.
-
#harness_config(_options = {}) ⇒ Object
Get harness configuration.
-
#initialize(config, project_dir) ⇒ InMemoryConfigManager
constructor
Initialize with wizard's in-memory config hash.
-
#provider_auth_config(provider_name, _options = {}) ⇒ Object
Get provider auth configuration (redacts sensitive values).
-
#provider_config(provider_name, _options = {}) ⇒ Object
Get provider configuration.
-
#provider_default_flags(provider_name, _options = {}) ⇒ Object
Get provider default flags.
-
#provider_endpoints(provider_name, _options = {}) ⇒ Object
Get provider endpoints.
-
#provider_features(provider_name, _options = {}) ⇒ Object
Get provider features.
-
#provider_max_tokens(provider_name, _options = {}) ⇒ Object
Get provider max tokens.
-
#provider_model_weights(provider_name, _options = {}) ⇒ Object
Get provider model weights.
-
#provider_models(provider_name, _options = {}) ⇒ Object
Get provider models.
-
#provider_monitoring_config(provider_name, _options = {}) ⇒ Object
Get provider monitoring configuration.
-
#provider_names(_options = {}) ⇒ Object
Get configured provider names.
-
#provider_priority(provider_name, _options = {}) ⇒ Object
Get provider priority.
-
#provider_supports_feature?(provider_name, feature, options = {}) ⇒ Boolean
Check if provider supports feature.
-
#provider_type(provider_name, _options = {}) ⇒ Object
Get provider type.
-
#rate_limit_config(_options = {}) ⇒ Object
Get rate limit configuration.
-
#reload_config ⇒ Object
Reload configuration (no-op for in-memory).
-
#retry_config(_options = {}) ⇒ Object
Get retry configuration.
-
#validation_errors ⇒ Object
Get validation errors (empty for in-memory config).
-
#validation_warnings ⇒ Object
Get validation warnings (empty for in-memory config).
Constructor Details
#initialize(config, project_dir) ⇒ InMemoryConfigManager
Initialize with wizard's in-memory config hash
23 24 25 26 27 28 29 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 23 def initialize(config, project_dir) @config = config || {} @project_dir = project_dir Aidp.log_debug("in_memory_config_manager", "initialized", providers: provider_names) end |
Instance Attribute Details
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
17 18 19 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 17 def project_dir @project_dir end |
Instance Method Details
#all_providers(_options = {}) ⇒ Object
Get all provider configurations
51 52 53 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 51 def all_providers( = {}) @config[:providers] || {} end |
#circuit_breaker_config(_options = {}) ⇒ Object
Get circuit breaker configuration
163 164 165 166 167 168 169 170 171 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 163 def circuit_breaker_config( = {}) cfg = harness_config[:circuit_breaker] || {} { enabled: cfg[:enabled] != false, failure_threshold: cfg[:failure_threshold] || 5, timeout: cfg[:timeout] || 300, half_open_max_calls: cfg[:half_open_max_calls] || 3 } end |
#config(_options = {}) ⇒ Object
Get complete configuration (returns a copy to prevent mutation)
32 33 34 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 32 def config( = {}) deep_dup(@config) end |
#config_summary ⇒ Object
Get configuration summary
97 98 99 100 101 102 103 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 97 def config_summary { providers: provider_names.size, default_provider: default_provider, fallback_providers: fallback_providers.size } end |
#config_valid? ⇒ Boolean
Check if configuration is valid
74 75 76 77 78 79 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 74 def config_valid? result = !!(default_provider && provider_config(default_provider)) Aidp.log_debug("in_memory_config_manager", "config_valid_check", valid: result, default_provider: default_provider) result end |
#default_provider(_options = {}) ⇒ Object
Get default provider
62 63 64 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 62 def default_provider( = {}) harness_config[:default_provider] || harness_config["default_provider"] end |
#fallback_providers(_options = {}) ⇒ Object
Get fallback providers
67 68 69 70 71 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 67 def fallback_providers( = {}) fallbacks = harness_config[:fallback_providers] || harness_config["fallback_providers"] || [] configured = provider_names fallbacks.select { |p| configured.include?(p.to_s) } end |
#harness_config(_options = {}) ⇒ Object
Get harness configuration
37 38 39 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 37 def harness_config( = {}) @config[:harness] || {} end |
#provider_auth_config(provider_name, _options = {}) ⇒ Object
Get provider auth configuration (redacts sensitive values)
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 219 def provider_auth_config(provider_name, = {}) cfg = provider_config(provider_name) return {} unless cfg auth = cfg[:auth] || cfg["auth"] || {} { # Only expose the env var name, not actual keys api_key_env: auth[:api_key_env] || auth["api_key_env"], # Redact actual API key - callers should use api_key_env api_key: (auth[:api_key] || auth["api_key"]) ? "[REDACTED]" : nil } end |
#provider_config(provider_name, _options = {}) ⇒ Object
Get provider configuration
42 43 44 45 46 47 48 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 42 def provider_config(provider_name, = {}) providers = @config[:providers] || {} config = providers[provider_name.to_sym] || providers[provider_name.to_s] Aidp.log_debug("in_memory_config_manager", "provider_config_retrieved", provider: provider_name, found: !config.nil?) config end |
#provider_default_flags(provider_name, _options = {}) ⇒ Object
Get provider default flags
211 212 213 214 215 216 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 211 def provider_default_flags(provider_name, = {}) cfg = provider_config(provider_name) return [] unless cfg flags = cfg[:default_flags] || cfg["default_flags"] || [] flags.map(&:to_s) end |
#provider_endpoints(provider_name, _options = {}) ⇒ Object
Get provider endpoints
232 233 234 235 236 237 238 239 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 232 def provider_endpoints(provider_name, = {}) cfg = provider_config(provider_name) return {} unless cfg endpoints = cfg[:endpoints] || cfg["endpoints"] || {} { default: endpoints[:default] || endpoints["default"] } end |
#provider_features(provider_name, _options = {}) ⇒ Object
Get provider features
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 121 def provider_features(provider_name, = {}) cfg = provider_config(provider_name) return {} unless cfg features = cfg[:features] || cfg["features"] || {} { file_upload: features[:file_upload] == true, code_generation: features[:code_generation] != false, analysis: features[:analysis] != false, vision: features[:vision] == true } end |
#provider_max_tokens(provider_name, _options = {}) ⇒ Object
Get provider max tokens
204 205 206 207 208 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 204 def provider_max_tokens(provider_name, = {}) cfg = provider_config(provider_name) return nil unless cfg cfg[:max_tokens] || cfg["max_tokens"] end |
#provider_model_weights(provider_name, _options = {}) ⇒ Object
Get provider model weights
196 197 198 199 200 201 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 196 def provider_model_weights(provider_name, = {}) cfg = provider_config(provider_name) return {} unless cfg weights = cfg[:model_weights] || cfg["model_weights"] || {} weights.transform_values { |w| [w.to_i, 1].max } end |
#provider_models(provider_name, _options = {}) ⇒ Object
Get provider models
113 114 115 116 117 118 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 113 def provider_models(provider_name, = {}) cfg = provider_config(provider_name) return [] unless cfg models = cfg[:models] || cfg["models"] || [] models.map(&:to_s) end |
#provider_monitoring_config(provider_name, _options = {}) ⇒ Object
Get provider monitoring configuration
185 186 187 188 189 190 191 192 193 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 185 def provider_monitoring_config(provider_name, = {}) cfg = provider_config(provider_name) return {} unless cfg monitoring = cfg[:monitoring] || cfg["monitoring"] || {} { enabled: monitoring[:enabled] != false, metrics_interval: monitoring[:metrics_interval] || 60 } end |
#provider_names(_options = {}) ⇒ Object
Get configured provider names
56 57 58 59 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 56 def provider_names( = {}) providers = all_providers providers.keys.map(&:to_s) end |
#provider_priority(provider_name, _options = {}) ⇒ Object
Get provider priority
143 144 145 146 147 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 143 def provider_priority(provider_name, = {}) cfg = provider_config(provider_name) return 1 unless cfg cfg[:priority] || cfg["priority"] || 1 end |
#provider_supports_feature?(provider_name, feature, options = {}) ⇒ Boolean
Check if provider supports feature
134 135 136 137 138 139 140 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 134 def provider_supports_feature?(provider_name, feature, = {}) features = provider_features(provider_name, ) result = features[feature.to_sym] == true Aidp.log_debug("in_memory_config_manager", "feature_support_check", provider: provider_name, feature: feature, supported: result) result end |
#provider_type(provider_name, _options = {}) ⇒ Object
Get provider type
106 107 108 109 110 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 106 def provider_type(provider_name, = {}) cfg = provider_config(provider_name) return nil unless cfg cfg[:type] || cfg["type"] end |
#rate_limit_config(_options = {}) ⇒ Object
Get rate limit configuration
174 175 176 177 178 179 180 181 182 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 174 def rate_limit_config( = {}) cfg = harness_config[:rate_limit] || {} { enabled: cfg[:enabled] != false, default_reset_time: cfg[:default_reset_time] || 3600, burst_limit: cfg[:burst_limit] || 10, sustained_limit: cfg[:sustained_limit] || 5 } end |
#reload_config ⇒ Object
Reload configuration (no-op for in-memory)
92 93 94 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 92 def reload_config # No-op: in-memory config doesn't need reloading end |
#retry_config(_options = {}) ⇒ Object
Get retry configuration
150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 150 def retry_config( = {}) cfg = harness_config[:retry] || {} { enabled: cfg[:enabled] != false, max_attempts: cfg[:max_attempts] || 3, base_delay: cfg[:base_delay] || 1.0, max_delay: cfg[:max_delay] || 60.0, exponential_base: cfg[:exponential_base] || 2.0, jitter: cfg[:jitter] != false } end |
#validation_errors ⇒ Object
Get validation errors (empty for in-memory config)
82 83 84 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 82 def validation_errors [] end |
#validation_warnings ⇒ Object
Get validation warnings (empty for in-memory config)
87 88 89 |
# File 'lib/aidp/setup/in_memory_config_manager.rb', line 87 def validation_warnings [] end |