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
JavaScript
/**
* 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 };