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,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Configuration Loader Module
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and saving configuration files.
|
|
5
|
+
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs').promises;
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Load configuration from override file
|
|
13
|
+
* @param {string} overrideFile - Path to override file
|
|
14
|
+
* @param {Object} logger - Logger instance
|
|
15
|
+
* @returns {Promise<Object>} - Override configuration
|
|
16
|
+
*/
|
|
17
|
+
async function loadOverrideFile(overrideFile, logger) {
|
|
18
|
+
try {
|
|
19
|
+
const exists = await fs.access(overrideFile).then(() => true).catch(() => false);
|
|
20
|
+
if (!exists) return {};
|
|
21
|
+
|
|
22
|
+
const content = await fs.readFile(overrideFile, 'utf8');
|
|
23
|
+
const config = JSON.parse(content);
|
|
24
|
+
|
|
25
|
+
if (logger) {
|
|
26
|
+
logger.debug('Loaded override file configuration', {
|
|
27
|
+
file: overrideFile,
|
|
28
|
+
keys: Object.keys(config)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return config;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (logger) {
|
|
35
|
+
logger.warn('Failed to load override file', {
|
|
36
|
+
file: overrideFile,
|
|
37
|
+
error: error.message
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Load configuration from file
|
|
46
|
+
* @param {string} filePath - Path to config file
|
|
47
|
+
* @param {Object} logger - Logger instance
|
|
48
|
+
* @returns {Promise<Object>} - File configuration
|
|
49
|
+
*/
|
|
50
|
+
async function loadConfigFile(filePath, logger) {
|
|
51
|
+
try {
|
|
52
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
53
|
+
const config = JSON.parse(content);
|
|
54
|
+
|
|
55
|
+
if (logger) {
|
|
56
|
+
logger.debug('Loaded config file', {
|
|
57
|
+
file: filePath,
|
|
58
|
+
keys: Object.keys(config)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return config;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (logger) {
|
|
65
|
+
logger.warn('Failed to load config file', {
|
|
66
|
+
file: filePath,
|
|
67
|
+
error: error.message
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Save configuration to file
|
|
76
|
+
* @param {string} filePath - Path to save file
|
|
77
|
+
* @param {Object} config - Configuration to save
|
|
78
|
+
* @param {Object} logger - Logger instance
|
|
79
|
+
* @returns {Promise<Object>} - Save result
|
|
80
|
+
*/
|
|
81
|
+
async function saveConfigFile(filePath, config, logger) {
|
|
82
|
+
const result = {
|
|
83
|
+
success: false,
|
|
84
|
+
error: null,
|
|
85
|
+
filePath
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
// Ensure directory exists
|
|
90
|
+
const dir = path.dirname(filePath);
|
|
91
|
+
await fs.mkdir(dir, { recursive: true });
|
|
92
|
+
|
|
93
|
+
// Save configuration
|
|
94
|
+
const content = JSON.stringify(config, null, 2);
|
|
95
|
+
await fs.writeFile(filePath, content, 'utf8');
|
|
96
|
+
|
|
97
|
+
result.success = true;
|
|
98
|
+
|
|
99
|
+
if (logger) {
|
|
100
|
+
logger.info('Configuration saved successfully', {
|
|
101
|
+
file: filePath,
|
|
102
|
+
keys: Object.keys(config)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
} catch (error) {
|
|
107
|
+
result.error = error.message;
|
|
108
|
+
|
|
109
|
+
if (logger) {
|
|
110
|
+
logger.error('Failed to save configuration', {
|
|
111
|
+
file: filePath,
|
|
112
|
+
error: error.message
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = {
|
|
121
|
+
loadOverrideFile,
|
|
122
|
+
loadConfigFile,
|
|
123
|
+
saveConfigFile
|
|
124
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Converters Module
|
|
3
|
+
*
|
|
4
|
+
* Provides type conversion functions for configuration values.
|
|
5
|
+
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get type converters
|
|
10
|
+
* @returns {Object} - Type conversion functions
|
|
11
|
+
*/
|
|
12
|
+
function getTypeConverters() {
|
|
13
|
+
return {
|
|
14
|
+
'boolean': (value) => {
|
|
15
|
+
if (typeof value === 'boolean') return value;
|
|
16
|
+
const str = String(value).toLowerCase();
|
|
17
|
+
return str === 'true' || str === '1' || str === 'yes' || str === 'on';
|
|
18
|
+
},
|
|
19
|
+
'number': (value) => {
|
|
20
|
+
const num = Number(value);
|
|
21
|
+
return isNaN(num) ? 0 : num;
|
|
22
|
+
},
|
|
23
|
+
'string': (value) => String(value),
|
|
24
|
+
'array': (value) => {
|
|
25
|
+
if (Array.isArray(value)) return value;
|
|
26
|
+
const str = String(value);
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(str);
|
|
29
|
+
} catch {
|
|
30
|
+
return str.split(',').map(s => s.trim()).filter(s => s);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
'object': (value) => {
|
|
34
|
+
if (typeof value === 'object' && value !== null) return value;
|
|
35
|
+
const str = String(value);
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(str);
|
|
38
|
+
} catch {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get variable type from default value
|
|
47
|
+
* @param {*} defaultValue - Default value
|
|
48
|
+
* @returns {string} - Variable type
|
|
49
|
+
*/
|
|
50
|
+
function getVariableType(defaultValue) {
|
|
51
|
+
if (typeof defaultValue === 'boolean') return 'boolean';
|
|
52
|
+
if (typeof defaultValue === 'number') return 'number';
|
|
53
|
+
if (Array.isArray(defaultValue)) return 'array';
|
|
54
|
+
if (typeof defaultValue === 'object' && defaultValue !== null) return 'object';
|
|
55
|
+
return 'string';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
getTypeConverters,
|
|
60
|
+
getVariableType
|
|
61
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable Mappings Module
|
|
3
|
+
*
|
|
4
|
+
* Defines environment variable to configuration path mappings.
|
|
5
|
+
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get default variable mappings
|
|
10
|
+
* @returns {Object} - Variable mappings
|
|
11
|
+
*/
|
|
12
|
+
function getDefaultVariableMappings() {
|
|
13
|
+
return {
|
|
14
|
+
// Installation settings
|
|
15
|
+
'INSTALL_TIMEOUT': 'installation.timeout',
|
|
16
|
+
'MAX_CONCURRENT_INSTALLATIONS': 'installation.maxConcurrent',
|
|
17
|
+
'RETRY_ATTEMPTS': 'installation.retryAttempts',
|
|
18
|
+
'RETRY_DELAY': 'installation.retryDelay',
|
|
19
|
+
'AUTO_ELEVATE': 'installation.autoElevate',
|
|
20
|
+
|
|
21
|
+
// Logging settings
|
|
22
|
+
'LOG_LEVEL': 'logging.level',
|
|
23
|
+
'LOG_FILE': 'logging.file',
|
|
24
|
+
'LOG_FORMAT': 'logging.format',
|
|
25
|
+
'VERBOSE_LOGGING': 'logging.verbose',
|
|
26
|
+
|
|
27
|
+
// Cache settings
|
|
28
|
+
'CACHE_DIR': 'cache.directory',
|
|
29
|
+
'CACHE_SIZE': 'cache.maxSize',
|
|
30
|
+
'CACHE_TTL': 'cache.ttl',
|
|
31
|
+
|
|
32
|
+
// Network settings
|
|
33
|
+
'HTTP_TIMEOUT': 'network.timeout',
|
|
34
|
+
'HTTP_PROXY': 'network.proxy',
|
|
35
|
+
'HTTP_USER_AGENT': 'network.userAgent',
|
|
36
|
+
'RATE_LIMIT_DELAY': 'network.rateLimitDelay',
|
|
37
|
+
|
|
38
|
+
// Security settings
|
|
39
|
+
'SECURITY_STRICT_MODE': 'security.strictMode',
|
|
40
|
+
'SECURITY_MAX_FILE_SIZE': 'security.maxFileSize',
|
|
41
|
+
'SECURITY_ALLOWED_EXTENSIONS': 'security.allowedExtensions',
|
|
42
|
+
|
|
43
|
+
// Performance settings
|
|
44
|
+
'PERFORMANCE_MONITORING': 'performance.monitoring',
|
|
45
|
+
'PERFORMANCE_METRICS_FILE': 'performance.metricsFile',
|
|
46
|
+
'PERFORMANCE_FLUSH_INTERVAL': 'performance.flushInterval',
|
|
47
|
+
|
|
48
|
+
// Agent settings
|
|
49
|
+
'DEFAULT_AGENTS_FILE': 'agents.defaultFile',
|
|
50
|
+
'AGENT_DISCOVERY_ENABLED': 'agents.discoveryEnabled',
|
|
51
|
+
'AGENT_AUTO_UPDATE': 'agents.autoUpdate'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get variable descriptions
|
|
57
|
+
* @returns {Object} - Variable descriptions
|
|
58
|
+
*/
|
|
59
|
+
function getVariableDescriptions() {
|
|
60
|
+
return {
|
|
61
|
+
'INSTALL_TIMEOUT': 'Installation timeout in milliseconds',
|
|
62
|
+
'MAX_CONCURRENT_INSTALLATIONS': 'Maximum concurrent installations',
|
|
63
|
+
'RETRY_ATTEMPTS': 'Number of retry attempts for failed operations',
|
|
64
|
+
'RETRY_DELAY': 'Delay between retry attempts in milliseconds',
|
|
65
|
+
'AUTO_ELEVATE': 'Automatically request administrator privileges',
|
|
66
|
+
'LOG_LEVEL': 'Logging level (error, warn, info, debug)',
|
|
67
|
+
'LOG_FILE': 'Path to log file',
|
|
68
|
+
'LOG_FORMAT': 'Log format (json, text)',
|
|
69
|
+
'VERBOSE_LOGGING': 'Enable verbose logging',
|
|
70
|
+
'CACHE_DIR': 'Cache directory path',
|
|
71
|
+
'CACHE_SIZE': 'Maximum cache size in bytes',
|
|
72
|
+
'CACHE_TTL': 'Cache time-to-live in milliseconds',
|
|
73
|
+
'HTTP_TIMEOUT': 'HTTP request timeout in milliseconds',
|
|
74
|
+
'HTTP_PROXY': 'HTTP proxy URL',
|
|
75
|
+
'HTTP_USER_AGENT': 'HTTP user agent string',
|
|
76
|
+
'RATE_LIMIT_DELAY': 'Delay for rate limiting in milliseconds',
|
|
77
|
+
'SECURITY_STRICT_MODE': 'Enable strict security mode',
|
|
78
|
+
'SECURITY_MAX_FILE_SIZE': 'Maximum allowed file size in bytes',
|
|
79
|
+
'SECURITY_ALLOWED_EXTENSIONS': 'Comma-separated list of allowed file extensions',
|
|
80
|
+
'PERFORMANCE_MONITORING': 'Enable performance monitoring',
|
|
81
|
+
'PERFORMANCE_METRICS_FILE': 'Path to performance metrics file',
|
|
82
|
+
'PERFORMANCE_FLUSH_INTERVAL': 'Performance metrics flush interval in milliseconds',
|
|
83
|
+
'DEFAULT_AGENTS_FILE': 'Path to default agents configuration file',
|
|
84
|
+
'AGENT_DISCOVERY_ENABLED': 'Enable automatic agent discovery',
|
|
85
|
+
'AGENT_AUTO_UPDATE': 'Enable automatic agent updates'
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
getDefaultVariableMappings,
|
|
91
|
+
getVariableDescriptions
|
|
92
|
+
};
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Discovery Service
|
|
3
|
+
*
|
|
4
|
+
* Discovers and manages new agent CLI tools.
|
|
5
|
+
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs').promises;
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const DiscoveryScanner = require('./discovery-scanner');
|
|
11
|
+
const { DiscoveryResult } = require('./discovery-results');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Agent Discovery Service class
|
|
15
|
+
*/
|
|
16
|
+
class AgentDiscoveryService {
|
|
17
|
+
/**
|
|
18
|
+
* Create discovery service instance
|
|
19
|
+
* @param {Object} options - Service options
|
|
20
|
+
*/
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.configManager = options.configManager || null;
|
|
23
|
+
this.logger = options.logger || null;
|
|
24
|
+
this.fileManager = options.fileManager || null;
|
|
25
|
+
this.discoveryPaths = options.discoveryPaths || ['/usr/local/bin', '/opt/bin', '/usr/bin/local/bin', '/snap/bin'];
|
|
26
|
+
this.timeout = options.timeout || 30000;
|
|
27
|
+
this.maxConcurrency = options.maxConcurrency || 3;
|
|
28
|
+
this.discoveryHistoryFile = options.discoveryHistoryFile || './discovery-history.json';
|
|
29
|
+
this.discoveryStatusFile = options.discoveryStatusFile || './discovery-status.json';
|
|
30
|
+
|
|
31
|
+
// Create scanner instance
|
|
32
|
+
this.scanner = new DiscoveryScanner({
|
|
33
|
+
discoveryPaths: this.discoveryPaths,
|
|
34
|
+
timeout: this.timeout,
|
|
35
|
+
maxConcurrency: this.maxConcurrency,
|
|
36
|
+
logger: this.logger
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Discover agents from configured paths
|
|
42
|
+
* @returns {Promise<Object>} - Discovery result
|
|
43
|
+
*/
|
|
44
|
+
async discoverAgents() {
|
|
45
|
+
const startTime = Date.now();
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
if (this.logger) {
|
|
49
|
+
await this.logger.info('Starting agent discovery', {
|
|
50
|
+
paths: this.discoveryPaths,
|
|
51
|
+
timeout: this.timeout
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Run discovery scan
|
|
56
|
+
const result = await this.scanner.scanAllPaths();
|
|
57
|
+
|
|
58
|
+
// Save discovery history
|
|
59
|
+
await this.saveDiscoveryHistory(result);
|
|
60
|
+
|
|
61
|
+
// Update discovery status
|
|
62
|
+
await this.updateDiscoveryStatus(result);
|
|
63
|
+
|
|
64
|
+
const duration = Date.now() - startTime;
|
|
65
|
+
|
|
66
|
+
if (this.logger) {
|
|
67
|
+
await this.logger.info('Agent discovery completed', {
|
|
68
|
+
duration,
|
|
69
|
+
...result.getSummary()
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
success: true,
|
|
75
|
+
result: result.toJSON(),
|
|
76
|
+
duration,
|
|
77
|
+
timestamp: new Date().toISOString()
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} catch (error) {
|
|
81
|
+
const duration = Date.now() - startTime;
|
|
82
|
+
|
|
83
|
+
if (this.logger) {
|
|
84
|
+
await this.logger.error('Agent discovery failed', {
|
|
85
|
+
error: error.message,
|
|
86
|
+
duration
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
error: error.message,
|
|
93
|
+
duration,
|
|
94
|
+
timestamp: new Date().toISOString()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get discovery history
|
|
101
|
+
* @param {number} limit - Maximum number of entries
|
|
102
|
+
* @returns {Promise<Array>} - Discovery history
|
|
103
|
+
*/
|
|
104
|
+
async getDiscoveryHistory(limit = 50) {
|
|
105
|
+
try {
|
|
106
|
+
const data = await fs.readFile(this.discoveryHistoryFile, 'utf8');
|
|
107
|
+
const history = JSON.parse(data);
|
|
108
|
+
return Array.isArray(history) ? history.slice(-limit) : [];
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get current discovery status
|
|
116
|
+
* @returns {Promise<Object>} - Current status
|
|
117
|
+
*/
|
|
118
|
+
async getDiscoveryStatus() {
|
|
119
|
+
try {
|
|
120
|
+
const data = await fs.readFile(this.discoveryStatusFile, 'utf8');
|
|
121
|
+
return JSON.parse(data);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
return {
|
|
124
|
+
status: 'idle',
|
|
125
|
+
lastDiscovery: null,
|
|
126
|
+
totalDiscovered: 0
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Save discovery history
|
|
133
|
+
* @param {DiscoveryResult} result - Discovery result
|
|
134
|
+
* @returns {Promise<void>}
|
|
135
|
+
*/
|
|
136
|
+
async saveDiscoveryHistory(result) {
|
|
137
|
+
try {
|
|
138
|
+
const history = await this.getDiscoveryHistory(1000); // Get more for internal use
|
|
139
|
+
const newEntry = {
|
|
140
|
+
timestamp: new Date().toISOString(),
|
|
141
|
+
sessionId: result.sessionId,
|
|
142
|
+
summary: result.getSummary()
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
history.push(newEntry);
|
|
146
|
+
|
|
147
|
+
// Keep only last 100 entries
|
|
148
|
+
const trimmedHistory = history.slice(-100);
|
|
149
|
+
|
|
150
|
+
await fs.writeFile(
|
|
151
|
+
this.discoveryHistoryFile,
|
|
152
|
+
JSON.stringify(trimmedHistory, null, 2),
|
|
153
|
+
'utf8'
|
|
154
|
+
);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (this.logger) {
|
|
157
|
+
await this.logger.warn('Failed to save discovery history', {
|
|
158
|
+
error: error.message
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Update discovery status
|
|
166
|
+
* @param {DiscoveryResult} result - Discovery result
|
|
167
|
+
* @returns {Promise<void>}
|
|
168
|
+
*/
|
|
169
|
+
async updateDiscoveryStatus(result) {
|
|
170
|
+
try {
|
|
171
|
+
const status = {
|
|
172
|
+
status: 'completed',
|
|
173
|
+
lastDiscovery: new Date().toISOString(),
|
|
174
|
+
sessionId: result.sessionId,
|
|
175
|
+
totalDiscovered: result.agents.length,
|
|
176
|
+
summary: result.getSummary()
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
await fs.writeFile(
|
|
180
|
+
this.discoveryStatusFile,
|
|
181
|
+
JSON.stringify(status, null, 2),
|
|
182
|
+
'utf8'
|
|
183
|
+
);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (this.logger) {
|
|
186
|
+
await this.logger.warn('Failed to update discovery status', {
|
|
187
|
+
error: error.message
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Clear discovery history
|
|
195
|
+
* @returns {Promise<void>}
|
|
196
|
+
*/
|
|
197
|
+
async clearDiscoveryHistory() {
|
|
198
|
+
try {
|
|
199
|
+
await fs.writeFile(this.discoveryHistoryFile, '[]', 'utf8');
|
|
200
|
+
|
|
201
|
+
if (this.logger) {
|
|
202
|
+
await this.logger.info('Discovery history cleared');
|
|
203
|
+
}
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (this.logger) {
|
|
206
|
+
await this.logger.error('Failed to clear discovery history', {
|
|
207
|
+
error: error.message
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get service information
|
|
215
|
+
* @returns {Object} - Service info
|
|
216
|
+
*/
|
|
217
|
+
getServiceInfo() {
|
|
218
|
+
return {
|
|
219
|
+
discoveryPaths: this.discoveryPaths,
|
|
220
|
+
timeout: this.timeout,
|
|
221
|
+
maxConcurrency: this.maxConcurrency,
|
|
222
|
+
historyFile: this.discoveryHistoryFile,
|
|
223
|
+
statusFile: this.discoveryStatusFile,
|
|
224
|
+
features: [
|
|
225
|
+
'filesystem scanning',
|
|
226
|
+
'agent verification',
|
|
227
|
+
'confidence scoring',
|
|
228
|
+
'discovery history',
|
|
229
|
+
'status tracking'
|
|
230
|
+
],
|
|
231
|
+
limitations: [
|
|
232
|
+
'limited to configured paths',
|
|
233
|
+
'depends on file system permissions',
|
|
234
|
+
'confidence scoring based on heuristics'
|
|
235
|
+
]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Create discovery service with default configuration
|
|
241
|
+
* @param {Object} config - Configuration overrides
|
|
242
|
+
* @returns {AgentDiscoveryService} - Service instance
|
|
243
|
+
*/
|
|
244
|
+
static createDefault(config = {}) {
|
|
245
|
+
return new AgentDiscoveryService({
|
|
246
|
+
discoveryPaths: ['/usr/local/bin', '/opt/bin', '/usr/bin/local/bin', '/snap/bin'],
|
|
247
|
+
timeout: 30000,
|
|
248
|
+
maxConcurrency: 3,
|
|
249
|
+
discoveryHistoryFile: './discovery-history.json',
|
|
250
|
+
discoveryStatusFile: './discovery-status.json',
|
|
251
|
+
...config
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Create discovery service for development
|
|
257
|
+
* @param {Object} config - Configuration overrides
|
|
258
|
+
* @returns {AgentDiscoveryService} - Development service instance
|
|
259
|
+
*/
|
|
260
|
+
static createForDevelopment(config = {}) {
|
|
261
|
+
return new AgentDiscoveryService({
|
|
262
|
+
discoveryPaths: ['./test-agents', '/usr/local/bin'],
|
|
263
|
+
timeout: 10000,
|
|
264
|
+
maxConcurrency: 2,
|
|
265
|
+
discoveryHistoryFile: './dev-discovery-history.json',
|
|
266
|
+
discoveryStatusFile: './dev-discovery-status.json',
|
|
267
|
+
...config
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
module.exports = AgentDiscoveryService;
|