- Implement multi-agent orchestration system for parallel AI tasks - Add role-based AI assignment (coder, reviewer, critic, architect, etc) - Create predefined workflows (code-review, implement-feature, optimize, debug) - Add local LLM support with auto-detection (Ollama, LocalAI, etc) - Implement async job management with idle timeout - Add authentication system with OAuth2 PKCE flow - Create comprehensive test suite with integration tests - Add headless Chrome testing for auth flows - Create mock AI server for testing all endpoints - Add visual test runners and demo scripts - Update CI/CD pipeline for all services - Rename CLI from 'hanzo-dev' to 'dev' for simplicity - Update repository references to github.com/hanzoai/dev Key features: - Parallel execution of multiple AI agents - Git worktree support for isolated development - Universal context sync across tools - Secure API key management - Comprehensive workflow system
189 lines
6.1 KiB
JavaScript
189 lines
6.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const chalk = require('chalk');
|
|
|
|
console.log(chalk.bold.cyan('\n🎭 Dev CLI Workflow Demo\n'));
|
|
console.log(chalk.gray('Demonstrating multi-agent workflows in action'));
|
|
console.log(chalk.gray('='.repeat(60)));
|
|
console.log();
|
|
|
|
// Simulate workflow execution
|
|
async function simulateWorkflow() {
|
|
// Code Review Workflow
|
|
console.log(chalk.bold.blue('\n🔍 Running Code Review Workflow'));
|
|
console.log(chalk.gray('$ dev workflow code-review'));
|
|
console.log();
|
|
|
|
// Step 1: Initial Review (Parallel)
|
|
console.log(chalk.yellow('Step 1: initial-review (parallel execution)'));
|
|
|
|
await showAgentWork('Gemini (Reviewer)', 'gemini', `
|
|
Analyzing code structure and patterns...
|
|
✓ Clean function separation
|
|
✓ Proper module exports
|
|
⚠️ Missing TypeScript types
|
|
⚠️ No input validation
|
|
`.trim(), 'blue');
|
|
|
|
await showAgentWork('Codex (Critic)', 'codex', `
|
|
Identifying potential issues...
|
|
⚠️ No error handling for edge cases
|
|
⚠️ Missing unit tests
|
|
💡 Consider adding JSDoc comments
|
|
💡 Implement input type checking
|
|
`.trim(), 'green');
|
|
|
|
await showAgentWork('Claude (Architect)', 'claude', `
|
|
Evaluating architecture and design...
|
|
✓ Single responsibility principle followed
|
|
✓ Functions are pure and testable
|
|
🏗️ Consider extracting to a Math utility class
|
|
🏗️ Add configuration for precision handling
|
|
`.trim(), 'magenta');
|
|
|
|
console.log();
|
|
|
|
// Step 2: Synthesis
|
|
console.log(chalk.yellow('Step 2: synthesize'));
|
|
|
|
await showAgentWork('Claude (Synthesizer)', 'claude', `
|
|
📝 Synthesized Code Review Report
|
|
|
|
**Priority 1 - Critical Issues:**
|
|
• Add input validation for type safety
|
|
• Implement error handling for edge cases
|
|
|
|
**Priority 2 - Important Improvements:**
|
|
• Add comprehensive unit tests
|
|
• Include TypeScript type definitions
|
|
• Add JSDoc documentation
|
|
|
|
**Priority 3 - Nice to Have:**
|
|
• Extract to utility class for better organization
|
|
• Add configuration options for precision
|
|
• Consider memoization for performance
|
|
|
|
**Overall Assessment:** 🌟🌟🌟 (3/5)
|
|
The code is functional but needs robustness improvements.
|
|
`.trim(), 'cyan');
|
|
|
|
console.log(chalk.green('\n✓ Code review workflow completed!'));
|
|
|
|
// Feature Implementation Workflow
|
|
console.log(chalk.bold.blue('\n🚀 Running Feature Implementation Workflow'));
|
|
console.log(chalk.gray('$ dev workflow implement-feature "add user authentication"'));
|
|
console.log();
|
|
|
|
// Step 1: Design
|
|
console.log(chalk.yellow('Step 1: design'));
|
|
|
|
await showAgentWork('Claude (Architect)', 'claude', `
|
|
🏗️ Authentication System Design
|
|
|
|
**Architecture:**
|
|
• JWT-based authentication
|
|
• Refresh token rotation
|
|
• Role-based access control (RBAC)
|
|
|
|
**Components:**
|
|
1. AuthController - Handle login/logout
|
|
2. AuthMiddleware - Validate tokens
|
|
3. UserService - User management
|
|
4. TokenService - JWT operations
|
|
|
|
**Database Schema:**
|
|
- users (id, email, password_hash, created_at)
|
|
- refresh_tokens (token, user_id, expires_at)
|
|
- roles (id, name, permissions)
|
|
`.trim(), 'magenta');
|
|
|
|
console.log();
|
|
|
|
// Step 2: Implementation (Parallel)
|
|
console.log(chalk.yellow('Step 2: implement (parallel execution)'));
|
|
|
|
await Promise.all([
|
|
showAgentWork('Aider (Coder)', 'aider', `
|
|
Implementing authentication system...
|
|
✓ Created AuthController.js
|
|
✓ Created AuthMiddleware.js
|
|
✓ Created UserService.js
|
|
✓ Added JWT token generation
|
|
✓ Implemented password hashing
|
|
`.trim(), 'green', 0),
|
|
|
|
showAgentWork('Codex (Tester)', 'codex', `
|
|
Writing test suite...
|
|
✓ Created auth.test.js
|
|
✓ Added login endpoint tests
|
|
✓ Added token validation tests
|
|
✓ Added middleware tests
|
|
✓ 100% code coverage achieved
|
|
`.trim(), 'blue', 0),
|
|
|
|
showAgentWork('Gemini (Documenter)', 'gemini', `
|
|
Creating documentation...
|
|
✓ Updated API.md with auth endpoints
|
|
✓ Created AUTH_GUIDE.md
|
|
✓ Added inline code comments
|
|
✓ Generated OpenAPI spec
|
|
✓ Created integration examples
|
|
`.trim(), 'yellow', 0)
|
|
]);
|
|
|
|
console.log();
|
|
|
|
// Step 3: Review
|
|
console.log(chalk.yellow('Step 3: review'));
|
|
|
|
console.log(chalk.gray('Agents voting on implementation quality...'));
|
|
await sleep(1000);
|
|
|
|
console.log(chalk.green('✓ Claude: Approved - Clean architecture'));
|
|
console.log(chalk.green('✓ Gemini: Approved - Well documented'));
|
|
|
|
console.log(chalk.green('\n✓ Feature implementation workflow completed!'));
|
|
|
|
// Summary
|
|
console.log(chalk.bold.cyan('\n📊 Workflow Summary'));
|
|
console.log(chalk.gray('='.repeat(60)));
|
|
console.log(chalk.green('✓ 2 workflows executed successfully'));
|
|
console.log(chalk.blue('✓ 7 AI agents collaborated'));
|
|
console.log(chalk.yellow('✓ Parallel execution saved ~60% time'));
|
|
console.log(chalk.magenta('✓ Comprehensive results achieved'));
|
|
}
|
|
|
|
// Helper to show agent work with animation
|
|
async function showAgentWork(name, tool, output, color = 'white', delay = 200) {
|
|
const spinner = ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'];
|
|
let i = 0;
|
|
|
|
process.stdout.write(chalk[color](`\n[${tool}] ${name} `));
|
|
|
|
const interval = setInterval(() => {
|
|
process.stdout.write(`\r${chalk[color](`[${tool}] ${name} ${spinner[i++ % spinner.length]}`)}`);
|
|
}, 100);
|
|
|
|
await sleep(delay);
|
|
clearInterval(interval);
|
|
|
|
process.stdout.write(`\r${chalk[color](`[${tool}] ${name} ✓`)}\n`);
|
|
console.log(chalk.gray(output));
|
|
}
|
|
|
|
function sleep(ms) {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
|
|
// Run the demo
|
|
if (require.main === module) {
|
|
simulateWorkflow().then(() => {
|
|
console.log(chalk.green('\n\n✨ Workflow demo completed!'));
|
|
console.log(chalk.cyan('\nTry it yourself:'));
|
|
console.log(chalk.gray(' dev workflow code-review'));
|
|
console.log(chalk.gray(' dev workflow implement-feature "your feature"'));
|
|
console.log(chalk.gray(' dev workflow optimize "your code"'));
|
|
console.log(chalk.gray(' dev workflow debug "your issue"'));
|
|
console.log();
|
|
});
|
|
} |