vibecodingmachine-core 2026.2.20-438 → 2026.2.26-1642

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 (202) hide show
  1. package/README.md +240 -0
  2. package/package.json +10 -2
  3. package/src/agents/Agent.js +300 -0
  4. package/src/agents/AgentAdditionService.js +311 -0
  5. package/src/agents/AgentCheckService.js +690 -0
  6. package/src/agents/AgentInstallationService.js +140 -0
  7. package/src/agents/AgentSetupService.js +467 -0
  8. package/src/agents/AgentStatus.js +183 -0
  9. package/src/agents/AgentVerificationService.js +634 -0
  10. package/src/agents/ConfigurationSchemaValidator.js +543 -0
  11. package/src/agents/EnvironmentConfigurationManager.js +602 -0
  12. package/src/agents/InstallationErrorHandler.js +372 -0
  13. package/src/agents/InstallationLog.js +363 -0
  14. package/src/agents/InstallationMethod.js +510 -0
  15. package/src/agents/InstallationOrchestrator.js +352 -0
  16. package/src/agents/InstallationProgressReporter.js +372 -0
  17. package/src/agents/InstallationRetryManager.js +322 -0
  18. package/src/agents/InstallationType.js +254 -0
  19. package/src/agents/OperationTypes.js +310 -0
  20. package/src/agents/PerformanceMetricsCollector.js +493 -0
  21. package/src/agents/SecurityValidationService.js +534 -0
  22. package/src/agents/VerificationTest.js +354 -0
  23. package/src/agents/VerificationType.js +226 -0
  24. package/src/agents/WindowsPermissionHandler.js +518 -0
  25. package/src/agents/config/AgentConfigManager.js +393 -0
  26. package/src/agents/config/AgentDefaultsRegistry.js +373 -0
  27. package/src/agents/config/ConfigValidator.js +281 -0
  28. package/src/agents/discovery/AgentDiscoveryService.js +707 -0
  29. package/src/agents/logging/AgentLogger.js +511 -0
  30. package/src/agents/status/AgentStatusManager.js +481 -0
  31. package/src/agents/storage/FileManager.js +454 -0
  32. package/src/agents/verification/AgentCommunicationTester.js +474 -0
  33. package/src/agents/verification/BaseVerifier.js +430 -0
  34. package/src/agents/verification/CommandVerifier.js +480 -0
  35. package/src/agents/verification/FileOperationVerifier.js +453 -0
  36. package/src/agents/verification/ResultAnalyzer.js +707 -0
  37. package/src/agents/verification/TestRequirementManager.js +495 -0
  38. package/src/agents/verification/VerificationRunner.js +433 -0
  39. package/src/agents/windows/BaseWindowsInstaller.js +441 -0
  40. package/src/agents/windows/ChocolateyInstaller.js +509 -0
  41. package/src/agents/windows/DirectInstaller.js +443 -0
  42. package/src/agents/windows/InstallerFactory.js +391 -0
  43. package/src/agents/windows/NpmInstaller.js +505 -0
  44. package/src/agents/windows/PowerShellInstaller.js +458 -0
  45. package/src/agents/windows/WinGetInstaller.js +390 -0
  46. package/src/analysis/analysis-reporter.js +132 -0
  47. package/src/analysis/boundary-detector.js +712 -0
  48. package/src/analysis/categorizer.js +340 -0
  49. package/src/analysis/codebase-scanner.js +384 -0
  50. package/src/analysis/line-counter.js +513 -0
  51. package/src/analysis/priority-calculator.js +679 -0
  52. package/src/analysis/report/analysis-report.js +250 -0
  53. package/src/analysis/report/package-analyzer.js +278 -0
  54. package/src/analysis/report/recommendation-generator.js +382 -0
  55. package/src/analysis/report/statistics-generator.js +515 -0
  56. package/src/analysis/reports/analysis-report-model.js +101 -0
  57. package/src/analysis/reports/recommendation-generator.js +283 -0
  58. package/src/analysis/reports/report-generators.js +191 -0
  59. package/src/analysis/reports/statistics-calculator.js +231 -0
  60. package/src/analysis/reports/trend-analyzer.js +219 -0
  61. package/src/analysis/strategy-generator.js +814 -0
  62. package/src/auto-mode/AutoModeBusinessLogic.js +836 -0
  63. package/src/config/refactoring-config.js +307 -0
  64. package/src/health-tracking/json-storage.js +38 -2
  65. package/src/ide-integration/applescript-manager-core.js +233 -0
  66. package/src/ide-integration/applescript-manager.cjs +357 -28
  67. package/src/ide-integration/applescript-manager.js +89 -3599
  68. package/src/ide-integration/cdp-manager.js +306 -0
  69. package/src/ide-integration/claude-code-cli-manager.cjs +1 -1
  70. package/src/ide-integration/continuation-handler.js +337 -0
  71. package/src/ide-integration/ide-status-checker.js +292 -0
  72. package/src/ide-integration/macos-ide-manager.js +627 -0
  73. package/src/ide-integration/macos-text-sender.js +528 -0
  74. package/src/ide-integration/response-reader.js +548 -0
  75. package/src/ide-integration/windows-automation-manager.js +121 -0
  76. package/src/ide-integration/windows-ide-manager.js +373 -0
  77. package/src/index.cjs +25 -3
  78. package/src/index.js +15 -1
  79. package/src/llm/direct-llm-manager.cjs +90 -2
  80. package/src/models/compliance-report.js +538 -0
  81. package/src/models/file-analysis.js +681 -0
  82. package/src/models/refactoring-plan.js +770 -0
  83. package/src/monitoring/alert-system.js +834 -0
  84. package/src/monitoring/compliance-progress-tracker.js +437 -0
  85. package/src/monitoring/continuous-scan-notifications.js +661 -0
  86. package/src/monitoring/continuous-scanner.js +279 -0
  87. package/src/monitoring/file-monitor/file-analyzer.js +262 -0
  88. package/src/monitoring/file-monitor/file-monitor.js +237 -0
  89. package/src/monitoring/file-monitor/watcher.js +194 -0
  90. package/src/monitoring/file-monitor.js +17 -0
  91. package/src/monitoring/notification-manager.js +437 -0
  92. package/src/monitoring/scanner-core.js +368 -0
  93. package/src/monitoring/scanner-events.js +214 -0
  94. package/src/monitoring/violation-notification-system.js +515 -0
  95. package/src/refactoring/boundaries/cohesion-analyzer.js +316 -0
  96. package/src/refactoring/boundaries/extraction-result.js +285 -0
  97. package/src/refactoring/boundaries/extraction-strategies.js +392 -0
  98. package/src/refactoring/boundaries/module-boundary.js +209 -0
  99. package/src/refactoring/boundary/boundary-detector.js +741 -0
  100. package/src/refactoring/boundary/boundary-types.js +405 -0
  101. package/src/refactoring/boundary/extraction-strategies.js +554 -0
  102. package/src/refactoring/boundary-extraction-result.js +77 -0
  103. package/src/refactoring/boundary-extraction-strategies.js +330 -0
  104. package/src/refactoring/boundary-extractor.js +384 -0
  105. package/src/refactoring/boundary-types.js +46 -0
  106. package/src/refactoring/circular/circular-dependency.js +88 -0
  107. package/src/refactoring/circular/cycle-detection.js +147 -0
  108. package/src/refactoring/circular/dependency-node.js +82 -0
  109. package/src/refactoring/circular/dependency-result.js +107 -0
  110. package/src/refactoring/circular/dependency-types.js +58 -0
  111. package/src/refactoring/circular/graph-builder.js +213 -0
  112. package/src/refactoring/circular/resolution-strategy.js +72 -0
  113. package/src/refactoring/circular/strategy-generator.js +229 -0
  114. package/src/refactoring/circular-dependency-resolver-original.js +809 -0
  115. package/src/refactoring/circular-dependency-resolver.js +200 -0
  116. package/src/refactoring/code-mover.js +761 -0
  117. package/src/refactoring/file-splitter.js +696 -0
  118. package/src/refactoring/functionality-validator.js +816 -0
  119. package/src/refactoring/import-manager.js +774 -0
  120. package/src/refactoring/module-boundary.js +107 -0
  121. package/src/refactoring/refactoring-executor.js +672 -0
  122. package/src/refactoring/refactoring-rollback.js +614 -0
  123. package/src/refactoring/test-validator.js +631 -0
  124. package/src/requirement-management/default-requirement-manager.js +321 -0
  125. package/src/requirement-management/requirement-file-parser.js +159 -0
  126. package/src/requirement-management/requirement-sequencer.js +221 -0
  127. package/src/rui/commands/AgentCommandParser.js +600 -0
  128. package/src/rui/commands/AgentCommands.js +487 -0
  129. package/src/rui/commands/AgentResponseFormatter.js +832 -0
  130. package/src/scripts/verify-full-compliance.js +269 -0
  131. package/src/sync/sync-engine-core.js +1 -0
  132. package/src/sync/sync-engine-remote-handlers.js +135 -0
  133. package/src/task-generation/automated-task-generator.js +351 -0
  134. package/src/task-generation/prioritizer.js +287 -0
  135. package/src/task-generation/task-list-updater.js +215 -0
  136. package/src/task-generation/task-management-integration.js +480 -0
  137. package/src/task-generation/task-manager-integration.js +270 -0
  138. package/src/task-generation/violation-task-generator.js +474 -0
  139. package/src/task-management/continuous-scan-integration.js +342 -0
  140. package/src/timeout-management/index.js +12 -3
  141. package/src/timeout-management/response-time-tracker.js +167 -0
  142. package/src/timeout-management/timeout-calculator.js +159 -0
  143. package/src/timeout-management/timeout-config-manager.js +172 -0
  144. package/src/utils/ast-analyzer.js +417 -0
  145. package/src/utils/current-requirement-manager.js +276 -0
  146. package/src/utils/current-requirement-operations.js +472 -0
  147. package/src/utils/dependency-mapper.js +456 -0
  148. package/src/utils/download-with-progress.js +4 -2
  149. package/src/utils/electron-update-checker.js +4 -1
  150. package/src/utils/file-size-analyzer.js +272 -0
  151. package/src/utils/import-updater.js +280 -0
  152. package/src/utils/refactoring-tools.js +512 -0
  153. package/src/utils/report-generator.js +569 -0
  154. package/src/utils/reports/report-analysis.js +218 -0
  155. package/src/utils/reports/report-types.js +55 -0
  156. package/src/utils/reports/summary-generators.js +102 -0
  157. package/src/utils/requirement-file-management.js +157 -0
  158. package/src/utils/requirement-helpers/requirement-file-ops.js +392 -0
  159. package/src/utils/requirement-helpers/requirement-mover.js +414 -0
  160. package/src/utils/requirement-helpers/requirement-parser.js +326 -0
  161. package/src/utils/requirement-helpers/requirement-status.js +320 -0
  162. package/src/utils/requirement-helpers-new.js +55 -0
  163. package/src/utils/requirement-helpers-refactored.js +367 -0
  164. package/src/utils/requirement-helpers.js +291 -1191
  165. package/src/utils/requirement-movement-operations.js +450 -0
  166. package/src/utils/requirement-movement.js +312 -0
  167. package/src/utils/requirement-parsing-helpers.js +56 -0
  168. package/src/utils/requirement-statistics.js +200 -0
  169. package/src/utils/requirement-text-utils.js +58 -0
  170. package/src/utils/rollback/rollback-handlers.js +125 -0
  171. package/src/utils/rollback/rollback-operation.js +63 -0
  172. package/src/utils/rollback/rollback-recorder.js +166 -0
  173. package/src/utils/rollback/rollback-state-manager.js +175 -0
  174. package/src/utils/rollback/rollback-types.js +33 -0
  175. package/src/utils/rollback/rollback-utils.js +110 -0
  176. package/src/utils/rollback-manager-original.js +569 -0
  177. package/src/utils/rollback-manager.js +202 -0
  178. package/src/utils/smoke-test-cli.js +362 -0
  179. package/src/utils/smoke-test-gui.js +351 -0
  180. package/src/utils/smoke-test-orchestrator.js +321 -0
  181. package/src/utils/smoke-test-runner.js +60 -0
  182. package/src/utils/smoke-test-web.js +347 -0
  183. package/src/utils/specification-helpers.js +39 -13
  184. package/src/utils/specification-migration.js +97 -0
  185. package/src/utils/test-runner.js +579 -0
  186. package/src/utils/validation-framework.js +518 -0
  187. package/src/validation/compliance-analyzer.js +197 -0
  188. package/src/validation/compliance-report-generator.js +343 -0
  189. package/src/validation/compliance-reporter.js +711 -0
  190. package/src/validation/compliance-rules.js +127 -0
  191. package/src/validation/constitution-validator-new.js +196 -0
  192. package/src/validation/constitution-validator.js +17 -0
  193. package/src/validation/file-validators.js +170 -0
  194. package/src/validation/line-limit/file-analyzer.js +201 -0
  195. package/src/validation/line-limit/line-limit-validator.js +208 -0
  196. package/src/validation/line-limit/validation-result.js +144 -0
  197. package/src/validation/line-limit-core.js +225 -0
  198. package/src/validation/line-limit-reporter.js +134 -0
  199. package/src/validation/line-limit-result.js +125 -0
  200. package/src/validation/line-limit-validator.js +41 -0
  201. package/src/validation/metrics-calculator.js +660 -0
  202. package/src/sync/sync-engine-backup.js +0 -559
