Class: Aidp::Execute::Runner

Inherits:
Object
  • Object
show all
Includes:
MessageDisplay
Defined in:
lib/aidp/execute/runner.rb

Constant Summary

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP

Instance Method Summary collapse

Methods included from MessageDisplay

#display_message, #in_test_environment?, included, #message_display_prompt, #suppress_display_message?

Constructor Details

#initialize(project_dir, harness_runner = nil, prompt: TTY::Prompt.new) ⇒ Runner

Returns a new instance of Runner.



15
16
17
18
19
20
21
22
23
# File 'lib/aidp/execute/runner.rb', line 15

def initialize(project_dir, harness_runner = nil, prompt: TTY::Prompt.new)
  @project_dir = project_dir
  @harness_runner = harness_runner
  @is_harness_mode = !harness_runner.nil?
  @file_manager = Aidp::Storage::FileManager.new(File.join(project_dir, ".aidp"))
  @prompt = prompt
  @skills_registry = nil # Lazy-loaded
  @skills_composer = Aidp::Skills::Composer.new
end

Instance Method Details

#all_stepsObject

Harness integration methods



81
82
83
84
85
86
87
88
# File 'lib/aidp/execute/runner.rb', line 81

def all_steps
  # Use selected steps from harness if available, otherwise all steps
  if @is_harness_mode && @harness_runner&.instance_variable_get(:@selected_steps)
    @harness_runner.instance_variable_get(:@selected_steps)
  else
    Aidp::Execute::Steps::SPEC.keys
  end
end

#all_steps_completed?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/aidp/execute/runner.rb', line 94

def all_steps_completed?
  all_steps.all? { |step| progress.step_completed?(step) }
end

#get_step_description(step_name) ⇒ Object



114
115
116
117
# File 'lib/aidp/execute/runner.rb', line 114

def get_step_description(step_name)
  spec = get_step_spec(step_name)
  spec ? spec["description"] : nil
end

#get_step_outputs(step_name) ⇒ Object



124
125
126
127
# File 'lib/aidp/execute/runner.rb', line 124

def get_step_outputs(step_name)
  spec = get_step_spec(step_name)
  spec ? spec["outs"] : []
end

#get_step_spec(step_name) ⇒ Object



110
111
112
# File 'lib/aidp/execute/runner.rb', line 110

def get_step_spec(step_name)
  Aidp::Execute::Steps::SPEC[step_name]
end

#get_step_templates(step_name) ⇒ Object



129
130
131
132
# File 'lib/aidp/execute/runner.rb', line 129

def get_step_templates(step_name)
  spec = get_step_spec(step_name)
  spec ? spec["templates"] : []
end

#harness_statusObject

Harness-aware status information



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/aidp/execute/runner.rb', line 135

def harness_status
  {
    mode: :execute,
    total_steps: all_steps.size,
    completed_steps: progress.completed_steps.size,
    current_step: progress.current_step,
    next_step: next_step,
    all_completed: all_steps_completed?,
    started_at: progress.started_at,
    progress_percentage: all_steps_completed? ? 100.0 : (progress.completed_steps.size.to_f / all_steps.size * 100).round(2)
  }
end

#is_gate_step?(step_name) ⇒ Boolean

Returns:

  • (Boolean)


119
120
121
122
# File 'lib/aidp/execute/runner.rb', line 119

def is_gate_step?(step_name)
  spec = get_step_spec(step_name)
  spec ? spec["gate"] : false
end

#mark_step_completed(step_name) ⇒ Object



102
103
104
# File 'lib/aidp/execute/runner.rb', line 102

def mark_step_completed(step_name)
  progress.mark_step_completed(step_name)
end

#mark_step_in_progress(step_name) ⇒ Object



106
107
108
# File 'lib/aidp/execute/runner.rb', line 106

def mark_step_in_progress(step_name)
  progress.mark_step_in_progress(step_name)
end

#next_stepObject



90
91
92
# File 'lib/aidp/execute/runner.rb', line 90

def next_step
  all_steps.find { |step| !progress.step_completed?(step) }
end

#progressObject



25
26
27
# File 'lib/aidp/execute/runner.rb', line 25

def progress
  @progress ||= Aidp::Execute::Progress.new(@project_dir)
end

#run_step(step_name, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/aidp/execute/runner.rb', line 33

def run_step(step_name, options = {})
  # Always validate step exists first
  step_spec = Aidp::Execute::Steps::SPEC[step_name]
  raise "Step '#{step_name}' not found" unless step_spec

  # In harness mode, use the harness's provider management
  if @is_harness_mode
    run_step_with_harness(step_name, options)
  else
    run_step_standalone(step_name, options)
  end
end

#run_step_standalone(step_name, options = {}) ⇒ Object

Standalone step execution (simplified - synchronous)



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/aidp/execute/runner.rb', line 62

def run_step_standalone(step_name, options = {})
  display_message("🚀 Running execution step synchronously: #{step_name}", type: :info)

  start_time = Time.now
  prompt = composed_prompt(step_name, options)

  # Execute step synchronously with a simple provider
  result = execute_step_synchronously(step_name, prompt, options)

  duration = Time.now - start_time

  # Store execution metrics
  @file_manager.record_step_execution(step_name, "cursor", duration, result[:status] == "completed")

  display_message("✅ Execution step completed in #{duration.round(2)}s", type: :success)
  result
end

#run_step_with_harness(step_name, options = {}) ⇒ Object

Harness-aware step execution



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/aidp/execute/runner.rb', line 47

def run_step_with_harness(step_name, options = {})
  step_spec = Aidp::Execute::Steps::SPEC[step_name]

  # Check if work loops are enabled in configuration
  config = @harness_runner.instance_variable_get(:@configuration)
  if config&.work_loop_enabled?
    # Use WorkLoopRunner for execution
    run_step_with_work_loop(step_name, step_spec, options)
  else
    # Use traditional single-pass execution
    run_step_traditional(step_name, step_spec, options)
  end
end

#step_completed?(step_name) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/aidp/execute/runner.rb', line 98

def step_completed?(step_name)
  progress.step_completed?(step_name)
end