aide-cli
Version:
AIDE - The companion control system for Claude Code with intelligent task management
169 lines (145 loc) ⢠5.92 kB
JavaScript
const chalk = require('chalk');
const { program } = require('commander');
const pkg = require('../package.json');
const installer = require('../lib/installer');
const verifier = require('../lib/verifier');
program
.name('aide')
.description('AIDE: Adaptive Intelligent Development Enhancer for Claude Code')
.version(pkg.version);
program
.command('install')
.description('Install AIDE integration with Claude Code')
.option('-f, --force', 'Force reinstallation even if already installed')
.option('--python <cmd>', 'Specify Python command to use')
.option('--claude-dir <dir>', 'Specify Claude Code directory')
.option('--daemon', 'Enable daemon mode for seamless command execution')
.option('--no-daemon', 'Use direct Python execution (no background daemon)')
.action(async (options) => {
console.log(chalk.blue.bold('\nš AIDE Installer\n'));
try {
// Set daemon mode as default if not specified
if (options.daemon === undefined && options.noDaemon === undefined) {
console.log(chalk.green('š¤ Daemon mode enabled by default for seamless command execution'));
console.log(chalk.gray(' Use --no-daemon if you prefer direct execution mode'));
options.daemon = true;
} else if (options.noDaemon) {
options.daemon = false;
}
await installer.install(options);
console.log(chalk.green.bold('\nā
AIDE installed successfully!'));
console.log(chalk.yellow('\nš” Open a new Claude Code session to use AIDE'));
console.log(chalk.gray(' Try: "Create a new project" and watch AIDE activate automatically\n'));
} catch (error) {
console.error(chalk.red.bold('\nā Installation failed:'));
console.error(chalk.red(error.message));
console.log(chalk.yellow('\nš§ Troubleshooting:'));
console.log(chalk.gray(' 1. Make sure Claude Code is installed'));
console.log(chalk.gray(' 2. Check that Python 3.7+ is available'));
console.log(chalk.gray(' 3. Run with --force to reinstall'));
console.log(chalk.gray(' 4. Specify Python with --python python3\n'));
process.exit(1);
}
});
program
.command('verify')
.description('Verify AIDE installation')
.action(async () => {
console.log(chalk.blue.bold('\nš Verifying AIDE Installation\n'));
try {
const result = await verifier.verify();
if (result.success) {
console.log(chalk.green.bold('ā
AIDE is properly installed'));
console.log(chalk.green(` Python: ${result.python}`));
console.log(chalk.green(` Claude dir: ${result.claudeDir}`));
console.log(chalk.green(` Scripts: ${result.scriptsCount} installed`));
} else {
console.log(chalk.red.bold('ā AIDE installation issues found:'));
result.issues.forEach(issue => {
console.log(chalk.red(` ⢠${issue}`));
});
console.log(chalk.yellow('\nš” Run "aide install --force" to fix'));
}
} catch (error) {
console.error(chalk.red.bold('ā Verification failed:'));
console.error(chalk.red(error.message));
}
});
program
.command('uninstall')
.description('Remove AIDE integration')
.option('--keep-backups', 'Keep backup files')
.action(async (options) => {
console.log(chalk.yellow.bold('\nšļø Uninstalling AIDE\n'));
try {
await installer.uninstall(options);
console.log(chalk.green.bold('ā
AIDE uninstalled successfully'));
} catch (error) {
console.error(chalk.red.bold('ā Uninstallation failed:'));
console.error(chalk.red(error.message));
}
});
program
.command('status')
.description('Show AIDE status for current project')
.action(async () => {
try {
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);
// Check if .aide exists in current directory
const fs = require('fs-extra');
const aideExists = await fs.pathExists('.aide');
if (!aideExists) {
console.log(chalk.yellow('ā ļø AIDE not initialized in this project'));
console.log(chalk.gray(' Start working in Claude Code to auto-initialize'));
return;
}
// Run aide status
const { stdout } = await execAsync('python3 ~/.claude/aide_status.py');
console.log(stdout);
} catch (error) {
console.error(chalk.red('ā Cannot show status:'));
console.error(chalk.red(error.message));
}
});
program
.command('language [lang]')
.description('Change interface language (en|es)')
.action(async (lang) => {
try {
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);
// Run language change command
const command = lang ?
`python3 ~/.claude/aide_i18n.py ${lang}` :
'python3 ~/.claude/aide_i18n.py';
const { stdout } = await execAsync(command);
console.log(stdout);
} catch (error) {
console.error(chalk.red('ā Language change failed:'));
console.error(chalk.red(error.message));
}
});
program
.command('daemon <action>')
.description('Control AIDE daemon (start|stop|status)')
.action(async (action) => {
try {
const { spawn } = require('child_process');
const path = require('path');
const daemonScript = path.join(__dirname, '..', 'lib', 'aide-daemon.js');
const child = spawn('node', [daemonScript, action], {
stdio: 'inherit'
});
child.on('close', (code) => {
process.exit(code);
});
} catch (error) {
console.error(chalk.red('ā Daemon command failed:'));
console.error(chalk.red(error.message));
}
});
program.parse();