vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850
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/package.json +1 -1
- package/src/agents/AgentCheckDiscoveryService.js +180 -0
- package/src/agents/AgentCheckService.js +18 -261
- package/src/agents/AgentCheckStatisticsService.js +195 -0
- package/src/agents/EnvironmentConfigurationManager.js +31 -380
- package/src/agents/InstallationType.js +19 -6
- package/src/agents/SimpleAgentCheckService.js +472 -0
- package/src/agents/config-managers/ConfigUtils.js +72 -0
- package/src/agents/config-managers/DefaultConfig.js +58 -0
- package/src/agents/config-managers/EnvVarLoader.js +66 -0
- package/src/agents/config-managers/FileConfigLoader.js +124 -0
- package/src/agents/config-managers/TypeConverters.js +61 -0
- package/src/agents/config-managers/VariableMappings.js +92 -0
- package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
- package/src/agents/discovery/AgentDiscoveryService.js +29 -403
- package/src/agents/discovery/agent-validator.js +262 -0
- package/src/agents/discovery/discovery-results.js +176 -0
- package/src/agents/discovery/discovery-scanner.js +268 -0
- package/src/agents/discovery/discovery-utils.js +161 -0
- package/src/agents/discovery/executable-analyzer.js +290 -0
- package/src/agents/discovery/history-manager.js +310 -0
- package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
- package/src/agents/verification/ResultAnalyzer.js +30 -431
- package/src/agents/verification/analysis-utils.js +310 -0
- package/src/agents/verification/batch-analyzer.js +440 -0
- package/src/agents/verification/pattern-recognizer.js +369 -0
- package/src/agents/verification/report-generator.js +320 -0
- package/src/agents/verification/test-analyzer.js +290 -0
- package/src/agents/windows/InstallerFactory.js +4 -0
- package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
- package/src/analysis/analysis-engine.js +314 -0
- package/src/analysis/ast-analyzer.js +342 -0
- package/src/analysis/boundary-detector-refactored.js +378 -0
- package/src/analysis/boundary-detector.js +200 -603
- package/src/analysis/boundary-scanner.js +609 -0
- package/src/analysis/boundary-types.js +118 -0
- package/src/analysis/boundary-utils.js +293 -0
- package/src/analysis/deadline-priority-calculator.js +18 -0
- package/src/analysis/detection-methods.js +347 -0
- package/src/analysis/importance-priority-calculator.js +18 -0
- package/src/analysis/priority/factor-calculators.js +204 -0
- package/src/analysis/priority/factor-helpers.js +71 -0
- package/src/analysis/priority/priority-constants.js +73 -0
- package/src/analysis/priority/priority-factor-calculators.js +301 -0
- package/src/analysis/priority/reasons-generator.js +44 -0
- package/src/analysis/priority-calculator.js +15 -580
- package/src/analysis/strategy-generator.js +16 -66
- package/src/analysis/type-priority-calculator.js +18 -0
- package/src/analysis/urgency-priority-calculator.js +18 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
- package/src/commands/disable-requirement.js +60 -0
- package/src/commands/disable-spec.js +60 -0
- package/src/commands/enable-requirement.js +60 -0
- package/src/commands/enable-spec.js +60 -0
- package/src/commands/registry.js +1 -6
- package/src/commands/requirements.js +8 -2
- package/src/ide-integration/applescript-manager.cjs +9 -24
- package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
- package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
- package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
- package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
- package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
- package/src/ide-integration/cdp-manager.js +28 -573
- package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
- package/src/ide-integration/ide-openers/claude-opener.js +171 -0
- package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
- package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
- package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
- package/src/ide-integration/macos-ide-manager.js +20 -582
- package/src/ide-integration/macos-quota-checker.js +164 -0
- package/src/ide-integration/macos-text-sender.js +19 -38
- package/src/ide-integration/provider-manager.cjs +52 -7
- package/src/index.cjs +6 -0
- package/src/index.js +10 -0
- package/src/llm/direct-llm-manager.cjs +501 -0
- package/src/localization/translations/en-part1.js +363 -0
- package/src/localization/translations/en-part2.js +320 -0
- package/src/localization/translations/en.js +4 -687
- package/src/localization/translations/es-part1.js +363 -0
- package/src/localization/translations/es-part2.js +320 -0
- package/src/localization/translations/es.js +4 -688
- package/src/models/file-analysis-collection.js +139 -0
- package/src/models/file-analysis-metrics.js +50 -0
- package/src/models/file-analysis.js +15 -262
- package/src/models/plan-manager.js +410 -0
- package/src/models/refactoring-models.js +380 -0
- package/src/models/refactoring-plan-refactored.js +81 -0
- package/src/models/refactoring-plan.js +2 -663
- package/src/monitoring/alert-system.js +4 -45
- package/src/monitoring/continuous-scan-notifications.js +37 -191
- package/src/monitoring/notification-handlers/base-handler.js +58 -0
- package/src/monitoring/notification-handlers/error-handler.js +36 -0
- package/src/monitoring/notification-handlers/index.js +21 -0
- package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
- package/src/monitoring/notification-handlers/progress-handler.js +48 -0
- package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
- package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
- package/src/provider-registry.js +8 -0
- package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
- package/src/refactoring/boundary/boundary-detector.js +26 -596
- package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
- package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
- package/src/refactoring/boundary/detectors/class-detector.js +247 -0
- package/src/refactoring/boundary/detectors/config-detector.js +270 -0
- package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
- package/src/refactoring/boundary/detectors/function-detector.js +248 -0
- package/src/refactoring/boundary/detectors/module-detector.js +249 -0
- package/src/refactoring/boundary/detectors/object-detector.js +247 -0
- package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
- package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
- package/src/refactoring/circular-dependency-resolver-original.js +16 -76
- package/src/refactoring/code-mover-refactored.js +309 -0
- package/src/refactoring/code-mover.js +48 -355
- package/src/refactoring/execution-status.js +18 -0
- package/src/refactoring/execution-strategies.js +172 -0
- package/src/refactoring/file-splitter-core.js +568 -0
- package/src/refactoring/file-splitter-types.js +136 -0
- package/src/refactoring/file-splitter.js +2 -682
- package/src/refactoring/functionality-validator.js +11 -51
- package/src/refactoring/import-manager-refactored.js +385 -0
- package/src/refactoring/import-manager.js +112 -487
- package/src/refactoring/import-models.js +189 -0
- package/src/refactoring/import-parser.js +306 -0
- package/src/refactoring/move-executor.js +431 -0
- package/src/refactoring/move-utils.js +368 -0
- package/src/refactoring/operation-executor.js +76 -0
- package/src/refactoring/plan-creator.js +36 -0
- package/src/refactoring/plan-executor.js +143 -0
- package/src/refactoring/plan-validator.js +68 -0
- package/src/refactoring/refactoring-executor-result.js +70 -0
- package/src/refactoring/refactoring-executor.js +34 -569
- package/src/refactoring/refactoring-operation.js +94 -0
- package/src/refactoring/refactoring-plan.js +69 -0
- package/src/refactoring/refactoring-rollback.js +22 -527
- package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
- package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
- package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
- package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
- package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
- package/src/refactoring/test-validator.js +32 -448
- package/src/refactoring/validation/baseline-runner.js +71 -0
- package/src/refactoring/validation/report-generator.js +136 -0
- package/src/refactoring/validation/result-comparator.js +92 -0
- package/src/refactoring/validation/test-suite.js +59 -0
- package/src/refactoring/validation/test-validation-result.js +83 -0
- package/src/refactoring/validation/validation-runner.js +95 -0
- package/src/refactoring/validation/validation-status.js +18 -0
- package/src/rui/commands/AgentCommandParser.js +60 -369
- package/src/rui/commands/AgentResponseFormatter.js +7 -47
- package/src/rui/commands/parsers/CommandMapper.js +148 -0
- package/src/rui/commands/parsers/CommandValidator.js +228 -0
- package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
- package/src/rui/commands/parsers/TokenParser.js +69 -0
- package/src/rui/commands/parsers/tokenizer.js +153 -0
- package/src/utils/current-requirement-operations.js +50 -1
- package/src/utils/report-generator.js +18 -514
- package/src/utils/report-generators/analysis-generator.js +115 -0
- package/src/utils/report-generators/base-generator.js +141 -0
- package/src/utils/report-generators/compliance-generator.js +41 -0
- package/src/utils/report-generators/format-handlers.js +185 -0
- package/src/utils/report-generators/refactoring-generator.js +46 -0
- package/src/utils/report-generators/validation-generator.js +63 -0
- package/src/utils/requirement-enable-disable.js +265 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
- package/src/utils/requirement-helpers/requirement-mover.js +88 -1
- package/src/utils/requirement-helpers.js +5 -2
- package/src/utils/smoke-test-cli.js +45 -8
- package/src/utils/specification-enable-disable.js +122 -0
- package/src/utils/specification-helpers.js +30 -4
- package/src/utils/specification-migration.js +5 -5
- package/src/utils/test-comparator.js +118 -0
- package/src/utils/test-config.js +54 -0
- package/src/utils/test-executor.js +133 -0
- package/src/utils/test-parser.js +215 -0
- package/src/utils/test-runner-baseline.js +63 -0
- package/src/utils/test-runner-core.js +98 -0
- package/src/utils/test-runner-report.js +39 -0
- package/src/utils/test-runner-validation.js +71 -0
- package/src/utils/test-runner.js +11 -535
- package/src/validation/comparison-analyzer.js +333 -0
- package/src/validation/compliance-reporter-new.js +282 -0
- package/src/validation/compliance-reporter-refactored.js +344 -0
- package/src/validation/compliance-reporter.js +278 -591
- package/src/validation/compliance-utils.js +278 -0
- package/src/validation/html-generator.js +446 -0
- package/src/validation/metrics/category-calculator.js +137 -0
- package/src/validation/metrics/metrics-helpers.js +155 -0
- package/src/validation/metrics/overview-calculator.js +85 -0
- package/src/validation/metrics/overview-metrics.js +41 -0
- package/src/validation/metrics/quality-calculator.js +166 -0
- package/src/validation/metrics/size-calculator.js +69 -0
- package/src/validation/metrics-calculator.js +27 -551
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Discovery - History Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages discovery history and status tracking.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Record discovery operation in history
|
|
9
|
+
* @param {string} operation - Operation type
|
|
10
|
+
* @param {Object} details - Operation details
|
|
11
|
+
* @param {Object} fileManager - File manager instance
|
|
12
|
+
* @param {Object} logger - Logger instance
|
|
13
|
+
*/
|
|
14
|
+
async function recordDiscoveryOperation(operation, details, fileManager, logger) {
|
|
15
|
+
const historyEntry = {
|
|
16
|
+
timestamp: new Date().toISOString(),
|
|
17
|
+
operation,
|
|
18
|
+
...details
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let history = [];
|
|
22
|
+
if (fileManager) {
|
|
23
|
+
try {
|
|
24
|
+
const historyData = await fileManager.readFile('discovery-history');
|
|
25
|
+
history = JSON.parse(historyData || '[]');
|
|
26
|
+
} catch (error) {
|
|
27
|
+
// File doesn't exist yet, start with empty history
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
history.push(historyEntry);
|
|
32
|
+
|
|
33
|
+
// Keep only last 100 entries
|
|
34
|
+
if (history.length > 100) {
|
|
35
|
+
history = history.slice(-100);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (fileManager) {
|
|
39
|
+
await fileManager.writeFile('discovery-history', JSON.stringify(history, null, 2));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (logger) {
|
|
43
|
+
logger.info('Discovery operation recorded', {
|
|
44
|
+
operation,
|
|
45
|
+
details
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get discovery status
|
|
52
|
+
* @param {Object} fileManager - File manager instance
|
|
53
|
+
* @returns {Promise<Object>} - Discovery status
|
|
54
|
+
*/
|
|
55
|
+
async function getDiscoveryStatus(fileManager) {
|
|
56
|
+
try {
|
|
57
|
+
if (fileManager) {
|
|
58
|
+
const statusData = await fileManager.readFile('discovery-status');
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
status: JSON.parse(statusData || '{}')
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
error: 'Discovery status file not found'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get discovery history
|
|
74
|
+
* @param {Object} fileManager - File manager instance
|
|
75
|
+
* @returns {Promise<Object>} - Discovery history
|
|
76
|
+
*/
|
|
77
|
+
async function getDiscoveryHistory(fileManager) {
|
|
78
|
+
try {
|
|
79
|
+
if (fileManager) {
|
|
80
|
+
const historyData = await fileManager.readFile('discovery-history');
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
history: JSON.parse(historyData || '[]')
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
success: false,
|
|
89
|
+
error: 'Discovery history file not found'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Update discovery status
|
|
96
|
+
* @param {Array} validAgents - Valid agents
|
|
97
|
+
* @param {number} totalDiscovered - Total discovered count
|
|
98
|
+
* @param {number} duplicateCount - Duplicate count
|
|
99
|
+
* @param {Array} warnings - Warnings array
|
|
100
|
+
* @param {Array} errors - Errors array
|
|
101
|
+
* @param {Object} fileManager - File manager instance
|
|
102
|
+
* @param {Object} logger - Logger instance
|
|
103
|
+
*/
|
|
104
|
+
async function updateDiscoveryStatus(validAgents, totalDiscovered, duplicateCount, warnings, errors, fileManager, logger) {
|
|
105
|
+
const status = {
|
|
106
|
+
lastDiscovery: new Date().toISOString(),
|
|
107
|
+
totalDiscovered,
|
|
108
|
+
validAgents: validAgents.length,
|
|
109
|
+
duplicates: duplicateCount,
|
|
110
|
+
warnings: warnings.length,
|
|
111
|
+
errors: errors.length,
|
|
112
|
+
agents: validAgents.map(agent => ({
|
|
113
|
+
id: agent.id,
|
|
114
|
+
name: agent.name,
|
|
115
|
+
type: agent.type,
|
|
116
|
+
version: agent.version,
|
|
117
|
+
path: agent.path
|
|
118
|
+
}))
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
if (fileManager) {
|
|
122
|
+
await fileManager.writeFile('discovery-status', JSON.stringify(status, null, 2));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (logger) {
|
|
126
|
+
logger.info('Discovery status updated', {
|
|
127
|
+
totalDiscovered,
|
|
128
|
+
validAgents: validAgents.length,
|
|
129
|
+
duplicates: duplicateCount
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Clear discovery history
|
|
136
|
+
* @param {Object} fileManager - File manager instance
|
|
137
|
+
* @param {Object} logger - Logger instance
|
|
138
|
+
*/
|
|
139
|
+
async function clearDiscoveryHistory(fileManager, logger) {
|
|
140
|
+
try {
|
|
141
|
+
if (fileManager) {
|
|
142
|
+
await fileManager.writeFile('discovery-history', '[]');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (logger) {
|
|
146
|
+
logger.info('Discovery history cleared');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
success: true,
|
|
151
|
+
message: 'Discovery history cleared successfully'
|
|
152
|
+
};
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (logger) {
|
|
155
|
+
logger.error('Failed to clear discovery history', {
|
|
156
|
+
error: error.message
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: error.message
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get discovery statistics
|
|
169
|
+
* @param {Object} fileManager - File manager instance
|
|
170
|
+
* @returns {Promise<Object>} - Discovery statistics
|
|
171
|
+
*/
|
|
172
|
+
async function getDiscoveryStatistics(fileManager) {
|
|
173
|
+
try {
|
|
174
|
+
const historyResult = await getDiscoveryHistory(fileManager);
|
|
175
|
+
const statusResult = await getDiscoveryStatus(fileManager);
|
|
176
|
+
|
|
177
|
+
if (!historyResult.success || !statusResult.success) {
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
error: 'Failed to retrieve discovery data'
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const history = historyResult.history;
|
|
185
|
+
const status = statusResult.status;
|
|
186
|
+
|
|
187
|
+
// Calculate statistics
|
|
188
|
+
const stats = {
|
|
189
|
+
totalOperations: history.length,
|
|
190
|
+
lastDiscovery: status.lastDiscovery,
|
|
191
|
+
totalAgentsDiscovered: status.totalDiscovered || 0,
|
|
192
|
+
validAgents: status.validAgents || 0,
|
|
193
|
+
duplicateRate: status.totalDiscovered > 0 ?
|
|
194
|
+
((status.duplicates || 0) / status.totalDiscovered * 100).toFixed(2) + '%' : '0%',
|
|
195
|
+
agentTypes: {},
|
|
196
|
+
recentOperations: history.slice(-10).reverse()
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Count agent types
|
|
200
|
+
if (status.agents) {
|
|
201
|
+
for (const agent of status.agents) {
|
|
202
|
+
stats.agentTypes[agent.type] = (stats.agentTypes[agent.type] || 0) + 1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Calculate operation frequency
|
|
207
|
+
const operationCounts = {};
|
|
208
|
+
for (const operation of history) {
|
|
209
|
+
operationCounts[operation.operation] = (operationCounts[operation.operation] || 0) + 1;
|
|
210
|
+
}
|
|
211
|
+
stats.operationFrequency = operationCounts;
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
success: true,
|
|
215
|
+
statistics: stats
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return {
|
|
219
|
+
success: false,
|
|
220
|
+
error: error.message
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Export discovery data
|
|
227
|
+
* @param {Object} fileManager - File manager instance
|
|
228
|
+
* @param {string} format - Export format ('json' or 'csv')
|
|
229
|
+
* @returns {Promise<Object>} - Export result
|
|
230
|
+
*/
|
|
231
|
+
async function exportDiscoveryData(fileManager, format = 'json') {
|
|
232
|
+
try {
|
|
233
|
+
const historyResult = await getDiscoveryHistory(fileManager);
|
|
234
|
+
const statusResult = await getDiscoveryStatus(fileManager);
|
|
235
|
+
|
|
236
|
+
if (!historyResult.success || !statusResult.success) {
|
|
237
|
+
return {
|
|
238
|
+
success: false,
|
|
239
|
+
error: 'Failed to retrieve discovery data for export'
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const exportData = {
|
|
244
|
+
exportedAt: new Date().toISOString(),
|
|
245
|
+
format,
|
|
246
|
+
status: statusResult.status,
|
|
247
|
+
history: historyResult.history
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
let content;
|
|
251
|
+
let filename;
|
|
252
|
+
|
|
253
|
+
if (format === 'csv') {
|
|
254
|
+
content = convertToCSV(exportData);
|
|
255
|
+
filename = `discovery-export-${Date.now()}.csv`;
|
|
256
|
+
} else {
|
|
257
|
+
content = JSON.stringify(exportData, null, 2);
|
|
258
|
+
filename = `discovery-export-${Date.now()}.json`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (fileManager) {
|
|
262
|
+
await fileManager.writeFile(filename, content);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
success: true,
|
|
267
|
+
filename,
|
|
268
|
+
format,
|
|
269
|
+
size: content.length
|
|
270
|
+
};
|
|
271
|
+
} catch (error) {
|
|
272
|
+
return {
|
|
273
|
+
success: false,
|
|
274
|
+
error: error.message
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Convert discovery data to CSV format
|
|
281
|
+
* @param {Object} data - Discovery data
|
|
282
|
+
* @returns {string} - CSV content
|
|
283
|
+
*/
|
|
284
|
+
function convertToCSV(data) {
|
|
285
|
+
const headers = ['timestamp', 'operation', 'agentId', 'agentName', 'details'];
|
|
286
|
+
const rows = [headers.join(',')];
|
|
287
|
+
|
|
288
|
+
for (const entry of data.history) {
|
|
289
|
+
const row = [
|
|
290
|
+
entry.timestamp || '',
|
|
291
|
+
entry.operation || '',
|
|
292
|
+
entry.agentId || '',
|
|
293
|
+
entry.agentName || '',
|
|
294
|
+
JSON.stringify(entry.details || {})
|
|
295
|
+
];
|
|
296
|
+
rows.push(row.join(','));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return rows.join('\n');
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
module.exports = {
|
|
303
|
+
recordDiscoveryOperation,
|
|
304
|
+
getDiscoveryStatus,
|
|
305
|
+
getDiscoveryHistory,
|
|
306
|
+
updateDiscoveryStatus,
|
|
307
|
+
clearDiscoveryHistory,
|
|
308
|
+
getDiscoveryStatistics,
|
|
309
|
+
exportDiscoveryData
|
|
310
|
+
};
|
|
@@ -0,0 +1,341 @@
|
|
|
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
|
+
const {
|
|
11
|
+
determineSeverity,
|
|
12
|
+
categorizeResult,
|
|
13
|
+
generateRecommendations,
|
|
14
|
+
calculateConfidence,
|
|
15
|
+
analyzeDetails,
|
|
16
|
+
identifyPatterns,
|
|
17
|
+
identifyRiskFactors
|
|
18
|
+
} = require('./analysis-utils');
|
|
19
|
+
const ReportGenerator = require('./report-generator');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Verification result analyzer class
|
|
23
|
+
*/
|
|
24
|
+
class ResultAnalyzer {
|
|
25
|
+
/**
|
|
26
|
+
* Create result analyzer instance
|
|
27
|
+
* @param {Object} options - Analyzer options
|
|
28
|
+
*/
|
|
29
|
+
constructor(options = {}) {
|
|
30
|
+
this.logger = options.logger || null;
|
|
31
|
+
this.strictMode = options.strictMode || false;
|
|
32
|
+
this.detailedAnalysis = options.detailedAnalysis !== false;
|
|
33
|
+
this.reportGenerator = new ReportGenerator({
|
|
34
|
+
logger: this.logger,
|
|
35
|
+
includeDetails: this.detailedAnalysis,
|
|
36
|
+
format: options.reportFormat || 'json'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Analyze single test result
|
|
42
|
+
* @param {Object} testResult - Test result to analyze
|
|
43
|
+
* @returns {Object} - Analysis result
|
|
44
|
+
*/
|
|
45
|
+
analyzeTestResult(testResult) {
|
|
46
|
+
const analysis = {
|
|
47
|
+
testId: testResult.testId,
|
|
48
|
+
success: testResult.success,
|
|
49
|
+
severity: determineSeverity(testResult),
|
|
50
|
+
category: categorizeResult(testResult),
|
|
51
|
+
recommendations: generateRecommendations(testResult),
|
|
52
|
+
confidence: calculateConfidence(testResult)
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Add detailed analysis if enabled
|
|
56
|
+
if (this.detailedAnalysis) {
|
|
57
|
+
analysis.details = analyzeDetails(testResult);
|
|
58
|
+
analysis.patterns = identifyPatterns(testResult);
|
|
59
|
+
analysis.riskFactors = identifyRiskFactors(testResult);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return analysis;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Analyze multiple test results
|
|
67
|
+
* @param {Array} testResults - Array of test results
|
|
68
|
+
* @returns {Object} - Batch analysis result
|
|
69
|
+
*/
|
|
70
|
+
analyzeBatchResults(testResults) {
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
if (this.logger) {
|
|
75
|
+
this.logger.info('Starting batch result analysis', {
|
|
76
|
+
resultCount: testResults.length,
|
|
77
|
+
strictMode: this.strictMode
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const individualAnalyses = testResults.map(result =>
|
|
82
|
+
this.analyzeTestResult(result)
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const batchAnalysis = {
|
|
86
|
+
metadata: {
|
|
87
|
+
analyzedAt: new Date().toISOString(),
|
|
88
|
+
totalResults: testResults.length,
|
|
89
|
+
analysisDuration: 0,
|
|
90
|
+
strictMode: this.strictMode
|
|
91
|
+
},
|
|
92
|
+
summary: this.generateBatchSummary(individualAnalyses),
|
|
93
|
+
individualResults: individualAnalyses,
|
|
94
|
+
recommendations: this.generateBatchRecommendations(individualAnalyses)
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
batchAnalysis.metadata.analysisDuration = Date.now() - startTime;
|
|
98
|
+
|
|
99
|
+
if (this.logger) {
|
|
100
|
+
this.logger.info('Batch analysis completed', {
|
|
101
|
+
duration: batchAnalysis.metadata.analysisDuration,
|
|
102
|
+
criticalIssues: batchAnalysis.summary.criticalIssues,
|
|
103
|
+
successRate: batchAnalysis.summary.successRate
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return batchAnalysis;
|
|
108
|
+
|
|
109
|
+
} catch (error) {
|
|
110
|
+
const duration = Date.now() - startTime;
|
|
111
|
+
|
|
112
|
+
if (this.logger) {
|
|
113
|
+
this.logger.error('Batch analysis failed', {
|
|
114
|
+
error: error.message,
|
|
115
|
+
duration
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
metadata: {
|
|
121
|
+
analyzedAt: new Date().toISOString(),
|
|
122
|
+
totalResults: testResults.length,
|
|
123
|
+
analysisDuration: duration,
|
|
124
|
+
strictMode: this.strictMode,
|
|
125
|
+
error: error.message
|
|
126
|
+
},
|
|
127
|
+
error: error.message,
|
|
128
|
+
success: false
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generate batch analysis summary
|
|
135
|
+
* @param {Array} analyses - Array of individual analyses
|
|
136
|
+
* @returns {Object} - Batch summary
|
|
137
|
+
*/
|
|
138
|
+
generateBatchSummary(analyses) {
|
|
139
|
+
const summary = {
|
|
140
|
+
totalTests: analyses.length,
|
|
141
|
+
successfulTests: 0,
|
|
142
|
+
failedTests: 0,
|
|
143
|
+
criticalIssues: 0,
|
|
144
|
+
warningIssues: 0,
|
|
145
|
+
testTypes: {},
|
|
146
|
+
severityDistribution: {
|
|
147
|
+
critical: 0,
|
|
148
|
+
error: 0,
|
|
149
|
+
warning: 0,
|
|
150
|
+
info: 0
|
|
151
|
+
},
|
|
152
|
+
averageConfidence: 0
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
let totalConfidence = 0;
|
|
156
|
+
|
|
157
|
+
analyses.forEach(analysis => {
|
|
158
|
+
// Count success/failure
|
|
159
|
+
if (analysis.success) {
|
|
160
|
+
summary.successfulTests++;
|
|
161
|
+
} else {
|
|
162
|
+
summary.failedTests++;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Count severity
|
|
166
|
+
summary.severityDistribution[analysis.severity]++;
|
|
167
|
+
|
|
168
|
+
// Count critical issues
|
|
169
|
+
if (analysis.severity === 'critical') {
|
|
170
|
+
summary.criticalIssues++;
|
|
171
|
+
} else if (analysis.severity === 'warning') {
|
|
172
|
+
summary.warningIssues++;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Count test types
|
|
176
|
+
const testType = analysis.testId ? analysis.testId.split('-')[0] : 'unknown';
|
|
177
|
+
summary.testTypes[testType] = (summary.testTypes[testType] || 0) + 1;
|
|
178
|
+
|
|
179
|
+
// Accumulate confidence
|
|
180
|
+
totalConfidence += analysis.confidence;
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Calculate averages and rates
|
|
184
|
+
summary.averageConfidence = analyses.length > 0 ? (totalConfidence / analyses.length).toFixed(3) : 0;
|
|
185
|
+
summary.successRate = analyses.length > 0 ? (summary.successfulTests / analyses.length * 100).toFixed(2) : 0;
|
|
186
|
+
summary.failureRate = analyses.length > 0 ? (summary.failedTests / analyses.length * 100).toFixed(2) : 0;
|
|
187
|
+
|
|
188
|
+
return summary;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Generate batch recommendations
|
|
193
|
+
* @param {Array} analyses - Array of individual analyses
|
|
194
|
+
* @returns {Array} - Batch recommendations
|
|
195
|
+
*/
|
|
196
|
+
generateBatchRecommendations(analyses) {
|
|
197
|
+
const recommendations = [];
|
|
198
|
+
const failedAnalyses = analyses.filter(a => !a.success);
|
|
199
|
+
|
|
200
|
+
// Analyze common failure patterns
|
|
201
|
+
const failureCategories = {};
|
|
202
|
+
failedAnalyses.forEach(analysis => {
|
|
203
|
+
const category = analysis.category;
|
|
204
|
+
failureCategories[category] = (failureCategories[category] || 0) + 1;
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// Generate recommendations based on failure patterns
|
|
208
|
+
Object.entries(failureCategories).forEach(([category, count]) => {
|
|
209
|
+
if (count > 0) {
|
|
210
|
+
const priority = count > 3 ? 'critical' : count > 1 ? 'high' : 'medium';
|
|
211
|
+
recommendations.push({
|
|
212
|
+
type: 'action',
|
|
213
|
+
priority,
|
|
214
|
+
category,
|
|
215
|
+
count,
|
|
216
|
+
message: `${count} ${category.replace('_', ' ')} failures detected`,
|
|
217
|
+
action: `address_${category}_issues`
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Add confidence-based recommendations
|
|
223
|
+
const lowConfidenceAnalyses = analyses.filter(a => a.confidence < 0.5);
|
|
224
|
+
if (lowConfidenceAnalyses.length > 0) {
|
|
225
|
+
recommendations.push({
|
|
226
|
+
type: 'quality',
|
|
227
|
+
priority: 'medium',
|
|
228
|
+
message: `${lowConfidenceAnalyses.length} tests with low confidence detected`,
|
|
229
|
+
action: 'improve_test_reliability'
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Sort by priority and relevance
|
|
234
|
+
recommendations.sort((a, b) => {
|
|
235
|
+
const priorityOrder = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
236
|
+
const scoreA = (priorityOrder[a.priority] || 0) + (a.count || 0);
|
|
237
|
+
const scoreB = (priorityOrder[b.priority] || 0) + (b.count || 0);
|
|
238
|
+
return scoreB - scoreA;
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return recommendations.slice(0, 10); // Limit to top 10 recommendations
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Generate and export analysis report
|
|
246
|
+
* @param {Array} testResults - Array of test results
|
|
247
|
+
* @param {string} outputPath - Output file path
|
|
248
|
+
* @returns {Promise<Object>} - Analysis result and export status
|
|
249
|
+
*/
|
|
250
|
+
async generateAndExportReport(testResults, outputPath) {
|
|
251
|
+
try {
|
|
252
|
+
const analysis = this.analyzeBatchResults(testResults);
|
|
253
|
+
const report = this.reportGenerator.generateReport(testResults, {
|
|
254
|
+
analyzerOptions: {
|
|
255
|
+
strictMode: this.strictMode,
|
|
256
|
+
detailedAnalysis: this.detailedAnalysis
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
await this.reportGenerator.exportToFile(report, outputPath);
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
success: true,
|
|
264
|
+
analysis,
|
|
265
|
+
reportPath: outputPath,
|
|
266
|
+
summary: analysis.summary
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
} catch (error) {
|
|
270
|
+
if (this.logger) {
|
|
271
|
+
this.logger.error('Failed to generate and export report', {
|
|
272
|
+
outputPath,
|
|
273
|
+
error: error.message
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
success: false,
|
|
279
|
+
error: error.message,
|
|
280
|
+
outputPath
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Get analyzer information
|
|
287
|
+
* @returns {Object} - Analyzer info
|
|
288
|
+
*/
|
|
289
|
+
getAnalyzerInfo() {
|
|
290
|
+
return {
|
|
291
|
+
strictMode: this.strictMode,
|
|
292
|
+
detailedAnalysis: this.detailedAnalysis,
|
|
293
|
+
reportFormat: this.reportGenerator.format,
|
|
294
|
+
features: [
|
|
295
|
+
'individual test analysis',
|
|
296
|
+
'batch analysis',
|
|
297
|
+
'severity assessment',
|
|
298
|
+
'recommendation generation',
|
|
299
|
+
'pattern identification',
|
|
300
|
+
'risk assessment',
|
|
301
|
+
'report generation'
|
|
302
|
+
],
|
|
303
|
+
capabilities: [
|
|
304
|
+
'multi-format reports',
|
|
305
|
+
'confidence scoring',
|
|
306
|
+
'trend analysis',
|
|
307
|
+
'batch processing'
|
|
308
|
+
]
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Create analyzer with default configuration
|
|
314
|
+
* @param {Object} config - Configuration overrides
|
|
315
|
+
* @returns {ResultAnalyzer} - Analyzer instance
|
|
316
|
+
*/
|
|
317
|
+
static createDefault(config = {}) {
|
|
318
|
+
return new ResultAnalyzer({
|
|
319
|
+
strictMode: false,
|
|
320
|
+
detailedAnalysis: true,
|
|
321
|
+
reportFormat: 'json',
|
|
322
|
+
...config
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Create analyzer for strict analysis
|
|
328
|
+
* @param {Object} config - Configuration overrides
|
|
329
|
+
* @returns {ResultAnalyzer} - Strict analyzer instance
|
|
330
|
+
*/
|
|
331
|
+
static createStrict(config = {}) {
|
|
332
|
+
return new ResultAnalyzer({
|
|
333
|
+
strictMode: true,
|
|
334
|
+
detailedAnalysis: true,
|
|
335
|
+
reportFormat: 'json',
|
|
336
|
+
...config
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
module.exports = ResultAnalyzer;
|