@@ -0,0 +1,707 @@
1
+ /**
2
+ * Verification Result Analyzer
3
+ *
4
+ * Analyzes and interprets verification test results.
5
+ * Follows constitutional requirements: <555 lines, test-first approach.
6
+ */
7
+
8
+ const { AgentStatus } = require('../AgentStatus');
9
+ const { VerificationType } = require('../VerificationType');
10
+
11
+ /**
12
+ * Verification result analyzer class
13
+ */
14
+ class ResultAnalyzer {
15
+ /**
16
+ * Create result analyzer instance
17
+ * @param {Object} options - Analyzer options
18
+ */
19
+ constructor(options = {}) {
20
+ this.logger = options.logger || null;
21
+ this.strictMode = options.strictMode || false;
22
+ this.detailedAnalysis = options.detailedAnalysis !== false;
23
+ }
24
+
25
+ /**
26
+ * Analyze single test result
27
+ * @param {Object} testResult - Test result to analyze
28
+ * @returns {Object} - Analysis result
29
+ */
30
+ analyzeTestResult(testResult) {
31
+ const analysis = {
32
+ testId: testResult.testId,
33
+ success: testResult.success,
34
+ severity: this.determineSeverity(testResult),
35
+ category: this.categorizeResult(testResult),
36
+ recommendations: this.generateRecommendations(testResult),
37
+ confidence: this.calculateConfidence(testResult)
38
+ };
39
+
40
+ // Add detailed analysis if enabled
41
+ if (this.detailedAnalysis) {
42
+ analysis.details = this.analyzeDetails(testResult);
43
+ analysis.patterns = this.identifyPatterns(testResult);
44
+ analysis.riskFactors = this.identifyRiskFactors(testResult);
45
+ }
46
+
47
+ return analysis;
48
+ }
49
+
50
+ /**
51
+ * Analyze agent verification results
52
+ * @param {Object} verificationResult - Agent verification result
53
+ * @returns {Object} - Analysis result
54
+ */
55
+ analyzeAgentResult(verificationResult) {
56
+ const analysis = {
57
+ agentId: verificationResult.agentId,
58
+ overallSuccess: verificationResult.success,
59
+ status: this.determineAgentStatus(verificationResult),
60
+ summary: this.createSummary(verificationResult),
61
+ issues: this.identifyIssues(verificationResult),
62
+ recommendations: this.generateAgentRecommendations(verificationResult),
63
+ confidence: this.calculateAgentConfidence(verificationResult)
64
+ };
65
+
66
+ // Analyze individual test results
67
+ if (verificationResult.results) {
68
+ analysis.testAnalyses = verificationResult.results.map(testResult =>
69
+ this.analyzeTestResult(testResult)
70
+ );
71
+
72
+ // Aggregate test analysis
73
+ analysis.testSummary = this.aggregateTestAnalyses(analysis.testAnalyses);
74
+ }
75
+
76
+ return analysis;
77
+ }
78
+
79
+ /**
80
+ * Analyze batch verification results
81
+ * @param {Object} batchResult - Batch verification result
82
+ * @returns {Object} - Analysis result
83
+ */
84
+ analyzeBatchResult(batchResult) {
85
+ const analysis = {
86
+ batchId: batchResult.batchId || batchResult.testId,
87
+ overallSuccess: batchResult.success,
88
+ summary: this.createBatchSummary(batchResult),
89
+ agentAnalyses: [],
90
+ patterns: this.identifyBatchPatterns(batchResult),
91
+ recommendations: this.generateBatchRecommendations(batchResult),
92
+ confidence: this.calculateBatchConfidence(batchResult)
93
+ };
94
+
95
+ // Analyze individual agent results
96
+ if (batchResult.results) {
97
+ analysis.agentAnalyses = batchResult.results.map(agentResult =>
98
+ this.analyzeAgentResult(agentResult)
99
+ );
100
+
101
+ // Aggregate agent analyses
102
+ analysis.agentSummary = this.aggregateAgentAnalyses(analysis.agentAnalyses);
103
+ }
104
+
105
+ return analysis;
106
+ }
107
+
108
+ /**
109
+ * Determine result severity
110
+ * @param {Object} testResult - Test result
111
+ * @returns {string} - Severity level
112
+ */
113
+ determineSeverity(testResult) {
114
+ if (!testResult.success) {
115
+ // Determine failure severity
116
+ if (testResult.error) {
117
+ const error = testResult.error.toLowerCase();
118
+
119
+ if (error.includes('timeout') || error.includes('network')) {
120
+ return 'medium';
121
+ } else if (error.includes('permission') || error.includes('access denied')) {
122
+ return 'high';
123
+ } else if (error.includes('not found') || error.includes('command not found')) {
124
+ return 'high';
125
+ } else {
126
+ return 'low';
127
+ }
128
+ }
129
+ }
130
+
131
+ return 'none';
132
+ }
133
+
134
+ /**
135
+ * Categorize test result
136
+ * @param {Object} testResult - Test result
137
+ * @returns {string} - Result category
138
+ */
139
+ categorizeResult(testResult) {
140
+ if (!testResult.success) {
141
+ if (testResult.error) {
142
+ const error = testResult.error.toLowerCase();
143
+
144
+ if (error.includes('timeout')) {
145
+ return 'timeout';
146
+ } else if (error.includes('permission') || error.includes('access')) {
147
+ return 'permission';
148
+ } else if (error.includes('not found') || error.includes('missing')) {
149
+ return 'missing';
150
+ } else if (error.includes('network') || error.includes('connection')) {
151
+ return 'network';
152
+ } else {
153
+ return 'unknown';
154
+ }
155
+ }
156
+ }
157
+
158
+ return 'success';
159
+ }
160
+
161
+ /**
162
+ * Generate recommendations for test result
163
+ * @param {Object} testResult - Test result
164
+ * @returns {Array} - Recommendations
165
+ */
166
+ generateRecommendations(testResult) {
167
+ const recommendations = [];
168
+
169
+ if (!testResult.success) {
170
+ const category = this.categorizeResult(testResult);
171
+
172
+ switch (category) {
173
+ case 'timeout':
174
+ recommendations.push('Increase timeout value for this test');
175
+ recommendations.push('Check system performance and resource availability');
176
+ break;
177
+
178
+ case 'permission':
179
+ recommendations.push('Check file/directory permissions');
180
+ recommendations.push('Run with appropriate user privileges');
181
+ break;
182
+
183
+ case 'missing':
184
+ recommendations.push('Verify agent installation');
185
+ recommendations.push('Check command availability in PATH');
186
+ break;
187
+
188
+ case 'network':
189
+ recommendations.push('Check network connectivity');
190
+ recommendations.push('Verify firewall settings');
191
+ break;
192
+
193
+ default:
194
+ recommendations.push('Review test configuration');
195
+ recommendations.push('Check system logs for detailed error information');
196
+ }
197
+ }
198
+
199
+ return recommendations;
200
+ }
201
+
202
+ /**
203
+ * Calculate confidence score
204
+ * @param {Object} testResult - Test result
205
+ * @returns {number} - Confidence score (0-100)
206
+ */
207
+ calculateConfidence(testResult) {
208
+ if (!testResult.success) {
209
+ return 0;
210
+ }
211
+
212
+ let confidence = 80; // Base confidence for successful tests
213
+
214
+ // Adjust based on test duration
215
+ if (testResult.duration) {
216
+ if (testResult.duration < 1000) {
217
+ confidence += 10; // Very fast test
218
+ } else if (testResult.duration > 30000) {
219
+ confidence -= 10; // Very slow test
220
+ }
221
+ }
222
+
223
+ // Adjust based on test type
224
+ if (testResult.type === VerificationType.FILE_OPERATION) {
225
+ confidence += 5; // File operations are more reliable
226
+ }
227
+
228
+ return Math.min(100, Math.max(0, confidence));
229
+ }
230
+
231
+ /**
232
+ * Analyze detailed test information
233
+ * @param {Object} testResult - Test result
234
+ * @returns {Object} - Detailed analysis
235
+ */
236
+ analyzeDetails(testResult) {
237
+ const details = {};
238
+
239
+ if (testResult.duration) {
240
+ details.performance = {
241
+ duration: testResult.duration,
242
+ category: this.categorizePerformance(testResult.duration),
243
+ acceptable: testResult.duration < 30000
244
+ };
245
+ }
246
+
247
+ if (testResult.type) {
248
+ details.testType = {
249
+ type: testResult.type,
250
+ reliability: this.getTestTypeReliability(testResult.type)
251
+ };
252
+ }
253
+
254
+ if (testResult.error) {
255
+ details.error = {
256
+ message: testResult.error,
257
+ type: this.categorizeResult(testResult),
258
+ recoverable: this.isRecoverableError(testResult.error)
259
+ };
260
+ }
261
+
262
+ return details;
263
+ }
264
+
265
+ /**
266
+ * Identify patterns in test result
267
+ * @param {Object} testResult - Test result
268
+ * @returns {Array} - Identified patterns
269
+ */
270
+ identifyPatterns(testResult) {
271
+ const patterns = [];
272
+
273
+ if (testResult.error) {
274
+ const error = testResult.error.toLowerCase();
275
+
276
+ if (error.includes('timeout')) {
277
+ patterns.push('timeout-pattern');
278
+ }
279
+
280
+ if (error.includes('permission') || error.includes('access')) {
281
+ patterns.push('permission-pattern');
282
+ }
283
+
284
+ if (error.includes('not found')) {
285
+ patterns.push('missing-dependency-pattern');
286
+ }
287
+ }
288
+
289
+ if (testResult.duration && testResult.duration > 30000) {
290
+ patterns.push('slow-performance-pattern');
291
+ }
292
+
293
+ return patterns;
294
+ }
295
+
296
+ /**
297
+ * Identify risk factors
298
+ * @param {Object} testResult - Test result
299
+ * @returns {Array} - Risk factors
300
+ */
301
+ identifyRiskFactors(testResult) {
302
+ const risks = [];
303
+
304
+ if (!testResult.success) {
305
+ const severity = this.determineSeverity(testResult);
306
+
307
+ if (severity === 'high') {
308
+ risks.push('critical-failure-risk');
309
+ }
310
+
311
+ if (this.categorizeResult(testResult) === 'permission') {
312
+ risks.push('security-risk');
313
+ }
314
+
315
+ if (testResult.type === VerificationType.COMMAND_EXECUTION && !testResult.success) {
316
+ risks.push('command-execution-risk');
317
+ }
318
+ }
319
+
320
+ return risks;
321
+ }
322
+
323
+ /**
324
+ * Determine agent status based on verification result
325
+ * @param {Object} verificationResult - Verification result
326
+ * @returns {string} - Agent status
327
+ */
328
+ determineAgentStatus(verificationResult) {
329
+ if (!verificationResult.success) {
330
+ return AgentStatus.ERROR;
331
+ }
332
+
333
+ if (verificationResult.summary) {
334
+ if (verificationResult.summary.allPassed) {
335
+ return AgentStatus.VERIFIED;
336
+ } else if (verificationResult.summary.passed > 0) {
337
+ return AgentStatus.INSTALLED; // Partial success
338
+ }
339
+ }
340
+
341
+ return AgentStatus.ERROR;
342
+ }
343
+
344
+ /**
345
+ * Create summary for agent result
346
+ * @param {Object} verificationResult - Verification result
347
+ * @returns {Object} - Summary
348
+ */
349
+ createSummary(verificationResult) {
350
+ const summary = {
351
+ agentId: verificationResult.agentId,
352
+ success: verificationResult.success,
353
+ duration: verificationResult.duration || 0
354
+ };
355
+
356
+ if (verificationResult.summary) {
357
+ summary.tests = verificationResult.summary;
358
+ }
359
+
360
+ if (verificationResult.results) {
361
+ summary.totalTests = verificationResult.results.length;
362
+ summary.passedTests = verificationResult.results.filter(r => r.success).length;
363
+ summary.failedTests = summary.totalTests - summary.passedTests;
364
+ }
365
+
366
+ return summary;
367
+ }
368
+
369
+ /**
370
+ * Identify issues in verification result
371
+ * @param {Object} verificationResult - Verification result
372
+ * @returns {Array} - Issues
373
+ */
374
+ identifyIssues(verificationResult) {
375
+ const issues = [];
376
+
377
+ if (!verificationResult.success) {
378
+ if (verificationResult.error) {
379
+ issues.push({
380
+ type: 'verification-failure',
381
+ severity: 'high',
382
+ message: verificationResult.error
383
+ });
384
+ }
385
+ }
386
+
387
+ if (verificationResult.results) {
388
+ verificationResult.results.forEach((testResult, index) => {
389
+ if (!testResult.success) {
390
+ issues.push({
391
+ type: 'test-failure',
392
+ severity: this.determineSeverity(testResult),
393
+ testId: testResult.testId,
394
+ message: testResult.error || 'Test failed'
395
+ });
396
+ }
397
+ });
398
+ }
399
+
400
+ return issues;
401
+ }
402
+
403
+ /**
404
+ * Generate recommendations for agent
405
+ * @param {Object} verificationResult - Verification result
406
+ * @returns {Array} - Recommendations
407
+ */
408
+ generateAgentRecommendations(verificationResult) {
409
+ const recommendations = [];
410
+
411
+ if (!verificationResult.success) {
412
+ recommendations.push('Review agent installation and configuration');
413
+
414
+ if (verificationResult.results) {
415
+ const failedTests = verificationResult.results.filter(r => !r.success);
416
+ const categories = [...new Set(failedTests.map(t => this.categorizeResult(t)))];
417
+
418
+ categories.forEach(category => {
419
+ switch (category) {
420
+ case 'permission':
421
+ recommendations.push('Check file and directory permissions');
422
+ break;
423
+ case 'missing':
424
+ recommendations.push('Verify agent dependencies are installed');
425
+ break;
426
+ case 'timeout':
427
+ recommendations.push('Increase timeout values or optimize performance');
428
+ break;
429
+ }
430
+ });
431
+ }
432
+ }
433
+
434
+ return recommendations;
435
+ }
436
+
437
+ /**
438
+ * Calculate confidence for agent result
439
+ * @param {Object} verificationResult - Verification result
440
+ * @returns {number} - Confidence score
441
+ */
442
+ calculateAgentConfidence(verificationResult) {
443
+ if (!verificationResult.success || !verificationResult.results) {
444
+ return 0;
445
+ }
446
+
447
+ const testConfidences = verificationResult.results.map(testResult =>
448
+ this.calculateConfidence(testResult)
449
+ );
450
+
451
+ return Math.round(testConfidences.reduce((sum, conf) => sum + conf, 0) / testConfidences.length);
452
+ }
453
+
454
+ /**
455
+ * Aggregate test analyses
456
+ * @param {Array} testAnalyses - Test analyses
457
+ * @returns {Object} - Aggregated summary
458
+ */
459
+ aggregateTestAnalyses(testAnalyses) {
460
+ const summary = {
461
+ totalTests: testAnalyses.length,
462
+ successfulTests: testAnalyses.filter(t => t.success).length,
463
+ severityDistribution: {},
464
+ categoryDistribution: {},
465
+ averageConfidence: 0
466
+ };
467
+
468
+ // Calculate distributions
469
+ testAnalyses.forEach(analysis => {
470
+ const severity = analysis.severity;
471
+ const category = analysis.category;
472
+
473
+ summary.severityDistribution[severity] = (summary.severityDistribution[severity] || 0) + 1;
474
+ summary.categoryDistribution[category] = (summary.categoryDistribution[category] || 0) + 1;
475
+ });
476
+
477
+ // Calculate average confidence
478
+ const confidences = testAnalyses.map(t => t.confidence).filter(c => c > 0);
479
+ if (confidences.length > 0) {
480
+ summary.averageConfidence = Math.round(confidences.reduce((sum, conf) => sum + conf, 0) / confidences.length);
481
+ }
482
+
483
+ return summary;
484
+ }
485
+
486
+ /**
487
+ * Categorize performance
488
+ * @param {number} duration - Test duration in milliseconds
489
+ * @returns {string} - Performance category
490
+ */
491
+ categorizePerformance(duration) {
492
+ if (duration < 1000) return 'excellent';
493
+ if (duration < 5000) return 'good';
494
+ if (duration < 15000) return 'acceptable';
495
+ if (duration < 30000) return 'slow';
496
+ return 'very-slow';
497
+ }
498
+
499
+ /**
500
+ * Get test type reliability
501
+ * @param {string} testType - Test type
502
+ * @returns {number} - Reliability score (0-100)
503
+ */
504
+ getTestTypeReliability(testType) {
505
+ const reliability = {
506
+ [VerificationType.FILE_OPERATION]: 90,
507
+ [VerificationType.COMMAND_EXECUTION]: 75,
508
+ [VerificationType.API_CALL]: 80,
509
+ [VerificationType.NETWORK_TEST]: 60
510
+ };
511
+
512
+ return reliability[testType] || 50;
513
+ }
514
+
515
+ /**
516
+ * Check if error is recoverable
517
+ * @param {string} error - Error message
518
+ * @returns {boolean} - Whether error is recoverable
519
+ */
520
+ isRecoverableError(error) {
521
+ const recoverablePatterns = [
522
+ 'timeout',
523
+ 'network',
524
+ 'connection',
525
+ 'temporary'
526
+ ];
527
+
528
+ const errorLower = error.toLowerCase();
529
+ return recoverablePatterns.some(pattern => errorLower.includes(pattern));
530
+ }
531
+
532
+ /**
533
+ * Create batch summary
534
+ * @param {Object} batchResult - Batch result
535
+ * @returns {Object} - Batch summary
536
+ */
537
+ createBatchSummary(batchResult) {
538
+ const summary = {
539
+ totalAgents: batchResult.results ? batchResult.results.length : 0,
540
+ successfulAgents: 0,
541
+ failedAgents: 0,
542
+ totalDuration: batchResult.duration || 0
543
+ };
544
+
545
+ if (batchResult.results) {
546
+ summary.successfulAgents = batchResult.results.filter(r => r.success).length;
547
+ summary.failedAgents = summary.totalAgents - summary.successfulAgents;
548
+ }
549
+
550
+ return summary;
551
+ }
552
+
553
+ /**
554
+ * Identify batch patterns
555
+ * @param {Object} batchResult - Batch result
556
+ * @returns {Array} - Batch patterns
557
+ */
558
+ identifyBatchPatterns(batchResult) {
559
+ const patterns = [];
560
+
561
+ if (batchResult.results) {
562
+ const failures = batchResult.results.filter(r => !r.success);
563
+
564
+ if (failures.length > 0) {
565
+ // Check for common failure categories
566
+ const categories = failures.map(f => this.categorizeResult(f));
567
+ const commonCategories = categories.filter((cat, index) => categories.indexOf(cat) === index);
568
+
569
+ if (commonCategories.length === 1) {
570
+ patterns.push(`consistent-${commonCategories[0]}-failures`);
571
+ }
572
+
573
+ // Check for timeout patterns
574
+ const timeoutFailures = failures.filter(f => this.categorizeResult(f) === 'timeout');
575
+ if (timeoutFailures.length > failures.length / 2) {
576
+ patterns.push('widespread-timeout-issues');
577
+ }
578
+ }
579
+ }
580
+
581
+ return patterns;
582
+ }
583
+
584
+ /**
585
+ * Generate batch recommendations
586
+ * @param {Object} batchResult - Batch result
587
+ * @returns {Array} - Recommendations
588
+ */
589
+ generateBatchRecommendations(batchResult) {
590
+ const recommendations = [];
591
+
592
+ if (batchResult.results) {
593
+ const failures = batchResult.results.filter(r => !r.success);
594
+
595
+ if (failures.length > 0) {
596
+ const patterns = this.identifyBatchPatterns(batchResult);
597
+
598
+ patterns.forEach(pattern => {
599
+ if (pattern.includes('permission')) {
600
+ recommendations.push('Review system-wide permissions and access rights');
601
+ } else if (pattern.includes('timeout')) {
602
+ recommendations.push('Increase timeout values for batch operations');
603
+ } else if (pattern.includes('missing')) {
604
+ recommendations.push('Verify all agent dependencies are properly installed');
605
+ }
606
+ });
607
+
608
+ if (failures.length === batchResult.results.length) {
609
+ recommendations.push('Review system configuration and environment');
610
+ }
611
+ }
612
+ }
613
+
614
+ return recommendations;
615
+ }
616
+
617
+ /**
618
+ * Calculate batch confidence
619
+ * @param {Object} batchResult - Batch result
620
+ * @returns {number} - Confidence score
621
+ */
622
+ calculateBatchConfidence(batchResult) {
623
+ if (!batchResult.results || batchResult.results.length === 0) {
624
+ return 0;
625
+ }
626
+
627
+ const agentConfidences = batchResult.results.map(agentResult =>
628
+ this.calculateAgentConfidence(agentResult)
629
+ ).filter(conf => conf > 0);
630
+
631
+ if (agentConfidences.length === 0) {
632
+ return 0;
633
+ }
634
+
635
+ return Math.round(agentConfidences.reduce((sum, conf) => sum + conf, 0) / agentConfidences.length);
636
+ }
637
+
638
+ /**
639
+ * Aggregate agent analyses
640
+ * @param {Array} agentAnalyses - Agent analyses
641
+ * @returns {Object} - Aggregated summary
642
+ */
643
+ aggregateAgentAnalyses(agentAnalyses) {
644
+ const summary = {
645
+ totalAgents: agentAnalyses.length,
646
+ successfulAgents: agentAnalyses.filter(a => a.overallSuccess).length,
647
+ statusDistribution: {},
648
+ averageConfidence: 0,
649
+ commonIssues: []
650
+ };
651
+
652
+ // Calculate status distribution
653
+ agentAnalyses.forEach(analysis => {
654
+ const status = analysis.status;
655
+ summary.statusDistribution[status] = (summary.statusDistribution[status] || 0) + 1;
656
+ });
657
+
658
+ // Calculate average confidence
659
+ const confidences = agentAnalyses.map(a => a.confidence).filter(c => c > 0);
660
+ if (confidences.length > 0) {
661
+ summary.averageConfidence = Math.round(confidences.reduce((sum, conf) => sum + conf, 0) / confidences.length);
662
+ }
663
+
664
+ // Identify common issues
665
+ const allIssues = agentAnalyses.flatMap(a => a.issues || []);
666
+ const issueTypes = allIssues.map(issue => issue.type);
667
+ const issueCounts = {};
668
+
669
+ issueTypes.forEach(type => {
670
+ issueCounts[type] = (issueCounts[type] || 0) + 1;
671
+ });
672
+
673
+ // Get most common issues
674
+ const sortedIssues = Object.entries(issueCounts)
675
+ .sort(([,a], [,b]) => b - a)
676
+ .slice(0, 3)
677
+ .map(([type, count]) => ({ type, count }));
678
+
679
+ summary.commonIssues = sortedIssues;
680
+
681
+ return summary;
682
+ }
683
+
684
+ /**
685
+ * Get analyzer information
686
+ * @returns {Object} - Analyzer info
687
+ */
688
+ getInfo() {
689
+ return {
690
+ name: 'Verification Result Analyzer',
691
+ version: '1.0.0',
692
+ strictMode: this.strictMode,
693
+ detailedAnalysis: this.detailedAnalysis,
694
+ features: [
695
+ 'test result analysis',
696
+ 'agent result analysis',
697
+ 'batch result analysis',
698
+ 'severity assessment',
699
+ 'recommendation generation',
700
+ 'pattern identification',
701
+ 'confidence scoring'
702
+ ]
703
+ };
704
+ }
705
+ }
706
+
707
+ module.exports = ResultAnalyzer;