abedelbahnasy55's picture
feat: cloud simulator - Docker, dashboard, auto-start
ccb6b75
#!/usr/bin/env node
import { Command } from 'commander';
import HumanBehaviorEngine from './index.js';
import logger from './utils/logger.js';
import chalk from 'chalk';
import figlet from 'figlet';
import inquirer from 'inquirer';
const program = new Command();
program
.name('activity-simulator')
.description('Human-like developer behavior simulator - interacts with real GitHub repos')
.version('3.0.0');
program
.command('simulate')
.description('Start the human behavior simulator')
.option('--once', 'Run a single cycle and exit')
.action(async (options) => {
console.log(
chalk.cyan(
figlet.textSync('Human Sim', { font: 'Standard' })
)
);
const engine = new HumanBehaviorEngine();
process.on('SIGINT', async () => {
await engine.stop();
process.exit(0);
});
if (options.once) {
await engine.runOnce();
} else {
await engine.start();
}
});
program
.command('status')
.description('Show simulator status')
.action(async () => {
const engine = new HumanBehaviorEngine();
const status = await engine.getStatus();
console.log(chalk.bold('\n🤖 Human Behavior Engine Status\n'));
console.log(chalk`{cyan Running:} ${status.running ? chalk.green('Yes') : chalk.yellow('No')}`);
console.log(chalk`{cyan Work Hours:} ${status.isWorkHours ? chalk.green('Active') : chalk.red('Inactive')}`);
console.log(chalk`{cyan Mood:} ${status.mood}`);
console.log(chalk`{cyan Period:} ${status.period}`);
console.log(chalk`{cyan Day:} ${status.day}`);
console.log(chalk`{cyan Role:} ${status.role}`);
console.log(chalk`{cyan Working On:} ${status.workingOn || 'Nothing specific'}`);
console.log(chalk`{cyan Next Work:} ${status.nextWorkTime}`);
console.log(chalk`{cyan AI Provider:} ${status.aiProvider}`);
console.log(chalk`{cyan Timezone:} ${status.timezone}`);
console.log(chalk`\n{bold Memory}`);
console.log(chalk`{cyan Total Memories:} ${status.memory.totalMemories}`);
console.log(chalk`{cyan Recent Decisions:} ${status.memory.recentDecisions}`);
console.log(chalk`{cyan Recent Conversations:} ${status.memory.recentConversations}`);
console.log(chalk`\n{bold Configuration}`);
console.log(chalk`{cyan Work Hours:} ${status.config.workHours}`);
console.log(chalk`{cyan Lunch Break:} ${status.config.lunchBreak}`);
console.log(chalk`{cyan Weekends:} ${status.config.weekendDays}`);
console.log('');
});
program
.command('setup')
.description('Interactive setup wizard')
.action(async () => {
console.log(
chalk.cyan(
figlet.textSync('Setup', { font: 'Standard' })
)
);
const answers = await inquirer.prompt([
{
type: 'input',
name: 'githubToken',
message: 'GitHub Personal Access Token:',
validate: (input) => input.length > 0 || 'Token is required',
},
{
type: 'input',
name: 'githubOwner',
message: 'GitHub username or organization:',
validate: (input) => input.length > 0 || 'Username is required',
},
{
type: 'input',
name: 'githubRepo',
message: 'Repository name:',
validate: (input) => input.length > 0 || 'Repo name is required',
},
{
type: 'list',
name: 'aiProvider',
message: 'AI Provider:',
choices: [
{ name: 'Ollama (local, free)', value: 'ollama' },
{ name: 'Hugging Face (free tier)', value: 'huggingface' },
],
},
{
type: 'input',
name: 'timezone',
message: 'Timezone:',
default: 'Africa/Cairo',
},
]);
const envContent = `GITHUB_TOKEN=${answers.githubToken}
GITHUB_OWNER=${answers.githubOwner}
GITHUB_REPO=${answers.githubRepo}
AI_PROVIDER=${answers.aiProvider}
TIMEZONE=${answers.timezone}
NO_WORK_HOURS_RESTRICTION=true
`;
console.log(chalk.green('\nConfiguration generated!'));
console.log('Add this to your .env file:\n');
console.log(chalk.gray(envContent));
});
program
.command('test-ai')
.description('Test AI provider connection')
.action(async () => {
const engine = new HumanBehaviorEngine();
console.log(chalk`Testing AI provider: {cyan ${engine.config.ai.provider}}\n`);
try {
const response = await engine.ai.generate(
'Say "connection successful" in one sentence.',
{ maxTokens: 50 }
);
console.log(chalk.green('✓ AI Provider: Connected'));
console.log(chalk`Response: {gray ${response}}`);
} catch (error) {
console.log(chalk.red(`✗ AI Provider: Failed - ${error.message}`));
}
});
program
.command('test-github')
.description('Test GitHub connection')
.action(async () => {
const engine = new HumanBehaviorEngine();
console.log(chalk`Testing GitHub connection to: {cyan ${engine.config.github.owner}/${engine.config.github.repo}}\n`);
try {
const commits = await engine.github.getCommitHistory('main', 1);
console.log(chalk.green('✓ GitHub: Connected'));
console.log(chalk`Latest commit: {gray ${commits[0]?.commit?.message || 'N/A'}}`);
} catch (error) {
console.log(chalk.red(`✗ GitHub: Failed - ${error.message}`));
}
});
program.parse();