pame-core-cli
Version:
PAME.AI Core Operating System CLI - Open Source AI Platform for Agentic Commerce
95 lines • 4.7 kB
JavaScript
import { Command } from 'commander';
import chalk from 'chalk';
import inquirer from 'inquirer';
import { execSync } from 'child_process';
import { CoreAIService } from '../utils/ai-service.js';
import ora from 'ora';
import { createPanel, createSecurityNotice } from '../utils/cli-ui.js';
export const coreAiCommand = new Command('ai')
.description('🤖 AI-powered assistant for PAME Core team operations')
.option('-v, --verbose', 'Show detailed AI reasoning and security analysis')
.action(async (options) => {
console.log(createSecurityNotice());
console.log(chalk.hex('#FF6B6B').bold('\n🤖 PAME Core AI Assistant'));
console.log(chalk.gray('AI-powered operations for the core team.\n'));
try {
const coreAI = new CoreAIService();
const projectPath = process.cwd();
while (true) {
const { userInput } = await inquirer.prompt([{
type: 'input',
name: 'userInput',
message: 'Core operation request:',
validate: (input) => input.trim().length > 0 || 'Please enter a command'
}]);
if (userInput.toLowerCase() === 'exit' || userInput.toLowerCase() === 'quit') {
console.log(chalk.green('\n👋 Core session ended.'));
break;
}
if (userInput.toLowerCase() === '/help') {
showCoreAIHelp();
continue;
}
const spinner = ora('🧠 Processing core operation...').start();
try {
const aiResponse = await coreAI.processNaturalLanguage(userInput, projectPath);
spinner.stop();
const analysisContent = [
`Command: ${aiResponse.command} ${aiResponse.args.join(' ')}`,
`Explanation: ${aiResponse.explanation}`,
`Confidence: ${aiResponse.confidence}%`,
`Risk Level: ${aiResponse.riskLevel.toUpperCase()}`
].join('\n');
console.log(createPanel(analysisContent, {
title: '🎯 Core AI Analysis',
type: 'info'
}));
if (aiResponse.confidence > 70) {
const { shouldExecute } = await inquirer.prompt([{
type: 'confirm',
name: 'shouldExecute',
message: 'Execute this core operation?',
default: aiResponse.confidence > 85
}]);
if (shouldExecute) {
console.log(chalk.green('\n⚡ Executing core operation...\n'));
try {
const fullCommand = `${aiResponse.command} ${aiResponse.args.join(' ')}`;
console.log(chalk.dim(`[AUDIT] ${new Date().toISOString()} - Executing: ${fullCommand}`));
execSync(fullCommand, { stdio: 'inherit' });
console.log(chalk.green('\n✅ Core operation completed successfully!'));
}
catch (error) {
console.error(chalk.red('\n❌ Core operation failed:'), error);
}
}
}
else {
console.log(chalk.yellow('\n⚠ Low confidence - manual review recommended.'));
}
}
catch (error) {
spinner.stop();
console.error(chalk.red('\n❌ Core AI processing failed:'), error);
}
console.log(chalk.gray('\nType "exit" to quit, "/help" for commands\n'));
}
}
catch (error) {
console.error(chalk.red('Core AI Assistant error:'), error);
process.exit(1);
}
});
function showCoreAIHelp() {
console.log(chalk.blue('\n🤖 Core AI Assistant Help\n'));
console.log(chalk.white('Example Core Operations:'));
console.log(chalk.gray(' • "Deploy app platform to production"'));
console.log(chalk.gray(' • "Check system health across all services"'));
console.log(chalk.gray(' • "Set up new WhatsApp integration"'));
console.log(chalk.gray(' • "Monitor team access and permissions"\n'));
console.log(chalk.white('Security Features:'));
console.log(chalk.gray(' • All operations are logged and audited'));
console.log(chalk.gray(' • High-risk operations require confirmation'));
console.log(chalk.gray(' • Automatic risk assessment for all commands\n'));
}
//# sourceMappingURL=ai-simple.js.map