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.
1,342 lines (1,174 loc) β’ 97.7 kB
JavaScript
#!/usr/bin/env node
import { Command } from 'commander';
import { promises as fs } from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import process from 'process';
import { BackgroundAgentLoader } from './background-agent-loader.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const program = new Command();
// Initialize Background Agent Loader
const agentLoader = new BackgroundAgentLoader();
// Responsive Display Functions
function getTerminalWidth() {
// Check environment variable first, then stdout.columns, then default to 80
return parseInt(process.env.COLUMNS) || process.stdout.columns || 80;
}
function createResponsiveLogo() {
const width = getTerminalWidth();
if (width < 70) {
// Compact logo for small screens
return `
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β ββββββ βββ ββ βββββ π― ONE β
β ββ ββ ββββ ββ ββ Still Hiring β
β ββ ββ ββ ββ ββ βββββ Humans? β
β ββ ββ ββ ββββ ββ β
β ββββββ ββ βββ βββββ ATTRACT>CONVERT>GROWβ
β With AI Agents β
β https://one.ie/ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ`;
} else if (width < 120) {
// Medium logo for standard screens
return `
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββ ββββ βββββββββββ π― ONE Framework β
β ββββββββββββββ βββββββββββ Still Hiring Humans? β
β βββ βββββββββ βββββββββ β
β βββ βββββββββββββββββββ ATTRACT > CONVERT > GROW β
β ββββββββββββ ββββββββββββββ With AI Agents β
β βββββββ βββ βββββββββββββ https://one.ie/ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ`;
} else {
// Full logo for large screens
return `
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββ ββββ βββββββββββ βββββββββββββββββββββββββββ β
β ββββββββββββββ βββββββββββ β Still Hiring Humans? β β
β βββ βββββββββ βββββββββ β β β
β βββ βββββββββββββββββββ βββββββββββββββββββββββββββ β
β ββββββββββββ ββββββββββββββ π― ATTRACT > CONVERT > GROW β
β βββββββ βββ βββββββββββββ With AI Agents β
β https://one.ie/ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ`;
}
}
function createResponsiveMenu() {
const width = getTerminalWidth();
if (width < 70) {
// Compact menu for small screens
return `
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ JOIN AI AGENT TEAMS β
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β πΌ TEAMS: β
β [1] π¬ Research [2] π Content β
β [3] π Marketing [4] π° Sales β
β [5] π€ Service [6] π¨ Design β
β [7] π οΈ Engineering [8] π Education β
β [9] π§ Intelligence β
β β
β ποΈ MENU: β
β [H] π₯ Humans [A] π€ Agents β
β [T] π’ Teams [t] π οΈ Tools β
β [L] π Stories [W] π Workflows β
β β
β π STUDIO: β
β [i] π‘ Ideas [w] π Stories β
β [P] π Playbooks [B] π Books β
β [D] π Templates β
β β
β π― MISSION: β
β [O] π Coordinate [M] π§ Tasks β
β [F] π Flows β
β β
β βΉοΈ PLATFORM: β
β [?] β Help [K] π Knowledge β
β [S] π Status [Q] πͺ Exit β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ`;
} else {
// Full menu for larger screens
return `
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π€ JOIN EXPERT TEAMS OF AI AGENTS AND HUMANS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β πΌ TEAMS: β
β [1] π¬ Research - Deep insights & market intelligence β
β [2] π Content - Stories, books & compelling copy β
β [3] π Marketing - Viral growth & brand strategies β
β [4] π° Sales - Revenue acceleration & deal closing β
β [5] π€ Service - Customer success & experience design β
β [6] π¨ Design - Beautiful interfaces & visual identity β
β [7] π οΈ Engineering - Full-stack development & architecture β
β [8] π Education - Learning experiences & knowledge scale β
β [9] π§ Intelligence - Data science & predictive modeling β
β β
β ποΈ MENU: β
β [H] π₯ Humans - Connect with our global community β
β [A] π€ Agents - 18 specialized AI personalities β
β [T] π’ Teams - Cross-functional collaboration hubs β
β [t] π οΈ Tools - CLI, GitHub, shadcn/ui, Convex, IDE β
β [L] π Listen to Stories - Tell stories β
β [W] π Workflows - Proven business methodologies β
β β
β π STUDIO: β
β [i] π‘ What's Your Idea? - Capture creative vision β
β [w] π Write a Story - Narratives & case studies β
β [P] π Create a Playbook - Custom industry guides β
β [B] π Publish a Book - Complete publications (PDF/EPUB) β
β [D] π Use Template - Professional document frameworks β
β β
β π― MISSION CONTROL: β
β [O] π Coordinate - Multi-agent coordination β
β [M] π§ Tasks - Direct task execution β
β [F] π Flows - Custom workflow creation β
β β
β βΉοΈ PLATFORM: β
β [?] β Help - Complete command reference β
β [K] π Knowledge - ONE Playbookology & frameworks β
β [S] π Status - Your projects & progress β
β [Q] πͺ Exit - Leave platform β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ`;
}
}
function displayONEInterface() {
console.clear();
console.log(createResponsiveLogo());
console.log(createResponsiveMenu());
console.log('\n**π― Select your path to exponential growth:**');
console.log('_[Enter choice: 1-9, L, H, A, T, t, W, i, w, P, B, D, O, M, F, ?, K, S, Q]_');
console.log('\n**βοΈ Write a Story: /story**');
}
// Mission 9: Beautiful Simplicity Through Unified Orchestration
// Single gateway to the entire ONE ecosystem
// Team-based agent categorization with hyphenated naming convention
const MARKETING_TEAM_AGENTS = [
// New team-prefixed agents
'marketing-director',
'marketing-content-poster',
// Legacy marketing agents (gradually migrating to team-prefixed names)
'elevate-marketing-orchestrator',
'brand-identity-specialist',
'content-hook-specialist',
'customer-journey-designer',
'customer-success-manager',
'engagement-specialist',
'lead-capture-expert',
'lead-magnet-creator',
'market-research-analyst',
'nurture-campaign-manager',
'sales-environment-optimizer',
'upsell-strategist',
'advocacy-campaign-designer',
// Crypto Marketing Agents
'crypto-marketing-orchestrator',
'crypto-architecture-specialist',
'crypto-token-analyst',
'crypto-market-researcher',
'crypto-community-psychologist',
'crypto-strategic-synthesizer',
'crypto-viral-content-creator',
'crypto-diamond-formation-specialist',
'crypto-airdrop-strategist',
'crypto-wallet-identification-expert',
'crypto-engagement-specialist',
'crypto-dex-optimization-expert',
'crypto-ecosystem-expansion-manager',
'crypto-analytics-educator',
'crypto-network-effect-amplifier',
'crypto-optimization-analyst',
'playbook-generator',
'content-playbook-writer'
];
const ENGINEERING_TEAM_AGENTS = [
// New team-prefixed agents
'engineering-director',
// Legacy engineering agents (gradually migrating to team-prefixed names)
'one-orchestrator',
'one-master',
'analyst',
'architect',
'dev',
'pm',
'po',
'qa',
'sm',
'ux-expert'
];
const DESIGN_TEAM_AGENTS = [
// Design team agents (to be created)
'design-director',
'design-ui-specialist',
'design-brand-manager',
'ux-expert' // Moving from engineering to design
];
function filterAgentsByTeam(agents, team) {
const teamAgents = {
'marketing': MARKETING_TEAM_AGENTS,
'engineering': ENGINEERING_TEAM_AGENTS,
'design': DESIGN_TEAM_AGENTS
};
return agents.filter(agent => teamAgents[team]?.includes(agent));
}
program
.name('one')
.description('πΌ ONE Framework - Beautiful Simplicity Through Unified Orchestration')
.version('1.0.0');
// Default command - show responsive interface when called without arguments
program
.command('interface')
.alias('ui')
.description('π¨ Launch the interactive ONE interface')
.action(() => {
displayONEInterface();
});
// ========================================
// MISSION 9: UNIFIED COMMAND ARCHITECTURE
// ========================================
// Single `/one` gateway to entire ecosystem
// Core Mission 9 Commands - The Symphony Interface
program
.command('mission [name]')
.alias('m')
.description('π― Launch goal-oriented campaigns')
.option('-l, --list', 'List available missions')
.option('-c, --create', 'Create new mission')
.option('-s, --status', 'Show mission status')
.action(async (name, options) => {
await handleMissionCommand(name, options);
});
program
.command('story [name]')
.alias('s')
.description('π Execute narrative workflows')
.option('-l, --list', 'List available stories')
.option('-c, --create', 'Create new story')
.option('-m, --mission <mission>', 'Filter by mission')
.action(async (name, options) => {
await handleStoryCommand(name, options);
});
program
.command('agent [name]')
.alias('a')
.description('π€ Invoke specialized AI agents')
.option('-l, --list', 'List all available agents')
.option('-t, --team <team>', 'Filter by team')
.option('-c, --claude', 'List Claude Code agents')
.option('-i, --info <agent>', 'Show agent information')
.action(async (name, options) => {
await handleAgentCommand(name, options);
});
program
.command('team [name]')
.alias('t')
.description('π₯ Coordinate agent groups')
.option('-l, --list', 'List available teams')
.option('-m, --members <team>', 'Show team members')
.action(async (name, options) => {
await handleTeamCommand(name, options);
});
program
.command('workflow [name]')
.alias('w')
.description('β‘ Run proven processes')
.option('-l, --list', 'List available workflows')
.option('-r, --run <workflow>', 'Execute workflow')
.action(async (name, options) => {
await handleWorkflowCommand(name, options);
});
program
.command('template [name]')
.description('π Generate documents')
.option('-l, --list', 'List available templates')
.option('-c, --create <template>', 'Create from template')
.action(async (name, options) => {
await handleTemplateCommand(name, options);
});
program
.command('task [name]')
.description('β
Execute specific actions')
.option('-l, --list', 'List available tasks')
.option('-r, --run <task>', 'Execute task')
.action(async (name, options) => {
await handleTaskCommand(name, options);
});
program
.command('checklist [name]')
.alias('c')
.description('π Validate quality')
.option('-l, --list', 'List available checklists')
.option('-r, --run <checklist>', 'Execute checklist')
.action(async (name, options) => {
await handleChecklistCommand(name, options);
});
program
.command('data [name]')
.alias('d')
.description('πΎ Access knowledge base')
.option('-l, --list', 'List available data')
.option('-s, --search <query>', 'Search knowledge base')
.action(async (name, options) => {
await handleDataCommand(name, options);
});
program
.command('playbook [name]')
.alias('p')
.description('π Industry guides and playbooks')
.option('-l, --list', 'List available playbooks')
.option('-g, --generate <client>', 'Generate client playbook')
.option('-i, --industry <industry>', 'Industry filter')
.action(async (name, options) => {
await handlePlaybookCommand(name, options);
});
program
.command('tool [name]')
.description('π οΈ Utility functions')
.option('-l, --list', 'List available tools')
.option('-r, --run <tool>', 'Execute tool')
.action(async (name, options) => {
await handleToolCommand(name, options);
});
// Mission 9 Help - Context-aware assistance
program
.command('help [command]')
.alias('h')
.description('β Intelligent assistance')
.action(async (command) => {
await handleHelpCommand(command);
});
// Mission 9 Symphony Status
program
.command('status')
.description('πΌ Show symphony orchestration status')
.action(async () => {
await showSymphonyStatus();
});
program
.command('build-bundles')
.description('Build web bundles for agents and teams')
.option('-a, --agents-only', 'Build only agent bundles')
.option('-t, --teams-only', 'Build only team bundles')
.option('-e, --expansions-only', 'Build only expansion pack bundles')
.option('--no-expansions', 'Skip building expansion packs')
.option('--no-clean', 'Skip cleaning output directories')
.action(async (options) => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({
rootDir: process.cwd()
});
try {
if (options.clean) {
console.log('Cleaning output directories...');
await builder.cleanOutputDirs();
}
if (options.expansionsOnly) {
console.log('Building expansion pack bundles...');
await builder.buildAllExpansionPacks({ clean: false });
} else {
if (!options.teamsOnly) {
console.log('Building agent bundles...');
await builder.buildAgents();
}
if (!options.agentsOnly) {
console.log('Building team bundles...');
await builder.buildTeams();
}
if (!options.noExpansions) {
console.log('Building expansion pack bundles...');
await builder.buildAllExpansionPacks({ clean: false });
}
}
console.log('Build completed successfully!');
} catch (error) {
console.error('Build failed:', error.message);
process.exit(1);
}
});
program
.command('build:expansions')
.description('Build web bundles for all expansion packs')
.option('--expansion <name>', 'Build specific expansion pack only')
.option('--no-clean', 'Skip cleaning output directories')
.action(async (options) => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({
rootDir: process.cwd()
});
try {
if (options.expansion) {
console.log(`Building expansion pack: ${options.expansion}`);
await builder.buildExpansionPack(options.expansion, { clean: options.clean });
} else {
console.log('Building all expansion packs...');
await builder.buildAllExpansionPacks({ clean: options.clean });
}
console.log('Expansion pack build completed successfully!');
} catch (error) {
console.error('Expansion pack build failed:', error.message);
process.exit(1);
}
});
program
.command('list:agents')
.description('List all available agents')
.action(async () => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({ rootDir: process.cwd() });
const agents = await builder.resolver.listAgents();
console.log('Available agents:');
agents.forEach(agent => console.log(` - ${agent}`));
});
program
.command('list:expansions')
.description('List all available expansion packs')
.action(async () => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({ rootDir: process.cwd() });
const expansions = await builder.listExpansionPacks();
console.log('Available expansion packs:');
expansions.forEach(expansion => console.log(` - ${expansion}`));
});
program
.command('validate')
.description('Validate agent and team configurations')
.action(async () => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({ rootDir: process.cwd() });
try {
// Validate by attempting to build all agents and teams
const agents = await builder.resolver.listAgents();
const teams = await builder.resolver.listTeams();
console.log('Validating agents...');
for (const agent of agents) {
await builder.resolver.resolveAgentDependencies(agent);
console.log(` β ${agent}`);
}
console.log('\nValidating teams...');
for (const team of teams) {
await builder.resolver.resolveTeamDependencies(team);
console.log(` β ${team}`);
}
console.log('\nAll configurations are valid!');
} catch (error) {
console.error('Validation failed:', error.message);
process.exit(1);
}
});
program
.command('upgrade')
.description('Upgrade a one-playbook V3 project to V4')
.option('-p, --project <path>', 'Path to V3 project (defaults to current directory)')
.option('--dry-run', 'Show what would be changed without making changes')
.option('--no-backup', 'Skip creating backup (not recommended)')
.action(async (options) => {
const { default: V3ToV4Upgrader } = await import('./upgraders/v3-to-v4-upgrader.js');
const upgrader = new V3ToV4Upgrader();
await upgrader.upgrade({
projectPath: options.project,
dryRun: options.dryRun,
backup: options.backup
});
});
// Marketing Domain Command
program
.command('market [subcommand] [name]')
.description('Marketing-focused agent interface and playbook management')
.option('--list', 'List available marketing agents')
.option('--help-domain', 'Show marketing domain help')
.option('--version <version>', 'Version for archive command')
.option('--description <desc>', 'Description for archive command')
.option('--format <format>', 'Format for generate/export commands')
.option('--industry <industry>', 'Industry for playbook commands')
.action(async (subcommand, name, options) => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({ rootDir: process.cwd() });
// Handle subcommands
if (subcommand) {
const { default: PlaybookManager } = await import('./playbook-generator/lib/manager.js');
const manager = new PlaybookManager({ rootDir: process.cwd() });
switch (subcommand) {
case 'create-playbook':
// Redirect to existing create-playbook command
const { default: PlaybookWizard } = await import('./playbook-generator/lib/wizard.js');
const wizard = new PlaybookWizard({ rootDir: process.cwd() });
if (!name) {
console.error('Error: Please specify client name');
console.error('Usage: one market create-playbook "Client Name" [--industry type]');
process.exit(1);
}
try {
await wizard.createClientPlaybook(name);
console.log('\nNext step: Generate your playbook with:');
console.log(` one market generate --client ${name.toLowerCase().replace(/\s+/g, '-')}`);
} catch (error) {
console.error('Error creating playbook:', error.message);
process.exit(1);
}
return;
case 'list-playbooks':
// Show existing playbooks
console.log('π Marketing Playbooks:\n');
try {
const { promises: fs } = await import('fs');
// List clients
try {
const clients = await fs.readdir('one/playbooks/clients');
if (clients.length > 0) {
console.log('π’ Clients:');
for (const client of clients) {
try {
await fs.access(`one/playbooks/clients/${client}/config.yaml`);
console.log(` - ${client}`);
} catch {}
}
console.log();
}
} catch {}
// List industries
try {
const industries = await fs.readdir('one/playbooks/industries');
if (industries.length > 0) {
console.log('π Industries:');
for (const industry of industries) {
try {
await fs.access(`one/playbooks/industries/${industry}/config.yaml`);
console.log(` - ${industry}`);
} catch {}
}
}
} catch {}
} catch (error) {
console.log('No playbooks found.');
}
return;
case 'generate':
if (!name) {
console.error('Error: Please specify --client name');
process.exit(1);
}
// Redirect to generate-playbook
const { PlaybookGenerator } = await import('./playbook-generator/index.js');
const generator = new PlaybookGenerator({
rootDir: process.cwd(),
outputDir: './output/playbooks'
});
try {
const configPath = `one/playbooks/clients/${name}/config.yaml`;
const result = await generator.generatePlaybook(configPath, {
format: options.format || 'both',
verbose: true
});
console.log('\nPlaybook generation completed!');
console.log(`Generated files: ${result.files.join(', ')}`);
} catch (error) {
console.error('Generation failed:', error.message);
process.exit(1);
}
return;
case 'archive':
if (!name) {
console.error('Error: Please specify --client name');
process.exit(1);
}
try {
const result = await manager.archivePlaybook('client', name, {
version: options.version,
description: options.description
});
console.log(`β
Archive created: ${result.metadata.version}`);
await manager.trackChanges('client', name, `Archive ${name} - ${result.metadata.version}`);
} catch (error) {
console.error('Archive failed:', error.message);
process.exit(1);
}
return;
case 'export':
if (!name) {
console.error('Error: Please specify --client name');
process.exit(1);
}
try {
const result = await manager.exportPlaybook('client', name, {
format: options.format
});
console.log(`β
Export package created: ${result.zipPath}`);
} catch (error) {
console.error('Export failed:', error.message);
process.exit(1);
}
return;
default:
// Fall through to show agents
break;
}
}
// Original functionality
if (options.list) {
const allAgents = await builder.resolver.listAgents();
const marketingAgents = filterAgentsByTeam(allAgents, 'marketing');
console.log('Available marketing-team agents:');
marketingAgents.forEach(agent => console.log(` - ${agent}`));
return;
}
if (options.helpDomain) {
console.log(`
π― ONE Marketing Playbook
Transform your marketing from random acts to predictable revenue with the proven Elevate Framework.
Available Commands:
one market --list List all marketing agents
one market --help-domain Show this help
Playbook Management:
one market create-playbook "Client" Create new client playbook
one market list-playbooks List existing playbooks
one market generate --client name Generate playbook PDFs
one market archive --client name Archive playbook version
one market export --client name Export distribution package
Marketing Specialists:
Foundation Team:
- brand-identity-specialist Build clarity on brand positioning
- market-research-analyst Understand your market landscape
- customer-journey-designer Map customer experience paths
ATTRACT Team (Elevate Reach):
- content-hook-specialist Create compelling content hooks
- lead-magnet-creator Design irresistible lead magnets
- lead-capture-expert Optimize landing pages for conversion
CONVERT Team (Elevate Sales):
- engagement-specialist Design engagement sequences
- sales-environment-optimizer Optimize sales environment
- nurture-campaign-manager Create nurture campaigns
GROW Team (Elevate Value):
- upsell-strategist Develop upsell strategies
- customer-success-manager Manage customer success programs
- advocacy-campaign-designer Design customer advocacy campaigns
Orchestrator:
- elevate-marketing-orchestrator Guide through complete Elevate framework
Usage Examples:
one market --list # See all marketing agents
one market create-playbook "Acme Corp" --industry saas
one market generate --client acme-corp --format pdf
one market archive --client acme-corp --version v1.2
For development/engineering tasks, use: one engineer
`);
return;
}
// Default behavior - show available marketing agents
const allAgents = await builder.resolver.listAgents();
const marketingAgents = filterAgentsByTeam(allAgents, 'marketing');
console.log('π― ONE Marketing Playbook - Available Agents:');
marketingAgents.forEach(agent => console.log(` - ${agent}`));
console.log('\nPlaybook Commands:');
console.log(' one market create-playbook "Client Name"');
console.log(' one market list-playbooks');
console.log(' one market generate --client name');
console.log('\nUse --help-domain for detailed information.');
});
// Engineering Domain Command
program
.command('engineer')
.description('Launch engineering-focused agent interface')
.option('--list', 'List available engineering agents')
.option('--help-domain', 'Show engineering domain help')
.action(async (options) => {
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({ rootDir: process.cwd() });
if (options.list) {
const allAgents = await builder.resolver.listAgents();
const engineeringAgents = filterAgentsByTeam(allAgents, 'engineering');
console.log('Available engineering-team agents:');
engineeringAgents.forEach(agent => console.log(` - ${agent}`));
return;
}
if (options.helpDomain) {
console.log(`
π ONE Engineering Playbook
Complete AI-powered development framework for systematic software delivery.
Available Commands:
one engineer --list List all engineering agents
one engineer --help-domain Show this help
Engineering Team:
Planning & Analysis:
- analyst Business analysis and requirements gathering
- pm Product management and roadmap planning
- architect System design and technical architecture
Development:
- dev Code implementation and debugging
- ux-expert UI/UX design and user experience
- sm Scrum master and project coordination
Quality & Operations:
- qa Quality assurance and testing
- po Product owner and backlog management
Universal Agents:
- one-orchestrator Multi-agent workflow coordination
- one-master Universal task executor
Workflows:
Greenfield: Complete new project development
Brownfield: Enhancement of existing projects
Usage Examples:
one engineer --list # See all engineering agents
npm run build-bundles # Build development bundles
npm run validate # Validate agent configurations
For marketing tasks, use: one market
`);
return;
}
// Default behavior - show available engineering agents
const allAgents = await builder.resolver.listAgents();
const engineeringAgents = filterAgentsByTeam(allAgents, 'engineering');
console.log('π ONE Engineering Playbook - Available Agents:');
engineeringAgents.forEach(agent => console.log(` - ${agent}`));
console.log('\nUse --help-domain for detailed information about engineering agents.');
});
// Handle /one command specifically
program
.command('/')
.description('π¨ Launch the interactive ONE interface')
.action(() => {
displayONEInterface();
});
// Dynamic agent launch command - matches any agent name (includes one:agent-name support)
program
.arguments('<agent-name> [args...]')
.description('Launch a specific agent (supports both legacy and one:agent-name patterns)')
.action(async (agentName, args) => {
// Check if it's the special "/one" command
if (agentName === '/one' || agentName === 'one') {
displayONEInterface();
return;
}
// Check if this is a one:agent-name pattern - handle with BackgroundAgentLoader
if (agentName.startsWith('one:')) {
const command = agentName.replace('one:', '');
console.log(`π€ Executing agent command: ${agentName}`);
console.log('π Agent execution via BackgroundAgentLoader...\n');
try {
// Check if agent exists before attempting to load
const availableAgents = await agentLoader.listAvailableAgents();
const validAgents = availableAgents.filter(agent => agent !== 'README' && !agent.startsWith('.'));
if (!validAgents.includes(command)) {
console.error(`β Agent '${command}' not found in .claude/agents/`);
console.error('\nπ Available agents:');
validAgents.forEach(agent => {
console.error(` - one:${agent}`);
});
process.exit(1);
}
// Load agent using BackgroundAgentLoader
const agent = await agentLoader.loadAgent(command);
if (!agent) {
console.error(`β Failed to load agent '${command}'`);
process.exit(1);
}
// Get agent arguments
const agentArgs = args && args.length > 0 ? args.join(' ') : '';
// Execute agent with context and arguments
const context = {
command: agentName,
timestamp: new Date().toISOString(),
arguments: agentArgs,
workingDirectory: process.cwd()
};
console.log(`β
Agent loaded: ${agent.name || command}`);
console.log(`π Description: ${agent.description || 'No description available'}`);
console.log(`π’ Team: ${agent.team || 'Core'}`);
if (agentArgs) {
console.log(`π¬ Arguments: ${agentArgs}`);
}
// Execute the agent with coordination enabled
const executionOptions = {
enableCoordination: true,
maxSpawn: 2,
executeSpawnedAgents: false // Don't execute spawned agents immediately
};
const result = await agentLoader.executeAgent(command, context, agentArgs, executionOptions);
console.log('\nπ― Agent execution completed successfully!');
console.log(`β±οΈ Execution time: ${result.executionTime || 'N/A'}`);
// Display coordination results if available
if (result.coordination) {
console.log('\nπ€ Agent Coordination:');
console.log(` π‘ Session ID: ${result.coordination.sessionId}`);
console.log(` π€ Spawned Agents: ${result.coordination.spawnedAgents.length}`);
if (result.coordination.spawnedAgents.length > 0) {
result.coordination.spawnedAgents.forEach(agent => {
console.log(` β’ ${agent.name} (${agent.role})`);
});
}
console.log(` π€ Coordinated Agents: ${result.coordination.coordinatedAgents.length}`);
if (result.coordination.coordinatedAgents.length > 0) {
result.coordination.coordinatedAgents.forEach(agent => {
console.log(` β’ ${agent.name} (${agent.role})`);
});
}
console.log(` β±οΈ Coordination Duration: ${result.coordination.duration}ms`);
}
if (result.output) {
console.log('\nπ€ Agent output:');
console.log(result.output);
}
} catch (error) {
// Handle premium agent access errors specially
if (error.code === 'PREMIUM_ACCESS_REQUIRED') {
console.error('π Premium Agent Access Required\n');
// Generate and display upgrade prompt
const upgradePrompt = await agentLoader.generateUpgradePrompt(command);
console.log(upgradePrompt);
process.exit(1);
}
console.error('β Agent execution failed:', error.message);
// Provide helpful debugging information
console.log('\nπ Troubleshooting:');
console.log(' β’ Ensure agent exists in .claude/agents/ directory');
console.log(' β’ Check agent file format and structure');
console.log(' β’ Try: node one/tools/cli.js one:engineering-director');
console.log(' β’ View available agents with: one agent --list --claude');
if (process.env.NODE_ENV === 'development' && error.stack) {
console.log('\nπ Stack trace:');
console.log(error.stack);
}
process.exit(1);
}
return;
}
const { default: WebBuilder } = await import('./builders/web-builder.js');
const builder = new WebBuilder({ rootDir: process.cwd() });
try {
const agents = await builder.resolver.listAgents();
if (agents.includes(agentName)) {
console.log(`Launching agent: ${agentName}`);
console.log(`Agent bundle path: dist/${agentName}.md`);
console.log('\nYou can now use this agent in your preferred AI tool.');
} else {
console.error(`Error: Agent '${agentName}' not found.`);
console.error('Available agents:');
agents.forEach(agent => console.error(` - ${agent}`));
process.exit(1);
}
} catch (error) {
console.error('Error:', error.message);
process.exit(1);
}
});
// Create New Playbook Command (Interactive Wizard)
program
.command('create-playbook')
.description('Create a new playbook with interactive setup wizard')
.option('--client <name>', 'Create playbook for specific client')
.option('--industry <name>', 'Create playbook for industry')
.action(async (options) => {
const { default: PlaybookWizard } = await import('./playbook-generator/lib/wizard.js');
try {
const wizard = new PlaybookWizard({
rootDir: process.cwd()
});
if (options.client) {
await wizard.createClientPlaybook(options.client);
} else if (options.industry) {
await wizard.createIndustryPlaybook(options.industry);
} else {
console.error('Error: Must specify --client <name> or --industry <name>');
process.exit(1);
}
} catch (error) {
const { ErrorHandler } = await import('./playbook-generator/lib/errors.js');
const handled = ErrorHandler.handle(error, 'create-playbook');
const helpInfo = ErrorHandler.createUserHelp(handled);
console.error(helpInfo.error);
console.error(helpInfo.help);
process.exit(1);
}
});
// Playbook Generation Command
program
.command('generate-playbook')
.description('Generate custom playbooks for clients or industries')
.option('--client <name>', 'Generate playbook for specific client')
.option('--industry <name>', 'Generate playbook for industry')
.option('--config <path>', 'Use custom configuration file')
.option('--format <format>', 'Output format: pdf, epub, enhanced-pdf, both, all', 'both')
.option('--output <dir>', 'Output directory', './output/playbooks')
.option('--interactive', 'Review each chapter as it\'s generated')
.option('--verbose', 'Enable verbose output')
.option('--dry-run', 'Show what would be generated without creating files')
.action(async (options) => {
// Use the new packaged version for compatibility
const { PlaybookGenerator } = await import('./playbook-generator/index.js');
try {
const generator = new PlaybookGenerator({
rootDir: process.cwd(),
outputDir: options.output
});
let configPath;
if (options.config) {
configPath = options.config;
} else if (options.client) {
// Try new folder structure first, fall back to legacy
const newStructure = `one/playbooks/clients/${options.client}/config.yaml`;
const legacyStructure = `one/playbooks/clients/${options.client}-config.yaml`;
const fs = await import('fs');
if (fs.existsSync(newStructure)) {
configPath = newStructure;
} else if (fs.existsSync(legacyStructure)) {
configPath = legacyStructure;
} else {
console.error(`Error: Configuration not found for client '${options.client}'`);
console.error('Try running: one create-playbook --client ' + options.client);
process.exit(1);
}
} else if (options.industry) {
// Try new folder structure first, fall back to legacy
const newStructure = `one/playbooks/industries/${options.industry}/config.yaml`;
const legacyStructure = `one/playbooks/industries/${options.industry}-config.yaml`;
const fs = await import('fs');
if (fs.existsSync(newStructure)) {
configPath = newStructure;
} else if (fs.existsSync(legacyStructure)) {
configPath = legacyStructure;
} else {
console.error(`Error: Configuration not found for industry '${options.industry}'`);
console.error('Try running: one create-playbook --industry ' + options.industry);
process.exit(1);
}
} else {
console.error('Error: Must specify --client, --industry, or --config option');
process.exit(1);
}
console.log(`Generating playbook from: ${configPath}`);
if (options.dryRun) {
console.log('DRY RUN MODE - No files will be created');
await generator.validateConfig(configPath);
console.log('Configuration is valid!');
} else {
const result = await generator.generatePlaybook(configPath, {
format: options.format,
verbose: options.verbose || false,
interactive: options.interactive
});
console.log('\nPlaybook generation completed!');
console.log(`Generated files: ${result.files.join(', ')}`);
}
} catch (error) {
const { ErrorHandler } = await import('./playbook-generator/lib/errors.js');
const handled = ErrorHandler.handle(error, 'generate-playbook');
const helpInfo = ErrorHandler.createUserHelp(handled);
console.error(helpInfo.error);
console.error(helpInfo.help);
process.exit(1);
}
});
// List available playbook configurations
program
.command('list-playbooks')
.description('List available playbook configurations')
.action(async () => {
const { promises: fs } = await import('fs');
try {
console.log('π Available Playbook Configurations:\n');
// List industry configs (both legacy and new structure)
try {
const industries = new Set();
// Check legacy structure
try {
const industryFiles = await fs.readdir('one/playbooks/industries');
industryFiles
.filter(f => f.endsWith('-config.yaml'))
.forEach(f => industries.add(f.replace('-config.yaml', '')));
} catch (e) {}
// Check new structure
try {
const industryFiles = await fs.readdir('one/playbooks/industries');
const dirs = await Promise.all(
industryFiles.map(async item => {
try {
const stat = await fs.stat(`one/playbooks/industries/${item}`);
if (stat.isDirectory()) {
const configExists = await fs.access(`one/playbooks/industries/${item}/config.yaml`).then(() => true).catch(() => false);
return configExists ? item : null;
}
return null;
} catch {
return null;
}
})
);
dirs.filter(Boolean).forEach(dir => industries.add(dir));
} catch (e) {}
if (industries.size > 0) {
console.log('π Industries:');
Array.from(industries).sort().forEach(industry => console.log(` - ${industry}`));
console.log();
} else {
console.log('π Industries: No configurations found\n');
}
} catch (e) {
console.log('π Industries: No configurations found\n');
}
// List client configs (both legacy and new structure)
try {
const clients = new Set();
// Check legacy structure
try {
const clientFiles = await fs.readdir('one/playbooks/clients');
clientFiles
.filter(f => f.endsWith('-config.yaml'))
.forEach(f => clients.add(f.replace('-config.yaml', '')));
} catch (e) {}
// Check new structure
try {
const clientFiles = await fs.readdir('one/playbooks/clients');
const dirs = await Promise.all(
clientFiles.map(async item => {
try {
const stat = await fs.stat(`one/playbooks/clients/${item}`);
if (stat.isDirectory()) {
const configExists = await fs.access(`one/playbooks/clients/${item}/config.yaml`).then(() => true).catch(() => false);
return configExists ? item : null;
}
return null;
} catch {
return null;
}
})
);
dirs.filter(Boolean).forEach(dir => clients.add(dir));
} catch (e) {}
if (clients.size > 0) {
console.log('π’ Clients:');
Array.from(clients).sort().forEach(client => console.log(` - ${client}`));
console.log();
} else {
console.log('π’ Clients: No configurations found\n');
}
} catch (e) {
console.log('π’ Clients: No configurations found\n');
}
console.log('Usage Examples:');
console.log(' one generate-playbook --industry saas --format pdf');
console.log(' one generate-playbook --client acme-corp --format epub');
console.log(' one generate-playbook --config custom/my-config.yaml');
} catch (error) {
console.error('Error listing playbooks:', error.message);
}
});
// Archive playbook command
program
.command('archive-playbook')
.description('Archive a client or industry playbook with versioning')
.option('--client <name>', 'Archive client playbook')
.option('--industry <name>', 'Archive industry playbook')
.option('--version <version>', 'Version tag (default: timestamp)')
.option('--description <desc>', 'Archive description')
.action(async (options) => {
const { default: PlaybookManager } = await import('./playbook-generator/lib/manager.js');
const manager = new PlaybookManager({ rootDir: process.cwd() });
try {
let type, name;
if (options.client) {
type = 'client';
name = options.client;
} else if (options.industry) {
type = 'industry';
name = options.industry;
} else {
console.error('Error: Must specify --client or --industry');
process.exit(1);
}
console.log(`Archiving ${type} playbook: ${name}...`);
const result = await manager.archivePlaybook(type, name, {
version: options.version,
description: options.description
});
console.log(`β
Archive created successfully!`);
console.log(` Path: ${result.archivePath}`);
console.log(` Version: ${result.metadata.version}`);
// Also track changes in git
await manager.trackChanges(type, name, `Archive ${name} - ${result.metadata.version}`);
} catch (error) {
console.error('Archive failed:', error.message);
process.exit(1);
}
});
// Export playbook command
program
.command('export-playbook')
.description('Export playbook as a distributable package')
.option('--client <name>', 'Export client playbook')
.option('--industry <name>', 'Export industry playbook')
.option('--format <format>', 'Export format (default: full)')
.action(async (options) => {
const { default: PlaybookManager } = await import('./playbook-generator/lib/manager.js');
const manager = new PlaybookManager({ rootDir: process.cwd() });
try {
let type, name;
if (options.client) {
type = 'client';
name = options.client;
} else if (options.industry) {
type = 'industry';
name = options.industry;
} else {
console.error('Error: Must specify --client or --industry');
process.exit(1);
}
console.log(`Exporting ${type} playbook: ${name}...`);
const result = await manager.exportPlaybook(type, name, {
format: options.format
});
console.log(`β
Export package created successfully!`);
console.log(` Package: ${result.zipPath}`);
console.log(` Files included: ${result.metadata.included_files.length}`);
} catch (error) {
console.error('Export failed:', error.message);
process.exit(1);
}
});
// Backup playbook command
program
.command('backup-playbook')
.description('Create a backup snapshot of a playbook')
.option('--client <name>', 'Backup client playbook')
.option('--industry <name>', 'Backup industry playbook')
.action(async (options) => {
const { default: PlaybookManager } = await import('./playbook-generator/lib/manager.js');
const manager = new PlaybookManager({ rootDir: process.cwd() });
try {
let type, name;
if (options.client) {
type = 'client';
name = options.client;
} else if (options.industry) {
type = 'industry';
name = options.industry;
} else {
console.error('Error: Must specify --client or --industry');
process.exit(1);
}
console.log(`Creating backup of ${type} playbook: ${name}...`);
const result = await manager.backupPlaybook(type, name);
console.log(`β
Backup created successfully!`);
console.log(` Backup ID: ${result.timestamp}`);
console.log(` Location: ${result.backupPath}`);
} catch (error) {
console.error('Backup failed:', error.message);
process.exit(1);
}
});
// List archives command
program
.command('list-archives')
.description('List available archives for a playbook')
.option('--client <name>', 'List client playbook archives')
.option('--industry <name>', 'List industry playbook archives')
.action(async (options) => {
const { default: PlaybookManager } = await import('./playbook-generator/lib/manager.js');
const manager = new PlaybookManager({ rootDir: process.cwd() });
t