Class: Ralph::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ralph/config.rb

Constant Summary collapse

OPTIONS =

Single source of truth for config option names and their defaults. Use a lambda for mutable defaults to avoid shared state.

{
  prompt:                -> { PromptTemplate.new("") },
  min_iterations:        1,
  max_iterations:        0,
  completion_promise:    "COMPLETE",
  tasks_mode:            false,
  task_promise:          "READY_FOR_NEXT_TASK",
  model:                 "",
  chosen_agent:            "opencode",
  disable_plugins:       false,
  allow_all_permissions: true,
  stream_output:         true,
  verbose_tools:         false,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Config

Returns a new instance of Config.



25
26
27
28
29
30
31
32
# File 'lib/ralph/config.rb', line 25

def initialize(**opts)
  OPTIONS.each do |key, default|
    value = opts.fetch(key) { default.respond_to?(:call) ? default.call : default }
    instance_variable_set(:"@#{key}", value)
  end
  @current_pid = nil
  @stopping    = false
end

Instance Attribute Details

#current_pidObject

Runtime state (not constructor args, not in to_h).



23
24
25
# File 'lib/ralph/config.rb', line 23

def current_pid
  @current_pid
end

#stoppingObject

Runtime state (not constructor args, not in to_h).



23
24
25
# File 'lib/ralph/config.rb', line 23

def stopping
  @stopping
end

Instance Method Details

#to_hObject

Returns a hash of options suitable for passing to Loop#call. Excludes runtime state (current_pid, stopping).



36
37
38
# File 'lib/ralph/config.rb', line 36

def to_h
  OPTIONS.keys.map { |k| [k, send(k)] }.to_h
end