UNPKG

blue-beatle

Version:

🤖 AI-Powered Development Assistant - Intelligent code analysis, problem solving, and terminal automation using Gemini API

169 lines (144 loc) 5.87 kB
#!/usr/bin/env node /** * 🤖 Blue Beatle - AI-Powered Development Assistant * Simplified version for npm package */ const fs = require('fs'); const path = require('path'); const os = require('os'); // Get package info const pkg = require('../package.json'); // Simple argument parsing const args = process.argv.slice(2); const command = args[0]; const subcommand = args[1]; // Colors for console output (simple version) const colors = { red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', cyan: '\x1b[36m', white: '\x1b[37m', gray: '\x1b[90m', reset: '\x1b[0m', bold: '\x1b[1m' }; function colorize(color, text) { return `${colors[color]}${text}${colors.reset}`; } function showBanner() { console.log(colorize('cyan', '🤖 Blue Beatle - AI-Powered Development Assistant')); console.log(colorize('gray', `Version ${pkg.version}`)); console.log(''); } function showHelp() { showBanner(); console.log(colorize('blue', '📖 Usage:')); console.log(' blue-beatle --help Show this help'); console.log(' blue-beatle --version Show version'); console.log(' blue-beatle setup Run initial setup'); console.log(' blue-beatle config --setup-api Setup Gemini API key'); console.log(' blue-beatle ai "<question>" Ask AI for help'); console.log(' blue-beatle interactive Start interactive mode'); console.log(' blue-beatle analyze [path] Analyze code'); console.log(' blue-beatle exec "<command>" Execute with AI help'); console.log(''); console.log(colorize('yellow', '🔑 Getting Started:')); console.log('1. Get your free Gemini API key: https://makersuite.google.com/app/apikey'); console.log('2. Run: blue-beatle config --setup-api'); console.log('3. Start using: blue-beatle ai "help me with my code"'); console.log(''); console.log(colorize('green', '✨ Features:')); console.log('• AI-powered code analysis and problem solving'); console.log('• Smart terminal command execution'); console.log('• Security and performance auditing'); console.log('• Interactive AI chat mode'); console.log('• Project management automation'); console.log(''); console.log(colorize('blue', '📚 Documentation: https://github.com/engineermarcus/marcus-alias')); } function showVersion() { console.log(`Blue Beatle v${pkg.version}`); } function showSetupMessage() { showBanner(); console.log(colorize('yellow', '⚠️ Setup Required')); console.log(''); console.log('Blue Beatle requires some dependencies to be installed.'); console.log('Please run the following commands:'); console.log(''); console.log(colorize('cyan', '1. Install dependencies:')); console.log(' npm install'); console.log(''); console.log(colorize('cyan', '2. Setup your API key:')); console.log(' blue-beatle config --setup-api'); console.log(''); console.log(colorize('cyan', '3. Get your free API key at:')); console.log(' https://makersuite.google.com/app/apikey'); console.log(''); console.log('After setup, you can use all Blue Beatle features!'); } function simpleApiSetup() { showBanner(); console.log(colorize('blue', '🔑 API Key Setup')); console.log(''); console.log('To use Blue Beatle, you need a free Gemini API key.'); console.log(''); console.log(colorize('cyan', '1. Get your API key:')); console.log(' https://makersuite.google.com/app/apikey'); console.log(''); console.log(colorize('cyan', '2. Set your API key as environment variable:')); console.log(' export GEMINI_API_KEY="your-api-key-here"'); console.log(' # Or on Windows:'); console.log(' set GEMINI_API_KEY=your-api-key-here'); console.log(''); console.log(colorize('cyan', '3. Install dependencies and run full setup:')); console.log(' npm install'); console.log(' blue-beatle config --setup-api'); console.log(''); console.log('After setup, you can use: blue-beatle ai "your question"'); } function checkDependencies() { const nodeModulesPath = path.join(__dirname, '..', 'node_modules'); return fs.existsSync(nodeModulesPath); } function main() { try { // Handle help and version without dependencies if (command === '--help' || command === '-h' || command === 'help') { showHelp(); return; } if (command === '--version' || command === '-v' || command === 'version') { showVersion(); return; } if (command === 'config' && subcommand === '--setup-api') { simpleApiSetup(); return; } // Check if dependencies are installed if (!checkDependencies()) { showSetupMessage(); return; } // Try to load the full application try { const fullApp = require('../src/index.js'); // The full app should handle the arguments } catch (error) { console.log(colorize('red', '❌ Error loading Blue Beatle:')); console.log(error.message); console.log(''); console.log(colorize('yellow', '💡 Try running:')); console.log(' npm install'); console.log(' blue-beatle --help'); } } catch (error) { console.error(colorize('red', '❌ Blue Beatle Error:'), error.message); process.exit(1); } } // Run the application main();