Spaces:
Sleeping
Sleeping
File size: 5,320 Bytes
ccb6b75 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | #!/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();
|