Class: Aidp::Watch::Runner
- Inherits:
-
Object
- Object
- Aidp::Watch::Runner
- Includes:
- MessageDisplay
- Defined in:
- lib/aidp/watch/runner.rb
Overview
Coordinates the watch mode loop: monitors issues, handles plan/build triggers, and keeps running until interrupted.
Constant Summary collapse
- DEFAULT_INTERVAL =
30
Constants included from MessageDisplay
Instance Method Summary collapse
-
#initialize(issues_url:, interval: DEFAULT_INTERVAL, provider_name: nil, gh_available: nil, project_dir: Dir.pwd, once: false, use_workstreams: true, prompt: TTY::Prompt.new, safety_config: {}, force: false, verbose: false) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Methods included from MessageDisplay
#display_message, included, #message_display_prompt
Constructor Details
#initialize(issues_url:, interval: DEFAULT_INTERVAL, provider_name: nil, gh_available: nil, project_dir: Dir.pwd, once: false, use_workstreams: true, prompt: TTY::Prompt.new, safety_config: {}, force: false, verbose: false) ⇒ Runner
Returns a new instance of Runner.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/aidp/watch/runner.rb', line 29 def initialize(issues_url:, interval: DEFAULT_INTERVAL, provider_name: nil, gh_available: nil, project_dir: Dir.pwd, once: false, use_workstreams: true, prompt: TTY::Prompt.new, safety_config: {}, force: false, verbose: false) @prompt = prompt @interval = interval @once = once @project_dir = project_dir @force = force @verbose = verbose @provider_name = provider_name @safety_config = safety_config owner, repo = RepositoryClient.parse_issues_url(issues_url) @repository_client = RepositoryClient.new(owner: owner, repo: repo, gh_available: gh_available) @safety_checker = RepositorySafetyChecker.new( repository_client: @repository_client, config: safety_config ) @state_store = StateStore.new(project_dir: project_dir, repository: "#{owner}/#{repo}") @state_extractor = GitHubStateExtractor.new(repository_client: @repository_client) # Extract label configuration from safety_config (it's actually the full watch config) label_config = safety_config[:labels] || safety_config["labels"] || {} # Extract detection comment configuration (issue #280) # Enabled by default, can be disabled in config @post_detection_comments = if safety_config.key?(:post_detection_comments) safety_config[:post_detection_comments] elsif safety_config.key?("post_detection_comments") safety_config["post_detection_comments"] else true # Enabled by default end @plan_processor = PlanProcessor.new( repository_client: @repository_client, state_store: @state_store, plan_generator: PlanGenerator.new(provider_name: provider_name, verbose: verbose), label_config: label_config ) @build_processor = BuildProcessor.new( repository_client: @repository_client, state_store: @state_store, project_dir: project_dir, use_workstreams: use_workstreams, verbose: verbose, label_config: label_config ) @auto_processor = AutoProcessor.new( repository_client: @repository_client, state_store: @state_store, build_processor: @build_processor, label_config: label_config, verbose: verbose ) # Initialize auto-update coordinator @auto_update_coordinator = Aidp::AutoUpdate.coordinator(project_dir: project_dir) @last_update_check = nil @review_processor = ReviewProcessor.new( repository_client: @repository_client, state_store: @state_store, provider_name: provider_name, project_dir: project_dir, label_config: label_config, verbose: verbose ) @ci_fix_processor = CiFixProcessor.new( repository_client: @repository_client, state_store: @state_store, provider_name: provider_name, project_dir: project_dir, label_config: label_config, verbose: verbose ) @auto_pr_processor = AutoPrProcessor.new( repository_client: @repository_client, state_store: @state_store, review_processor: @review_processor, ci_fix_processor: @ci_fix_processor, label_config: label_config, verbose: verbose ) @change_request_processor = ChangeRequestProcessor.new( repository_client: @repository_client, state_store: @state_store, provider_name: provider_name, project_dir: project_dir, label_config: label_config, change_request_config: safety_config[:pr_change_requests] || safety_config["pr_change_requests"] || {}, safety_config: safety_config[:safety] || safety_config["safety"] || {}, verbose: verbose ) end |
Instance Method Details
#start ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/aidp/watch/runner.rb', line 122 def start # Check for and restore from checkpoint (after auto-update) restore_from_checkpoint_if_exists # Validate safety requirements before starting @safety_checker.validate_watch_mode_safety!(force: @force) Aidp.log_info( "watch_runner", "watch_mode_started", repo: @repository_client.full_repo, interval: @interval, once: @once, use_workstreams: @use_workstreams, verbose: @verbose ) ("š Watch mode enabled for #{@repository_client.full_repo}", type: :highlight) ("Polling every #{@interval} seconds. Press Ctrl+C to stop.", type: :muted) loop do Aidp.log_debug("watch_runner", "poll_cycle.begin", repo: @repository_client.full_repo, interval: @interval) process_cycle Aidp.log_debug("watch_runner", "poll_cycle.complete", once: @once, next_poll_in: @once ? nil : @interval) break if @once Aidp.log_debug("watch_runner", "poll_cycle.sleep", seconds: @interval) sleep @interval end rescue Interrupt ("\nā¹ļø Watch mode interrupted by user", type: :warning) rescue RepositorySafetyChecker::UnsafeRepositoryError => e ("\n#{e.message}", type: :error) raise end |