Class: Roast::Workflow::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/workflow/configuration.rb

Overview

Encapsulates workflow configuration data and provides structured access to the configuration settings

Defined Under Namespace

Classes: MCPTool

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_path, options = {}) ⇒ Configuration

Returns a new instance of Configuration.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roast/workflow/configuration.rb', line 20

def initialize(workflow_path, options = {})
  @workflow_path = workflow_path

  # Load configuration using ConfigurationLoader
  @config_hash = ConfigurationLoader.load(workflow_path)

  # Extract basic configuration values
  @name = ConfigurationLoader.extract_name(@config_hash, workflow_path)
  @steps = ConfigurationLoader.extract_steps(@config_hash)
  @pre_processing = ConfigurationLoader.extract_pre_processing(@config_hash)
  @post_processing = ConfigurationLoader.extract_post_processing(@config_hash)
  @tools, @tool_configs = ConfigurationLoader.extract_tools(@config_hash)
  @mcp_tools = ConfigurationLoader.extract_mcp_tools(@config_hash)
  @function_configs = ConfigurationLoader.extract_functions(@config_hash)
  @model = ConfigurationLoader.extract_model(@config_hash)
  @context_management = ConfigurationLoader.extract_context_management(@config_hash)

  # Initialize components
  @api_configuration = ApiConfiguration.new(@config_hash)
  @step_finder = StepFinder.new(@steps)

  # Process target and resource
  @target = ConfigurationLoader.extract_target(@config_hash, options)
  process_resource
end

Instance Attribute Details

#config_hashObject (readonly)

Returns the value of attribute config_hash.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def config_hash
  @config_hash
end

#context_managementObject (readonly)

Returns the value of attribute context_management.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def context_management
  @context_management
end

#function_configsObject (readonly)

Returns the value of attribute function_configs.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def function_configs
  @function_configs
end

#mcp_toolsObject (readonly)

Returns the value of attribute mcp_tools.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def mcp_tools
  @mcp_tools
end

#modelObject (readonly)

Returns the value of attribute model.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def name
  @name
end

#post_processingObject (readonly)

Returns the value of attribute post_processing.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def post_processing
  @post_processing
end

#pre_processingObject (readonly)

Returns the value of attribute pre_processing.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def pre_processing
  @pre_processing
end

#resourceObject (readonly)

Returns the value of attribute resource.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def resource
  @resource
end

#stepsObject (readonly)

Returns the value of attribute steps.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def steps
  @steps
end

#targetObject

Returns the value of attribute target.



11
12
13
# File 'lib/roast/workflow/configuration.rb', line 11

def target
  @target
end

#tool_configsObject (readonly)

Returns the value of attribute tool_configs.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def tool_configs
  @tool_configs
end

#toolsObject (readonly)

Returns the value of attribute tools.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def tools
  @tools
end

#workflow_pathObject (readonly)

Returns the value of attribute workflow_path.



10
11
12
# File 'lib/roast/workflow/configuration.rb', line 10

def workflow_path
  @workflow_path
end

Instance Method Details

#api_tokenObject

Delegate api_token to effective_token for backward compatibility



16
17
18
# File 'lib/roast/workflow/configuration.rb', line 16

def api_token
  @api_configuration.effective_token
end

#basenameObject



50
51
52
# File 'lib/roast/workflow/configuration.rb', line 50

def basename
  @basename ||= File.basename(workflow_path, ".yml")
end

#context_pathObject



46
47
48
# File 'lib/roast/workflow/configuration.rb', line 46

def context_path
  @context_path ||= File.dirname(workflow_path)
end

#find_step_index(steps_array = nil, target_step = nil) ⇒ Integer?

Find the index of a step in the workflow steps array

Parameters:

  • steps (Array)

    Optional - The steps array to search (defaults to self.steps)

  • target_step (String) (defaults to: nil)

    The name of the step to find

Returns:

  • (Integer, nil)

    The index of the step, or nil if not found



66
67
68
69
70
71
72
73
74
# File 'lib/roast/workflow/configuration.rb', line 66

def find_step_index(steps_array = nil, target_step = nil)
  # Handle different call patterns for backward compatibility
  if steps_array.is_a?(String) && target_step.nil?
    target_step = steps_array
    steps_array = nil
  end

  @step_finder.find_index(target_step, steps_array)
end

#function_config(function_name) ⇒ Hash

Get configuration for a specific function

Parameters:

  • function_name (String, Symbol)

    The name of the function (e.g., ‘grep’, ‘search_file’)

Returns:

  • (Hash)

    The configuration for the function or empty hash if not found



79
80
81
# File 'lib/roast/workflow/configuration.rb', line 79

def function_config(function_name)
  @function_configs[function_name.to_s] || {}
end

#get_step_config(step_name) ⇒ Object



58
59
60
# File 'lib/roast/workflow/configuration.rb', line 58

def get_step_config(step_name)
  @config_hash[step_name] || {}
end

#has_target?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/roast/workflow/configuration.rb', line 54

def has_target?
  !target.nil? && !target.empty?
end

#tool_config(tool_name) ⇒ Hash

Get configuration for a specific tool

Parameters:

  • tool_name (String)

    The name of the tool (e.g., ‘Roast::Tools::Cmd’)

Returns:

  • (Hash)

    The configuration for the tool or empty hash if not found



86
87
88
# File 'lib/roast/workflow/configuration.rb', line 86

def tool_config(tool_name)
  @tool_configs[tool_name.to_s] || {}
end