vibe-coding-toolbox
Version:
CLI tools for AI-powered prompt enhancement, local project scanning, and component analysis - extends vibecodingtoolbox.com
144 lines (123 loc) • 5.9 kB
JavaScript
const { program } = require('commander');
const chalk = require('chalk').default || require('chalk');
const packageJson = require('../package.json');
const { configManager } = require('../src/config/configManager');
// Import command modules (to be created)
const authCommand = require('../src/commands/auth');
const enhanceCommand = require('../src/commands/enhance');
const scanCommand = require('../src/commands/scan');
const componentCommand = require('../src/commands/component');
const creditsCommand = require('../src/commands/credits');
const configCommand = require('../src/commands/config');
// ASCII Art Banner
const banner = `
${chalk.blueBright('╔══════════════════════════════════════════════════╗')}
${chalk.blueBright('║')} ${chalk.white.bold('Vibe Coding Toolbox CLI')} ${chalk.gray(`v${packageJson.version}`)} ${chalk.blueBright('║')}
${chalk.blueBright('║')} ${chalk.gray('AI-powered development enhancement')} ${chalk.blueBright('║')}
${chalk.blueBright('╚══════════════════════════════════════════════════╝')}
`;
// Configure the CLI
program
.name('vibe')
.description(packageJson.description)
.version(packageJson.version)
.addHelpText('before', banner)
.addHelpText('after', `
${chalk.bold('Quick Start:')}
${chalk.gray('First time setup:')} vibe auth login
${chalk.gray('Enhance a prompt:')} vibe enhance "Create a REST API"
${chalk.gray('Scan your project:')} vibe scan --context
${chalk.gray('Analyze components:')} vibe component analyze --framework react
${chalk.bold('Examples:')}
${chalk.gray('# Enhance a prompt with AI')}
$ vibe enhance "Build a todo app with authentication"
${chalk.gray('# Scan project and generate context')}
$ vibe scan --context --output context.json
${chalk.gray('# Check component complexity')}
$ vibe component complexity --framework react
${chalk.bold('Authentication Status:')}
Commands marked with ${chalk.yellow('*')} require authentication via 'vibe auth login'
${chalk.bold('Available Help Commands:')}
$ vibe --help # This main help menu
$ vibe auth --help # Authentication guide & API key setup
$ vibe enhance --help # AI enhancement options & examples
$ vibe scan --help # Project scanning options
$ vibe credits --help # Credit usage & balance info
$ vibe config --help # Configuration settings
$ vibe component --help # Component analysis tools
$ vibe component analyze --help # Component structure analysis
$ vibe component complexity --help # Complexity metrics details
$ vibe component suggestions --help # Refactoring suggestions
${chalk.gray('For detailed help on any command:')}
$ vibe [command] --help
`);
// Global options
program
.option('-v, --verbose', 'enable verbose logging')
.option('--no-color', 'disable color output');
// Old config command removed - now using the enhanced config command module
// Register commands
authCommand(program);
enhanceCommand(program);
scanCommand(program);
creditsCommand(program);
configCommand(program);
// Component analysis commands
const component = program
.command('component')
.description('Analyze UI components in your project (no auth required)');
component
.command('analyze [componentName]')
.description('Analyze components structure, props, methods, and dependencies')
.option('-p, --path <path>', 'Path to project directory (default: current directory)', process.cwd())
.option('-f, --framework <framework>', 'Framework to analyze: react, vue, angular (auto-detects if not specified)')
.option('-o, --output <file>', 'Save results to JSON file')
.option('-v, --verbose', 'Show detailed analysis including file paths')
.action(componentCommand.analyzeCommand)
.addHelpText('after', `
Examples:
$ vibe component analyze # Analyze all components
$ vibe component analyze Button # Analyze specific component
$ vibe component analyze -f react -o report.json
`);
component
.command('complexity')
.description('Calculate complexity scores, lines of code, methods, and nesting depth')
.option('-p, --path <path>', 'Path to project directory (default: current directory)', process.cwd())
.option('-f, --framework <framework>', 'Framework to analyze: react, vue, angular')
.action(componentCommand.complexityCommand)
.addHelpText('after', `
Examples:
$ vibe component complexity # Show complexity metrics
$ vibe component complexity -f react # Specify framework
Metrics shown:
- Complexity level (Low/Medium/High)
- Lines of code
- Number of methods
- Props count
- Maximum nesting depth
`);
component
.command('suggestions')
.description('Identify duplicate patterns and suggest refactoring opportunities')
.option('-p, --path <path>', 'Path to project directory (default: current directory)', process.cwd())
.option('-f, --framework <framework>', 'Framework to analyze: react, vue, angular')
.action(componentCommand.suggestionsCommand)
.addHelpText('after', `
Examples:
$ vibe component suggestions # Get refactoring suggestions
$ vibe component suggestions -f vue # Specify framework
Provides:
- Reusability recommendations
- Duplicate code detection
- Refactoring opportunities
- Most reused components list
- Component reusability scores
`);
// Parse command line arguments
program.parse();
// Show help if no command is provided
if (program.args.length === 0) {
program.help();
}