sophia-code
Version:
Production-ready agentic CLI code editor with AI-powered coding assistance, planning, and multi-agent delegation. Enterprise-grade security and reliability.
90 lines (73 loc) • 2.98 kB
JavaScript
/**
* Post-install script for sophia-code
* Sets up the Python environment and dependencies
*/
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const ora = require('ora');
const packageRoot = process.cwd();
const setupScript = process.platform === 'win32' ? 'setup.bat' : './setup.sh';
console.log(chalk.blue('🤖 Setting up Sophia Code...'));
// Check if we're in the right directory
if (!fs.existsSync(path.join(packageRoot, 'setup.sh'))) {
console.log(chalk.yellow('⚠️ Setup script not found, skipping Python environment setup.'));
console.log(chalk.gray(' This is normal if installing from npm registry.'));
process.exit(0);
}
const spinner = ora('Setting up Python virtual environment...').start();
// Run the setup script
const setupProcess = spawn(setupScript, [], {
cwd: packageRoot,
stdio: 'pipe',
shell: true
});
let output = '';
let errorOutput = '';
setupProcess.stdout.on('data', (data) => {
output += data.toString();
});
setupProcess.stderr.on('data', (data) => {
errorOutput += data.toString();
});
setupProcess.on('close', (code) => {
if (code === 0) {
spinner.succeed('Python environment setup complete!');
console.log(chalk.green('✅ Sophia v1.0.0 is ready for production!'));
console.log('');
console.log(chalk.cyan('🚀 Get started:'));
console.log(chalk.white(' 1. Get your Groq API key from: https://console.groq.com/'));
console.log(chalk.white(' 2. Set it: export GROQ_API_KEY="your_api_key_here"'));
console.log(chalk.white(' 3. Optional: export GITHUB_TOKEN="your_github_token"'));
console.log(chalk.white(' 4. Run: sophia'));
console.log('');
console.log(chalk.cyan('🏥 Production features:'));
console.log(chalk.white(' • Use "/health" to check system status'));
console.log(chalk.white(' • Use "/safe on" for secure environments'));
console.log(chalk.white(' • Enterprise-grade rate limiting & security'));
console.log('');
} else {
spinner.fail('Failed to set up Python environment');
console.error(chalk.red('❌ Setup failed with exit code:', code));
if (errorOutput) {
console.log(chalk.yellow('Error details:'));
console.log(errorOutput);
}
console.log(chalk.cyan('💡 You may need to:'));
console.log(chalk.white(' - Install Python 3.9+ on your system'));
console.log(chalk.white(' - Run manually: cd node_modules/sophia-code && ./setup.sh'));
// Don't fail the npm install, just warn
process.exit(0);
}
});
setupProcess.on('error', (error) => {
spinner.fail('Failed to run setup script');
console.error(chalk.red('❌ Error:', error.message));
if (error.code === 'ENOENT') {
console.log(chalk.cyan('💡 Make sure you have bash/shell available on your system.'));
}
// Don't fail the npm install, just warn
process.exit(0);
});