agentic-qe 1.3.4 → 1.3.6
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.
- package/.claude/agents/qe-code-complexity.md +291 -0
- package/.claude/settings.json +2 -2
- package/CHANGELOG.md +289 -0
- package/README.md +56 -26
- package/dist/agents/BaseAgent.d.ts +6 -2
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +62 -51
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts +139 -0
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts.map +1 -0
- package/dist/agents/CodeComplexityAnalyzerAgent.js +403 -0
- package/dist/agents/CodeComplexityAnalyzerAgent.js.map +1 -0
- package/dist/agents/FleetCommanderAgent.js +2 -2
- package/dist/agents/FleetCommanderAgent.js.map +1 -1
- package/dist/agents/QualityGateAgent.d.ts +5 -5
- package/dist/agents/QualityGateAgent.d.ts.map +1 -1
- package/dist/agents/QualityGateAgent.js +33 -19
- package/dist/agents/QualityGateAgent.js.map +1 -1
- package/dist/agents/TestDataArchitectAgent.d.ts +9 -0
- package/dist/agents/TestDataArchitectAgent.d.ts.map +1 -1
- package/dist/agents/TestDataArchitectAgent.js +96 -2
- package/dist/agents/TestDataArchitectAgent.js.map +1 -1
- package/dist/agents/TestGeneratorAgent.d.ts +23 -1
- package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
- package/dist/agents/TestGeneratorAgent.js +279 -54
- package/dist/agents/TestGeneratorAgent.js.map +1 -1
- package/dist/agents/coordination/AgentCoordinator.d.ts +98 -0
- package/dist/agents/coordination/AgentCoordinator.d.ts.map +1 -0
- package/dist/agents/coordination/AgentCoordinator.js +196 -0
- package/dist/agents/coordination/AgentCoordinator.js.map +1 -0
- package/dist/agents/lifecycle/AgentLifecycleManager.d.ts +107 -0
- package/dist/agents/lifecycle/AgentLifecycleManager.d.ts.map +1 -0
- package/dist/agents/lifecycle/AgentLifecycleManager.js +220 -0
- package/dist/agents/lifecycle/AgentLifecycleManager.js.map +1 -0
- package/dist/agents/memory/AgentMemoryService.d.ts +173 -0
- package/dist/agents/memory/AgentMemoryService.d.ts.map +1 -0
- package/dist/agents/memory/AgentMemoryService.js +297 -0
- package/dist/agents/memory/AgentMemoryService.js.map +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +45 -3
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/routing/index.d.ts +1 -1
- package/dist/cli/commands/routing/index.d.ts.map +1 -1
- package/dist/cli/commands/routing/index.js +29 -19
- package/dist/cli/commands/routing/index.js.map +1 -1
- package/dist/cli/commands/skills/index.d.ts +4 -0
- package/dist/cli/commands/skills/index.d.ts.map +1 -1
- package/dist/cli/commands/skills/index.js +8 -2
- package/dist/cli/commands/skills/index.js.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.d.ts +2 -1
- package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.js +4 -1
- package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
- package/dist/core/memory/dao/AccessControlDAO.d.ts +66 -0
- package/dist/core/memory/dao/AccessControlDAO.d.ts.map +1 -0
- package/dist/core/memory/dao/AccessControlDAO.js +140 -0
- package/dist/core/memory/dao/AccessControlDAO.js.map +1 -0
- package/dist/core/memory/dao/BaseDAO.d.ts +34 -0
- package/dist/core/memory/dao/BaseDAO.d.ts.map +1 -0
- package/dist/core/memory/dao/BaseDAO.js +34 -0
- package/dist/core/memory/dao/BaseDAO.js.map +1 -0
- package/dist/core/memory/dao/BlackboardDAO.d.ts +90 -0
- package/dist/core/memory/dao/BlackboardDAO.d.ts.map +1 -0
- package/dist/core/memory/dao/BlackboardDAO.js +223 -0
- package/dist/core/memory/dao/BlackboardDAO.js.map +1 -0
- package/dist/core/memory/dao/EventDAO.d.ts +83 -0
- package/dist/core/memory/dao/EventDAO.d.ts.map +1 -0
- package/dist/core/memory/dao/EventDAO.js +177 -0
- package/dist/core/memory/dao/EventDAO.js.map +1 -0
- package/dist/core/memory/dao/MemoryEntryDAO.d.ts +57 -0
- package/dist/core/memory/dao/MemoryEntryDAO.d.ts.map +1 -0
- package/dist/core/memory/dao/MemoryEntryDAO.js +159 -0
- package/dist/core/memory/dao/MemoryEntryDAO.js.map +1 -0
- package/dist/core/memory/dao/WorkflowDAO.d.ts +85 -0
- package/dist/core/memory/dao/WorkflowDAO.d.ts.map +1 -0
- package/dist/core/memory/dao/WorkflowDAO.js +182 -0
- package/dist/core/memory/dao/WorkflowDAO.js.map +1 -0
- package/dist/core/memory/services/AccessControlService.d.ts +123 -0
- package/dist/core/memory/services/AccessControlService.d.ts.map +1 -0
- package/dist/core/memory/services/AccessControlService.js +249 -0
- package/dist/core/memory/services/AccessControlService.js.map +1 -0
- package/dist/core/memory/services/MemoryStoreService.d.ts +69 -0
- package/dist/core/memory/services/MemoryStoreService.d.ts.map +1 -0
- package/dist/core/memory/services/MemoryStoreService.js +214 -0
- package/dist/core/memory/services/MemoryStoreService.js.map +1 -0
- package/dist/learning/ExperienceReplayBuffer.d.ts +143 -0
- package/dist/learning/ExperienceReplayBuffer.d.ts.map +1 -0
- package/dist/learning/ExperienceReplayBuffer.js +255 -0
- package/dist/learning/ExperienceReplayBuffer.js.map +1 -0
- package/dist/learning/LearningEngine.d.ts +50 -1
- package/dist/learning/LearningEngine.d.ts.map +1 -1
- package/dist/learning/LearningEngine.js +140 -0
- package/dist/learning/LearningEngine.js.map +1 -1
- package/dist/learning/QLearning.d.ts +154 -0
- package/dist/learning/QLearning.d.ts.map +1 -0
- package/dist/learning/QLearning.js +337 -0
- package/dist/learning/QLearning.js.map +1 -0
- package/dist/learning/index.d.ts +2 -0
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +2 -0
- package/dist/learning/index.js.map +1 -1
- package/dist/mcp/handlers/base-handler.d.ts.map +1 -1
- package/dist/mcp/handlers/base-handler.js +4 -1
- package/dist/mcp/handlers/base-handler.js.map +1 -1
- package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts +11 -1
- package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts.map +1 -1
- package/dist/mcp/handlers/prediction/regression-risk-analyze.js +63 -8
- package/dist/mcp/handlers/prediction/regression-risk-analyze.js.map +1 -1
- package/dist/mcp/handlers/quality-analyze.d.ts +7 -1
- package/dist/mcp/handlers/quality-analyze.d.ts.map +1 -1
- package/dist/mcp/handlers/quality-analyze.js +18 -1
- package/dist/mcp/handlers/quality-analyze.js.map +1 -1
- package/dist/mcp/handlers/test-generate.d.ts.map +1 -1
- package/dist/mcp/handlers/test-generate.js +24 -8
- package/dist/mcp/handlers/test-generate.js.map +1 -1
- package/dist/mcp/services/AgentRegistry.d.ts +5 -0
- package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
- package/dist/mcp/services/AgentRegistry.js +19 -0
- package/dist/mcp/services/AgentRegistry.js.map +1 -1
- package/dist/mcp/streaming/CoverageAnalyzeStreamHandler.d.ts +11 -1
- package/dist/mcp/streaming/CoverageAnalyzeStreamHandler.d.ts.map +1 -1
- package/dist/mcp/streaming/CoverageAnalyzeStreamHandler.js +12 -0
- package/dist/mcp/streaming/CoverageAnalyzeStreamHandler.js.map +1 -1
- package/dist/mcp/streaming/TestExecuteStreamHandler.d.ts +10 -1
- package/dist/mcp/streaming/TestExecuteStreamHandler.d.ts.map +1 -1
- package/dist/mcp/streaming/TestExecuteStreamHandler.js +11 -0
- package/dist/mcp/streaming/TestExecuteStreamHandler.js.map +1 -1
- package/dist/reasoning/QEReasoningBank.d.ts +89 -2
- package/dist/reasoning/QEReasoningBank.d.ts.map +1 -1
- package/dist/reasoning/QEReasoningBank.js +396 -10
- package/dist/reasoning/QEReasoningBank.js.map +1 -1
- package/dist/utils/__mocks__/Database.d.ts +64 -0
- package/dist/utils/__mocks__/Database.d.ts.map +1 -0
- package/dist/utils/__mocks__/Database.js +134 -0
- package/dist/utils/__mocks__/Database.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodeComplexityAnalyzerAgent - Analyzes code complexity with AI-powered recommendations
|
|
3
|
+
*
|
|
4
|
+
* This is a learning example agent that demonstrates:
|
|
5
|
+
* - BaseAgent lifecycle patterns
|
|
6
|
+
* - Memory system integration
|
|
7
|
+
* - Learning engine integration
|
|
8
|
+
* - Event-driven architecture
|
|
9
|
+
* - Agent coordination patterns
|
|
10
|
+
*
|
|
11
|
+
* Purpose: Educational demonstration of the Agentic QE Fleet architecture
|
|
12
|
+
*/
|
|
13
|
+
import { BaseAgent, BaseAgentConfig } from './BaseAgent';
|
|
14
|
+
import { QETask, PostTaskData } from '../types';
|
|
15
|
+
interface Logger {
|
|
16
|
+
info(message: string, ...args: any[]): void;
|
|
17
|
+
warn(message: string, ...args: any[]): void;
|
|
18
|
+
error(message: string, ...args: any[]): void;
|
|
19
|
+
debug(message: string, ...args: any[]): void;
|
|
20
|
+
}
|
|
21
|
+
export interface CodeComplexityConfig extends BaseAgentConfig {
|
|
22
|
+
thresholds?: {
|
|
23
|
+
cyclomaticComplexity?: number;
|
|
24
|
+
cognitiveComplexity?: number;
|
|
25
|
+
linesOfCode?: number;
|
|
26
|
+
};
|
|
27
|
+
enableRecommendations?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface ComplexityAnalysisRequest {
|
|
30
|
+
files: Array<{
|
|
31
|
+
path: string;
|
|
32
|
+
content: string;
|
|
33
|
+
language: string;
|
|
34
|
+
}>;
|
|
35
|
+
options?: {
|
|
36
|
+
includeRecommendations?: boolean;
|
|
37
|
+
severity?: 'low' | 'medium' | 'high' | 'all';
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface ComplexityMetrics {
|
|
41
|
+
cyclomaticComplexity: number;
|
|
42
|
+
cognitiveComplexity: number;
|
|
43
|
+
linesOfCode: number;
|
|
44
|
+
functionCount: number;
|
|
45
|
+
averageComplexityPerFunction: number;
|
|
46
|
+
}
|
|
47
|
+
export interface ComplexityIssue {
|
|
48
|
+
file: string;
|
|
49
|
+
location: string;
|
|
50
|
+
type: 'cyclomatic' | 'cognitive' | 'size';
|
|
51
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
52
|
+
current: number;
|
|
53
|
+
threshold: number;
|
|
54
|
+
recommendation?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ComplexityAnalysisResult {
|
|
57
|
+
overall: ComplexityMetrics;
|
|
58
|
+
fileMetrics: Map<string, ComplexityMetrics>;
|
|
59
|
+
issues: ComplexityIssue[];
|
|
60
|
+
score: number;
|
|
61
|
+
recommendations: string[];
|
|
62
|
+
analysisTime: number;
|
|
63
|
+
}
|
|
64
|
+
export declare class CodeComplexityAnalyzerAgent extends BaseAgent {
|
|
65
|
+
protected readonly logger: Logger;
|
|
66
|
+
private thresholds;
|
|
67
|
+
private enableRecommendations;
|
|
68
|
+
constructor(config: CodeComplexityConfig);
|
|
69
|
+
/**
|
|
70
|
+
* Main analysis entry point
|
|
71
|
+
*/
|
|
72
|
+
analyzeComplexity(request: ComplexityAnalysisRequest): Promise<ComplexityAnalysisResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Analyze a single file
|
|
75
|
+
*/
|
|
76
|
+
private analyzeFile;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate maximum nesting level
|
|
79
|
+
*/
|
|
80
|
+
private calculateMaxNestingLevel;
|
|
81
|
+
/**
|
|
82
|
+
* Detect complexity issues
|
|
83
|
+
*/
|
|
84
|
+
private detectIssues;
|
|
85
|
+
/**
|
|
86
|
+
* Determine severity based on how much threshold is exceeded
|
|
87
|
+
*/
|
|
88
|
+
private getSeverity;
|
|
89
|
+
/**
|
|
90
|
+
* Calculate overall metrics from file metrics
|
|
91
|
+
*/
|
|
92
|
+
private calculateOverallMetrics;
|
|
93
|
+
/**
|
|
94
|
+
* Calculate quality score (0-100)
|
|
95
|
+
*/
|
|
96
|
+
private calculateQualityScore;
|
|
97
|
+
/**
|
|
98
|
+
* Generate AI-powered recommendations
|
|
99
|
+
*/
|
|
100
|
+
private generateRecommendations;
|
|
101
|
+
/**
|
|
102
|
+
* Pre-task hook - Called before task execution
|
|
103
|
+
* Demonstrates loading context before work
|
|
104
|
+
*/
|
|
105
|
+
protected onPreTask(data: {
|
|
106
|
+
assignment: any;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Post-task hook - Called after successful task execution
|
|
110
|
+
* Demonstrates storing results and coordination
|
|
111
|
+
*/
|
|
112
|
+
protected onPostTask(data: PostTaskData): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Task error hook - Called when task fails
|
|
115
|
+
* Demonstrates error handling and recovery
|
|
116
|
+
*/
|
|
117
|
+
protected onTaskError(data: {
|
|
118
|
+
assignment: any;
|
|
119
|
+
error: Error;
|
|
120
|
+
}): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Initialize agent components - Called during initialization
|
|
123
|
+
*/
|
|
124
|
+
protected initializeComponents(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Perform task - Called by BaseAgent.executeTask()
|
|
127
|
+
*/
|
|
128
|
+
protected performTask(task: QETask): Promise<ComplexityAnalysisResult>;
|
|
129
|
+
/**
|
|
130
|
+
* Load agent knowledge - Called during initialization
|
|
131
|
+
*/
|
|
132
|
+
protected loadKnowledge(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Clean up agent resources - Called during termination
|
|
135
|
+
*/
|
|
136
|
+
protected cleanup(): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
export {};
|
|
139
|
+
//# sourceMappingURL=CodeComplexityAnalyzerAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeComplexityAnalyzerAgent.d.ts","sourceRoot":"","sources":["../../src/agents/CodeComplexityAnalyzerAgent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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AAC;IAiBnE;;;OAGG;cACa,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC7D;;;OAGG;cACa,WAAW,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBnF;;OAEG;cACa,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrD;;OAEG;cACa,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAU5E;;OAEG;cACa,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAc9C;;OAEG;cACa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAIzC"}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CodeComplexityAnalyzerAgent - Analyzes code complexity with AI-powered recommendations
|
|
4
|
+
*
|
|
5
|
+
* This is a learning example agent that demonstrates:
|
|
6
|
+
* - BaseAgent lifecycle patterns
|
|
7
|
+
* - Memory system integration
|
|
8
|
+
* - Learning engine integration
|
|
9
|
+
* - Event-driven architecture
|
|
10
|
+
* - Agent coordination patterns
|
|
11
|
+
*
|
|
12
|
+
* Purpose: Educational demonstration of the Agentic QE Fleet architecture
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CodeComplexityAnalyzerAgent = void 0;
|
|
16
|
+
const BaseAgent_1 = require("./BaseAgent");
|
|
17
|
+
const types_1 = require("../types");
|
|
18
|
+
class ConsoleLogger {
|
|
19
|
+
info(message, ...args) {
|
|
20
|
+
console.log(`[INFO] ${message}`, ...args);
|
|
21
|
+
}
|
|
22
|
+
warn(message, ...args) {
|
|
23
|
+
console.warn(`[WARN] ${message}`, ...args);
|
|
24
|
+
}
|
|
25
|
+
error(message, ...args) {
|
|
26
|
+
console.error(`[ERROR] ${message}`, ...args);
|
|
27
|
+
}
|
|
28
|
+
debug(message, ...args) {
|
|
29
|
+
console.debug(`[DEBUG] ${message}`, ...args);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Main Agent Class
|
|
34
|
+
// ============================================================================
|
|
35
|
+
class CodeComplexityAnalyzerAgent extends BaseAgent_1.BaseAgent {
|
|
36
|
+
constructor(config) {
|
|
37
|
+
// Define agent capabilities
|
|
38
|
+
const capabilities = [
|
|
39
|
+
{
|
|
40
|
+
name: 'complexity-analysis',
|
|
41
|
+
version: '1.0.0',
|
|
42
|
+
description: 'Analyze code complexity metrics'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'refactoring-recommendations',
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
description: 'Provide AI-powered refactoring suggestions'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'pattern-detection',
|
|
51
|
+
version: '1.0.0',
|
|
52
|
+
description: 'Detect complex code patterns'
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
// Initialize base agent with extended config
|
|
56
|
+
super({
|
|
57
|
+
...config,
|
|
58
|
+
type: types_1.QEAgentType.QUALITY_ANALYZER, // Reusing existing type for demo
|
|
59
|
+
capabilities
|
|
60
|
+
});
|
|
61
|
+
this.logger = new ConsoleLogger();
|
|
62
|
+
// Set thresholds
|
|
63
|
+
this.thresholds = {
|
|
64
|
+
cyclomaticComplexity: config.thresholds?.cyclomaticComplexity ?? 10,
|
|
65
|
+
cognitiveComplexity: config.thresholds?.cognitiveComplexity ?? 15,
|
|
66
|
+
linesOfCode: config.thresholds?.linesOfCode ?? 300
|
|
67
|
+
};
|
|
68
|
+
this.enableRecommendations = config.enableRecommendations ?? true;
|
|
69
|
+
}
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// Core Analysis Methods
|
|
72
|
+
// ============================================================================
|
|
73
|
+
/**
|
|
74
|
+
* Main analysis entry point
|
|
75
|
+
*/
|
|
76
|
+
async analyzeComplexity(request) {
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
try {
|
|
79
|
+
// Store request in memory for coordination
|
|
80
|
+
await this.memoryStore.store(`aqe/complexity/${this.agentId.id}/current-request`, request, 3600 // 1 hour TTL
|
|
81
|
+
);
|
|
82
|
+
// Analyze each file
|
|
83
|
+
const fileMetrics = new Map();
|
|
84
|
+
const issues = [];
|
|
85
|
+
for (const file of request.files) {
|
|
86
|
+
const metrics = await this.analyzeFile(file);
|
|
87
|
+
fileMetrics.set(file.path, metrics);
|
|
88
|
+
// Detect issues based on thresholds
|
|
89
|
+
const fileIssues = this.detectIssues(file.path, metrics);
|
|
90
|
+
issues.push(...fileIssues);
|
|
91
|
+
}
|
|
92
|
+
// Calculate overall metrics
|
|
93
|
+
const overall = this.calculateOverallMetrics(fileMetrics);
|
|
94
|
+
// Calculate quality score (0-100)
|
|
95
|
+
const score = this.calculateQualityScore(overall, issues);
|
|
96
|
+
// Generate recommendations if enabled
|
|
97
|
+
const recommendations = this.enableRecommendations
|
|
98
|
+
? await this.generateRecommendations(issues, overall)
|
|
99
|
+
: [];
|
|
100
|
+
const result = {
|
|
101
|
+
overall,
|
|
102
|
+
fileMetrics,
|
|
103
|
+
issues,
|
|
104
|
+
score,
|
|
105
|
+
recommendations,
|
|
106
|
+
analysisTime: Date.now() - startTime
|
|
107
|
+
};
|
|
108
|
+
// Store results in memory for other agents
|
|
109
|
+
await this.memoryStore.store(`aqe/complexity/${this.agentId.id}/latest-result`, result, 86400 // 24 hours TTL
|
|
110
|
+
);
|
|
111
|
+
// Emit completion event for coordination
|
|
112
|
+
this.eventBus.emit('complexity:analysis:completed', {
|
|
113
|
+
agentId: this.agentId,
|
|
114
|
+
result,
|
|
115
|
+
timestamp: new Date()
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
// Store error in memory
|
|
121
|
+
await this.memoryStore.store(`aqe/complexity/${this.agentId.id}/errors/${Date.now()}`, {
|
|
122
|
+
error: error instanceof Error ? error.message : String(error),
|
|
123
|
+
request,
|
|
124
|
+
timestamp: new Date()
|
|
125
|
+
}, 604800 // 7 days TTL
|
|
126
|
+
);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Analyze a single file
|
|
132
|
+
*/
|
|
133
|
+
async analyzeFile(file) {
|
|
134
|
+
// Basic complexity calculation (simplified for demo)
|
|
135
|
+
const lines = file.content.split('\n');
|
|
136
|
+
const linesOfCode = lines.filter(line => line.trim() && !line.trim().startsWith('//')).length;
|
|
137
|
+
// Count functions (simplified - looks for 'function' keyword)
|
|
138
|
+
const functionMatches = file.content.match(/function\s+\w+/g) || [];
|
|
139
|
+
const functionCount = functionMatches.length;
|
|
140
|
+
// Calculate cyclomatic complexity (simplified)
|
|
141
|
+
// Count decision points: if, for, while, case, catch, &&, ||
|
|
142
|
+
const decisionPoints = [
|
|
143
|
+
...(file.content.match(/\b(if|for|while|case|catch)\b/g) || []),
|
|
144
|
+
...(file.content.match(/(&&|\|\|)/g) || [])
|
|
145
|
+
].length;
|
|
146
|
+
const cyclomaticComplexity = decisionPoints + 1;
|
|
147
|
+
// Cognitive complexity (simplified - similar to cyclomatic but with nesting penalty)
|
|
148
|
+
const nestingLevel = this.calculateMaxNestingLevel(file.content);
|
|
149
|
+
const cognitiveComplexity = cyclomaticComplexity + nestingLevel * 2;
|
|
150
|
+
const averageComplexityPerFunction = functionCount > 0 ? cyclomaticComplexity / functionCount : 0;
|
|
151
|
+
return {
|
|
152
|
+
cyclomaticComplexity,
|
|
153
|
+
cognitiveComplexity,
|
|
154
|
+
linesOfCode,
|
|
155
|
+
functionCount,
|
|
156
|
+
averageComplexityPerFunction
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Calculate maximum nesting level
|
|
161
|
+
*/
|
|
162
|
+
calculateMaxNestingLevel(content) {
|
|
163
|
+
let maxLevel = 0;
|
|
164
|
+
let currentLevel = 0;
|
|
165
|
+
for (const char of content) {
|
|
166
|
+
if (char === '{') {
|
|
167
|
+
currentLevel++;
|
|
168
|
+
maxLevel = Math.max(maxLevel, currentLevel);
|
|
169
|
+
}
|
|
170
|
+
else if (char === '}') {
|
|
171
|
+
currentLevel = Math.max(0, currentLevel - 1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return maxLevel;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Detect complexity issues
|
|
178
|
+
*/
|
|
179
|
+
detectIssues(filePath, metrics) {
|
|
180
|
+
const issues = [];
|
|
181
|
+
// Check cyclomatic complexity
|
|
182
|
+
if (metrics.cyclomaticComplexity > this.thresholds.cyclomaticComplexity) {
|
|
183
|
+
issues.push({
|
|
184
|
+
file: filePath,
|
|
185
|
+
location: 'overall',
|
|
186
|
+
type: 'cyclomatic',
|
|
187
|
+
severity: this.getSeverity(metrics.cyclomaticComplexity, this.thresholds.cyclomaticComplexity),
|
|
188
|
+
current: metrics.cyclomaticComplexity,
|
|
189
|
+
threshold: this.thresholds.cyclomaticComplexity,
|
|
190
|
+
recommendation: 'Consider breaking down complex logic into smaller functions'
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// Check cognitive complexity
|
|
194
|
+
if (metrics.cognitiveComplexity > this.thresholds.cognitiveComplexity) {
|
|
195
|
+
issues.push({
|
|
196
|
+
file: filePath,
|
|
197
|
+
location: 'overall',
|
|
198
|
+
type: 'cognitive',
|
|
199
|
+
severity: this.getSeverity(metrics.cognitiveComplexity, this.thresholds.cognitiveComplexity),
|
|
200
|
+
current: metrics.cognitiveComplexity,
|
|
201
|
+
threshold: this.thresholds.cognitiveComplexity,
|
|
202
|
+
recommendation: 'Reduce nesting levels and simplify control flow'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Check file size
|
|
206
|
+
if (metrics.linesOfCode > this.thresholds.linesOfCode) {
|
|
207
|
+
issues.push({
|
|
208
|
+
file: filePath,
|
|
209
|
+
location: 'overall',
|
|
210
|
+
type: 'size',
|
|
211
|
+
severity: this.getSeverity(metrics.linesOfCode, this.thresholds.linesOfCode),
|
|
212
|
+
current: metrics.linesOfCode,
|
|
213
|
+
threshold: this.thresholds.linesOfCode,
|
|
214
|
+
recommendation: 'Consider splitting this file into smaller modules'
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return issues;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Determine severity based on how much threshold is exceeded
|
|
221
|
+
*/
|
|
222
|
+
getSeverity(current, threshold) {
|
|
223
|
+
const ratio = current / threshold;
|
|
224
|
+
if (ratio >= 2.0)
|
|
225
|
+
return 'critical';
|
|
226
|
+
if (ratio >= 1.5)
|
|
227
|
+
return 'high';
|
|
228
|
+
if (ratio >= 1.2)
|
|
229
|
+
return 'medium';
|
|
230
|
+
return 'low';
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Calculate overall metrics from file metrics
|
|
234
|
+
*/
|
|
235
|
+
calculateOverallMetrics(fileMetrics) {
|
|
236
|
+
const values = Array.from(fileMetrics.values());
|
|
237
|
+
const count = values.length || 1;
|
|
238
|
+
return {
|
|
239
|
+
cyclomaticComplexity: values.reduce((sum, m) => sum + m.cyclomaticComplexity, 0) / count,
|
|
240
|
+
cognitiveComplexity: values.reduce((sum, m) => sum + m.cognitiveComplexity, 0) / count,
|
|
241
|
+
linesOfCode: values.reduce((sum, m) => sum + m.linesOfCode, 0),
|
|
242
|
+
functionCount: values.reduce((sum, m) => sum + m.functionCount, 0),
|
|
243
|
+
averageComplexityPerFunction: values.reduce((sum, m) => sum + m.averageComplexityPerFunction, 0) / count
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Calculate quality score (0-100)
|
|
248
|
+
*/
|
|
249
|
+
calculateQualityScore(metrics, issues) {
|
|
250
|
+
let score = 100;
|
|
251
|
+
// Deduct points for issues
|
|
252
|
+
for (const issue of issues) {
|
|
253
|
+
const deduction = {
|
|
254
|
+
low: 5,
|
|
255
|
+
medium: 10,
|
|
256
|
+
high: 20,
|
|
257
|
+
critical: 30
|
|
258
|
+
}[issue.severity];
|
|
259
|
+
score -= deduction;
|
|
260
|
+
}
|
|
261
|
+
// Additional deduction for overall complexity
|
|
262
|
+
const avgComplexity = metrics.averageComplexityPerFunction;
|
|
263
|
+
if (avgComplexity > 20)
|
|
264
|
+
score -= 10;
|
|
265
|
+
if (avgComplexity > 30)
|
|
266
|
+
score -= 20;
|
|
267
|
+
return Math.max(0, Math.min(100, score));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Generate AI-powered recommendations
|
|
271
|
+
*/
|
|
272
|
+
async generateRecommendations(issues, metrics) {
|
|
273
|
+
const recommendations = [];
|
|
274
|
+
// Group issues by type
|
|
275
|
+
const issuesByType = new Map();
|
|
276
|
+
for (const issue of issues) {
|
|
277
|
+
const list = issuesByType.get(issue.type) || [];
|
|
278
|
+
list.push(issue);
|
|
279
|
+
issuesByType.set(issue.type, list);
|
|
280
|
+
}
|
|
281
|
+
// Generate recommendations based on patterns
|
|
282
|
+
if (issuesByType.has('cyclomatic')) {
|
|
283
|
+
recommendations.push('Apply Extract Method refactoring to reduce cyclomatic complexity', 'Consider using strategy pattern for complex conditional logic');
|
|
284
|
+
}
|
|
285
|
+
if (issuesByType.has('cognitive')) {
|
|
286
|
+
recommendations.push('Use early returns to reduce nesting levels', 'Extract nested loops into separate methods', 'Consider using guard clauses to simplify control flow');
|
|
287
|
+
}
|
|
288
|
+
if (issuesByType.has('size')) {
|
|
289
|
+
recommendations.push('Split large files into focused modules following Single Responsibility Principle', 'Group related functions into separate classes or modules');
|
|
290
|
+
}
|
|
291
|
+
// General recommendations based on metrics
|
|
292
|
+
if (metrics.averageComplexityPerFunction > 15) {
|
|
293
|
+
recommendations.push('Target: Keep function complexity under 10 for better maintainability');
|
|
294
|
+
}
|
|
295
|
+
return recommendations;
|
|
296
|
+
}
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// BaseAgent Lifecycle Hooks (Demonstration)
|
|
299
|
+
// ============================================================================
|
|
300
|
+
/**
|
|
301
|
+
* Pre-task hook - Called before task execution
|
|
302
|
+
* Demonstrates loading context before work
|
|
303
|
+
*/
|
|
304
|
+
async onPreTask(data) {
|
|
305
|
+
this.logger.info('Pre-task hook: Loading complexity analysis context', {
|
|
306
|
+
taskId: data.assignment.id
|
|
307
|
+
});
|
|
308
|
+
// Load historical analysis data for learning
|
|
309
|
+
const historicalData = await this.memoryStore.retrieve(`aqe/complexity/${this.agentId.id}/history`);
|
|
310
|
+
if (historicalData) {
|
|
311
|
+
this.logger.debug('Loaded historical complexity data', {
|
|
312
|
+
count: historicalData.length
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Post-task hook - Called after successful task execution
|
|
318
|
+
* Demonstrates storing results and coordination
|
|
319
|
+
*/
|
|
320
|
+
async onPostTask(data) {
|
|
321
|
+
this.logger.info('Post-task hook: Storing complexity results', {
|
|
322
|
+
taskId: data.assignment.id
|
|
323
|
+
});
|
|
324
|
+
// Store result in history for learning
|
|
325
|
+
const history = await this.memoryStore.retrieve(`aqe/complexity/${this.agentId.id}/history`) || [];
|
|
326
|
+
history.push({
|
|
327
|
+
timestamp: new Date(),
|
|
328
|
+
taskId: data.assignment.id,
|
|
329
|
+
result: data.result
|
|
330
|
+
});
|
|
331
|
+
// Keep last 100 results
|
|
332
|
+
if (history.length > 100) {
|
|
333
|
+
history.shift();
|
|
334
|
+
}
|
|
335
|
+
await this.memoryStore.store(`aqe/complexity/${this.agentId.id}/history`, history, 2592000 // 30 days
|
|
336
|
+
);
|
|
337
|
+
// Emit event for other agents (e.g., test generator could use this)
|
|
338
|
+
this.eventBus.emit('complexity:analysis:stored', {
|
|
339
|
+
agentId: this.agentId,
|
|
340
|
+
timestamp: new Date()
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Task error hook - Called when task fails
|
|
345
|
+
* Demonstrates error handling and recovery
|
|
346
|
+
*/
|
|
347
|
+
async onTaskError(data) {
|
|
348
|
+
this.logger.error('Task error hook: Complexity analysis failed', {
|
|
349
|
+
taskId: data.assignment.id,
|
|
350
|
+
error: data.error.message
|
|
351
|
+
});
|
|
352
|
+
// Store error for analysis
|
|
353
|
+
await this.memoryStore.store(`aqe/complexity/${this.agentId.id}/errors/${Date.now()}`, {
|
|
354
|
+
taskId: data.assignment.id,
|
|
355
|
+
error: data.error.message,
|
|
356
|
+
stack: data.error.stack,
|
|
357
|
+
timestamp: new Date()
|
|
358
|
+
}, 604800 // 7 days
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
// ============================================================================
|
|
362
|
+
// BaseAgent Abstract Methods (Required)
|
|
363
|
+
// ============================================================================
|
|
364
|
+
/**
|
|
365
|
+
* Initialize agent components - Called during initialization
|
|
366
|
+
*/
|
|
367
|
+
async initializeComponents() {
|
|
368
|
+
this.logger.info('Initializing complexity analyzer components');
|
|
369
|
+
// Agent-specific initialization can go here
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Perform task - Called by BaseAgent.executeTask()
|
|
373
|
+
*/
|
|
374
|
+
async performTask(task) {
|
|
375
|
+
this.logger.info('Performing complexity analysis task', {
|
|
376
|
+
taskId: task.id,
|
|
377
|
+
type: task.type
|
|
378
|
+
});
|
|
379
|
+
const request = task.payload;
|
|
380
|
+
return await this.analyzeComplexity(request);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Load agent knowledge - Called during initialization
|
|
384
|
+
*/
|
|
385
|
+
async loadKnowledge() {
|
|
386
|
+
this.logger.info('Loading complexity analysis knowledge');
|
|
387
|
+
// Load learned thresholds from previous analyses
|
|
388
|
+
const learnedThresholds = await this.memoryStore.retrieve(`aqe/complexity/${this.agentId.id}/learned-thresholds`);
|
|
389
|
+
if (learnedThresholds) {
|
|
390
|
+
this.logger.debug('Loaded learned thresholds', learnedThresholds);
|
|
391
|
+
// Could adjust thresholds based on learned data
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Clean up agent resources - Called during termination
|
|
396
|
+
*/
|
|
397
|
+
async cleanup() {
|
|
398
|
+
this.logger.info('Cleaning up complexity analyzer resources');
|
|
399
|
+
// Clean up any resources (e.g., temp files, connections)
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
exports.CodeComplexityAnalyzerAgent = CodeComplexityAnalyzerAgent;
|
|
403
|
+
//# sourceMappingURL=CodeComplexityAnalyzerAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeComplexityAnalyzerAgent.js","sourceRoot":"","sources":["../../src/agents/CodeComplexityAnalyzerAgent.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,2CAAyD;AACzD,oCAKkB;AAalB,MAAM,aAAa;IACjB,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF;AA0DD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAa,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ingMonitorInterval = setInterval(async () => {
|
|
695
|
-
if (this.
|
|
695
|
+
if (this.lifecycleManager.getStatus() !== types_1.AgentStatus.ACTIVE)
|
|
696
696
|
return;
|
|
697
697
|
const decision = await this.makeScalingDecision();
|
|
698
698
|
if (decision.action !== 'no-action') {
|
|
@@ -764,7 +764,7 @@ class FleetCommanderAgent extends BaseAgent_1.BaseAgent {
|
|
|
764
764
|
// ============================================================================
|
|
765
765
|
startHeartbeatMonitoring() {
|
|
766
766
|
this.heartbeatMonitorInterval = setInterval(async () => {
|
|
767
|
-
if (this.
|
|
767
|
+
if (this.lifecycleManager.getStatus() !== types_1.AgentStatus.ACTIVE)
|
|
768
768
|
return;
|
|
769
769
|
const now = new Date();
|
|
770
770
|
const timeout = this.config.faultTolerance?.heartbeatTimeout || 15000;
|