Class: Aidp::Analyze::Runner

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

Constant Summary

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP

Constants included from DebugMixin

DebugMixin::DEBUG_BASIC, DebugMixin::DEBUG_OFF, DebugMixin::DEBUG_VERBOSE

Instance Method Summary collapse

Methods included from MessageDisplay

#display_message, included, #message_display_prompt

Methods included from DebugMixin

#debug_basic?, #debug_command, #debug_enabled?, #debug_error, #debug_execute_command, #debug_level, #debug_log, #debug_logger, #debug_provider, #debug_step, #debug_timing, #debug_verbose?, included, shared_logger

Constructor Details

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

Returns a new instance of Runner.



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

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



103
104
105
# File 'lib/aidp/analyze/runner.rb', line 103

def all_steps
  Aidp::Analyze::Steps::SPEC.keys
end

#all_steps_completed?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/aidp/analyze/runner.rb', line 111

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

#get_step_description(step_name) ⇒ Object



131
132
133
134
# File 'lib/aidp/analyze/runner.rb', line 131

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

#get_step_outputs(step_name) ⇒ Object



141
142
143
144
# File 'lib/aidp/analyze/runner.rb', line 141

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

#get_step_spec(step_name) ⇒ Object



127
128
129
# File 'lib/aidp/analyze/runner.rb', line 127

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

#get_step_templates(step_name) ⇒ Object



146
147
148
149
# File 'lib/aidp/analyze/runner.rb', line 146

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

#harness_statusObject

Harness-aware status information



152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/aidp/analyze/runner.rb', line 152

def harness_status
  {
    mode: :analyze,
    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)


136
137
138
139
# File 'lib/aidp/analyze/runner.rb', line 136

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

#mark_step_completed(step_name) ⇒ Object



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

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

#mark_step_in_progress(step_name) ⇒ Object



123
124
125
# File 'lib/aidp/analyze/runner.rb', line 123

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

#next_stepObject



107
108
109
# File 'lib/aidp/analyze/runner.rb', line 107

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

#progressObject



26
27
28
# File 'lib/aidp/analyze/runner.rb', line 26

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

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/aidp/analyze/runner.rb', line 34

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

  debug_step(step_name, "Starting execution", {
    harness_mode: @is_harness_mode,
    options: options.keys
  })

  # 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)



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/aidp/analyze/runner.rb', line 84

def run_step_standalone(step_name, options = {})
  display_message("🚀 Running 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("✅ Step completed in #{duration.round(2)}s", type: :success)
  result
end

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

Harness-aware step execution



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/aidp/analyze/runner.rb', line 53

def run_step_with_harness(step_name, options = {})
  # Get current provider from harness
  current_provider = get_harness_provider_safely
  provider_type = current_provider || "cursor"

  debug_step(step_name, "Harness execution", {
    provider: provider_type,
    project_dir: @project_dir
  })

  # Compose prompt with harness context
  prompt = composed_prompt_with_harness_context(step_name, options)

  debug_log("📝 Composed prompt for #{step_name}", level: :info, data: {
    prompt_length: prompt.length,
    provider: provider_type
  })

  # Execute with harness error handling
  result = execute_with_harness_provider(provider_type, prompt, step_name, options)

  debug_step(step_name, "Harness execution completed", {
    status: result[:status],
    provider: result[:provider]
  })

  # Process result for harness
  process_result_for_harness(result, step_name, options)
end

#step_completed?(step_name) ⇒ Boolean

Returns:

  • (Boolean)


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

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