Class: Aidp::Planning::Analyzers::FeedbackAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/planning/analyzers/feedback_analyzer.rb

Overview

Analyzes user feedback using AI to extract insights and recommendations Uses Zero Framework Cognition (ZFC) - NO regex, heuristics, or keyword matching All semantic analysis delegated to AI Decision Engine

Instance Method Summary collapse

Constructor Details

#initialize(ai_decision_engine:, config: nil) ⇒ FeedbackAnalyzer

Returns a new instance of FeedbackAnalyzer.



12
13
14
15
# File 'lib/aidp/planning/analyzers/feedback_analyzer.rb', line 12

def initialize(ai_decision_engine:, config: nil)
  @ai_decision_engine = ai_decision_engine
  @config = config || Aidp::Config.agile_config
end

Instance Method Details

#analyze(feedback_data) ⇒ Hash

Analyze feedback data and generate insights

Parameters:

  • feedback_data (Hash)

    Parsed feedback data from FeedbackDataParser

Returns:

  • (Hash)

    Analysis results with findings and recommendations



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/aidp/planning/analyzers/feedback_analyzer.rb', line 20

def analyze(feedback_data)
  Aidp.log_debug("feedback_analyzer", "analyze",
    response_count: feedback_data[:response_count],
    format: feedback_data[:format])

  # Use AI to perform semantic analysis
  analysis = analyze_with_ai(feedback_data)

  {
    summary: analysis[:summary],
    findings: analysis[:findings],
    trends: analysis[:trends],
    insights: analysis[:insights],
    sentiment_breakdown: analysis[:sentiment_breakdown],
    feature_feedback: analysis[:feature_feedback],
    recommendations: analysis[:recommendations],
    priority_issues: analysis[:priority_issues],
    positive_highlights: analysis[:positive_highlights],
    metadata: {
      generated_at: Time.now.iso8601,
      responses_analyzed: feedback_data[:response_count],
      source_file: feedback_data[:source_file],
      source_format: feedback_data[:format]
    }
  }
end

#format_as_markdown(analysis) ⇒ String

Format feedback analysis as markdown

Parameters:

  • analysis (Hash)

    Feedback analysis structure

Returns:

  • (String)

    Markdown formatted analysis



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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/aidp/planning/analyzers/feedback_analyzer.rb', line 50

def format_as_markdown(analysis)
  Aidp.log_debug("feedback_analyzer", "format_as_markdown")

  output = ["# User Feedback Analysis", ""]
  output << "**Generated:** #{analysis[:metadata][:generated_at]}"
  output << "**Responses Analyzed:** #{analysis[:metadata][:responses_analyzed]}"
  output << "**Source:** #{analysis[:metadata][:source_file]}"
  output << ""

  output << "## Executive Summary"
  output << ""
  output << analysis[:summary]
  output << ""

  output << "## Sentiment Breakdown"
  output << ""
  output << "| Sentiment | Count | Percentage |"
  output << "|-----------|-------|------------|"
  analysis[:sentiment_breakdown].each do |sentiment|
    output << "| #{sentiment[:type]} | #{sentiment[:count]} | #{sentiment[:percentage]}% |"
  end
  output << ""

  output << "## Key Findings"
  output << ""
  analysis[:findings].each_with_index do |finding, idx|
    output << "### #{idx + 1}. #{finding[:title]}"
    output << ""
    output << finding[:description]
    output << ""
    output << "**Evidence:**"
    finding[:evidence].each do |evidence|
      output << "- #{evidence}"
    end
    output << ""
    output << "**Impact:** #{finding[:impact]}"
    output << ""
  end

  output << "## Trends and Patterns"
  output << ""
  analysis[:trends].each_with_index do |trend, idx|
    output << "### #{idx + 1}. #{trend[:title]}"
    output << ""
    output << trend[:description]
    output << ""
    output << "**Frequency:** #{trend[:frequency]}"
    output << ""
    output << "**Implication:** #{trend[:implication]}"
    output << ""
  end

  output << "## Insights"
  output << ""
  analysis[:insights].each do |insight|
    output << "- **#{insight[:category]}:** #{insight[:description]}"
    output << ""
  end

  output << "## Feature-Specific Feedback"
  output << ""
  analysis[:feature_feedback].each do |feedback|
    output << "### #{feedback[:feature_name]}"
    output << ""
    output << "**Overall Sentiment:** #{feedback[:sentiment]}"
    output << ""
    output << "**Positive Feedback:**"
    feedback[:positive].each do |pos|
      output << "- #{pos}"
    end
    output << ""
    output << "**Negative Feedback:**"
    feedback[:negative].each do |neg|
      output << "- #{neg}"
    end
    output << ""
    output << "**Suggested Improvements:**"
    feedback[:improvements].each do |imp|
      output << "- #{imp}"
    end
    output << ""
  end

  output << "## Priority Issues"
  output << ""
  output << "Issues requiring immediate attention:"
  output << ""
  analysis[:priority_issues].each_with_index do |issue, idx|
    output << "#{idx + 1}. **#{issue[:title]}** (Priority: #{issue[:priority]})"
    output << "   - Impact: #{issue[:impact]}"
    output << "   - Affected Users: #{issue[:affected_users]}"
    output << "   - Recommended Action: #{issue[:action]}"
    output << ""
  end

  output << "## Positive Highlights"
  output << ""
  output << "What users loved:"
  output << ""
  analysis[:positive_highlights].each do |highlight|
    output << "- #{highlight}"
  end
  output << ""

  output << "## Recommendations"
  output << ""
  analysis[:recommendations].each_with_index do |rec, idx|
    output << "### #{idx + 1}. #{rec[:title]}"
    output << ""
    output << rec[:description]
    output << ""
    output << "**Rationale:** #{rec[:rationale]}"
    output << ""
    output << "**Effort:** #{rec[:effort]}"
    output << ""
    output << "**Expected Impact:** #{rec[:impact]}"
    output << ""
  end

  output.join("\n")
end