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.
Files changed (192) hide show
  1. package/package.json +1 -1
  2. package/src/agents/AgentCheckDiscoveryService.js +180 -0
  3. package/src/agents/AgentCheckService.js +18 -261
  4. package/src/agents/AgentCheckStatisticsService.js +195 -0
  5. package/src/agents/EnvironmentConfigurationManager.js +31 -380
  6. package/src/agents/InstallationType.js +19 -6
  7. package/src/agents/SimpleAgentCheckService.js +472 -0
  8. package/src/agents/config-managers/ConfigUtils.js +72 -0
  9. package/src/agents/config-managers/DefaultConfig.js +58 -0
  10. package/src/agents/config-managers/EnvVarLoader.js +66 -0
  11. package/src/agents/config-managers/FileConfigLoader.js +124 -0
  12. package/src/agents/config-managers/TypeConverters.js +61 -0
  13. package/src/agents/config-managers/VariableMappings.js +92 -0
  14. package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
  15. package/src/agents/discovery/AgentDiscoveryService.js +29 -403
  16. package/src/agents/discovery/agent-validator.js +262 -0
  17. package/src/agents/discovery/discovery-results.js +176 -0
  18. package/src/agents/discovery/discovery-scanner.js +268 -0
  19. package/src/agents/discovery/discovery-utils.js +161 -0
  20. package/src/agents/discovery/executable-analyzer.js +290 -0
  21. package/src/agents/discovery/history-manager.js +310 -0
  22. package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
  23. package/src/agents/verification/ResultAnalyzer.js +30 -431
  24. package/src/agents/verification/analysis-utils.js +310 -0
  25. package/src/agents/verification/batch-analyzer.js +440 -0
  26. package/src/agents/verification/pattern-recognizer.js +369 -0
  27. package/src/agents/verification/report-generator.js +320 -0
  28. package/src/agents/verification/test-analyzer.js +290 -0
  29. package/src/agents/windows/InstallerFactory.js +4 -0
  30. package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
  31. package/src/analysis/analysis-engine.js +314 -0
  32. package/src/analysis/ast-analyzer.js +342 -0
  33. package/src/analysis/boundary-detector-refactored.js +378 -0
  34. package/src/analysis/boundary-detector.js +200 -603
  35. package/src/analysis/boundary-scanner.js +609 -0
  36. package/src/analysis/boundary-types.js +118 -0
  37. package/src/analysis/boundary-utils.js +293 -0
  38. package/src/analysis/deadline-priority-calculator.js +18 -0
  39. package/src/analysis/detection-methods.js +347 -0
  40. package/src/analysis/importance-priority-calculator.js +18 -0
  41. package/src/analysis/priority/factor-calculators.js +204 -0
  42. package/src/analysis/priority/factor-helpers.js +71 -0
  43. package/src/analysis/priority/priority-constants.js +73 -0
  44. package/src/analysis/priority/priority-factor-calculators.js +301 -0
  45. package/src/analysis/priority/reasons-generator.js +44 -0
  46. package/src/analysis/priority-calculator.js +15 -580
  47. package/src/analysis/strategy-generator.js +16 -66
  48. package/src/analysis/type-priority-calculator.js +18 -0
  49. package/src/analysis/urgency-priority-calculator.js +18 -0
  50. package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
  51. package/src/commands/disable-requirement.js +60 -0
  52. package/src/commands/disable-spec.js +60 -0
  53. package/src/commands/enable-requirement.js +60 -0
  54. package/src/commands/enable-spec.js +60 -0
  55. package/src/commands/registry.js +1 -6
  56. package/src/commands/requirements.js +8 -2
  57. package/src/ide-integration/applescript-manager.cjs +9 -24
  58. package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
  59. package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
  60. package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
  61. package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
  62. package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
  63. package/src/ide-integration/cdp-manager.js +28 -573
  64. package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
  65. package/src/ide-integration/ide-openers/claude-opener.js +171 -0
  66. package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
  67. package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
  68. package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
  69. package/src/ide-integration/macos-ide-manager.js +20 -582
  70. package/src/ide-integration/macos-quota-checker.js +164 -0
  71. package/src/ide-integration/macos-text-sender.js +19 -38
  72. package/src/ide-integration/provider-manager.cjs +52 -7
  73. package/src/index.cjs +6 -0
  74. package/src/index.js +10 -0
  75. package/src/llm/direct-llm-manager.cjs +501 -0
  76. package/src/localization/translations/en-part1.js +363 -0
  77. package/src/localization/translations/en-part2.js +320 -0
  78. package/src/localization/translations/en.js +4 -687
  79. package/src/localization/translations/es-part1.js +363 -0
  80. package/src/localization/translations/es-part2.js +320 -0
  81. package/src/localization/translations/es.js +4 -688
  82. package/src/models/file-analysis-collection.js +139 -0
  83. package/src/models/file-analysis-metrics.js +50 -0
  84. package/src/models/file-analysis.js +15 -262
  85. package/src/models/plan-manager.js +410 -0
  86. package/src/models/refactoring-models.js +380 -0
  87. package/src/models/refactoring-plan-refactored.js +81 -0
  88. package/src/models/refactoring-plan.js +2 -663
  89. package/src/monitoring/alert-system.js +4 -45
  90. package/src/monitoring/continuous-scan-notifications.js +37 -191
  91. package/src/monitoring/notification-handlers/base-handler.js +58 -0
  92. package/src/monitoring/notification-handlers/error-handler.js +36 -0
  93. package/src/monitoring/notification-handlers/index.js +21 -0
  94. package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
  95. package/src/monitoring/notification-handlers/progress-handler.js +48 -0
  96. package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
  97. package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
  98. package/src/provider-registry.js +8 -0
  99. package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
  100. package/src/refactoring/boundary/boundary-detector.js +26 -596
  101. package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
  102. package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
  103. package/src/refactoring/boundary/detectors/class-detector.js +247 -0
  104. package/src/refactoring/boundary/detectors/config-detector.js +270 -0
  105. package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
  106. package/src/refactoring/boundary/detectors/function-detector.js +248 -0
  107. package/src/refactoring/boundary/detectors/module-detector.js +249 -0
  108. package/src/refactoring/boundary/detectors/object-detector.js +247 -0
  109. package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
  110. package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
  111. package/src/refactoring/circular-dependency-resolver-original.js +16 -76
  112. package/src/refactoring/code-mover-refactored.js +309 -0
  113. package/src/refactoring/code-mover.js +48 -355
  114. package/src/refactoring/execution-status.js +18 -0
  115. package/src/refactoring/execution-strategies.js +172 -0
  116. package/src/refactoring/file-splitter-core.js +568 -0
  117. package/src/refactoring/file-splitter-types.js +136 -0
  118. package/src/refactoring/file-splitter.js +2 -682
  119. package/src/refactoring/functionality-validator.js +11 -51
  120. package/src/refactoring/import-manager-refactored.js +385 -0
  121. package/src/refactoring/import-manager.js +112 -487
  122. package/src/refactoring/import-models.js +189 -0
  123. package/src/refactoring/import-parser.js +306 -0
  124. package/src/refactoring/move-executor.js +431 -0
  125. package/src/refactoring/move-utils.js +368 -0
  126. package/src/refactoring/operation-executor.js +76 -0
  127. package/src/refactoring/plan-creator.js +36 -0
  128. package/src/refactoring/plan-executor.js +143 -0
  129. package/src/refactoring/plan-validator.js +68 -0
  130. package/src/refactoring/refactoring-executor-result.js +70 -0
  131. package/src/refactoring/refactoring-executor.js +34 -569
  132. package/src/refactoring/refactoring-operation.js +94 -0
  133. package/src/refactoring/refactoring-plan.js +69 -0
  134. package/src/refactoring/refactoring-rollback.js +22 -527
  135. package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
  136. package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
  137. package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
  138. package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
  139. package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
  140. package/src/refactoring/test-validator.js +32 -448
  141. package/src/refactoring/validation/baseline-runner.js +71 -0
  142. package/src/refactoring/validation/report-generator.js +136 -0
  143. package/src/refactoring/validation/result-comparator.js +92 -0
  144. package/src/refactoring/validation/test-suite.js +59 -0
  145. package/src/refactoring/validation/test-validation-result.js +83 -0
  146. package/src/refactoring/validation/validation-runner.js +95 -0
  147. package/src/refactoring/validation/validation-status.js +18 -0
  148. package/src/rui/commands/AgentCommandParser.js +60 -369
  149. package/src/rui/commands/AgentResponseFormatter.js +7 -47
  150. package/src/rui/commands/parsers/CommandMapper.js +148 -0
  151. package/src/rui/commands/parsers/CommandValidator.js +228 -0
  152. package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
  153. package/src/rui/commands/parsers/TokenParser.js +69 -0
  154. package/src/rui/commands/parsers/tokenizer.js +153 -0
  155. package/src/utils/current-requirement-operations.js +50 -1
  156. package/src/utils/report-generator.js +18 -514
  157. package/src/utils/report-generators/analysis-generator.js +115 -0
  158. package/src/utils/report-generators/base-generator.js +141 -0
  159. package/src/utils/report-generators/compliance-generator.js +41 -0
  160. package/src/utils/report-generators/format-handlers.js +185 -0
  161. package/src/utils/report-generators/refactoring-generator.js +46 -0
  162. package/src/utils/report-generators/validation-generator.js +63 -0
  163. package/src/utils/requirement-enable-disable.js +265 -0
  164. package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
  165. package/src/utils/requirement-helpers/requirement-mover.js +88 -1
  166. package/src/utils/requirement-helpers.js +5 -2
  167. package/src/utils/smoke-test-cli.js +45 -8
  168. package/src/utils/specification-enable-disable.js +122 -0
  169. package/src/utils/specification-helpers.js +30 -4
  170. package/src/utils/specification-migration.js +5 -5
  171. package/src/utils/test-comparator.js +118 -0
  172. package/src/utils/test-config.js +54 -0
  173. package/src/utils/test-executor.js +133 -0
  174. package/src/utils/test-parser.js +215 -0
  175. package/src/utils/test-runner-baseline.js +63 -0
  176. package/src/utils/test-runner-core.js +98 -0
  177. package/src/utils/test-runner-report.js +39 -0
  178. package/src/utils/test-runner-validation.js +71 -0
  179. package/src/utils/test-runner.js +11 -535
  180. package/src/validation/comparison-analyzer.js +333 -0
  181. package/src/validation/compliance-reporter-new.js +282 -0
  182. package/src/validation/compliance-reporter-refactored.js +344 -0
  183. package/src/validation/compliance-reporter.js +278 -591
  184. package/src/validation/compliance-utils.js +278 -0
  185. package/src/validation/html-generator.js +446 -0
  186. package/src/validation/metrics/category-calculator.js +137 -0
  187. package/src/validation/metrics/metrics-helpers.js +155 -0
  188. package/src/validation/metrics/overview-calculator.js +85 -0
  189. package/src/validation/metrics/overview-metrics.js +41 -0
  190. package/src/validation/metrics/quality-calculator.js +166 -0
  191. package/src/validation/metrics/size-calculator.js +69 -0
  192. package/src/validation/metrics-calculator.js +27 -551
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Discovery Utilities
3
+ *
4
+ * Utility functions for agent discovery operations.
5
+ */
6
+
7
+ const fs = require('fs').promises;
8
+ const path = require('path');
9
+ const { spawn, exec } = require('child_process');
10
+ const { promisify } = require('util');
11
+
12
+ const execAsync = promisify(exec);
13
+
14
+ /**
15
+ * Check if a command exists on the system
16
+ * @param {string} command - Command to check
17
+ * @returns {Promise<boolean>} - True if command exists
18
+ */
19
+ async function commandExists(command) {
20
+ try {
21
+ await execAsync(`which ${command}`);
22
+ return true;
23
+ } catch (error) {
24
+ return false;
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Get command help text
30
+ * @param {string} command - Command to get help for
31
+ * @param {number} timeout - Timeout in milliseconds
32
+ * @returns {Promise<string>} - Help text
33
+ */
34
+ async function getCommandHelp(command, timeout = 5000) {
35
+ return new Promise((resolve) => {
36
+ const child = spawn(command, ['--help'], {
37
+ stdio: ['pipe', 'pipe', 'pipe'],
38
+ timeout
39
+ });
40
+
41
+ let stdout = '';
42
+ let stderr = '';
43
+
44
+ child.stdout.on('data', (data) => {
45
+ stdout += data.toString();
46
+ });
47
+
48
+ child.stderr.on('data', (data) => {
49
+ stderr += data.toString();
50
+ });
51
+
52
+ child.on('close', (code) => {
53
+ resolve(stdout || stderr || `Command exited with code ${code}`);
54
+ });
55
+
56
+ child.on('error', (error) => {
57
+ resolve(`Error: ${error.message}`);
58
+ });
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Scan directory for executable files
64
+ * @param {string} dirPath - Directory to scan
65
+ * @returns {Promise<Array>} - Array of executable files
66
+ */
67
+ async function scanDirectory(dirPath) {
68
+ try {
69
+ const entries = await fs.readdir(dirPath, { withFileTypes: true });
70
+ const executables = [];
71
+
72
+ for (const entry of entries) {
73
+ if (entry.isFile()) {
74
+ const fullPath = path.join(dirPath, entry.name);
75
+ try {
76
+ await fs.access(fullPath, fs.constants.X_OK);
77
+ executables.push({
78
+ name: entry.name,
79
+ path: fullPath,
80
+ type: 'executable'
81
+ });
82
+ } catch (error) {
83
+ // Not executable, skip
84
+ }
85
+ }
86
+ }
87
+
88
+ return executables;
89
+ } catch (error) {
90
+ return [];
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Check if file is an agent CLI tool
96
+ * @param {Object} fileInfo - File information
97
+ * @returns {Promise<boolean>} - True if appears to be an agent
98
+ */
99
+ async function isAgentTool(fileInfo) {
100
+ const { name, path: filePath } = fileInfo;
101
+
102
+ // Skip common non-agent executables
103
+ const skipPatterns = [
104
+ /^(ls|cd|pwd|cat|echo|rm|cp|mv|mkdir|chmod|chown)/,
105
+ /^(node|npm|yarn|python|pip|git|curl|wget)/,
106
+ /^(docker|kubectl|helm|aws|az|gcloud)/
107
+ ];
108
+
109
+ for (const pattern of skipPatterns) {
110
+ if (pattern.test(name)) {
111
+ return false;
112
+ }
113
+ }
114
+
115
+ // Check if it has agent-like help output
116
+ try {
117
+ const help = await getCommandHelp(filePath, 3000);
118
+ const agentKeywords = [
119
+ 'agent', 'ai', 'assistant', 'chat', 'llm', 'model',
120
+ 'openai', 'anthropic', 'claude', 'gpt', 'gemini'
121
+ ];
122
+
123
+ return agentKeywords.some(keyword =>
124
+ help.toLowerCase().includes(keyword.toLowerCase())
125
+ );
126
+ } catch (error) {
127
+ return false;
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Get file metadata
133
+ * @param {string} filePath - Path to file
134
+ * @returns {Promise<Object>} - File metadata
135
+ */
136
+ async function getFileMetadata(filePath) {
137
+ try {
138
+ const stats = await fs.stat(filePath);
139
+ return {
140
+ size: stats.size,
141
+ modified: stats.mtime,
142
+ created: stats.birthtime,
143
+ isExecutable: !!(stats.mode & parseInt('111', 8))
144
+ };
145
+ } catch (error) {
146
+ return {
147
+ size: 0,
148
+ modified: new Date(),
149
+ created: new Date(),
150
+ isExecutable: false
151
+ };
152
+ }
153
+ }
154
+
155
+ module.exports = {
156
+ commandExists,
157
+ getCommandHelp,
158
+ scanDirectory,
159
+ isAgentTool,
160
+ getFileMetadata
161
+ };
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Agent Discovery - Executable Analyzer
3
+ *
4
+ * Analyzes executable files to determine if they are agent tools.
5
+ */
6
+
7
+ const fs = require('fs').promises;
8
+ const path = require('path');
9
+ const { spawn, exec } = require('child_process');
10
+ const { promisify } = require('util');
11
+
12
+ const execAsync = promisify(exec);
13
+
14
+ /**
15
+ * Analyze executable file for agent information
16
+ * @param {string} filePath - Path to executable file
17
+ * @param {Object} logger - Logger instance
18
+ * @returns {Promise<Object>} - Agent information or null
19
+ */
20
+ async function analyzeExecutable(filePath, logger = null) {
21
+ try {
22
+ // Get file info
23
+ const stat = await fs.stat(filePath);
24
+ const fileName = path.basename(filePath);
25
+
26
+ // Basic agent information
27
+ const agentInfo = {
28
+ id: generateAgentId(fileName),
29
+ name: sanitizeAgentName(fileName),
30
+ path: filePath,
31
+ type: detectAgentType(fileName),
32
+ version: 'unknown',
33
+ capabilities: [],
34
+ description: '',
35
+ size: stat.size,
36
+ modified: stat.mtime,
37
+ discovered: new Date().toISOString()
38
+ };
39
+
40
+ // Try to extract more information
41
+ await Promise.allSettled([
42
+ extractVersion(agentInfo, filePath, logger),
43
+ extractDescription(agentInfo, filePath, logger),
44
+ detectCapabilities(agentInfo, filePath, logger)
45
+ ]);
46
+
47
+ return agentInfo;
48
+ } catch (error) {
49
+ if (logger) {
50
+ await logger.warn(`Failed to analyze executable ${filePath}: ${error.message}`);
51
+ }
52
+ return null;
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Generate agent ID from filename
58
+ * @param {string} fileName - Filename
59
+ * @returns {string} - Agent ID
60
+ */
61
+ function generateAgentId(fileName) {
62
+ const baseName = path.parse(fileName).name;
63
+ return baseName.toLowerCase().replace(/[^a-z0-9]/g, '-');
64
+ }
65
+
66
+ /**
67
+ * Sanitize agent name
68
+ * @param {string} fileName - Filename
69
+ * @returns {string} - Sanitized name
70
+ */
71
+ function sanitizeAgentName(fileName) {
72
+ const baseName = path.parse(fileName).name;
73
+ return baseName.replace(/[-_]/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
74
+ }
75
+
76
+ /**
77
+ * Detect agent type from filename
78
+ * @param {string} fileName - Filename
79
+ * @returns {string} - Agent type
80
+ */
81
+ function detectAgentType(fileName) {
82
+ const name = fileName.toLowerCase();
83
+
84
+ if (name.includes('ai') || name.includes('agent') || name.includes('assistant')) {
85
+ return 'ai-agent';
86
+ }
87
+ if (name.includes('cli') || name.includes('cmd') || name.includes('tool')) {
88
+ return 'cli-tool';
89
+ }
90
+ if (name.includes('bot') || name.includes('automation')) {
91
+ return 'automation-bot';
92
+ }
93
+
94
+ return 'unknown';
95
+ }
96
+
97
+ /**
98
+ * Extract version from executable
99
+ * @param {Object} agentInfo - Agent info object
100
+ * @param {string} filePath - File path
101
+ * @param {Object} logger - Logger instance
102
+ */
103
+ async function extractVersion(agentInfo, filePath, logger) {
104
+ try {
105
+ // Try common version flags
106
+ const versionFlags = ['--version', '-v', '--version', '-V'];
107
+
108
+ for (const flag of versionFlags) {
109
+ try {
110
+ const { stdout } = await execAsync(`${filePath} ${flag}`, {
111
+ timeout: 5000,
112
+ env: { ...process.env, NO_COLOR: '1' }
113
+ });
114
+
115
+ const version = parseVersionOutput(stdout);
116
+ if (version) {
117
+ agentInfo.version = version;
118
+ return;
119
+ }
120
+ } catch (error) {
121
+ // Try next flag
122
+ }
123
+ }
124
+
125
+ // Try to extract from file content (shebang, comments, etc.)
126
+ const content = await fs.readFile(filePath, 'utf8');
127
+ const version = extractVersionFromContent(content);
128
+ if (version) {
129
+ agentInfo.version = version;
130
+ }
131
+ } catch (error) {
132
+ if (logger) {
133
+ await logger.debug(`Version extraction failed for ${filePath}: ${error.message}`);
134
+ }
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Parse version output
140
+ * @param {string} output - Command output
141
+ * @returns {string|null} - Version string or null
142
+ */
143
+ function parseVersionOutput(output) {
144
+ const lines = output.trim().split('\n');
145
+
146
+ for (const line of lines) {
147
+ // Look for version patterns
148
+ const versionMatch = line.match(/(\d+\.\d+(\.\d+)?)/);
149
+ if (versionMatch) {
150
+ return versionMatch[1];
151
+ }
152
+
153
+ // Look for "version X.Y.Z" patterns
154
+ const versionWordMatch = line.match(/version\s+(\d+\.\d+(\.\d+)?)/i);
155
+ if (versionWordMatch) {
156
+ return versionWordMatch[1];
157
+ }
158
+ }
159
+
160
+ return null;
161
+ }
162
+
163
+ /**
164
+ * Extract version from file content
165
+ * @param {string} content - File content
166
+ * @returns {string|null} - Version string or null
167
+ */
168
+ function extractVersionFromContent(content) {
169
+ // Look for version in common patterns
170
+ const patterns = [
171
+ /version\s*=\s*['"`]([^'"`]+)['"`]/i,
172
+ /const\s+VERSION\s*=\s*['"`]([^'"`]+)['"`]/i,
173
+ /__version__\s*=\s*['"`]([^'"`]+)['"`]/i
174
+ ];
175
+
176
+ for (const pattern of patterns) {
177
+ const match = content.match(pattern);
178
+ if (match) {
179
+ return match[1];
180
+ }
181
+ }
182
+
183
+ return null;
184
+ }
185
+
186
+ /**
187
+ * Extract description from executable
188
+ * @param {Object} agentInfo - Agent info object
189
+ * @param {string} filePath - File path
190
+ * @param {Object} logger - Logger instance
191
+ */
192
+ async function extractDescription(agentInfo, filePath, logger) {
193
+ try {
194
+ // Try help flag
195
+ const { stdout } = await execAsync(`${filePath} --help`, {
196
+ timeout: 5000,
197
+ env: { ...process.env, NO_COLOR: '1' }
198
+ });
199
+
200
+ const description = parseDescriptionFromHelp(stdout);
201
+ if (description) {
202
+ agentInfo.description = description;
203
+ }
204
+ } catch (error) {
205
+ if (logger) {
206
+ await logger.debug(`Description extraction failed for ${filePath}: ${error.message}`);
207
+ }
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Parse description from help output
213
+ * @param {string} helpOutput - Help command output
214
+ * @returns {string} - Description
215
+ */
216
+ function parseDescriptionFromHelp(helpOutput) {
217
+ const lines = helpOutput.trim().split('\n');
218
+
219
+ // Look for description in first few lines
220
+ for (let i = 0; i < Math.min(5, lines.length); i++) {
221
+ const line = lines[i].trim();
222
+
223
+ // Skip empty lines and common help headers
224
+ if (!line || line.startsWith('Usage:') || line.startsWith('Options:')) {
225
+ continue;
226
+ }
227
+
228
+ // Return first meaningful line as description
229
+ if (line.length > 10 && !line.startsWith('-')) {
230
+ return line.substring(0, 200); // Limit length
231
+ }
232
+ }
233
+
234
+ return '';
235
+ }
236
+
237
+ /**
238
+ * Detect capabilities from executable
239
+ * @param {Object} agentInfo - Agent info object
240
+ * @param {string} filePath - File path
241
+ * @param {Object} logger - Logger instance
242
+ */
243
+ async function detectCapabilities(agentInfo, filePath, logger) {
244
+ const capabilities = [];
245
+
246
+ try {
247
+ // Check if it's a script
248
+ const content = await fs.readFile(filePath, 'utf8');
249
+
250
+ if (content.includes('chat') || content.includes('conversation')) {
251
+ capabilities.push('chat');
252
+ }
253
+
254
+ if (content.includes('code') || content.includes('programming')) {
255
+ capabilities.push('code-generation');
256
+ }
257
+
258
+ if (content.includes('file') || content.includes('document')) {
259
+ capabilities.push('file-processing');
260
+ }
261
+
262
+ if (content.includes('web') || content.includes('http')) {
263
+ capabilities.push('web-interaction');
264
+ }
265
+
266
+ // Check for common CLI patterns
267
+ if (content.includes('process.argv') || content.includes('yargs') || content.includes('commander')) {
268
+ capabilities.push('cli-interface');
269
+ }
270
+
271
+ } catch (error) {
272
+ if (logger) {
273
+ await logger.debug(`Capability detection failed for ${filePath}: ${error.message}`);
274
+ }
275
+ }
276
+
277
+ // Add default capabilities based on file type
278
+ capabilities.push('help');
279
+
280
+ agentInfo.capabilities = capabilities;
281
+ }
282
+
283
+ module.exports = {
284
+ analyzeExecutable,
285
+ generateAgentId,
286
+ sanitizeAgentName,
287
+ detectAgentType,
288
+ extractVersion,
289
+ detectCapabilities
290
+ };