sophia-code
Version:
Production-ready agentic CLI code editor with AI-powered coding assistance, planning, and multi-agent delegation. Enterprise-grade security and reliability.
109 lines (91 loc) โข 3.27 kB
JavaScript
/**
* Test script for sophia-code
* Verifies that Sophia CLI is working correctly
*/
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const packageRoot = process.cwd();
const venvPath = path.join(packageRoot, '.venv');
console.log(chalk.blue('๐งช Testing Sophia CLI...'));
// Test 1: Check if virtual environment exists
console.log(chalk.gray(' Checking Python virtual environment...'));
if (fs.existsSync(venvPath)) {
console.log(chalk.green(' โ
Virtual environment found'));
} else {
console.log(chalk.red(' โ Virtual environment not found'));
console.log(chalk.yellow(' Run: npm run setup-python'));
process.exit(1);
}
// Test 2: Check if Sophia CLI responds to --version
console.log(chalk.gray(' Testing Sophia CLI --version...'));
const sophiaPath = path.join(__dirname, '..', 'bin', 'sophia.js');
const testProcess = spawn('node', [sophiaPath, '--version'], {
cwd: packageRoot,
stdio: 'pipe',
env: {
...process.env,
PYTHONPATH: path.join(packageRoot, 'src')
}
});
let output = '';
let errorOutput = '';
testProcess.stdout.on('data', (data) => {
output += data.toString();
});
testProcess.stderr.on('data', (data) => {
errorOutput += data.toString();
});
testProcess.on('close', (code) => {
if (code === 0 && output.includes('Sophia CLI')) {
console.log(chalk.green(' โ
Sophia CLI version check passed'));
console.log(chalk.gray(` ${output.trim()}`));
// Test 3: Check configuration access
console.log(chalk.gray(' Testing configuration access...'));
const configProcess = spawn('node', [sophiaPath, '--config'], {
cwd: packageRoot,
stdio: 'pipe',
env: {
...process.env,
PYTHONPATH: path.join(packageRoot, 'src')
}
});
let configOutput = '';
configProcess.stdout.on('data', (data) => {
configOutput += data.toString();
});
configProcess.on('close', (configCode) => {
if (configCode === 0 && configOutput.includes('Configuration:')) {
console.log(chalk.green(' โ
Configuration access working'));
console.log('');
console.log(chalk.green('๐ All tests passed! Sophia is ready to use.'));
console.log('');
console.log(chalk.cyan('Next steps:'));
console.log(chalk.white(' 1. Set GROQ_API_KEY: export GROQ_API_KEY="your_key"'));
console.log(chalk.white(' 2. Run: sophia'));
} else {
console.log(chalk.red(' โ Configuration access failed'));
if (configOutput) console.log(chalk.gray(` ${configOutput}`));
process.exit(1);
}
});
} else {
console.log(chalk.red(' โ Sophia CLI version check failed'));
if (errorOutput) {
console.log(chalk.yellow(' Error details:'));
console.log(chalk.gray(` ${errorOutput}`));
}
if (output) {
console.log(chalk.yellow(' Output:'));
console.log(chalk.gray(` ${output}`));
}
process.exit(1);
}
});
testProcess.on('error', (error) => {
console.log(chalk.red(' โ Failed to run Sophia CLI'));
console.error(chalk.red(' Error:', error.message));
process.exit(1);
});