UNPKG

oneie

Version:

šŸ¤ ONE Personal Collaborative Intelligence - Creates personalized AI workspace from your me.md profile. Simple: npx oneie → edit me.md → generate personalized agents, workflows & missions. From students to enterprises, ONE adapts to your context.

496 lines (416 loc) • 18.6 kB
#!/usr/bin/env node /** * ONE - Personal Collaborative Intelligence * Main entry point for the ONE system */ import { Command } from 'commander'; import chalk from 'chalk'; import fs from 'fs-extra'; import path from 'path'; import { OneInstaller } from './one-installer.js'; import { MissionSystem } from './mission-system.js'; import { StorySystem } from './story-system.js'; import { TaskSystem } from './task-system.js'; const program = new Command(); program .name('oneie') .description('šŸ¤ ONE - Personal Collaborative Intelligence') .version('1.1.0'); // Main install command (default - engineering agents only) program .command('install', { isDefault: true }) .description('Install ONE and create your personal workspace with engineering team') .option('-a, --auto', 'Skip interactive setup', false) .action(async (options) => { try { const installer = new OneInstaller(); // Force core-only installation (engineering agents only) options.coreOnly = true; await installer.install(options); } catch (error) { console.error(chalk.red('āŒ Installation failed:'), error.message); process.exit(1); } }); // Secret marketing command program .command('marketing') .description('Install marketing team agents') .option('-a, --auto', 'Skip interactive setup', false) .action(async (options) => { try { const installer = new OneInstaller(); // Install all agents including marketing options.includeMarketing = true; await installer.install(options); } catch (error) { console.error(chalk.red('āŒ Marketing installation failed:'), error.message); process.exit(1); } }); // Generate content from me.md program .command('generate') .description('Generate personalized content from your me.md') .action(async () => { try { const installer = new OneInstaller(); await installer.generate(); } catch (error) { console.error(chalk.red('āŒ Generation failed:'), error.message); process.exit(1); } }); // Update me.md profile program .command('update-me') .alias('me') .description('Update your personal me.md profile') .action(async () => { try { const installer = new OneInstaller(); await installer.updateMe(); } catch (error) { console.error(chalk.red('āŒ Profile update failed:'), error.message); process.exit(1); } }); // Mission management program .command('mission') .description('Mission management commands') .argument('[command]', 'Mission command (create, list, status)') .argument('[args...]', 'Mission arguments') .action(async (command, args) => { const missionSystem = new MissionSystem(); try { if (!command || command === 'list') { const missions = await missionSystem.listMissions(); if (missions.length === 0) { console.log(chalk.yellow('\\nšŸ“‹ No missions yet')); console.log(chalk.gray('Create your first mission: npx oneie mission create "Your goal"')); return; } console.log(chalk.cyan.bold('\\nšŸŽÆ Your Missions\\n')); missions.forEach(mission => { const statusEmoji = { 'planning': 'šŸ“‹', 'active': 'šŸš€', 'completed': 'āœ…' }[mission.status] || 'šŸ“‹'; console.log(`${statusEmoji} ${mission.name}`); console.log(chalk.gray(` ${mission.objective}`)); console.log(chalk.gray(` Status: ${mission.status} | Created: ${new Date(mission.created).toLocaleDateString()}`)); console.log(''); }); } else if (command === 'create') { const objective = args.join(' ') || 'Complete current project'; console.log(chalk.cyan(`\\nšŸŽÆ Creating mission: ${objective}`)); const mission = await missionSystem.createMission(objective, { interactive: false }); console.log(chalk.green(`\\nāœ… Mission created: ${mission.name}`)); console.log(chalk.blue(`šŸ“‹ ID: ${mission.id}`)); console.log(chalk.gray('Next: npx oneie story create ' + mission.id + ' "Story objective"')); } else if (command === 'status') { const missionId = args[0]; if (!missionId) { console.log(chalk.red('āŒ Please provide mission ID')); return; } const mission = await missionSystem.getMission(missionId); if (!mission) { console.log(chalk.red(`āŒ Mission not found: ${missionId}`)); return; } console.log(chalk.cyan.bold(`\\nšŸŽÆ Mission: ${mission.name}`)); console.log(`Objective: ${mission.objective}`); console.log(`Status: ${mission.status}`); console.log(`Created: ${new Date(mission.created).toLocaleDateString()}`); console.log(`Agents: ${mission.agents.join(', ')}`); } else { console.log(chalk.red(`āŒ Unknown mission command: ${command}`)); console.log(chalk.gray('Available: create, list, status')); } } catch (error) { console.error(chalk.red('āŒ Mission command failed:'), error.message); process.exit(1); } }); // Story management program .command('story') .description('Story management commands') .argument('[command]', 'Story command (create, list, status)') .argument('[args...]', 'Story arguments') .action(async (command, args) => { const storySystem = new StorySystem(); try { if (!command || command === 'list') { const stories = await storySystem.listStories(); if (stories.length === 0) { console.log(chalk.yellow('\\nšŸ“š No stories yet')); console.log(chalk.gray('Create your first story: npx oneie story create <mission-id> "Story goal"')); return; } console.log(chalk.cyan.bold('\\nšŸ“š Your Stories\\n')); stories.forEach(story => { const statusEmoji = { 'planning': 'šŸ“‹', 'active': 'šŸš€', 'completed': 'āœ…' }[story.status] || 'šŸ“‹'; console.log(`${statusEmoji} ${story.name}`); console.log(chalk.gray(` Mission: ${story.missionId} | Status: ${story.status}`)); console.log(chalk.gray(` Agents: ${story.agents?.join(', ') || 'None'} | Tasks: ${story.tasks?.length || 0}`)); console.log(''); }); } else if (command === 'create') { const missionId = args[0]; const objective = args.slice(1).join(' '); if (!missionId) { console.log(chalk.red('āŒ Please provide mission ID')); console.log(chalk.gray('Usage: npx oneie story create <mission-id> "Story objective"')); return; } if (!objective) { console.log(chalk.red('āŒ Please provide story objective')); return; } console.log(chalk.cyan(`\\nšŸ“š Creating story: ${objective}`)); const story = await storySystem.createStory(missionId, objective, { interactive: false }); console.log(chalk.green(`\\nāœ… Story created: ${story.name}`)); console.log(chalk.blue(`šŸ“š ID: ${story.id}`)); console.log(chalk.gray('Next: npx oneie task create ' + story.id + ' "Task to complete"')); } else { console.log(chalk.red(`āŒ Unknown story command: ${command}`)); console.log(chalk.gray('Available: create, list')); } } catch (error) { console.error(chalk.red('āŒ Story command failed:'), error.message); process.exit(1); } }); // Task management program .command('task') .description('Task management commands') .argument('[command]', 'Task command (create, list, status)') .argument('[args...]', 'Task arguments') .action(async (command, args) => { const taskSystem = new TaskSystem(); try { if (!command || command === 'list') { const tasks = await taskSystem.listTasks(); if (tasks.length === 0) { console.log(chalk.yellow('\\nšŸ“‹ No tasks yet')); console.log(chalk.gray('Create your first task: npx oneie task create <story-id> "Task description"')); return; } console.log(chalk.cyan.bold('\\nšŸ“‹ Your Tasks\\n')); const activeTasks = tasks.filter(t => t.status === 'active'); const pendingTasks = tasks.filter(t => t.status === 'pending'); const completedTasks = tasks.filter(t => t.status === 'completed'); if (activeTasks.length > 0) { console.log(chalk.green('šŸš€ Active Tasks')); activeTasks.forEach(task => { console.log(` ⚔ ${task.name}`); console.log(chalk.gray(` Agents: ${task.agents.join(', ')}`)); }); console.log(''); } if (pendingTasks.length > 0) { console.log(chalk.yellow('ā³ Pending Tasks')); pendingTasks.slice(0, 5).forEach(task => { console.log(` šŸ“‹ ${task.name}`); console.log(chalk.gray(` Story: ${task.storyId}`)); }); if (pendingTasks.length > 5) { console.log(chalk.gray(` ... and ${pendingTasks.length - 5} more`)); } console.log(''); } console.log(chalk.blue(`šŸ“Š Summary: ${activeTasks.length} active, ${pendingTasks.length} pending, ${completedTasks.length} completed`)); } else if (command === 'create') { const storyId = args[0]; const taskName = args.slice(1).join(' '); if (!storyId) { console.log(chalk.red('āŒ Please provide story ID')); console.log(chalk.gray('Usage: npx oneie task create <story-id> "Task description"')); return; } if (!taskName) { console.log(chalk.red('āŒ Please provide task description')); return; } console.log(chalk.cyan(`\\nšŸ“‹ Creating task: ${taskName}`)); const task = await taskSystem.createTask(storyId, taskName, { interactive: false }); console.log(chalk.green(`\\nāœ… Task created: ${task.name}`)); console.log(chalk.blue(`šŸ“‹ ID: ${task.id}`)); console.log(chalk.gray(`šŸ¤– Agents: ${task.agents.join(', ')}`)); console.log(chalk.gray('Next: npx oneie task status ' + task.id)); } else { console.log(chalk.red(`āŒ Unknown task command: ${command}`)); console.log(chalk.gray('Available: create, list')); } } catch (error) { console.error(chalk.red('āŒ Task command failed:'), error.message); process.exit(1); } }); // Agent management commands program .command('agents') .description('Agent management and installation') .argument('[command]', 'Agent command (install, update, uninstall, status)') .option('--backup', 'Create backup before update/uninstall') .action(async (command, options) => { try { const installer = new OneInstaller(); const { AgentInstaller } = await import('../one/tools/agent-installer.js'); const agentInstaller = new AgentInstaller(); if (!command || command === 'status') { // Show agent status console.log(chalk.cyan.bold('\\nšŸ¤– Agent Installation Status\\n')); const status = await agentInstaller.getStatus(); if (!status.installed) { console.log(chalk.yellow('āš ļø Claude Code agents not installed')); console.log(chalk.gray('Run: npx oneie agents install')); return; } console.log(chalk.blue('šŸ“Š Agent Summary:')); console.log(` šŸ†“ Free Agents: ${status.agents.free}`); console.log(` šŸ’Ž Premium Agents: ${status.agents.premium}`); console.log(` šŸ“ Total Agents: ${status.agents.total}`); console.log(` āš™ļø Command Files: ${status.commands}`); if (status.license) { console.log(`\\nšŸ“„ License Status: ${status.license.status}`); if (status.license.licenseType) { console.log(` License Type: ${status.license.licenseType}`); console.log(` Expires: ${status.license.expiresAt ? new Date(status.license.expiresAt).toLocaleDateString() : 'N/A'}`); } } console.log(chalk.cyan('\\nšŸ’¬ Try your agents:')); console.log(' one:engineering-director "Help me with system design"'); console.log(' one:content-team-manager "Create a content strategy"'); if (status.license && status.license.status === 'active') { console.log(' one:marketing-director "Develop a marketing campaign"'); } } else if (command === 'install') { console.log(chalk.cyan.bold('\\nšŸ“¦ Installing Claude Code Agents\\n')); await agentInstaller.install(options); } else if (command === 'update') { console.log(chalk.cyan.bold('\\nšŸ”„ Updating Claude Code Agents\\n')); await agentInstaller.update(options); } else if (command === 'uninstall') { console.log(chalk.cyan.bold('\\nšŸ—‘ļø Uninstalling Claude Code Agents\\n')); const { confirm } = await import('inquirer').then(m => m.default); const { proceed } = await confirm.prompt([{ type: 'confirm', name: 'proceed', message: 'Are you sure you want to uninstall all agents?', default: false }]); if (proceed) { await agentInstaller.uninstall(options); } else { console.log(chalk.gray('Uninstall cancelled')); } } else if (command === 'list') { // Show personal agents (legacy behavior) if (!await installer.isInstalled()) { console.log(chalk.red('āŒ ONE is not installed here.')); console.log(chalk.gray('Run: npx oneie')); return; } console.log(chalk.cyan.bold('\\nšŸ¤– Your Personal AI Agents\\n')); const agentsDir = path.join(process.cwd(), '.one', 'agents'); if (await fs.pathExists(agentsDir)) { const agentFiles = await fs.readdir(agentsDir); const yamlFiles = agentFiles.filter(file => file.endsWith('.yaml')); if (yamlFiles.length === 0) { console.log(chalk.yellow('No personal agents found. Run: npx oneie generate')); return; } for (const file of yamlFiles) { const agentPath = path.join(agentsDir, file); const content = await fs.readFile(agentPath, 'utf8'); const frontMatter = content.match(/^---\\n([\\s\\S]*?)\\n---/); if (frontMatter) { try { const yaml = await import('js-yaml'); const config = yaml.default.load(frontMatter[1]); console.log(chalk.blue(`šŸ¤– ${config.name}`)); console.log(chalk.gray(` ${config.description.split('\\n')[0]}`)); if (config.expertise) { console.log(chalk.gray(` Expertise: ${JSON.parse(config.expertise).join(', ')}`)); } console.log(''); } catch (e) { console.log(chalk.gray(`šŸ¤– ${file.replace('.yaml', '')}`)); } } } } else { console.log(chalk.yellow('No agents directory found. Run: npx oneie generate')); } } else { console.log(chalk.red(`āŒ Unknown agent command: ${command}`)); console.log(chalk.gray('Available: install, update, uninstall, status, list')); } } catch (error) { console.error(chalk.red('āŒ Agent command failed:'), error.message); process.exit(1); } }); // Help command program .command('help') .description('Show help and usage examples') .action(() => { console.log(chalk.cyan.bold('\\nšŸ¤ ONE - Personal Collaborative Intelligence\\n')); console.log(chalk.blue('šŸš€ Getting Started:')); console.log(' npx oneie # Install engineering team workspace'); console.log(' npx oneie marketing # Add marketing team agents'); console.log(' npx oneie update-me # Update your me.md profile'); console.log(' npx oneie generate # Generate content from your profile'); console.log(''); console.log(chalk.blue('šŸŽÆ Mission-Story-Task Workflow:')); console.log(' npx oneie mission create "Build my app" # Create a mission'); console.log(' npx oneie story create <mission-id> "Setup" # Add stories to mission'); console.log(' npx oneie task create <story-id> "Code API" # Add tasks to story'); console.log(''); console.log(chalk.blue('šŸ¤– Your Personalized Workspace:')); console.log(' npx oneie agents # Agent management and status'); console.log(' npx oneie agents install # Install Claude Code agents'); console.log(' npx oneie agents list # View your personal agents'); console.log(' npx oneie mission list # See your missions'); console.log(' npx oneie story list # See your stories'); console.log(' npx oneie task list # See your tasks'); console.log(''); console.log(chalk.yellow('šŸ’” How it works:')); console.log('1. ONE reads your me.md profile (name, role, skills, goals)'); console.log('2. Creates personalized AI agents and workflows just for you'); console.log('3. Helps you organize work into missions → stories → tasks'); console.log('4. Agents help execute tasks based on your context and preferences'); console.log(''); console.log(chalk.gray('Your workspace adapts as you update me.md - try it!')); }); // Handle no command (default to install with core-only) program.action(async (options) => { try { const installer = new OneInstaller(); // Default to engineering agents only options.coreOnly = true; await installer.install(options); } catch (error) { console.error(chalk.red('āŒ Installation failed:'), error.message); process.exit(1); } }); program.parse(); export { program };