import { install } from './commands/install.js'; import { uninstall } from './commands/uninstall.js'; import { doctor } from './commands/doctor.js'; import { list } from './commands/list.js'; export async function run(args) { const command = args[0]; if (!command || command === '-h' || command === '--help') { showHelp(); return; } if (command === '--version' || command === '-v') { console.log('0.1.0'); return; } switch (command) { case 'install': await install(parseInstallArgs(args.slice(1))); break; case 'uninstall': await uninstall(parseInstallArgs(args.slice(1))); break; case 'doctor': await doctor(parseInstallArgs(args.slice(1))); break; case 'list': await list(parseListArgs(args.slice(1))); break; default: console.error(`Unknown command: ${command}`); showHelp(); process.exit(1); } } function showHelp() { console.log(` BuildCrew - The Build Crew for AI Development Usage: buildcrew [options] Commands: install [-p | -u] [-t ] [--dry-run] [--force] Install or update BuildCrew recipes for a platform. uninstall [-p | -u] [-t ] [--dry-run] Remove BuildCrew recipes for a platform. doctor [-p | -u] [-t ] Check the status of BuildCrew recipes. list [platforms | installed] List supported platforms or installed recipes. Options: -p, --project Install into current/project directory (default) -u, --user Install into user-level config directory -t, --target Target project directory (only with --project) --dry-run Show what would happen without making changes --force Overwrite files even if they conflict Platforms: opencode, claude, copilot Examples: buildcrew install copilot buildcrew install opencode -u buildcrew install claude -t ./my-app --dry-run buildcrew doctor copilot buildcrew uninstall opencode `); } function parseInstallArgs(args) { const result = { platform: null, project: false, user: false, target: null, dryRun: false, force: false }; for (let i = 0; i < args.length; i++) { const arg = args[i]; if (arg === '-p' || arg === '--project') { result.project = true; } else if (arg === '-u' || arg === '--user') { result.user = true; } else if (arg === '-t' || arg === '--target') { result.target = args[++i]; } else if (arg === '--dry-run') { result.dryRun = true; } else if (arg === '--force') { result.force = true; } else if (!arg.startsWith('-')) { if (!result.platform) { result.platform = arg; } } } return result; } function parseListArgs(args) { return { subcommand: args[0] || 'platforms' }; }