agentic-qe 1.5.1 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/.claude/agents/qe-api-contract-validator.md +118 -0
  2. package/.claude/agents/qe-chaos-engineer.md +320 -5
  3. package/.claude/agents/qe-code-complexity.md +360 -0
  4. package/.claude/agents/qe-coverage-analyzer.md +112 -0
  5. package/.claude/agents/qe-deployment-readiness.md +322 -6
  6. package/.claude/agents/qe-flaky-test-hunter.md +115 -0
  7. package/.claude/agents/qe-fleet-commander.md +319 -6
  8. package/.claude/agents/qe-performance-tester.md +234 -0
  9. package/.claude/agents/qe-production-intelligence.md +114 -0
  10. package/.claude/agents/qe-quality-analyzer.md +126 -0
  11. package/.claude/agents/qe-quality-gate.md +119 -0
  12. package/.claude/agents/qe-regression-risk-analyzer.md +114 -0
  13. package/.claude/agents/qe-requirements-validator.md +114 -0
  14. package/.claude/agents/qe-security-scanner.md +118 -0
  15. package/.claude/agents/qe-test-data-architect.md +234 -0
  16. package/.claude/agents/qe-test-executor.md +115 -0
  17. package/.claude/agents/qe-test-generator.md +114 -0
  18. package/.claude/agents/qe-visual-tester.md +305 -6
  19. package/.claude/agents/subagents/qe-code-reviewer.md +0 -4
  20. package/.claude/agents/subagents/qe-data-generator.md +0 -16
  21. package/.claude/agents/subagents/qe-integration-tester.md +0 -17
  22. package/.claude/agents/subagents/qe-performance-validator.md +0 -16
  23. package/.claude/agents/subagents/qe-security-auditor.md +0 -16
  24. package/.claude/agents/subagents/qe-test-implementer.md +0 -17
  25. package/.claude/agents/subagents/qe-test-refactorer.md +0 -17
  26. package/.claude/agents/subagents/qe-test-writer.md +0 -19
  27. package/.claude/skills/brutal-honesty-review/README.md +218 -0
  28. package/.claude/skills/brutal-honesty-review/SKILL.md +725 -0
  29. package/.claude/skills/brutal-honesty-review/resources/assessment-rubrics.md +295 -0
  30. package/.claude/skills/brutal-honesty-review/resources/review-template.md +102 -0
  31. package/.claude/skills/brutal-honesty-review/scripts/assess-code.sh +179 -0
  32. package/.claude/skills/brutal-honesty-review/scripts/assess-tests.sh +223 -0
  33. package/.claude/skills/cicd-pipeline-qe-orchestrator/README.md +301 -0
  34. package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +510 -0
  35. package/.claude/skills/cicd-pipeline-qe-orchestrator/resources/workflows/microservice-pipeline.md +239 -0
  36. package/.claude/skills/cicd-pipeline-qe-orchestrator/resources/workflows/mobile-pipeline.md +375 -0
  37. package/.claude/skills/cicd-pipeline-qe-orchestrator/resources/workflows/monolith-pipeline.md +268 -0
  38. package/.claude/skills/six-thinking-hats/README.md +190 -0
  39. package/.claude/skills/six-thinking-hats/SKILL.md +1215 -0
  40. package/.claude/skills/six-thinking-hats/resources/examples/api-testing-example.md +345 -0
  41. package/.claude/skills/six-thinking-hats/resources/templates/solo-session-template.md +167 -0
  42. package/.claude/skills/six-thinking-hats/resources/templates/team-session-template.md +336 -0
  43. package/CHANGELOG.md +2472 -2129
  44. package/README.md +48 -10
  45. package/dist/adapters/MemoryStoreAdapter.d.ts +38 -0
  46. package/dist/adapters/MemoryStoreAdapter.d.ts.map +1 -1
  47. package/dist/adapters/MemoryStoreAdapter.js +22 -0
  48. package/dist/adapters/MemoryStoreAdapter.js.map +1 -1
  49. package/dist/agents/BaseAgent.d.ts.map +1 -1
  50. package/dist/agents/BaseAgent.js +13 -0
  51. package/dist/agents/BaseAgent.js.map +1 -1
  52. package/dist/cli/commands/init-claude-md-template.d.ts +16 -0
  53. package/dist/cli/commands/init-claude-md-template.d.ts.map +1 -0
  54. package/dist/cli/commands/init-claude-md-template.js +69 -0
  55. package/dist/cli/commands/init-claude-md-template.js.map +1 -0
  56. package/dist/cli/commands/init.d.ts +1 -1
  57. package/dist/cli/commands/init.d.ts.map +1 -1
  58. package/dist/cli/commands/init.js +509 -460
  59. package/dist/cli/commands/init.js.map +1 -1
  60. package/dist/core/memory/AgentDBService.d.ts +33 -28
  61. package/dist/core/memory/AgentDBService.d.ts.map +1 -1
  62. package/dist/core/memory/AgentDBService.js +233 -290
  63. package/dist/core/memory/AgentDBService.js.map +1 -1
  64. package/dist/core/memory/EnhancedAgentDBService.d.ts.map +1 -1
  65. package/dist/core/memory/EnhancedAgentDBService.js +5 -3
  66. package/dist/core/memory/EnhancedAgentDBService.js.map +1 -1
  67. package/dist/core/memory/RealAgentDBAdapter.d.ts +9 -2
  68. package/dist/core/memory/RealAgentDBAdapter.d.ts.map +1 -1
  69. package/dist/core/memory/RealAgentDBAdapter.js +126 -100
  70. package/dist/core/memory/RealAgentDBAdapter.js.map +1 -1
  71. package/dist/core/memory/SwarmMemoryManager.d.ts +58 -0
  72. package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
  73. package/dist/core/memory/SwarmMemoryManager.js +176 -0
  74. package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
  75. package/dist/core/memory/index.d.ts.map +1 -1
  76. package/dist/core/memory/index.js +2 -1
  77. package/dist/core/memory/index.js.map +1 -1
  78. package/dist/learning/LearningEngine.d.ts +14 -27
  79. package/dist/learning/LearningEngine.d.ts.map +1 -1
  80. package/dist/learning/LearningEngine.js +57 -119
  81. package/dist/learning/LearningEngine.js.map +1 -1
  82. package/dist/learning/index.d.ts +0 -1
  83. package/dist/learning/index.d.ts.map +1 -1
  84. package/dist/learning/index.js +0 -1
  85. package/dist/learning/index.js.map +1 -1
  86. package/dist/mcp/handlers/learning/learning-query.d.ts +34 -0
  87. package/dist/mcp/handlers/learning/learning-query.d.ts.map +1 -0
  88. package/dist/mcp/handlers/learning/learning-query.js +156 -0
  89. package/dist/mcp/handlers/learning/learning-query.js.map +1 -0
  90. package/dist/mcp/handlers/learning/learning-store-experience.d.ts +30 -0
  91. package/dist/mcp/handlers/learning/learning-store-experience.d.ts.map +1 -0
  92. package/dist/mcp/handlers/learning/learning-store-experience.js +86 -0
  93. package/dist/mcp/handlers/learning/learning-store-experience.js.map +1 -0
  94. package/dist/mcp/handlers/learning/learning-store-pattern.d.ts +31 -0
  95. package/dist/mcp/handlers/learning/learning-store-pattern.d.ts.map +1 -0
  96. package/dist/mcp/handlers/learning/learning-store-pattern.js +126 -0
  97. package/dist/mcp/handlers/learning/learning-store-pattern.js.map +1 -0
  98. package/dist/mcp/handlers/learning/learning-store-qvalue.d.ts +30 -0
  99. package/dist/mcp/handlers/learning/learning-store-qvalue.d.ts.map +1 -0
  100. package/dist/mcp/handlers/learning/learning-store-qvalue.js +100 -0
  101. package/dist/mcp/handlers/learning/learning-store-qvalue.js.map +1 -0
  102. package/dist/mcp/server.d.ts +11 -0
  103. package/dist/mcp/server.d.ts.map +1 -1
  104. package/dist/mcp/server.js +98 -1
  105. package/dist/mcp/server.js.map +1 -1
  106. package/dist/mcp/services/LearningEventListener.d.ts +123 -0
  107. package/dist/mcp/services/LearningEventListener.d.ts.map +1 -0
  108. package/dist/mcp/services/LearningEventListener.js +322 -0
  109. package/dist/mcp/services/LearningEventListener.js.map +1 -0
  110. package/dist/mcp/tools.d.ts +4 -0
  111. package/dist/mcp/tools.d.ts.map +1 -1
  112. package/dist/mcp/tools.js +179 -0
  113. package/dist/mcp/tools.js.map +1 -1
  114. package/dist/types/memory-interfaces.d.ts +71 -0
  115. package/dist/types/memory-interfaces.d.ts.map +1 -1
  116. package/dist/utils/Calculator.d.ts +35 -0
  117. package/dist/utils/Calculator.d.ts.map +1 -0
  118. package/dist/utils/Calculator.js +50 -0
  119. package/dist/utils/Calculator.js.map +1 -0
  120. package/dist/utils/Logger.d.ts.map +1 -1
  121. package/dist/utils/Logger.js +4 -1
  122. package/dist/utils/Logger.js.map +1 -1
  123. package/package.json +7 -5
  124. package/.claude/agents/qe-api-contract-validator.md.backup +0 -1148
  125. package/.claude/agents/qe-api-contract-validator.md.backup-20251107-134747 +0 -1148
  126. package/.claude/agents/qe-api-contract-validator.md.backup-phase2-20251107-140039 +0 -1123
  127. package/.claude/agents/qe-chaos-engineer.md.backup +0 -808
  128. package/.claude/agents/qe-chaos-engineer.md.backup-20251107-134747 +0 -808
  129. package/.claude/agents/qe-chaos-engineer.md.backup-phase2-20251107-140039 +0 -787
  130. package/.claude/agents/qe-code-complexity.md.backup +0 -291
  131. package/.claude/agents/qe-code-complexity.md.backup-20251107-134747 +0 -291
  132. package/.claude/agents/qe-code-complexity.md.backup-phase2-20251107-140039 +0 -286
  133. package/.claude/agents/qe-coverage-analyzer.md.backup +0 -467
  134. package/.claude/agents/qe-coverage-analyzer.md.backup-20251107-134747 +0 -467
  135. package/.claude/agents/qe-coverage-analyzer.md.backup-phase2-20251107-140039 +0 -438
  136. package/.claude/agents/qe-deployment-readiness.md.backup +0 -1166
  137. package/.claude/agents/qe-deployment-readiness.md.backup-20251107-134747 +0 -1166
  138. package/.claude/agents/qe-deployment-readiness.md.backup-phase2-20251107-140039 +0 -1140
  139. package/.claude/agents/qe-flaky-test-hunter.md.backup +0 -1195
  140. package/.claude/agents/qe-flaky-test-hunter.md.backup-20251107-134747 +0 -1195
  141. package/.claude/agents/qe-flaky-test-hunter.md.backup-phase2-20251107-140039 +0 -1162
  142. package/.claude/agents/qe-fleet-commander.md.backup +0 -718
  143. package/.claude/agents/qe-fleet-commander.md.backup-20251107-134747 +0 -718
  144. package/.claude/agents/qe-fleet-commander.md.backup-phase2-20251107-140039 +0 -697
  145. package/.claude/agents/qe-performance-tester.md.backup +0 -428
  146. package/.claude/agents/qe-performance-tester.md.backup-20251107-134747 +0 -428
  147. package/.claude/agents/qe-performance-tester.md.backup-phase2-20251107-140039 +0 -372
  148. package/.claude/agents/qe-production-intelligence.md.backup +0 -1219
  149. package/.claude/agents/qe-production-intelligence.md.backup-20251107-134747 +0 -1219
  150. package/.claude/agents/qe-production-intelligence.md.backup-phase2-20251107-140039 +0 -1194
  151. package/.claude/agents/qe-quality-analyzer.md.backup +0 -425
  152. package/.claude/agents/qe-quality-analyzer.md.backup-20251107-134747 +0 -425
  153. package/.claude/agents/qe-quality-analyzer.md.backup-phase2-20251107-140039 +0 -394
  154. package/.claude/agents/qe-quality-gate.md.backup +0 -446
  155. package/.claude/agents/qe-quality-gate.md.backup-20251107-134747 +0 -446
  156. package/.claude/agents/qe-quality-gate.md.backup-phase2-20251107-140039 +0 -415
  157. package/.claude/agents/qe-regression-risk-analyzer.md.backup +0 -1009
  158. package/.claude/agents/qe-regression-risk-analyzer.md.backup-20251107-134747 +0 -1009
  159. package/.claude/agents/qe-regression-risk-analyzer.md.backup-phase2-20251107-140039 +0 -984
  160. package/.claude/agents/qe-requirements-validator.md.backup +0 -748
  161. package/.claude/agents/qe-requirements-validator.md.backup-20251107-134747 +0 -748
  162. package/.claude/agents/qe-requirements-validator.md.backup-phase2-20251107-140039 +0 -723
  163. package/.claude/agents/qe-security-scanner.md.backup +0 -634
  164. package/.claude/agents/qe-security-scanner.md.backup-20251107-134747 +0 -634
  165. package/.claude/agents/qe-security-scanner.md.backup-phase2-20251107-140039 +0 -573
  166. package/.claude/agents/qe-test-data-architect.md.backup +0 -1064
  167. package/.claude/agents/qe-test-data-architect.md.backup-20251107-134747 +0 -1064
  168. package/.claude/agents/qe-test-data-architect.md.backup-phase2-20251107-140039 +0 -1040
  169. package/.claude/agents/qe-test-executor.md.backup +0 -389
  170. package/.claude/agents/qe-test-executor.md.backup-20251107-134747 +0 -389
  171. package/.claude/agents/qe-test-executor.md.backup-phase2-20251107-140039 +0 -369
  172. package/.claude/agents/qe-test-generator.md.backup +0 -997
  173. package/.claude/agents/qe-test-generator.md.backup-20251107-134747 +0 -997
  174. package/.claude/agents/qe-visual-tester.md.backup +0 -777
  175. package/.claude/agents/qe-visual-tester.md.backup-20251107-134747 +0 -777
  176. package/.claude/agents/qe-visual-tester.md.backup-phase2-20251107-140039 +0 -756
  177. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +0 -54
  178. package/.claude/commands/analysis/performance-bottlenecks.md +0 -59
  179. package/.claude/commands/flow-nexus/app-store.md +0 -124
  180. package/.claude/commands/flow-nexus/challenges.md +0 -120
  181. package/.claude/commands/flow-nexus/login-registration.md +0 -65
  182. package/.claude/commands/flow-nexus/neural-network.md +0 -134
  183. package/.claude/commands/flow-nexus/payments.md +0 -116
  184. package/.claude/commands/flow-nexus/sandbox.md +0 -83
  185. package/.claude/commands/flow-nexus/swarm.md +0 -87
  186. package/.claude/commands/flow-nexus/user-tools.md +0 -152
  187. package/.claude/commands/flow-nexus/workflow.md +0 -115
  188. package/.claude/commands/memory/usage.md +0 -46
