-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-cli.ts
More file actions
530 lines (439 loc) · 19.5 KB
/
Copy pathsimple-cli.ts
File metadata and controls
530 lines (439 loc) · 19.5 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
#!/usr/bin/env node
import { Command } from 'commander';
import chalk from 'chalk';
import inquirer from 'inquirer';
import * as fs from 'fs-extra';
import * as path from 'path';
import ora from 'ora';
import { conductorSubAgents, exportForClaudeCode } from './subagents/conductor-subagents';
import { SubAgentIntegrationManager } from './subagents/integration-manager';
import { generateConductorHooks } from './hooks/conductor-hooks-architecture';
import { ElevenLabsIntegration } from './integrations/elevenlabs-integration';
import { subAgentCLI } from './subagents/subagent-discovery';
const program = new Command();
// 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')
.version('1.0.0');
// Initialize command
program
.command('init')
.description('Set up your AI development team')
.option('--quick', 'Quick setup with defaults')
.option('--hooks', 'Enable advanced hooks and automation')
.option('--tts', 'Enable text-to-speech notifications')
.option('--elevenlabs-key <key>', 'ElevenLabs API key for TTS features')
.action(async (options) => {
const spinner = ora('Setting up your AI development team...').start();
try {
// Create config directory
const configDir = path.join(process.cwd(), '.conductor');
await fs.ensureDir(configDir);
let config;
if (options.quick) {
config = {
version: '1.0.0',
projectType: 'auto-detect',
agents: ['architect', 'coder', 'qa', 'security'],
features: { hiveMind: true, memory: true }
};
spinner.text = 'Using quick setup...';
} else {
spinner.stop();
const answers = await inquirer.prompt([
{
type: 'list',
name: 'projectType',
message: 'What type of project is this?',
choices: [
{ name: 'Next.js App', value: 'nextjs' },
{ name: 'React SPA', value: 'react' },
{ name: 'Node.js API', value: 'nodejs' },
{ name: 'TypeScript Library', value: 'library' },
{ name: 'Auto-detect', value: 'auto' }
]
},
{
type: 'checkbox',
name: 'agents',
message: 'Select AI specialists:',
choices: [
{ name: 'Architect - System design', value: 'architect', checked: true },
{ name: 'Coder - Implementation', value: 'coder', checked: true },
{ name: 'QA - Testing & quality', value: 'qa', checked: true },
{ name: 'Security - Vulnerability scanning', value: 'security', checked: true },
{ name: 'Reviewer - Code review', value: 'reviewer' }
]
}
]);
config = { version: '1.0.0', ...answers };
spinner.start('Saving configuration...');
}
// Save config
const configFile = path.join(configDir, 'config.json');
await fs.writeJson(configFile, {
...config,
createdAt: new Date().toISOString()
}, { spaces: 2 });
// Create basic CLAUDE.md
const claudeFile = path.join(process.cwd(), 'CLAUDE.md');
let claudeContent = `# AI Development Team Configuration
Your Conductor CLI team is ready with ${config.agents.length} specialists.
## Quick Commands
- \`conductor ask "your question"\`
- \`conductor review <files>\`
- \`conductor swarm\`
Generated: ${new Date().toISOString()}
`;
// Add TTS documentation if enabled
if (options.tts || options.elevenlabsKey) {
claudeContent += `
# Text-to-Speech Integration
Text-to-speech capabilities have been configured for enhanced workflow feedback.
## Features
- Audio summaries of work completion
- Multiple TTS providers (ElevenLabs, OpenAI, pyttsx3 fallback)
- Integration with Claude Code sub-agents
- Work completion notifications with audio feedback
## Setup
1. **ElevenLabs** (Premium, high quality):
\`\`\`bash
conductor init --tts --elevenlabs-key YOUR_API_KEY
\`\`\`
Get your API key from: https://elevenlabs.io/app/settings/api-keys
2. **OpenAI TTS** (Alternative):
- Set OPENAI_API_KEY environment variable
- Uses OpenAI's TTS API for speech synthesis
3. **pyttsx3** (Local fallback):
- No API key required
- Uses system TTS capabilities
## Usage
- Audio summaries are automatically generated when work is completed
- Use \`tts\` or \`audio summary\` commands to trigger manual summaries
- Files are saved to \`output/work-summary-{timestamp}.mp3\`
## Sub-Agent Integration
Selected sub-agents now have access to TTS tools:
- work-completion-summary agent with audio feedback
- MCP server configuration for ElevenLabs integration
- Utility scripts for all TTS providers
`;
}
claudeContent += `
# important-instruction-reminders
Do what has been asked; nothing more, nothing less.
NEVER create files unless they're absolutely necessary for achieving your goal.
ALWAYS prefer editing an existing file to creating a new one.
NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
`;
await fs.writeFile(claudeFile, claudeContent);
// Generate Claude Code subagent configuration
const subAgentConfigDir = path.join(process.cwd(), '.claude');
await fs.ensureDir(subAgentConfigDir);
// Initialize sub-agent integration
const integrationManager = new SubAgentIntegrationManager(process.cwd());
await integrationManager.initialize();
const claudeConfig = exportForClaudeCode();
const subAgentFile = path.join(subAgentConfigDir, 'conductor-subagents.json');
await fs.writeJson(subAgentFile, claudeConfig, { spaces: 2 });
// Generate Claude Code hooks with user preferences
const { scripts, settings } = generateConductorHooks();
// Create hooks directory and scripts
const hooksDir = path.join(subAgentConfigDir, 'hooks');
await fs.ensureDir(hooksDir);
for (const [filename, content] of Object.entries(scripts)) {
const hookFile = path.join(hooksDir, filename);
await fs.writeFile(hookFile, content);
await fs.chmod(hookFile, 0o755); // Make executable
}
// Update settings.json with hooks configuration
const settingsFile = path.join(subAgentConfigDir, 'settings.json');
await fs.writeJson(settingsFile, settings, { spaces: 2 });
// Handle ElevenLabs TTS integration
if (options.tts || options.elevenlabsKey) {
spinner.text = 'Setting up TTS integration...';
const elevenLabs = new ElevenLabsIntegration();
// Generate TTS utilities
const ttsUtilities = elevenLabs.generateTTSUtilities();
const utilsDir = path.join(subAgentConfigDir, 'hooks', 'utils', 'tts');
await fs.ensureDir(utilsDir);
for (const [filename, content] of Object.entries(ttsUtilities)) {
const utilFile = path.join(utilsDir, filename);
await fs.writeFile(utilFile, content);
if (filename.endsWith('.py')) {
await fs.chmod(utilFile, 0o755);
}
}
// Generate MCP server configuration if API key provided
if (options.elevenlabsKey) {
// Update ElevenLabs integration with MCP server enabled
elevenLabs.enableMCPServer(options.elevenlabsKey);
const mcpConfig = elevenLabs.generateMCPServerConfig();
const mcpFile = path.join(subAgentConfigDir, 'mcp-servers.json');
await fs.writeJson(mcpFile, mcpConfig, { spaces: 2 });
// Update sub-agents with TTS capabilities
const enhancedSubAgents = elevenLabs.updateSubAgentConfigs(claudeConfig);
await fs.writeJson(subAgentFile, enhancedSubAgents, { spaces: 2 });
spinner.text = 'TTS integration configured with ElevenLabs API';
} else {
spinner.text = 'TTS utilities installed (API key needed for full features)';
}
// Always generate work completion agent (with or without MCP)
const workCompletionAgent = elevenLabs.generateWorkCompletionAgent();
const agentFile = path.join(subAgentConfigDir, 'agents', 'work-completion-summary.md');
await fs.ensureDir(path.dirname(agentFile));
await fs.writeFile(agentFile, workCompletionAgent);
}
spinner.succeed('AI development team ready!');
console.log('\n' + chalk.green('✨ Setup Complete!'));
console.log(chalk.cyan('Your AI specialists are ready to help.'));
console.log(chalk.blue('🤖 Claude Code sub-agents configured automatically'));
console.log(chalk.magenta('🔒 Security hooks and automation enabled'));
if (options.tts || options.elevenlabsKey) {
console.log(chalk.green('🔊 Text-to-speech integration configured'));
if (options.elevenlabsKey) {
console.log(chalk.blue('🎙️ ElevenLabs API integration active'));
} else if (options.tts) {
console.log(chalk.yellow('⚠️ Add --elevenlabs-key for full TTS features'));
}
}
console.log('\nTry these commands:');
console.log(chalk.yellow(' conductor ask "help me with authentication"'));
console.log(chalk.yellow(' conductor review src/'));
console.log(chalk.yellow(' conductor swarm\n'));
} catch (error) {
spinner.fail('Setup failed');
console.error(chalk.red('Error:'), (error as Error).message);
process.exit(1);
}
});
// Ask command
program
.command('ask <question>')
.description('Get help from AI specialists')
.option('-a, --agent <agent>', 'Specific agent to consult')
.action(async (question, options) => {
const spinner = ora('Consulting with AI team...').start();
try {
// Simulate AI processing
await new Promise(resolve => setTimeout(resolve, 1500));
spinner.succeed('AI team has responded!');
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(`Regarding "${question}" - here's my specialized analysis...`);
} else {
console.log(chalk.yellow('@architect:'));
console.log('From a design perspective, I recommend...');
console.log('\n' + chalk.yellow('@coder:'));
console.log('Here\'s how to implement this...');
console.log('\n' + chalk.yellow('@security:'));
console.log('Security considerations include...');
}
console.log('\n' + chalk.gray('Use `conductor swarm` to implement suggestions\n'));
} catch (error) {
spinner.fail('Consultation failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Review command
program
.command('review [files...]')
.description('Get code review from AI team')
.option('--security', 'Focus on security')
.option('--performance', 'Focus on performance')
.action(async (files, options) => {
const targets = files.length > 0 ? files.join(', ') : 'current directory';
const spinner = ora(`Reviewing ${targets}...`).start();
try {
spinner.text = 'Analyzing code...';
await new Promise(resolve => setTimeout(resolve, 1000));
spinner.text = 'Running security checks...';
await new Promise(resolve => setTimeout(resolve, 800));
spinner.succeed('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('⚠ 2 suggestions for improvement'));
console.log(chalk.blue('ℹ 3 style recommendations'));
if (options.security) {
console.log('\n' + chalk.red('🔒 Security:'));
console.log('• No vulnerabilities detected');
}
if (options.performance) {
console.log('\n' + chalk.yellow('⚡ Performance:'));
console.log('• Consider async optimization');
}
console.log('');
} catch (error) {
spinner.fail('Review failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Swarm command
program
.command('swarm')
.description('Activate parallel AI coordination')
.option('--mode <mode>', 'Mode: research, implement, analyze', 'research')
.action(async (options) => {
const spinner = ora('🐝 Activating swarm intelligence...').start();
try {
spinner.text = 'Coordinating AI agents...';
await new Promise(resolve => setTimeout(resolve, 1200));
spinner.text = `Running ${options.mode} mode...`;
await new Promise(resolve => setTimeout(resolve, 1500));
spinner.succeed('Swarm coordination complete!');
console.log('\n' + chalk.cyan('🐝 Swarm Results:'));
console.log(chalk.gray('─'.repeat(50)));
console.log(`• Mode: ${options.mode}`);
console.log('• 4 agents coordinated in parallel');
console.log('• Tasks completed efficiently');
console.log('• Results optimized and ready\n');
} catch (error) {
spinner.fail('Swarm failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Status command
program
.command('status')
.description('Show system status')
.action(async () => {
const spinner = ora('Checking status...').start();
try {
const integrationManager = new SubAgentIntegrationManager(process.cwd());
const status = await integrationManager.getStatus();
await new Promise(resolve => setTimeout(resolve, 500));
spinner.succeed('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(`✓ Agents: ${status.agentCount} configured`));
console.log(chalk.green('✓ Memory: Ready'));
if (status.configured) {
console.log(chalk.blue('✓ Claude Code sub-agents: Configured'));
console.log(chalk.gray(` Config path: ${status.configPath}`));
} else {
console.log(chalk.yellow('⚠ Claude Code sub-agents: Not configured'));
console.log(chalk.gray(' Run "conductor init" to set up sub-agents'));
}
if (isNpxMode) {
console.log(chalk.blue('ℹ Running via npx'));
}
console.log('');
} catch (error) {
spinner.fail('Status failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
// Sub-agent discovery and marketplace
program
.command('search <query>')
.description('Search for sub-agents from subagents.app and other marketplaces')
.option('-c, --category <category>', 'Filter by category')
.option('-l, --level <level>', 'Filter by level (Beginner, Intermediate, Advanced)')
.option('-r, --min-rating <rating>', 'Minimum rating (0-100)')
.option('-t, --tags <tags>', 'Filter by tags (comma-separated)')
.action(async (query, options) => {
try {
await subAgentCLI.searchCommand(query, options);
} catch (error) {
console.error(chalk.red('Search failed:'), (error as Error).message);
}
});
program
.command('categories')
.description('List available sub-agent categories')
.action(async () => {
try {
await subAgentCLI.categoriesCommand();
} catch (error) {
console.error(chalk.red('Failed to fetch categories:'), (error as Error).message);
}
});
program
.command('install <agent-id>')
.description('Install a sub-agent from the marketplace')
.action(async (agentId) => {
const spinner = ora('Installing sub-agent...').start();
try {
const config = await subAgentCLI.installCommand(agentId);
if (config) {
spinner.succeed('Sub-agent installed successfully!');
console.log(chalk.green('\n✨ Sub-agent is ready to use'));
console.log(chalk.cyan('Run "conductor init" to refresh your configuration\n'));
} else {
spinner.fail('Installation failed');
}
} catch (error) {
spinner.fail('Installation failed');
console.error(chalk.red('Error:'), (error as Error).message);
}
});
program
.command('marketplace')
.description('Browse sub-agent marketplace')
.option('-c, --category <category>', 'Browse specific category')
.action(async (options) => {
console.log(chalk.cyan('\n🏪 SubAgent Marketplace\n'));
if (options.category) {
console.log(chalk.yellow(`Browsing category: ${options.category}`));
await subAgentCLI.searchCommand('', { category: options.category });
} else {
console.log('Available commands:');
console.log(' conductor categories - List all categories');
console.log(' conductor search <query> - Search for agents');
console.log(' conductor marketplace -c <category> - Browse category');
console.log(' conductor install <id> - Install an agent\n');
console.log('Popular categories:');
console.log(' • core-development - Core development specialists');
console.log(' • frontend - Frontend and UI specialists');
console.log(' • backend - Backend and API specialists');
console.log(' • security - Security and audit specialists');
console.log(' • devops - DevOps and deployment specialists\n');
}
});
// Help with examples
program
.command('examples')
.description('Show usage examples')
.action(() => {
console.log(chalk.cyan('\n🚀 Conductor CLI Examples\n'));
console.log(chalk.yellow('Getting Started:'));
console.log(' conductor init --quick');
console.log(' conductor init --tts --elevenlabs-key YOUR_KEY');
console.log(' conductor ask "help me build authentication"');
console.log(' conductor swarm --mode=implement\n');
console.log(chalk.yellow('Sub-Agent Discovery:'));
console.log(' conductor search "react"');
console.log(' conductor categories');
console.log(' conductor marketplace -c core-development');
console.log(' conductor install implementation-specialist\n');
console.log(chalk.yellow('Code Review:'));
console.log(' conductor review src/');
console.log(' conductor review --security app.js');
console.log(' conductor review --performance\n');
console.log(chalk.yellow('AI Consultation:'));
console.log(' conductor ask "optimize this database query"');
console.log(' conductor ask "explain JWT vs sessions"');
console.log(' conductor ask "review my API design" --agent=architect\n');
});
// Default help
if (!process.argv.slice(2).length) {
console.log(chalk.cyan('\n🤖 Conductor CLI - Your AI Development Team\n'));
console.log('Quick start:');
console.log(' conductor init - Set up your AI team');
console.log(' conductor ask <question> - Get expert help');
console.log(' conductor examples - Show usage examples');
console.log(' conductor --help - Show all commands\n');
if (isNpxMode) {
console.log(chalk.gray('💡 Running via npx - no installation needed!'));
}
}
program.parse(process.argv);