Class: Aidp::Workflows::Selector

Inherits:
Object
  • Object
show all
Includes:
MessageDisplay
Defined in:
lib/aidp/workflows/selector.rb

Overview

Enhanced workflow selector with support for custom workflows Handles selection for analyze, execute, and hybrid modes

Constant Summary

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP

Instance Method Summary collapse

Methods included from MessageDisplay

#display_message, included, #message_display_prompt

Constructor Details

#initialize(prompt: TTY::Prompt.new) ⇒ Selector



14
15
16
# File 'lib/aidp/workflows/selector.rb', line 14

def initialize(prompt: TTY::Prompt.new)
  @prompt = prompt
end

Instance Method Details

#select_custom_steps(mode) ⇒ Object

Select custom steps for hybrid or custom workflows



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/aidp/workflows/selector.rb', line 69

def select_custom_steps(mode)
  display_message("\n⚙️ Custom Step Selection", type: :highlight)
  display_message("")

  if mode == :hybrid
    select_hybrid_steps
  elsif mode == :analyze
    select_steps_from_mode(:analyze)
  elsif mode == :execute
    select_steps_from_mode(:execute)
  end
end

#select_modeObject

Select mode (analyze, execute, or hybrid)



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aidp/workflows/selector.rb', line 19

def select_mode
  display_message("\n🚀 Welcome to AI Dev Pipeline!", type: :highlight)
  display_message("Choose your mode:\n", type: :highlight)

  choices = {
    "🔬 Analyze Mode" => :analyze,
    "🏗️  Execute Mode" => :execute,
    "🔀 Hybrid Mode" => :hybrid
  }

  @prompt.select("What would you like to do?", choices, per_page: 10)
end

#select_workflow(mode) ⇒ Object

Select workflow for the given mode



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
# File 'lib/aidp/workflows/selector.rb', line 33

def select_workflow(mode)
  workflows = Definitions.workflows_for_mode(mode)

  display_message("\n#{mode_header(mode)}", type: :highlight)
  display_message("Choose a workflow:\n")

  # Build choices with icons and descriptions
  choices = workflows.map do |key, workflow|
    {
      name: "#{workflow[:icon]} #{workflow[:name]} - #{workflow[:description]}",
      value: key
    }
  end

  selected = @prompt.select(
    "Select workflow:",
    choices,
    per_page: 15,
    help: "(↑/↓ to navigate, Enter to select)"
  )

  workflow = workflows[selected]

  # Show workflow details
  display_workflow_details(workflow)

  # Handle custom workflows
  if workflow[:steps] == :custom
    steps = select_custom_steps(mode)
    {workflow_key: selected, steps: steps, workflow: workflow}
  else
    {workflow_key: selected, steps: workflow[:steps], workflow: workflow}
  end
end