-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenhanced-cli-fixed.ts
More file actions
321 lines (271 loc) · 11.8 KB
/
Copy pathenhanced-cli-fixed.ts
File metadata and controls
321 lines (271 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#!/usr/bin/env node
import { Command } from 'commander';
import chalk from 'chalk';
import * as inquirer from 'inquirer';
import * as fs from 'fs-extra';
import * as path from 'path';
import ora from 'ora';
import { ContextScanner } from './stubs/context-scanner';
import { SubagentGenerator } from './subagent-generator';
import { ApprovalSystem } from './approval-system';
import { SmartDashboard } from './ux/smart-dashboard';
import { ContextualHelp } from './ux/contextual-help';
import { ErrorRecovery } from './ux/error-recovery';
import { ClaudeLauncher } from './claude-launcher';
import ClaudeFlowIntegration from './claude-flow-integration';
const program = new Command();
const contextualHelp = new ContextualHelp();
const errorRecovery = new ErrorRecovery();
// Detect NPX mode
const isNpxMode = process.env.CONDUCTOR_NPX_MODE === 'true' ||
process.env.npm_config_user_agent?.includes('npx');
if (isNpxMode) {
console.log(chalk.cyan('🚀 Running via npx - Welcome to Conductor CLI!'));
}
program
.name('conductor')
.description('AI-powered development assistant with specialized agents for your coding workflow')
.version('1.0.0');
// Enhanced initialization command with non-blocking loading
program
.command('init')
.description('Set up your AI development team and project structure')
.option('-f, --framework <framework>', 'Specify framework (nextjs, react, vue, etc.)')
.option('-t, --template <template>', 'Use project template')
.option('--skip-welcome', 'Skip welcome animation')
.option('--quick', 'Quick setup with sensible defaults')
.action(async (options) => {
const spinner = ora('Initializing Conductor CLI...').start();
try {
const { EnhancedLaunch } = await import('./ux/enhanced-launch-fixed');
const enhancedLaunch = new EnhancedLaunch();
spinner.succeed('Ready to configure your AI team');
await enhancedLaunch.initialize(options);
} catch (error) {
spinner.fail('Initialization failed');
console.error(chalk.red('Error:'), (error as Error).message);
if (!isNpxMode) {
process.exit(1);
}
}
});
// Natural language commands for better UX
program
.command('ask <question>')
.alias('consult')
.description('Get help from AI specialists - like having senior devs on your team')
.option('-a, --agent <agent>', 'Consult specific agent (@frontend, @backend, @pm, etc.)')
.option('-u, --urgent', 'High priority - get immediate team consensus')
.option('-c, --context <context>', 'Provide additional context')
.option('-d, --dashboard', 'Show live dashboard while processing')
.action(async (question, options) => {
const spinner = ora('Getting answers from your AI team...').start();
try {
if (options.dashboard) {
const dashboard = new SmartDashboard();
await dashboard.launch();
}
// Simulate AI team consultation
spinner.text = 'Consulting with specialized agents...';
await new Promise(resolve => setTimeout(resolve, 1500));
spinner.succeed('Got it! Your AI team has answered.');
console.log('\n' + chalk.cyan('🤖 AI Team Response:'));
console.log(chalk.gray('─'.repeat(50)));
if (options.agent) {
console.log(chalk.yellow(`${options.agent}:`));
console.log(`Based on your question "${question}", here's my analysis...`);
} else {
console.log(chalk.yellow('@architect:'));
console.log('From a design perspective, I suggest...');
console.log('\n' + chalk.yellow('@coder:'));
console.log('Here\'s the implementation approach...');
console.log('\n' + chalk.yellow('@security:'));
console.log('Security considerations include...');
}
console.log('\n' + chalk.gray('Run `conductor swarm` to implement suggestions'));
} catch (error) {
spinner.fail('Consultation failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
program
.command('explain <topic>')
.description('Get clear explanations on any dev topic from AI experts')
.option('-s, --simple', 'Use beginner-friendly explanations')
.option('-e, --examples', 'Include code examples')
.option('-l, --links', 'Include relevant documentation links')
.action(async (topic, options) => {
const spinner = ora(`Learning about: ${topic}`).start();
try {
await new Promise(resolve => setTimeout(resolve, 1000));
spinner.succeed('Explanation ready!');
console.log('\n' + chalk.cyan(`📚 Explaining: ${topic}`));
console.log(chalk.gray('─'.repeat(50)));
console.log('Here\'s a comprehensive explanation from your AI team...');
if (options.examples) {
console.log('\n' + chalk.yellow('Code Examples:'));
console.log('```javascript\n// Example implementation\n```');
}
if (options.links) {
console.log('\n' + chalk.blue('Useful Links:'));
console.log('• Documentation: https://...');
}
} catch (error) {
spinner.fail('Explanation failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Swarm intelligence commands
program
.command('swarm')
.description('Activate hive-mind coordination for parallel execution')
.option('--mode <mode>', 'Execution mode: research, implement, analyze', 'research')
.option('--workers <count>', 'Number of parallel workers', '3')
.option('--timeout <ms>', 'Task timeout in milliseconds', '30000')
.action(async (options) => {
const spinner = ora('🐝 Activating hive-mind coordination...').start();
try {
spinner.text = 'Spawning worker agents...';
await new Promise(resolve => setTimeout(resolve, 1000));
spinner.text = `Running ${options.mode} mode with ${options.workers} workers...`;
await new Promise(resolve => setTimeout(resolve, 2000));
spinner.succeed(`Swarm coordination complete! Mode: ${options.mode}`);
console.log('\n' + chalk.cyan('🐝 Swarm Results:'));
console.log(chalk.gray('─'.repeat(50)));
console.log(`• Mode: ${options.mode}`);
console.log(`• Workers: ${options.workers}`);
console.log('• Tasks completed in parallel');
console.log('• Results aggregated and optimized');
} catch (error) {
spinner.fail('Swarm coordination failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Code review command
program
.command('review [files...]')
.description('Get comprehensive code review from AI team')
.option('--security', 'Focus on security vulnerabilities')
.option('--performance', 'Focus on performance issues')
.option('--style', 'Focus on code style and best practices')
.action(async (files, options) => {
const targets = files.length > 0 ? files.join(', ') : 'current directory';
const spinner = ora(`Reviewing ${targets}...`).start();
try {
spinner.text = 'Analyzing code structure...';
await new Promise(resolve => setTimeout(resolve, 1000));
spinner.text = 'Running security checks...';
await new Promise(resolve => setTimeout(resolve, 1000));
spinner.text = 'Checking performance patterns...';
await new Promise(resolve => setTimeout(resolve, 800));
spinner.succeed('Code review complete!');
console.log('\n' + chalk.cyan('📋 Code Review Results:'));
console.log(chalk.gray('─'.repeat(50)));
console.log(chalk.green('✓ No critical issues found'));
console.log(chalk.yellow('⚠ 3 suggestions for improvement'));
console.log(chalk.blue('ℹ 5 style recommendations'));
if (options.security) {
console.log('\n' + chalk.red('🔒 Security Analysis:'));
console.log('• No vulnerabilities detected');
}
if (options.performance) {
console.log('\n' + chalk.yellow('⚡ Performance Analysis:'));
console.log('• Consider memoization in component X');
}
} catch (error) {
spinner.fail('Review failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Status and health commands
program
.command('status')
.description('Show AI team status and system health')
.action(async () => {
const spinner = ora('Checking system status...').start();
try {
await new Promise(resolve => setTimeout(resolve, 500));
spinner.succeed('System status retrieved');
console.log('\n' + chalk.cyan('🤖 Conductor CLI Status'));
console.log(chalk.gray('─'.repeat(50)));
console.log(chalk.green('✓ AI Team: Online'));
console.log(chalk.green('✓ Memory: 23MB used'));
console.log(chalk.green('✓ Agents: 6 active'));
console.log(chalk.green('✓ Hive-mind: Ready'));
if (isNpxMode) {
console.log(chalk.blue('ℹ Running via npx'));
}
} catch (error) {
spinner.fail('Status check failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Claude integration launch
program
.command('launch')
.description('Launch Claude Code with AI team integration')
.option('-d, --dashboard', 'Launch with dashboard')
.option('-p, --project <path>', 'Project path', process.cwd())
.action(async (options) => {
const spinner = ora('Launching Claude Code integration...').start();
try {
const claudeLauncher = new ClaudeLauncher(options.project);
await claudeLauncher.launch({
dashboard: options.dashboard,
project: options.project
});
spinner.succeed('Claude Code launched with AI team integration');
} catch (error) {
spinner.fail('Launch failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Help command with examples
program
.command('help-examples')
.description('Show common usage examples')
.action(() => {
console.log(chalk.cyan('\n🚀 Conductor CLI - Common Examples\n'));
console.log(chalk.yellow('Getting Started:'));
console.log(' conductor init --quick');
console.log(' conductor ask "help me build a REST API"');
console.log(' conductor swarm --implement\n');
console.log(chalk.yellow('Code Review:'));
console.log(' conductor review src/');
console.log(' conductor review --security');
console.log(' conductor review components/auth.tsx\n');
console.log(chalk.yellow('Team Consultation:'));
console.log(' conductor ask "how do I optimize this database query?"');
console.log(' conductor ask "review my authentication flow" --agent=@security');
console.log(' conductor explain "JWT vs sessions"\n');
console.log(chalk.yellow('Advanced Features:'));
console.log(' conductor swarm --mode=implement --workers=5');
console.log(' conductor launch --dashboard');
console.log(' conductor status\n');
});
// Error handling
program.on('command:*', (cmd) => {
console.log(chalk.red(`Unknown command: ${cmd[0]}`));
console.log('Run `conductor help` for available commands');
console.log('Run `conductor help-examples` for usage examples');
});
// Global error handling
process.on('unhandledRejection', (error) => {
console.error(chalk.red('Unhandled error:'), error);
if (!isNpxMode) {
process.exit(1);
}
});
program.parse(process.argv);
// Show help if no command provided
if (!process.argv.slice(2).length) {
console.log(chalk.cyan('\n🤖 Conductor CLI - Your AI Development Team\n'));
console.log('Get started with:');
console.log(' conductor init - Set up your AI team');
console.log(' conductor ask <question> - Get help from specialists');
console.log(' conductor help - Show all commands');
console.log(' conductor help-examples - Show usage examples\n');
if (isNpxMode) {
console.log(chalk.gray('💡 Tip: You\'re using npx - no installation needed!'));
}
}