Module: Aidp::Execute::AgentSignalParser

Defined in:
lib/aidp/execute/agent_signal_parser.rb

Class Method Summary collapse

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



39
40
41
42
43
44
45
# File 'lib/aidp/execute/agent_signal_parser.rb', line 39

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, tags|
    tasks << {
      description: description.strip,
      priority: (priority || "medium").downcase.to_sym,
      tags: tags ? tags.split(",").map(&:strip) : []
    }
  end

  tasks
end