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
JavaScript
/**
* šØ 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
};