Module: Aidp::Execute::AgentSignalParser
- Defined in:
- lib/aidp/execute/agent_signal_parser.rb
Class Method Summary collapse
- .extract_next_unit(output) ⇒ Object
- .normalize_token(raw) ⇒ Object
-
.parse_task_filing(output) ⇒ Object
Parse task filing signals from agent output Returns array of task hashes with description, priority, and tags.
-
.parse_task_status_updates(output) ⇒ Object
Parse task status update signals from agent output Returns array of status update hashes with task_id, status, and optional reason Pattern: Update task: task_id_here status: done|in_progress|pending|abandoned [reason: “reason”].
Class Method Details
.extract_next_unit(output) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/aidp/execute/agent_signal_parser.rb', line 6 def self.extract_next_unit(output) return nil unless output output.to_s.each_line do |line| token = token_from_line(line) next unless token return normalize_token(token) end nil end |
.normalize_token(raw) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/aidp/execute/agent_signal_parser.rb', line 61 def self.normalize_token(raw) return nil if raw.nil? || raw.empty? token = raw.downcase.strip token.gsub!(/\s+/, "_") token.to_sym end |
.parse_task_filing(output) ⇒ Object
Parse task filing signals from agent output Returns array of task hashes with description, priority, and tags
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aidp/execute/agent_signal_parser.rb', line 21 def self.parse_task_filing(output) return [] unless output tasks = [] # Pattern: File task: "description" [priority: high|medium|low] [tags: tag1,tag2] pattern = /File\s+task:\s*"([^"]+)"(?:\s+priority:\s*(high|medium|low))?(?:\s+tags:\s*([^\s]+))?/i output.to_s.scan(pattern).each do |description, priority, | tasks << { description: description.strip, priority: (priority || "medium").downcase.to_sym, tags: ? .split(",").map(&:strip) : [] } end tasks end |
.parse_task_status_updates(output) ⇒ Object
Parse task status update signals from agent output Returns array of status update hashes with task_id, status, and optional reason Pattern: Update task: task_id_here status: done|in_progress|pending|abandoned [reason: “reason”]
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/aidp/execute/agent_signal_parser.rb', line 42 def self.parse_task_status_updates(output) return [] unless output updates = [] # Pattern matches: Update task: task_123_abc status: done # Or: Update task: task_123_abc status: abandoned reason: "No longer needed" pattern = /Update\s+task:\s*(\S+)\s+status:\s*(done|in_progress|pending|abandoned)(?:\s+reason:\s*"([^"]+)")?/i output.to_s.scan(pattern).each do |task_id, status, reason| updates << { task_id: task_id.strip, status: status.downcase.to_sym, reason: reason&.strip } end updates end |