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
MessageDisplay::COLOR_MAP, MessageDisplay::CRITICAL_TYPES
Instance Attribute Summary collapse
-
#last_update_check ⇒ Object
writeonly
Sets the attribute last_update_check.
-
#post_detection_comments ⇒ Object
readonly
Expose for testability.
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, quiet: false) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Methods included from MessageDisplay
#display_message, included, #message_display_prompt, #quiet_mode?
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, quiet: false) ⇒ Runner
Returns a new instance of Runner.
24 25 26 27 28 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 121 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 |
# File 'lib/aidp/watch/runner.rb', line 24 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, quiet: false) @prompt = prompt @interval = interval @once = once @project_dir = project_dir @force = force @verbose = verbose @quiet = quiet @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 ) @feedback_collector = FeedbackCollector.new( repository_client: @repository_client, state_store: @state_store, project_dir: project_dir ) # Initialize worktree cleanup job (issue #367) cleanup_config = Aidp::Config.worktree_cleanup_config(project_dir) @worktree_cleanup_job = WorktreeCleanupJob.new( project_dir: project_dir, config: cleanup_config ) # Initialize worktree reconciler for dirty worktree handling reconciler_config = safety_config[:worktree_reconciliation] || safety_config["worktree_reconciliation"] || {} @worktree_reconciler = WorktreeReconciler.new( project_dir: project_dir, repository_client: @repository_client, build_processor: @build_processor, state_store: @state_store, config: reconciler_config ) @last_reconcile_at = nil # Initialize round-robin scheduler (issue #434) @round_robin_scheduler = RoundRobinScheduler.new( state_store: @state_store ) @needs_input_label = label_config[:needs_input] || label_config["needs_input"] || "aidp-needs-input" end |
Instance Attribute Details
#last_update_check=(value) ⇒ Object (writeonly)
Sets the attribute last_update_check
22 23 24 |
# File 'lib/aidp/watch/runner.rb', line 22 def last_update_check=(value) @last_update_check = value end |
#post_detection_comments ⇒ Object (readonly)
Expose for testability
21 22 23 |
# File 'lib/aidp/watch/runner.rb', line 21 def post_detection_comments @post_detection_comments end |
Instance Method Details
#start ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/aidp/watch/runner.rb', line 148 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.}", type: :error) raise end |