Class: RosettAi::RaiConfig
- Inherits:
-
Object
- Object
- RosettAi::RaiConfig
- Defined in:
- lib/rosett_ai/rai_config.rb
Overview
Loads and validates Rosett-AI runtime configuration from ~/.config/rosett-ai/config.yml.
Returns compiled defaults when no config file exists. User values are deep-merged over defaults and validated against the rai config JSON Schema.
Constant Summary collapse
- DEFAULTS =
{ 'default_engine' => 'claude', 'cache' => { 'enabled' => true, 'ttl_hours' => 24 }, 'detect' => { 'on_init' => true }, 'dbus' => { 'allow_plugin_management' => false } }.freeze
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
Class Method Summary collapse
Instance Method Summary collapse
- #cache_enabled? ⇒ Boolean
- #cache_ttl_hours ⇒ Object
- #dbus_allow_plugin_management? ⇒ Boolean
- #default_engine ⇒ Object
- #detect_on_init? ⇒ Boolean
-
#initialize(config_path: nil) ⇒ RaiConfig
constructor
A new instance of RaiConfig.
-
#update(key, value) ⇒ Object
Update a configuration key and persist to disk.
Constructor Details
#initialize(config_path: nil) ⇒ RaiConfig
Returns a new instance of RaiConfig.
23 24 25 26 |
# File 'lib/rosett_ai/rai_config.rb', line 23 def initialize(config_path: nil) @config_path = config_path || RosettAi.paths.rai_config_dir.join('config.yml') @data = load_config end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
21 22 23 |
# File 'lib/rosett_ai/rai_config.rb', line 21 def config_path @config_path end |
Class Method Details
.load(config_path: nil) ⇒ Object
34 35 36 |
# File 'lib/rosett_ai/rai_config.rb', line 34 def self.load(config_path: nil) new(config_path: config_path) end |
Instance Method Details
#cache_enabled? ⇒ Boolean
29 |
# File 'lib/rosett_ai/rai_config.rb', line 29 def cache_enabled? = @data.dig('cache', 'enabled') |
#cache_ttl_hours ⇒ Object
30 |
# File 'lib/rosett_ai/rai_config.rb', line 30 def cache_ttl_hours = @data.dig('cache', 'ttl_hours') |
#dbus_allow_plugin_management? ⇒ Boolean
32 |
# File 'lib/rosett_ai/rai_config.rb', line 32 def dbus_allow_plugin_management? = @data.dig('dbus', 'allow_plugin_management') == true |
#default_engine ⇒ Object
28 |
# File 'lib/rosett_ai/rai_config.rb', line 28 def default_engine = @data['default_engine'] |
#detect_on_init? ⇒ Boolean
31 |
# File 'lib/rosett_ai/rai_config.rb', line 31 def detect_on_init? = @data.dig('detect', 'on_init') |
#update(key, value) ⇒ Object
Update a configuration key and persist to disk.
42 43 44 45 46 47 |
# File 'lib/rosett_ai/rai_config.rb', line 42 def update(key, value) coerced = coerce_value(value) set_nested_key(@data, key, coerced) validate!(@data) persist! end |