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
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RUI Agent Command Parser
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Orchestrates command parsing using modular components.
|
|
5
5
|
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
const TokenParser = require('./parsers/TokenParser');
|
|
9
|
+
const ComponentExtractor = require('./parsers/ComponentExtractor');
|
|
10
|
+
const CommandValidator = require('./parsers/CommandValidator');
|
|
11
|
+
const CommandMapper = require('./parsers/CommandMapper');
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* RUI Agent Command Parser class
|
|
10
15
|
*/
|
|
@@ -18,10 +23,24 @@ class AgentCommandParser {
|
|
|
18
23
|
this.allowShortcuts = options.allowShortcuts !== false;
|
|
19
24
|
this.strictMode = options.strictMode || false;
|
|
20
25
|
|
|
21
|
-
//
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
|
|
26
|
+
// Initialize component modules
|
|
27
|
+
this.tokenParser = new TokenParser();
|
|
28
|
+
this.componentExtractor = new ComponentExtractor({
|
|
29
|
+
allowShortcuts: this.allowShortcuts,
|
|
30
|
+
tokenParser: this.tokenParser
|
|
31
|
+
});
|
|
32
|
+
this.commandValidator = new CommandValidator({
|
|
33
|
+
strictMode: this.strictMode
|
|
34
|
+
});
|
|
35
|
+
this.commandMapper = new CommandMapper({
|
|
36
|
+
caseSensitive: this.caseSensitive,
|
|
37
|
+
allowShortcuts: this.allowShortcuts
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Legacy property access for backward compatibility
|
|
41
|
+
this.commandMap = this.commandMapper.commandMap;
|
|
42
|
+
this.shortcutMap = this.commandMapper.shortcutMap;
|
|
43
|
+
this.parameterDefinitions = this.commandValidator.parameterDefinitions;
|
|
25
44
|
}
|
|
26
45
|
|
|
27
46
|
/**
|
|
@@ -35,11 +54,11 @@ class AgentCommandParser {
|
|
|
35
54
|
}
|
|
36
55
|
|
|
37
56
|
try {
|
|
38
|
-
const tokens = this.tokenize(commandString);
|
|
39
|
-
const { verb, resource, params } = this.extractComponents(tokens);
|
|
57
|
+
const tokens = this.tokenParser.tokenize(commandString);
|
|
58
|
+
const { verb, resource, params } = this.componentExtractor.extractComponents(tokens);
|
|
40
59
|
|
|
41
|
-
const normalizedVerb = this.normalizeVerb(verb);
|
|
42
|
-
const validatedCommand = this.validateCommand(normalizedVerb, resource, params);
|
|
60
|
+
const normalizedVerb = this.commandMapper.normalizeVerb(verb);
|
|
61
|
+
const validatedCommand = this.commandValidator.validateCommand(normalizedVerb, resource, params);
|
|
43
62
|
|
|
44
63
|
return {
|
|
45
64
|
...validatedCommand,
|
|
@@ -58,478 +77,150 @@ class AgentCommandParser {
|
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
/**
|
|
61
|
-
* Tokenize command string
|
|
80
|
+
* Tokenize command string (delegated to TokenParser)
|
|
62
81
|
* @param {string} commandString - Command string to tokenize
|
|
63
82
|
* @returns {Array} - Array of tokens
|
|
64
83
|
*/
|
|
65
84
|
tokenize(commandString) {
|
|
66
|
-
|
|
67
|
-
const tokens = [];
|
|
68
|
-
let current = '';
|
|
69
|
-
let inQuotes = false;
|
|
70
|
-
let quoteChar = '';
|
|
71
|
-
|
|
72
|
-
for (let i = 0; i < commandString.length; i++) {
|
|
73
|
-
const char = commandString[i];
|
|
74
|
-
|
|
75
|
-
if ((char === '"' || char === "'") && !inQuotes) {
|
|
76
|
-
inQuotes = true;
|
|
77
|
-
quoteChar = char;
|
|
78
|
-
} else if (char === quoteChar && inQuotes) {
|
|
79
|
-
inQuotes = false;
|
|
80
|
-
quoteChar = '';
|
|
81
|
-
} else if (char === ' ' && !inQuotes) {
|
|
82
|
-
if (current.trim()) {
|
|
83
|
-
tokens.push(current.trim());
|
|
84
|
-
current = '';
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
current += char;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (current.trim()) {
|
|
92
|
-
tokens.push(current.trim());
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return tokens;
|
|
85
|
+
return this.tokenParser.tokenize(commandString);
|
|
96
86
|
}
|
|
97
87
|
|
|
98
88
|
/**
|
|
99
|
-
* Extract verb, resource, and parameters from tokens
|
|
89
|
+
* Extract verb, resource, and parameters from tokens (delegated to ComponentExtractor)
|
|
100
90
|
* @param {Array} tokens - Command tokens
|
|
101
91
|
* @returns {Object} - Extracted components
|
|
102
92
|
*/
|
|
103
93
|
extractComponents(tokens) {
|
|
104
|
-
|
|
105
|
-
throw new Error('Empty command');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let verb = tokens[0];
|
|
109
|
-
let resource = '';
|
|
110
|
-
let params = {};
|
|
111
|
-
|
|
112
|
-
// Handle shortcuts (2-character commands)
|
|
113
|
-
if (this.allowShortcuts && tokens.length >= 2 && tokens[0].length <= 3) {
|
|
114
|
-
verb = tokens[0];
|
|
115
|
-
resource = tokens[1];
|
|
116
|
-
|
|
117
|
-
// Extract parameters from remaining tokens
|
|
118
|
-
for (let i = 2; i < tokens.length; i++) {
|
|
119
|
-
this.parseParameter(tokens[i], params);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Handle full commands
|
|
123
|
-
else if (tokens.length >= 2) {
|
|
124
|
-
verb = tokens[0];
|
|
125
|
-
resource = tokens[1];
|
|
126
|
-
|
|
127
|
-
// Extract parameters from remaining tokens
|
|
128
|
-
for (let i = 2; i < tokens.length; i++) {
|
|
129
|
-
this.parseParameter(tokens[i], params);
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
// Single token - might be verb only or verb+resource
|
|
133
|
-
const parts = tokens[0].split(/\s+/);
|
|
134
|
-
if (parts.length >= 2) {
|
|
135
|
-
verb = parts[0];
|
|
136
|
-
resource = parts[1];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return { verb, resource, params };
|
|
94
|
+
return this.componentExtractor.extractComponents(tokens);
|
|
141
95
|
}
|
|
142
96
|
|
|
143
97
|
/**
|
|
144
|
-
* Parse parameter token
|
|
98
|
+
* Parse parameter token (delegated to ComponentExtractor)
|
|
145
99
|
* @param {string} token - Parameter token
|
|
146
100
|
* @param {Object} params - Parameters object to update
|
|
147
101
|
*/
|
|
148
102
|
parseParameter(token, params) {
|
|
149
|
-
|
|
150
|
-
if (token.startsWith('--')) {
|
|
151
|
-
const flag = token.substring(2);
|
|
152
|
-
params[flag] = true;
|
|
153
|
-
}
|
|
154
|
-
// Handle short flags (-f)
|
|
155
|
-
else if (token.startsWith('-') && !token.startsWith('--')) {
|
|
156
|
-
const flag = token.substring(1);
|
|
157
|
-
params[flag] = true;
|
|
158
|
-
}
|
|
159
|
-
// Handle key=value parameters (--key=value)
|
|
160
|
-
else if (token.includes('=')) {
|
|
161
|
-
const [key, value] = token.split('=', 2);
|
|
162
|
-
const cleanKey = key.startsWith('--') ? key.substring(2) : key.startsWith('-') ? key.substring(1) : key;
|
|
163
|
-
params[cleanKey] = this.parseValue(value);
|
|
164
|
-
}
|
|
165
|
-
// Handle key value parameters (--key value)
|
|
166
|
-
else if (token.startsWith('--')) {
|
|
167
|
-
const key = token.substring(2);
|
|
168
|
-
params[key] = true; // Will be updated with next token if it's a value
|
|
169
|
-
}
|
|
170
|
-
// Positional parameter
|
|
171
|
-
else {
|
|
172
|
-
if (!params.positional) {
|
|
173
|
-
params.positional = [];
|
|
174
|
-
}
|
|
175
|
-
params.positional.push(this.parseValue(token));
|
|
176
|
-
}
|
|
103
|
+
return this.componentExtractor.parseParameter(token, params);
|
|
177
104
|
}
|
|
178
105
|
|
|
179
106
|
/**
|
|
180
|
-
* Parse parameter value
|
|
107
|
+
* Parse parameter value (delegated to TokenParser)
|
|
181
108
|
* @param {string} value - Raw value
|
|
182
109
|
* @returns {*} - Parsed value
|
|
183
110
|
*/
|
|
184
111
|
parseValue(value) {
|
|
185
|
-
|
|
186
|
-
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
187
|
-
(value.startsWith("'") && value.endsWith("'"))) {
|
|
188
|
-
value = value.slice(1, -1);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Parse as JSON if possible
|
|
192
|
-
try {
|
|
193
|
-
return JSON.parse(value);
|
|
194
|
-
} catch {
|
|
195
|
-
// Return as string if not valid JSON
|
|
196
|
-
return value;
|
|
197
|
-
}
|
|
112
|
+
return this.tokenParser.parseValue(value);
|
|
198
113
|
}
|
|
199
114
|
|
|
200
115
|
/**
|
|
201
|
-
* Normalize verb using command map
|
|
116
|
+
* Normalize verb using command map (delegated to CommandMapper)
|
|
202
117
|
* @param {string} verb - Raw verb
|
|
203
118
|
* @returns {string} - Normalized verb
|
|
204
119
|
*/
|
|
205
120
|
normalizeVerb(verb) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const normalized = this.caseSensitive ? verb : verb.toUpperCase();
|
|
209
|
-
|
|
210
|
-
// Check shortcuts first
|
|
211
|
-
if (this.allowShortcuts && this.shortcutMap[normalized]) {
|
|
212
|
-
return this.shortcutMap[normalized];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Check full commands
|
|
216
|
-
if (this.commandMap[normalized]) {
|
|
217
|
-
return this.commandMap[normalized];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return normalized;
|
|
121
|
+
return this.commandMapper.normalizeVerb(verb);
|
|
221
122
|
}
|
|
222
123
|
|
|
223
124
|
/**
|
|
224
|
-
* Validate command components
|
|
125
|
+
* Validate command components (delegated to CommandValidator)
|
|
225
126
|
* @param {string} verb - Command verb
|
|
226
127
|
* @param {string} resource - Command resource
|
|
227
128
|
* @param {Object} params - Command parameters
|
|
228
129
|
* @returns {Object} - Validation result
|
|
229
130
|
*/
|
|
230
131
|
validateCommand(verb, resource, params) {
|
|
231
|
-
|
|
232
|
-
success: true,
|
|
233
|
-
verb,
|
|
234
|
-
resource,
|
|
235
|
-
params,
|
|
236
|
-
errors: [],
|
|
237
|
-
warnings: []
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// Validate verb
|
|
241
|
-
if (!this.isValidVerb(verb)) {
|
|
242
|
-
validation.success = false;
|
|
243
|
-
validation.errors.push(`Unknown command: ${verb}`);
|
|
244
|
-
return validation;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Validate resource based on verb
|
|
248
|
-
const resourceValidation = this.validateResource(verb, resource);
|
|
249
|
-
if (!resourceValidation.valid) {
|
|
250
|
-
validation.success = false;
|
|
251
|
-
validation.errors.push(...resourceValidation.errors);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Validate parameters
|
|
255
|
-
const paramValidation = this.validateParameters(verb, resource, params);
|
|
256
|
-
if (!paramValidation.valid) {
|
|
257
|
-
validation.success = false;
|
|
258
|
-
validation.errors.push(...paramValidation.errors);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
validation.warnings.push(...paramValidation.warnings);
|
|
262
|
-
|
|
263
|
-
return validation;
|
|
132
|
+
return this.commandValidator.validateCommand(verb, resource, params);
|
|
264
133
|
}
|
|
265
134
|
|
|
266
135
|
/**
|
|
267
|
-
* Check if verb is valid
|
|
136
|
+
* Check if verb is valid (delegated to CommandValidator)
|
|
268
137
|
* @param {string} verb - Verb to check
|
|
269
138
|
* @returns {boolean} - Whether verb is valid
|
|
270
139
|
*/
|
|
271
140
|
isValidVerb(verb) {
|
|
272
|
-
|
|
273
|
-
'GET', 'LIST', 'POST', 'CHECK', 'PUT', 'UPDATE', 'DELETE', 'REMOVE',
|
|
274
|
-
'ENABLE', 'DISABLE', 'STATUS', 'HELP'
|
|
275
|
-
]);
|
|
276
|
-
|
|
277
|
-
return validVerbs.has(verb);
|
|
141
|
+
return this.commandValidator.isValidVerb(verb);
|
|
278
142
|
}
|
|
279
143
|
|
|
280
144
|
/**
|
|
281
|
-
* Validate resource for given verb
|
|
145
|
+
* Validate resource for given verb (delegated to CommandValidator)
|
|
282
146
|
* @param {string} verb - Command verb
|
|
283
147
|
* @param {string} resource - Resource to validate
|
|
284
148
|
* @returns {Object} - Validation result
|
|
285
149
|
*/
|
|
286
150
|
validateResource(verb, resource) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// Verbs that require resource
|
|
290
|
-
const resourceRequiredVerbs = new Set(['GET', 'PUT', 'UPDATE', 'DELETE', 'REMOVE', 'ENABLE', 'DISABLE']);
|
|
291
|
-
|
|
292
|
-
if (resourceRequiredVerbs.has(verb) && !resource) {
|
|
293
|
-
validation.valid = false;
|
|
294
|
-
validation.errors.push('Resource is required for this command');
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Validate resource format
|
|
298
|
-
if (resource && !this.isValidResource(resource)) {
|
|
299
|
-
validation.valid = false;
|
|
300
|
-
validation.errors.push(`Invalid resource: ${resource}`);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return validation;
|
|
151
|
+
return this.commandValidator.validateResource(verb, resource);
|
|
304
152
|
}
|
|
305
153
|
|
|
306
154
|
/**
|
|
307
|
-
* Check if resource is valid
|
|
155
|
+
* Check if resource is valid (delegated to CommandValidator)
|
|
308
156
|
* @param {string} resource - Resource to check
|
|
309
157
|
* @returns {boolean} - Whether resource is valid
|
|
310
158
|
*/
|
|
311
159
|
isValidResource(resource) {
|
|
312
|
-
|
|
313
|
-
return validResources.includes(resource.toLowerCase()) ||
|
|
314
|
-
resource.toLowerCase().startsWith('agent-');
|
|
160
|
+
return this.commandValidator.isValidResource(resource);
|
|
315
161
|
}
|
|
316
162
|
|
|
317
163
|
/**
|
|
318
|
-
* Validate command parameters
|
|
164
|
+
* Validate command parameters (delegated to CommandValidator)
|
|
319
165
|
* @param {string} verb - Command verb
|
|
320
166
|
* @param {string} resource - Command resource
|
|
321
167
|
* @param {Object} params - Parameters to validate
|
|
322
168
|
* @returns {Object} - Validation result
|
|
323
169
|
*/
|
|
324
170
|
validateParameters(verb, resource, params) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
// Get parameter definitions for this verb
|
|
328
|
-
const paramDefs = this.parameterDefinitions[verb] || {};
|
|
329
|
-
|
|
330
|
-
// Validate each parameter
|
|
331
|
-
for (const [paramName, paramValue] of Object.entries(params)) {
|
|
332
|
-
if (paramName === 'positional') continue;
|
|
333
|
-
|
|
334
|
-
const paramDef = paramDefs[paramName];
|
|
335
|
-
if (!paramDef) {
|
|
336
|
-
if (this.strictMode) {
|
|
337
|
-
validation.valid = false;
|
|
338
|
-
validation.errors.push(`Unknown parameter: ${paramName}`);
|
|
339
|
-
}
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// Type validation
|
|
344
|
-
if (paramDef.type && !this.validateParameterType(paramValue, paramDef.type)) {
|
|
345
|
-
validation.valid = false;
|
|
346
|
-
validation.errors.push(`Invalid type for parameter ${paramName}: expected ${paramDef.type}`);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Value validation
|
|
350
|
-
if (paramDef.validValues && !paramDef.validValues.includes(paramValue)) {
|
|
351
|
-
validation.valid = false;
|
|
352
|
-
validation.errors.push(`Invalid value for parameter ${paramName}: ${paramValue}. Valid values: ${paramDef.validValues.join(', ')}`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Check for required parameters
|
|
357
|
-
for (const [paramName, paramDef] of Object.entries(paramDefs)) {
|
|
358
|
-
if (paramDef.required && !(paramName in params)) {
|
|
359
|
-
validation.valid = false;
|
|
360
|
-
validation.errors.push(`Required parameter missing: ${paramName}`);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// Add warnings for special cases
|
|
365
|
-
if (verb === 'DELETE' && !params.confirm) {
|
|
366
|
-
validation.warnings.push('DELETE command requires confirmation (confirm=true)');
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (verb === 'CHECK' && params.timeout && params.timeout < 0) {
|
|
370
|
-
validation.warnings.push('Timeout should be positive');
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return validation;
|
|
171
|
+
return this.commandValidator.validateParameters(verb, resource, params);
|
|
374
172
|
}
|
|
375
173
|
|
|
376
174
|
/**
|
|
377
|
-
* Validate parameter type
|
|
175
|
+
* Validate parameter type (delegated to CommandValidator)
|
|
378
176
|
* @param {*} value - Parameter value
|
|
379
177
|
* @param {string} type - Expected type
|
|
380
178
|
* @returns {boolean} - Whether type is valid
|
|
381
179
|
*/
|
|
382
180
|
validateParameterType(value, type) {
|
|
383
|
-
|
|
384
|
-
case 'boolean':
|
|
385
|
-
return typeof value === 'boolean' || value === true || value === false;
|
|
386
|
-
case 'number':
|
|
387
|
-
return !isNaN(Number(value));
|
|
388
|
-
case 'string':
|
|
389
|
-
return typeof value === 'string';
|
|
390
|
-
case 'array':
|
|
391
|
-
return Array.isArray(value);
|
|
392
|
-
default:
|
|
393
|
-
return true; // Unknown type, assume valid
|
|
394
|
-
}
|
|
181
|
+
return this.commandValidator.validateParameterType(value, type);
|
|
395
182
|
}
|
|
396
183
|
|
|
397
184
|
/**
|
|
398
|
-
* Initialize command mappings
|
|
185
|
+
* Initialize command mappings (delegated to CommandMapper)
|
|
399
186
|
* @returns {Object} - Command map
|
|
400
187
|
*/
|
|
401
188
|
initializeCommandMap() {
|
|
402
|
-
return
|
|
403
|
-
'GET': 'GET',
|
|
404
|
-
'LIST': 'GET',
|
|
405
|
-
'POST': 'POST',
|
|
406
|
-
'CHECK': 'POST',
|
|
407
|
-
'PUT': 'PUT',
|
|
408
|
-
'UPDATE': 'PUT',
|
|
409
|
-
'DELETE': 'DELETE',
|
|
410
|
-
'REMOVE': 'DELETE',
|
|
411
|
-
'ENABLE': 'PUT',
|
|
412
|
-
'DISABLE': 'PUT',
|
|
413
|
-
'STATUS': 'GET',
|
|
414
|
-
'HELP': 'GET'
|
|
415
|
-
};
|
|
189
|
+
return this.commandMapper.initializeCommandMap();
|
|
416
190
|
}
|
|
417
191
|
|
|
418
192
|
/**
|
|
419
|
-
* Initialize shortcut mappings
|
|
193
|
+
* Initialize shortcut mappings (delegated to CommandMapper)
|
|
420
194
|
* @returns {Object} - Shortcut map
|
|
421
195
|
*/
|
|
422
196
|
initializeShortcutMap() {
|
|
423
|
-
return
|
|
424
|
-
'LA': 'GET', // List agents
|
|
425
|
-
'LI': 'GET', // List agents
|
|
426
|
-
'CH': 'POST', // Check agents
|
|
427
|
-
'CA': 'POST', // Check agents
|
|
428
|
-
'GE': 'GET', // Get agent
|
|
429
|
-
'UP': 'PUT', // Update agent
|
|
430
|
-
'EN': 'PUT', // Enable agent
|
|
431
|
-
'DI': 'PUT', // Disable agent
|
|
432
|
-
'RE': 'DELETE', // Remove agent
|
|
433
|
-
'RM': 'DELETE', // Remove agent
|
|
434
|
-
'ST': 'GET', // Status
|
|
435
|
-
'HE': 'GET' // Help
|
|
436
|
-
};
|
|
197
|
+
return this.commandMapper.initializeShortcutMap();
|
|
437
198
|
}
|
|
438
199
|
|
|
439
200
|
/**
|
|
440
|
-
* Initialize parameter definitions
|
|
201
|
+
* Initialize parameter definitions (delegated to CommandValidator)
|
|
441
202
|
* @returns {Object} - Parameter definitions
|
|
442
203
|
*/
|
|
443
204
|
initializeParameterDefinitions() {
|
|
444
|
-
return
|
|
445
|
-
'GET': {
|
|
446
|
-
'includeDisabled': { type: 'boolean', default: false },
|
|
447
|
-
'includeStatus': { type: 'boolean', default: true },
|
|
448
|
-
'includeLogs': { type: 'boolean', default: false },
|
|
449
|
-
'format': { type: 'string', validValues: ['table', 'json', 'csv'] },
|
|
450
|
-
'sort': { type: 'string', validValues: ['name', 'status', 'type', 'priority'] },
|
|
451
|
-
'status': { type: 'string' },
|
|
452
|
-
'limit': { type: 'number' },
|
|
453
|
-
'offset': { type: 'number' }
|
|
454
|
-
},
|
|
455
|
-
'POST': {
|
|
456
|
-
'agentIds': { type: 'array' },
|
|
457
|
-
'forceReinstall': { type: 'boolean', default: false },
|
|
458
|
-
'skipVerification': { type: 'boolean', default: false },
|
|
459
|
-
'timeout': { type: 'number', default: 300000 },
|
|
460
|
-
'parallel': { type: 'boolean', default: true },
|
|
461
|
-
'maxConcurrency': { type: 'number', default: 2 }
|
|
462
|
-
},
|
|
463
|
-
'PUT': {
|
|
464
|
-
'enabled': { type: 'boolean' },
|
|
465
|
-
'status': { type: 'string' },
|
|
466
|
-
'message': { type: 'string' }
|
|
467
|
-
},
|
|
468
|
-
'DELETE': {
|
|
469
|
-
'confirm': { type: 'boolean', required: true }
|
|
470
|
-
}
|
|
471
|
-
};
|
|
205
|
+
return this.commandValidator.initializeParameterDefinitions();
|
|
472
206
|
}
|
|
473
207
|
|
|
474
208
|
/**
|
|
475
|
-
* Get command suggestions
|
|
209
|
+
* Get command suggestions (delegated to CommandMapper)
|
|
476
210
|
* @param {string} partial - Partial command
|
|
477
211
|
* @returns {Array} - Suggestions
|
|
478
212
|
*/
|
|
479
213
|
getSuggestions(partial) {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const normalized = this.caseSensitive ? partial : partial.toUpperCase();
|
|
483
|
-
const suggestions = [];
|
|
484
|
-
|
|
485
|
-
// Command suggestions
|
|
486
|
-
for (const [command, normalizedCommand] of Object.entries(this.commandMap)) {
|
|
487
|
-
if (normalizedCommand.startsWith(normalized)) {
|
|
488
|
-
suggestions.push({
|
|
489
|
-
type: 'command',
|
|
490
|
-
value: command,
|
|
491
|
-
description: this.getCommandDescription(command)
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// Shortcut suggestions
|
|
497
|
-
if (this.allowShortcuts) {
|
|
498
|
-
for (const [shortcut, command] of Object.entries(this.shortcutMap)) {
|
|
499
|
-
if (shortcut.startsWith(normalized)) {
|
|
500
|
-
suggestions.push({
|
|
501
|
-
type: 'shortcut',
|
|
502
|
-
value: shortcut,
|
|
503
|
-
description: this.getCommandDescription(command)
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return suggestions;
|
|
214
|
+
return this.commandMapper.getSuggestions(partial);
|
|
510
215
|
}
|
|
511
216
|
|
|
512
217
|
/**
|
|
513
|
-
* Get command description
|
|
218
|
+
* Get command description (delegated to CommandMapper)
|
|
514
219
|
* @param {string} command - Command
|
|
515
220
|
* @returns {string} - Description
|
|
516
221
|
*/
|
|
517
222
|
getCommandDescription(command) {
|
|
518
|
-
|
|
519
|
-
'GET': 'Get agent or list agents',
|
|
520
|
-
'POST': 'Check agents',
|
|
521
|
-
'PUT': 'Update agent (enable/disable)',
|
|
522
|
-
'DELETE': 'Remove agent',
|
|
523
|
-
'LIST': 'List agents',
|
|
524
|
-
'CHECK': 'Check agents',
|
|
525
|
-
'ENABLE': 'Enable agent',
|
|
526
|
-
'DISABLE': 'Disable agent',
|
|
527
|
-
'REMOVE': 'Remove agent',
|
|
528
|
-
'STATUS': 'Get agent status',
|
|
529
|
-
'HELP': 'Show help'
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
return descriptions[command] || 'Unknown command';
|
|
223
|
+
return this.commandMapper.getCommandDescription(command);
|
|
533
224
|
}
|
|
534
225
|
|
|
535
226
|
/**
|
|
@@ -426,56 +426,26 @@ class AgentResponseFormatter {
|
|
|
426
426
|
*/
|
|
427
427
|
getStatusIcon(status) {
|
|
428
428
|
const icons = {
|
|
429
|
-
'VERIFIED': '✅',
|
|
430
|
-
'
|
|
431
|
-
'INSTALLING': '⏳',
|
|
432
|
-
'VERIFYING': '🔍',
|
|
433
|
-
'NOT_INSTALLED': '❌',
|
|
434
|
-
'ERROR': '🚫',
|
|
435
|
-
'RATE_LIMITED': '⏱️',
|
|
436
|
-
'DISABLED': '🚫'
|
|
429
|
+
'VERIFIED': '✅', 'INSTALLED': '📦', 'INSTALLING': '⏳', 'VERIFYING': '🔍',
|
|
430
|
+
'NOT_INSTALLED': '❌', 'ERROR': '🚫', 'RATE_LIMITED': '⏱️', 'DISABLED': '🚫'
|
|
437
431
|
};
|
|
438
|
-
|
|
439
432
|
return icons[status] || '❓';
|
|
440
433
|
}
|
|
441
434
|
|
|
442
|
-
/**
|
|
443
|
-
* Get status variant for UI
|
|
444
|
-
* @param {string} status - Agent status
|
|
445
|
-
* @returns {string} - Status variant
|
|
446
|
-
*/
|
|
447
435
|
getStatusVariant(status) {
|
|
448
436
|
const variants = {
|
|
449
|
-
'VERIFIED': 'success',
|
|
450
|
-
'
|
|
451
|
-
'INSTALLING': 'warning',
|
|
452
|
-
'VERIFYING': 'warning',
|
|
453
|
-
'NOT_INSTALLED': 'danger',
|
|
454
|
-
'ERROR': 'danger',
|
|
455
|
-
'RATE_LIMITED': 'warning',
|
|
456
|
-
'DISABLED': 'secondary'
|
|
437
|
+
'VERIFIED': 'success', 'INSTALLED': 'info', 'INSTALLING': 'warning', 'VERIFYING': 'warning',
|
|
438
|
+
'NOT_INSTALLED': 'danger', 'ERROR': 'danger', 'RATE_LIMITED': 'warning', 'DISABLED': 'secondary'
|
|
457
439
|
};
|
|
458
|
-
|
|
459
440
|
return variants[status] || 'secondary';
|
|
460
441
|
}
|
|
461
442
|
|
|
462
|
-
/**
|
|
463
|
-
* Get status description
|
|
464
|
-
* @param {string} status - Agent status
|
|
465
|
-
* @returns {string} - Status description
|
|
466
|
-
*/
|
|
467
443
|
getStatusDescription(status) {
|
|
468
444
|
const descriptions = {
|
|
469
|
-
'VERIFIED': 'Verified and ready',
|
|
470
|
-
'
|
|
471
|
-
'
|
|
472
|
-
'VERIFYING': 'Verifying...',
|
|
473
|
-
'NOT_INSTALLED': 'Not installed',
|
|
474
|
-
'ERROR': 'Error occurred',
|
|
475
|
-
'RATE_LIMITED': 'Rate limited',
|
|
476
|
-
'DISABLED': 'Disabled'
|
|
445
|
+
'VERIFIED': 'Verified and ready', 'INSTALLED': 'Installed (not verified)', 'INSTALLING': 'Installing...',
|
|
446
|
+
'VERIFYING': 'Verifying...', 'NOT_INSTALLED': 'Not installed', 'ERROR': 'Error occurred',
|
|
447
|
+
'RATE_LIMITED': 'Rate limited', 'DISABLED': 'Disabled'
|
|
477
448
|
};
|
|
478
|
-
|
|
479
449
|
return descriptions[status] || 'Unknown';
|
|
480
450
|
}
|
|
481
451
|
|
|
@@ -486,32 +456,22 @@ class AgentResponseFormatter {
|
|
|
486
456
|
*/
|
|
487
457
|
getQuickActions(agent) {
|
|
488
458
|
const actions = [];
|
|
489
|
-
|
|
490
459
|
if (agent.enabled) {
|
|
491
460
|
actions.push({ key: 'check', label: 'Check', shortcut: 'ch' });
|
|
492
461
|
}
|
|
493
|
-
|
|
494
462
|
if (agent.status === 'VERIFIED') {
|
|
495
463
|
actions.push({ key: 'logs', label: 'Logs', shortcut: 'lg' });
|
|
496
464
|
}
|
|
497
|
-
|
|
498
465
|
actions.push({ key: 'details', label: 'Details', shortcut: 'ge' });
|
|
499
|
-
|
|
500
466
|
return actions;
|
|
501
467
|
}
|
|
502
468
|
|
|
503
|
-
/**
|
|
504
|
-
* Get primary action for agent
|
|
505
|
-
* @param {Object} agent - Agent object
|
|
506
|
-
* @returns {Object} - Primary action
|
|
507
|
-
*/
|
|
508
469
|
getPrimaryAction(agent) {
|
|
509
470
|
if (agent.enabled && agent.status !== 'VERIFIED') {
|
|
510
471
|
return { key: 'check', label: 'Check Agent', icon: 'play' };
|
|
511
472
|
} else if (agent.status === 'VERIFIED') {
|
|
512
473
|
return { key: 'logs', label: 'View Logs', icon: 'file-text' };
|
|
513
474
|
}
|
|
514
|
-
|
|
515
475
|
return { key: 'details', label: 'View Details', icon: 'info' };
|
|
516
476
|
}
|
|
517
477
|
|