Class: Aidp::Watch::AutoPrProcessor

Inherits:
Object
  • Object
show all
Includes:
MessageDisplay
Defined in:
lib/aidp/watch/auto_pr_processor.rb

Overview

Handles the aidp-auto label on PRs by chaining review and CI-fix flows until the PR is ready for human review.

Constant Summary collapse

DEFAULT_AUTO_LABEL =
"aidp-auto"

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MessageDisplay

#display_message, included, #message_display_prompt

Constructor Details

#initialize(repository_client:, state_store:, review_processor:, ci_fix_processor:, label_config: {}, verbose: false) ⇒ AutoPrProcessor

Returns a new instance of AutoPrProcessor.



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

def initialize(repository_client:, state_store:, review_processor:, ci_fix_processor:, label_config: {}, verbose: false)
  @repository_client = repository_client
  @state_store = state_store
  @review_processor = review_processor
  @ci_fix_processor = ci_fix_processor
  @state_extractor = GitHubStateExtractor.new(repository_client: repository_client)
  @verbose = verbose
  @auto_label = label_config[:auto_trigger] || label_config["auto_trigger"] || DEFAULT_AUTO_LABEL
end

Instance Attribute Details

#auto_labelObject (readonly)

Returns the value of attribute auto_label.



40
41
42
# File 'lib/aidp/watch/auto_pr_processor.rb', line 40

def auto_label
  @auto_label
end

Instance Method Details

#process(pr) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aidp/watch/auto_pr_processor.rb', line 25

def process(pr)
  number = pr[:number]
  Aidp.log_debug("auto_pr_processor", "process_started", pr: number, title: pr[:title])
  display_message("🤖 Running autonomous review/CI loop for PR ##{number}", type: :info)

  # Run review and CI fix flows. Each processor is responsible for its own guards.
  @review_processor.process(pr)
  @ci_fix_processor.process(pr)

  finalize_if_ready(pr_number: number)
rescue => e
  Aidp.log_error("auto_pr_processor", "process_failed", pr: pr[:number], error: e.message, error_class: e.class.name)
  display_message("❌ aidp-auto failed on PR ##{pr[:number]}: #{e.message}", type: :error)
end