UNPKG

sophia-code

Version:

Production-ready agentic CLI code editor with AI-powered coding assistance, planning, and multi-agent delegation. Enterprise-grade security and reliability.

167 lines (143 loc) 4.6 kB
#!/usr/bin/env node /** * Dependency check script for sophia-code * Verifies all required dependencies are available */ const { spawn } = require('child_process'); const fs = require('fs'); const path = require('path'); const chalk = require('chalk'); const which = require('which'); console.log(chalk.blue('🔍 Checking Sophia Code Dependencies')); console.log(chalk.blue('====================================')); const checks = [ { name: 'Node.js', command: 'node', args: ['--version'], required: '>=14.0.0' }, { name: 'npm', command: 'npm', args: ['--version'], required: '>=6.0.0' }, { name: 'Python 3', command: 'python3', args: ['--version'], required: '>=3.9.0' }, { name: 'pip', command: 'pip3', args: ['--version'], required: 'any' } ]; let allPassed = true; function checkCommand(check) { return new Promise((resolve) => { // First check if command exists which(check.command) .then(() => { const process = spawn(check.command, check.args, { stdio: 'pipe' }); let output = ''; process.stdout.on('data', (data) => { output += data.toString(); }); process.on('close', (code) => { if (code === 0) { const version = output.trim().split(' ').pop() || 'unknown'; console.log(chalk.green(` ✅ ${check.name}: ${version}`)); resolve(true); } else { console.log(chalk.red(` ❌ ${check.name}: Failed to get version`)); allPassed = false; resolve(false); } }); process.on('error', () => { console.log(chalk.red(` ❌ ${check.name}: Not found`)); allPassed = false; resolve(false); }); }) .catch(() => { console.log(chalk.red(` ❌ ${check.name}: Not found`)); allPassed = false; resolve(false); }); }); } async function runChecks() { console.log(chalk.gray('Checking system dependencies...')); for (const check of checks) { await checkCommand(check); } console.log(''); // Check package-specific files console.log(chalk.gray('Checking package files...')); const packageRoot = process.cwd(); const requiredFiles = [ 'src/cli.py', 'src/groq_client.py', 'requirements.txt', 'setup.sh' ]; for (const file of requiredFiles) { const filePath = path.join(packageRoot, file); if (fs.existsSync(filePath)) { console.log(chalk.green(` ✅ ${file}`)); } else { console.log(chalk.red(` ❌ ${file}: Missing`)); allPassed = false; } } console.log(''); // Check virtual environment console.log(chalk.gray('Checking Python virtual environment...')); const venvPath = path.join(packageRoot, '.venv'); if (fs.existsSync(venvPath)) { console.log(chalk.green(' ✅ Virtual environment exists')); // Check if Python works in venv const venvPython = process.platform === 'win32' ? path.join(venvPath, 'Scripts', 'python.exe') : path.join(venvPath, 'bin', 'python'); if (fs.existsSync(venvPython)) { console.log(chalk.green(' ✅ Python executable in venv')); } else { console.log(chalk.red(' ❌ Python executable missing in venv')); allPassed = false; } } else { console.log(chalk.yellow(' ⚠️ Virtual environment not found')); console.log(chalk.gray(' Run: npm run setup-python')); } console.log(''); // Summary if (allPassed) { console.log(chalk.green('🎉 All dependencies check passed!')); console.log(''); console.log(chalk.cyan('Ready to use:')); console.log(chalk.white(' sophia --version')); console.log(chalk.white(' sophia --help')); console.log(chalk.white(' sophia')); } else { console.log(chalk.red('❌ Some dependencies are missing.')); console.log(''); console.log(chalk.cyan('To fix issues:')); console.log(chalk.white(' npm run setup-python # Set up Python environment')); console.log(chalk.white(' npm test # Test installation')); console.log(''); console.log(chalk.yellow('For system dependencies:')); console.log(chalk.white(' - Install Python 3.9+: https://python.org/downloads/')); console.log(chalk.white(' - Update Node.js: https://nodejs.org/')); process.exit(1); } } runChecks().catch((error) => { console.error(chalk.red('❌ Error during dependency check:'), error.message); process.exit(1); });