Class: Aidp::Watch::AutoProcessor

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

Overview

Handles the aidp-auto label on issues by delegating to the BuildProcessor and transferring the label to the created PR once work completes.

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:, build_processor:, label_config: {}, verbose: false) ⇒ AutoProcessor

Returns a new instance of AutoProcessor.



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

def initialize(repository_client:, state_store:, build_processor:, label_config: {}, verbose: false)
  @repository_client = repository_client
  @state_store = state_store
  @build_processor = build_processor
  @verbose = verbose

  # Allow overrides from watch config
  @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.



14
15
16
# File 'lib/aidp/watch/auto_processor.rb', line 14

def auto_label
  @auto_label
end

Instance Method Details

#process(issue) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/aidp/watch/auto_processor.rb', line 26

def process(issue)
  number = issue[:number]
  Aidp.log_debug("auto_processor", "process_started", issue: number, title: issue[:title])
  display_message("🤖 Starting autonomous build for issue ##{number}", type: :info)

  @build_processor.process(issue)

  status = @state_store.build_status(number)
  pr_url = status["pr_url"]
  pr_number = extract_pr_number(pr_url)

  unless status["status"] == "completed" && pr_number
    Aidp.log_debug("auto_processor", "no_pr_to_transfer", issue: number, status: status["status"], pr_url: pr_url)
    return
  end

  transfer_label_to_pr(issue_number: number, pr_number: pr_number)
rescue => e
  Aidp.log_error("auto_processor", "process_failed", issue: issue[:number], error: e.message, error_class: e.class.name)
  display_message("❌ aidp-auto failed for issue ##{issue[:number]}: #{e.message}", type: :error)
end