UNPKG

blue-beatle

Version:

šŸ¤– AI-Powered Development Assistant - Intelligent code analysis, problem solving, and terminal automation using Gemini API

274 lines (237 loc) • 9.01 kB
/** * šŸŽØ Display Utilities - Beautiful console output and formatting */ const chalk = require('chalk'); const figlet = require('figlet'); const gradient = require('gradient-string'); const boxen = require('boxen'); function showBanner() { console.clear(); const title = figlet.textSync('Blue Beatle', { font: 'ANSI Shadow', horizontalLayout: 'default', verticalLayout: 'default' }); const gradientTitle = gradient(['#00f5ff', '#0080ff', '#0040ff'])(title); console.log(gradientTitle); const subtitle = 'šŸ¤– AI-Powered Development Assistant'; const version = 'v1.0.0'; const author = 'by Engineermarcus'; console.log(chalk.cyan.bold(subtitle.padStart(subtitle.length + 20))); console.log(chalk.gray(version.padStart(version.length + 35))); console.log(chalk.gray(author.padStart(author.length + 33))); console.log(''); const features = [ '🧠 Intelligent code analysis with Gemini AI', '⚔ Smart terminal command execution', 'šŸ” Advanced security and performance scanning', 'šŸ“ Automated project management', 'šŸŽÆ Interactive AI assistant mode' ]; console.log(chalk.blue.bold('✨ Features:')); features.forEach(feature => { console.log(chalk.gray(` ${feature}`)); }); console.log(''); } function showHelp() { console.log(chalk.cyan('šŸ¤– Blue Beatle - AI-Powered Development Assistant\n')); const helpSections = [ { title: '🧠 AI Commands', commands: [ { cmd: 'ai <prompt>', desc: 'Ask AI to solve coding problems' }, { cmd: 'interactive', desc: 'Start interactive AI chat mode' }, { cmd: 'learn <topic>', desc: 'Learn about development topics' }, { cmd: 'debug [file]', desc: 'Debug code with AI assistance' }, { cmd: 'generate <type>', desc: 'Generate code with AI' } ] }, { title: 'šŸ” Code Analysis', commands: [ { cmd: 'analyze [path]', desc: 'Analyze code for issues' }, { cmd: 'watch [path]', desc: 'Watch files for changes' }, { cmd: 'perf [path]', desc: 'Performance analysis' }, { cmd: 'security [path]', desc: 'Security audit' } ] }, { title: '⚔ Terminal Execution', commands: [ { cmd: 'exec <command>', desc: 'Execute commands with AI help' }, { cmd: 'exec <cmd> --interactive', desc: 'Interactive command mode' }, { cmd: 'exec <cmd> --safe', desc: 'Safe mode with confirmations' } ] }, { title: 'šŸ“ Project Management', commands: [ { cmd: 'project --init', desc: 'Initialize new project' }, { cmd: 'project --setup <type>', desc: 'Setup project type' }, { cmd: 'project --deploy', desc: 'Deploy project' }, { cmd: 'project --test', desc: 'Run tests with analysis' } ] }, { title: 'āš™ļø Configuration', commands: [ { cmd: 'config --setup-api', desc: 'Setup Gemini API key' }, { cmd: 'config --set key=value', desc: 'Set configuration' }, { cmd: 'config --list', desc: 'List all settings' }, { cmd: 'setup', desc: 'Initial setup wizard' } ] } ]; helpSections.forEach(section => { console.log(chalk.blue.bold(section.title)); section.commands.forEach(({ cmd, desc }) => { console.log(chalk.gray(` ${cmd.padEnd(25)} ${desc}`)); }); console.log(''); }); console.log(chalk.yellow('šŸ’” Examples:')); console.log(chalk.gray(' macadida ai "help me fix this React component"')); console.log(chalk.gray(' macadida analyze --type security --fix')); console.log(chalk.gray(' macadida exec "npm install" --interactive')); console.log(chalk.gray(' macadida project --init')); console.log(chalk.gray(' macadida interactive')); console.log(''); console.log(chalk.cyan('šŸš€ Get started: macadida setup')); console.log(chalk.gray('šŸ“– Documentation: https://github.com/engineermarcus/marcus-alias')); } function showProgress(message, steps = []) { console.log(chalk.cyan(`\nšŸ”„ ${message}\n`)); steps.forEach((step, index) => { const status = step.completed ? 'āœ…' : step.current ? 'šŸ”„' : 'ā³'; const color = step.completed ? chalk.green : step.current ? chalk.yellow : chalk.gray; console.log(color(`${status} ${index + 1}. ${step.name}`)); }); console.log(''); } function showSuccess(message, details = []) { const box = boxen( chalk.green.bold(`āœ… ${message}`) + (details.length > 0 ? '\n\n' + details.map(d => chalk.gray(`• ${d}`)).join('\n') : ''), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'green' } ); console.log(box); } function showError(message, suggestions = []) { const box = boxen( chalk.red.bold(`āŒ ${message}`) + (suggestions.length > 0 ? '\n\n' + chalk.yellow('šŸ’” Suggestions:\n') + suggestions.map(s => chalk.gray(`• ${s}`)).join('\n') : ''), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'red' } ); console.log(box); } function showWarning(message, details = []) { const box = boxen( chalk.yellow.bold(`āš ļø ${message}`) + (details.length > 0 ? '\n\n' + details.map(d => chalk.gray(`• ${d}`)).join('\n') : ''), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'yellow' } ); console.log(box); } function showInfo(message, details = []) { const box = boxen( chalk.blue.bold(`ā„¹ļø ${message}`) + (details.length > 0 ? '\n\n' + details.map(d => chalk.gray(`• ${d}`)).join('\n') : ''), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'blue' } ); console.log(box); } function formatTable(data, headers) { const Table = require('cli-table3'); const table = new Table({ head: headers.map(h => chalk.cyan.bold(h)), style: { head: [], border: ['gray'] } }); data.forEach(row => { table.push(row); }); return table.toString(); } function formatCode(code, language = 'javascript') { const lines = code.split('\n'); const formatted = lines.map((line, index) => { const lineNumber = (index + 1).toString().padStart(3, ' '); return chalk.gray(`${lineNumber} │ `) + chalk.green(line); }).join('\n'); return `\n${chalk.blue(`ā”Œā”€ ${language.toUpperCase()} ─`)}\n${formatted}\n${chalk.blue('└─')}\n`; } function formatJson(obj) { return JSON.stringify(obj, null, 2) .split('\n') .map(line => { if (line.includes(':')) { const [key, ...value] = line.split(':'); return chalk.blue(key) + ':' + chalk.green(value.join(':')); } return chalk.gray(line); }) .join('\n'); } function showSpinner(message) { const ora = require('ora'); return ora(message).start(); } function formatFileSize(bytes) { const sizes = ['Bytes', 'KB', 'MB', 'GB']; if (bytes === 0) return '0 Bytes'; const i = Math.floor(Math.log(bytes) / Math.log(1024)); return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i]; } function formatDuration(ms) { if (ms < 1000) return `${ms}ms`; if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`; if (ms < 3600000) return `${(ms / 60000).toFixed(1)}m`; return `${(ms / 3600000).toFixed(1)}h`; } function createProgressBar(current, total, width = 40) { const percentage = Math.round((current / total) * 100); const filled = Math.round((current / total) * width); const empty = width - filled; const bar = 'ā–ˆ'.repeat(filled) + 'ā–‘'.repeat(empty); return `${chalk.cyan(bar)} ${percentage}% (${current}/${total})`; } module.exports = { showBanner, showHelp, showProgress, showSuccess, showError, showWarning, showInfo, formatTable, formatCode, formatJson, showSpinner, formatFileSize, formatDuration, createProgressBar };