@@ -1,291 +0,0 @@
1
- ---
2
- name: qe-code-complexity
3
- version: 1.0.0
4
- description: Educational code complexity analyzer demonstrating the Agentic QE Fleet architecture
5
- tags: [quality-engineering, complexity-analysis, refactoring, learning-example]
6
- capabilities: [complexity-analysis, refactoring-recommendations, pattern-detection]
7
- type: quality-analyzer
8
- ---
9
-
10
- # QE Code Complexity Analyzer
11
-
12
- ## Overview
13
-
14
- The Code Complexity Analyzer is an **educational agent** that demonstrates the complete Agentic QE Fleet architecture. It analyzes code complexity metrics and provides AI-powered refactoring recommendations.
15
-
16
- **Purpose**: Learning tool to understand how agents work in the AQE fleet.
17
-
18
- ## Capabilities
19
-
20
- ### 1. Complexity Analysis
21
- - **Cyclomatic Complexity**: Measures decision point density
22
- - **Cognitive Complexity**: Accounts for nesting and control flow
23
- - **File Size Analysis**: Identifies overly large files
24
- - **Function Metrics**: Tracks function count and average complexity
25
-
26
- ### 2. Refactoring Recommendations
27
- - AI-powered suggestions based on detected patterns
28
- - Severity-based prioritization (low, medium, high, critical)
29
- - Specific actionable advice (e.g., "Extract Method", "Reduce Nesting")
30
-
31
- ### 3. Quality Scoring
32
- - Holistic quality score (0-100)
33
- - Issue-based deductions
34
- - Helps prioritize refactoring efforts
35
-
36
- ## Key Learning Concepts
37
-
38
- ### BaseAgent Pattern
39
- ```typescript
40
- // All agents extend BaseAgent
41
- export class CodeComplexityAnalyzerAgent extends BaseAgent {
42
- // Define capabilities in constructor
43
- constructor(config: CodeComplexityConfig) {
44
- super({
45
- ...config,
46
- type: QEAgentType.QUALITY_ANALYZER,
47
- capabilities: [/* ... */]
48
- });
49
- }
50
- }
51
- ```
52
-
53
- ### Lifecycle Hooks
54
- ```typescript
55
- // Pre-task: Load context before work
56
- protected async onPreTask(data: { assignment: any }): Promise<void> {
57
- const history = await this.memoryStore.retrieve('aqe/complexity/.../history');
58
- // Use historical data to improve analysis
59
- }
60
-
61
- // Post-task: Store results and coordinate
62
- protected async onPostTask(data: PostTaskData): Promise<void> {
63
- await this.memoryStore.store('aqe/complexity/.../results', data.result);
64
- this.eventBus.emit('complexity:analysis:completed', { ... });
65
- }
66
-
67
- // Error handling: Learn from failures
68
- protected async onTaskError(data: { assignment: any; error: Error }): Promise<void> {
69
- await this.memoryStore.store('aqe/complexity/.../errors/...', { ... });
70
- }
71
- ```
72
-
73
- ### Memory System
74
- ```typescript
75
- // Store results for other agents
76
- await this.memoryStore.store(
77
- 'aqe/complexity/${agentId}/latest-result',
78
- result,
79
- 86400 // 24 hour TTL
80
- );
81
-
82
- // Retrieve for coordination
83
- const previous = await this.memoryStore.retrieve(
84
- 'aqe/complexity/${agentId}/history'
85
- );
86
- ```
87
-
88
- ### Event-Driven Architecture
89
- ```typescript
90
- // Emit events for coordination
91
- this.eventBus.emit('complexity:analysis:completed', {
92
- agentId: this.agentId,
93
- result: analysisResult,
94
- timestamp: new Date()
95
- });
96
-
97
- // Other agents can subscribe
98
- eventBus.on('complexity:analysis:completed', (event) => {
99
- // Test generator could prioritize complex code
100
- // Coverage analyzer could focus on complex functions
101
- });
102
- ```
103
-
104
- ## Usage Examples
105
-
106
- ### From Claude Code CLI
107
-
108
- ```bash
109
- # Analyze a single file
110
- claude "Use qe-code-complexity to analyze src/services/order-processor.ts"
111
-
112
- # Analyze multiple files
113
- claude "Run complexity analysis on all files in src/services/"
114
-
115
- # Get refactoring recommendations
116
- claude "Analyze src/utils/validator.ts and suggest refactorings"
117
- ```
118
-
119
- ### Via TypeScript
120
-
121
- ```typescript
122
- import { CodeComplexityAnalyzerAgent } from './agents/CodeComplexityAnalyzerAgent';
123
-
124
- // Initialize agent
125
- const agent = new CodeComplexityAnalyzerAgent({
126
- type: QEAgentType.QUALITY_ANALYZER,
127
- capabilities: [],
128
- context: { /* ... */ },
129
- memoryStore,
130
- eventBus,
131
- thresholds: {
132
- cyclomaticComplexity: 10,
133
- cognitiveComplexity: 15,
134
- linesOfCode: 300
135
- },
136
- enableRecommendations: true
137
- });
138
-
139
- await agent.initialize();
140
-
141
- // Analyze code
142
- const result = await agent.analyzeComplexity({
143
- files: [{
144
- path: 'complex.ts',
145
- content: sourceCode,
146
- language: 'typescript'
147
- }]
148
- });
149
-
150
- console.log('Quality Score:', result.score);
151
- console.log('Issues:', result.issues);
152
- console.log('Recommendations:', result.recommendations);
153
- ```
154
-
155
- ## Configuration
156
-
157
- ### Thresholds
158
-
159
- Customize complexity thresholds:
160
-
161
- ```typescript
162
- {
163
- thresholds: {
164
- cyclomaticComplexity: 10, // Default: 10
165
- cognitiveComplexity: 15, // Default: 15
166
- linesOfCode: 300 // Default: 300
167
- }
168
- }
169
- ```
170
-
171
- ### Features
172
-
173
- ```typescript
174
- {
175
- enableRecommendations: true, // Default: true
176
- enableLearning: true // Default: false (demo uses false)
177
- }
178
- ```
179
-
180
- ## Integration with Other Agents
181
-
182
- ### Test Generator
183
- The test-generator agent can use complexity analysis to:
184
- - Prioritize complex functions for testing
185
- - Generate more comprehensive tests for high-complexity code
186
- - Focus on edge cases in nested logic
187
-
188
- ```typescript
189
- eventBus.on('complexity:analysis:completed', async (event) => {
190
- if (event.result.issues.some(i => i.severity === 'critical')) {
191
- // Test generator: Create extra tests for critical complexity
192
- await testGeneratorAgent.generateTests({
193
- focusAreas: event.result.issues
194
- .filter(i => i.severity === 'critical')
195
- .map(i => i.file)
196
- });
197
- }
198
- });
199
- ```
200
-
201
- ### Coverage Analyzer
202
- The coverage-analyzer can use complexity data to:
203
- - Ensure high-complexity code has high coverage
204
- - Identify risk areas (high complexity + low coverage)
205
-
206
- ### Quality Gate
207
- The quality-gate can use complexity metrics as criteria:
208
- - Fail builds with critical complexity issues
209
- - Track complexity trends over time
210
- - Prevent complexity regressions
211
-
212
- ## Example Output
213
-
214
- ```
215
- Quality Score: 65/100
216
-
217
- ⚠️ Issues Detected:
218
- 1. [HIGH] cyclomatic
219
- Current: 23, Threshold: 10
220
- Consider breaking down complex logic into smaller functions
221
-
222
- 2. [MEDIUM] cognitive
223
- Current: 18, Threshold: 15
224
- Reduce nesting levels and simplify control flow
225
-
226
- 💡 Recommendations:
227
- 1. Apply Extract Method refactoring to reduce cyclomatic complexity
228
- 2. Use early returns to reduce nesting levels
229
- 3. Extract nested loops into separate methods
230
- ```
231
-
232
- ## Learning Objectives
233
-
234
- By studying this agent, you'll learn:
235
-
236
- 1. ✅ **BaseAgent Pattern**: How to extend and customize agents
237
- 2. ✅ **Lifecycle Hooks**: Pre-task, post-task, and error handling
238
- 3. ✅ **Memory System**: Storing and retrieving agent data
239
- 4. ✅ **Event System**: Coordinating multiple agents
240
- 5. ✅ **Testing Patterns**: Comprehensive test coverage
241
- 6. ✅ **Agent Coordination**: How agents work together
242
-
243
- ## Running the Example
244
-
245
- ```bash
246
- # Run the demo
247
- npx ts-node examples/complexity-analysis/demo.ts
248
-
249
- # Run tests
250
- npm test tests/agents/CodeComplexityAnalyzerAgent.test.ts
251
- ```
252
-
253
- ## Architecture Insights
254
-
255
- ### Memory Namespace
256
- - `aqe/complexity/${agentId}/current-request` - Active analysis request
257
- - `aqe/complexity/${agentId}/latest-result` - Most recent result
258
- - `aqe/complexity/${agentId}/history` - Historical analyses (last 100)
259
- - `aqe/complexity/${agentId}/errors/*` - Error tracking
260
-
261
- ### Events Emitted
262
- - `complexity:analysis:completed` - When analysis finishes successfully
263
- - `complexity:analysis:stored` - When results are persisted
264
-
265
- ### Capabilities Provided
266
- - `complexity-analysis` - Core analysis functionality
267
- - `refactoring-recommendations` - AI-powered suggestions
268
- - `pattern-detection` - Complex code pattern recognition
269
-
270
- ## Next Steps
271
-
272
- After understanding this agent, explore:
273
- - **TestGeneratorAgent**: See how it generates tests
274
- - **CoverageAnalyzerAgent**: Learn about O(log n) gap detection
275
- - **FleetManager**: Understand multi-agent coordination
276
- - **LearningEngine**: Discover how agents improve over time
277
-
278
- ## Resources
279
-
280
- - **Source Code**: `src/agents/CodeComplexityAnalyzerAgent.ts`
281
- - **Tests**: `tests/agents/CodeComplexityAnalyzerAgent.test.ts`
282
- - **Demo**: `examples/complexity-analysis/demo.ts`
283
- - **BaseAgent**: `src/agents/BaseAgent.ts`
284
-
285
- ---
286
-
287
- **Educational Agent**: This agent is designed for learning. For production complexity analysis, consider:
288
- - ESLint with complexity rules
289
- - SonarQube
290
- - CodeClimate
291
- - Commercial static analysis tools
@@ -1,291 +0,0 @@
1
- ---
2
- name: qe-code-complexity
3
- version: 1.0.0
4
- description: Educational code complexity analyzer demonstrating the Agentic QE Fleet architecture
5
- tags: [quality-engineering, complexity-analysis, refactoring, learning-example]
6
- capabilities: [complexity-analysis, refactoring-recommendations, pattern-detection]
7
- type: quality-analyzer
8
- ---
9
-
10
- # QE Code Complexity Analyzer
11
-
12
- ## Overview
13
-
14
- The Code Complexity Analyzer is an **educational agent** that demonstrates the complete Agentic QE Fleet architecture. It analyzes code complexity metrics and provides AI-powered refactoring recommendations.
15
-
16
- **Purpose**: Learning tool to understand how agents work in the AQE fleet.
17
-
18
- ## Capabilities
19
-
20
- ### 1. Complexity Analysis
21
- - **Cyclomatic Complexity**: Measures decision point density
22
- - **Cognitive Complexity**: Accounts for nesting and control flow
23
- - **File Size Analysis**: Identifies overly large files
24
- - **Function Metrics**: Tracks function count and average complexity
25
-
26
- ### 2. Refactoring Recommendations
27
- - AI-powered suggestions based on detected patterns
28
- - Severity-based prioritization (low, medium, high, critical)
29
- - Specific actionable advice (e.g., "Extract Method", "Reduce Nesting")
30
-
31
- ### 3. Quality Scoring
32
- - Holistic quality score (0-100)
33
- - Issue-based deductions
34
- - Helps prioritize refactoring efforts
35
-
36
- ## Key Learning Concepts
37
-
38
- ### BaseAgent Pattern
39
- ```typescript
40
- // All agents extend BaseAgent
41
- export class CodeComplexityAnalyzerAgent extends BaseAgent {
42
- // Define capabilities in constructor
43
- constructor(config: CodeComplexityConfig) {
44
- super({
45
- ...config,
46
- type: QEAgentType.QUALITY_ANALYZER,
47
- capabilities: [/* ... */]
48
- });
49
- }
50
- }
51
- ```
52
-
53
- ### Lifecycle Hooks
54
- ```typescript
55
- // Pre-task: Load context before work
56
- protected async onPreTask(data: { assignment: any }): Promise<void> {
57
- const history = await this.memoryStore.retrieve('aqe/complexity/.../history');
58
- // Use historical data to improve analysis
59
- }
60
-
61
- // Post-task: Store results and coordinate
62
- protected async onPostTask(data: PostTaskData): Promise<void> {
63
- await this.memoryStore.store('aqe/complexity/.../results', data.result);
64
- this.eventBus.emit('complexity:analysis:completed', { ... });
65
- }
66
-
67
- // Error handling: Learn from failures
68
- protected async onTaskError(data: { assignment: any; error: Error }): Promise<void> {
69
- await this.memoryStore.store('aqe/complexity/.../errors/...', { ... });
70
- }
71
- ```
72
-
73
- ### Memory System
74
- ```typescript
75
- // Store results for other agents
76
- await this.memoryStore.store(
77
- 'aqe/complexity/${agentId}/latest-result',
78
- result,
79
- 86400 // 24 hour TTL
80
- );
81
-
82
- // Retrieve for coordination
83
- const previous = await this.memoryStore.retrieve(
84
- 'aqe/complexity/${agentId}/history'
85
- );
86
- ```
87
-
88
- ### Event-Driven Architecture
89
- ```typescript
90
- // Emit events for coordination
91
- this.eventBus.emit('complexity:analysis:completed', {
92
- agentId: this.agentId,
93
- result: analysisResult,
94
- timestamp: new Date()
95
- });
96
-
97
- // Other agents can subscribe
98
- eventBus.on('complexity:analysis:completed', (event) => {
99
- // Test generator could prioritize complex code
100
- // Coverage analyzer could focus on complex functions
101
- });
102
- ```
103
-
104
- ## Usage Examples
105
-
106
- ### From Claude Code CLI
107
-
108
- ```bash
109
- # Analyze a single file
110
- claude "Use qe-code-complexity to analyze src/services/order-processor.ts"
111
-
112
- # Analyze multiple files
113
- claude "Run complexity analysis on all files in src/services/"
114
-
115
- # Get refactoring recommendations
116
- claude "Analyze src/utils/validator.ts and suggest refactorings"
117
- ```
118
-
119
- ### Via TypeScript
120
-
121
- ```typescript
122
- import { CodeComplexityAnalyzerAgent } from './agents/CodeComplexityAnalyzerAgent';
123
-
124
- // Initialize agent
125
- const agent = new CodeComplexityAnalyzerAgent({
126
- type: QEAgentType.QUALITY_ANALYZER,
127
- capabilities: [],
128
- context: { /* ... */ },
129
- memoryStore,
130
- eventBus,
131
- thresholds: {
132
- cyclomaticComplexity: 10,
133
- cognitiveComplexity: 15,
134
- linesOfCode: 300
135
- },
136
- enableRecommendations: true
137
- });
138
-
139
- await agent.initialize();
140
-
141
- // Analyze code
142
- const result = await agent.analyzeComplexity({
143
- files: [{
144
- path: 'complex.ts',
145
- content: sourceCode,
146
- language: 'typescript'
147
- }]
148
- });
149
-
150
- console.log('Quality Score:', result.score);
151
- console.log('Issues:', result.issues);
152
- console.log('Recommendations:', result.recommendations);
153
- ```
154
-
155
- ## Configuration
156
-
157
- ### Thresholds
158
-
159
- Customize complexity thresholds:
160
-
161
- ```typescript
162
- {
163
- thresholds: {
164
- cyclomaticComplexity: 10, // Default: 10
165
- cognitiveComplexity: 15, // Default: 15
166
- linesOfCode: 300 // Default: 300
167
- }
168
- }
169
- ```
170
-
171
- ### Features
172
-
173
- ```typescript
174
- {
175
- enableRecommendations: true, // Default: true
176
- enableLearning: true // Default: false (demo uses false)
177
- }
178
- ```
179
-
180
- ## Integration with Other Agents
181
-
182
- ### Test Generator
183
- The test-generator agent can use complexity analysis to:
184
- - Prioritize complex functions for testing
185
- - Generate more comprehensive tests for high-complexity code
186
- - Focus on edge cases in nested logic
187
-
188
- ```typescript
189
- eventBus.on('complexity:analysis:completed', async (event) => {
190
- if (event.result.issues.some(i => i.severity === 'critical')) {
191
- // Test generator: Create extra tests for critical complexity
192
- await testGeneratorAgent.generateTests({
193
- focusAreas: event.result.issues
194
- .filter(i => i.severity === 'critical')
195
- .map(i => i.file)
196
- });
197
- }
198
- });
199
- ```
200
-
201
- ### Coverage Analyzer
202
- The coverage-analyzer can use complexity data to:
203
- - Ensure high-complexity code has high coverage
204
- - Identify risk areas (high complexity + low coverage)
205
-
206
- ### Quality Gate
207
- The quality-gate can use complexity metrics as criteria:
208
- - Fail builds with critical complexity issues
209
- - Track complexity trends over time
210
- - Prevent complexity regressions
211
-
212
- ## Example Output
213
-
214
- ```
215
- Quality Score: 65/100
216
-
217
- ⚠️ Issues Detected:
218
- 1. [HIGH] cyclomatic
219
- Current: 23, Threshold: 10
220
- Consider breaking down complex logic into smaller functions
221
-
222
- 2. [MEDIUM] cognitive
223
- Current: 18, Threshold: 15
224
- Reduce nesting levels and simplify control flow
225
-
226
- 💡 Recommendations:
227
- 1. Apply Extract Method refactoring to reduce cyclomatic complexity
228
- 2. Use early returns to reduce nesting levels
229
- 3. Extract nested loops into separate methods
230
- ```
231
-
232
- ## Learning Objectives
233
-
234
- By studying this agent, you'll learn:
235
-
236
- 1. ✅ **BaseAgent Pattern**: How to extend and customize agents
237
- 2. ✅ **Lifecycle Hooks**: Pre-task, post-task, and error handling
238
- 3. ✅ **Memory System**: Storing and retrieving agent data
239
- 4. ✅ **Event System**: Coordinating multiple agents
240
- 5. ✅ **Testing Patterns**: Comprehensive test coverage
241
- 6. ✅ **Agent Coordination**: How agents work together
242
-
243
- ## Running the Example
244
-
245
- ```bash
246
- # Run the demo
247
- npx ts-node examples/complexity-analysis/demo.ts
248
-
249
- # Run tests
250
- npm test tests/agents/CodeComplexityAnalyzerAgent.test.ts
251
- ```
252
-
253
- ## Architecture Insights
254
-
255
- ### Memory Namespace
256
- - `aqe/complexity/${agentId}/current-request` - Active analysis request
257
- - `aqe/complexity/${agentId}/latest-result` - Most recent result
258
- - `aqe/complexity/${agentId}/history` - Historical analyses (last 100)
259
- - `aqe/complexity/${agentId}/errors/*` - Error tracking
260
-
261
- ### Events Emitted
262
- - `complexity:analysis:completed` - When analysis finishes successfully
263
- - `complexity:analysis:stored` - When results are persisted
264
-
265
- ### Capabilities Provided
266
- - `complexity-analysis` - Core analysis functionality
267
- - `refactoring-recommendations` - AI-powered suggestions
268
- - `pattern-detection` - Complex code pattern recognition
269
-
270
- ## Next Steps
271
-
272
- After understanding this agent, explore:
273
- - **TestGeneratorAgent**: See how it generates tests
274
- - **CoverageAnalyzerAgent**: Learn about O(log n) gap detection
275
- - **FleetManager**: Understand multi-agent coordination
276
- - **LearningEngine**: Discover how agents improve over time
277
-
278
- ## Resources
279
-
280
- - **Source Code**: `src/agents/CodeComplexityAnalyzerAgent.ts`
281
- - **Tests**: `tests/agents/CodeComplexityAnalyzerAgent.test.ts`
282
- - **Demo**: `examples/complexity-analysis/demo.ts`
283
- - **BaseAgent**: `src/agents/BaseAgent.ts`
284
-
285
- ---
286
-
287
- **Educational Agent**: This agent is designed for learning. For production complexity analysis, consider:
288
- - ESLint with complexity rules
289
- - SonarQube
290
- - CodeClimate
291
- - Commercial static analysis tools