Class: Aidp::Planning::Generators::WBSGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/planning/generators/wbs_generator.rb

Overview

Generates Work Breakdown Structure (WBS) with phase-based decomposition Breaks down projects into phases, tasks, and subtasks with dependencies

Constant Summary collapse

DEFAULT_PHASES =
[
  "Requirements",
  "Design",
  "Implementation",
  "Testing",
  "Deployment"
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(phases: DEFAULT_PHASES, config: nil) ⇒ WBSGenerator

Returns a new instance of WBSGenerator.



19
20
21
22
# File 'lib/aidp/planning/generators/wbs_generator.rb', line 19

def initialize(phases: DEFAULT_PHASES, config: nil)
  @phases = phases
  @config = config || Aidp::Config.waterfall_config
end

Instance Method Details

#format_as_markdown(wbs) ⇒ String

Format WBS as markdown

Parameters:

  • wbs (Hash)

    WBS structure

Returns:

  • (String)

    Markdown formatted WBS



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
# File 'lib/aidp/planning/generators/wbs_generator.rb', line 49

def format_as_markdown(wbs)
  Aidp.log_debug("wbs_generator", "format_as_markdown")

  output = ["# Work Breakdown Structure", ""]
  output << "Generated: #{wbs[:metadata][:generated_at]}"
  output << "Total Phases: #{wbs[:metadata][:phase_count]}"
  output << "Total Tasks: #{wbs[:metadata][:total_tasks]}"
  output << ""

  wbs[:phases].each do |phase|
    output << "## Phase: #{phase[:name]}"
    output << ""
    output << phase[:description] if phase[:description]
    output << ""

    phase[:tasks].each_with_index do |task, idx|
      output << "### #{idx + 1}. #{task[:name]}"
      output << ""
      output << task[:description] if task[:description]
      output << ""

      if task[:subtasks]&.any?
        task[:subtasks].each do |subtask|
          output << "  - #{subtask[:name]}"
        end
        output << ""
      end

      if task[:dependencies]&.any?
        output << "**Dependencies:** #{task[:dependencies].join(", ")}"
        output << ""
      end

      if task[:effort]
        output << "**Effort:** #{task[:effort]}"
        output << ""
      end
    end
  end

  output.join("\n")
end

#generate(prd:, tech_design: nil) ⇒ Hash

Generate WBS from PRD and technical design

Parameters:

  • prd (Hash)

    Parsed PRD document

  • tech_design (Hash) (defaults to: nil)

    Parsed technical design document

Returns:

  • (Hash)

    WBS structure with phases and tasks



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/aidp/planning/generators/wbs_generator.rb', line 28

def generate(prd:, tech_design: nil)
  Aidp.log_debug("wbs_generator", "generate", has_prd: !prd.nil?, has_design: !tech_design.nil?)

  wbs = {
    phases: build_phases(prd, tech_design),
    metadata: {
      generated_at: Time.now.iso8601,
      phase_count: @phases.size,
      total_tasks: 0
    }
  }

  wbs[:metadata][:total_tasks] = count_total_tasks(wbs[:phases])

  Aidp.log_debug("wbs_generator", "generated", total_tasks: wbs[:metadata][:total_tasks])
  wbs
end