oac.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env node
  2. /**
  3. * OpenAgents Control (OAC) CLI
  4. *
  5. * This is the main entry point for the @openagents/control package.
  6. * It runs the install.sh script to set up the OpenAgents Control system.
  7. */
  8. const { spawn } = require('child_process');
  9. const path = require('path');
  10. const fs = require('fs');
  11. // Get the package root directory
  12. const packageRoot = path.join(__dirname, '..');
  13. // Path to install.sh
  14. const installScript = path.join(packageRoot, 'install.sh');
  15. // Check if install.sh exists
  16. if (!fs.existsSync(installScript)) {
  17. console.error('Error: install.sh not found at', installScript);
  18. process.exit(1);
  19. }
  20. // Get command line arguments (skip node and script path)
  21. const args = process.argv.slice(2);
  22. // If no arguments provided, show help
  23. if (args.length === 0) {
  24. console.log(`
  25. ╔═══════════════════════════════════════════════════════════════╗
  26. ║ OpenAgents Control (OAC) ║
  27. ║ AI agent framework for plan-first development workflows ║
  28. ╚═══════════════════════════════════════════════════════════════╝
  29. Usage:
  30. oac [profile] Install with a specific profile
  31. oac --help Show this help message
  32. oac --version Show version information
  33. Available Profiles:
  34. essential Minimal setup (OpenAgent only)
  35. developer Full development setup (recommended)
  36. business Business-focused agents
  37. advanced Advanced features and specialists
  38. full Everything included
  39. Examples:
  40. oac Interactive installation
  41. oac developer Install with developer profile
  42. oac --help Show detailed help
  43. For more information, visit:
  44. https://github.com/darrenhinde/OpenAgentsControl
  45. `);
  46. process.exit(0);
  47. }
  48. // Handle --version flag
  49. if (args.includes('--version') || args.includes('-v')) {
  50. const packageJson = require(path.join(packageRoot, 'package.json'));
  51. console.log(`@openagents/control v${packageJson.version}`);
  52. process.exit(0);
  53. }
  54. // Handle --help flag
  55. if (args.includes('--help') || args.includes('-h')) {
  56. // Run install.sh with --help
  57. args.push('--help');
  58. }
  59. // Run the install script with bash
  60. const child = spawn('bash', [installScript, ...args], {
  61. cwd: packageRoot,
  62. stdio: 'inherit',
  63. env: {
  64. ...process.env,
  65. OAC_PACKAGE_ROOT: packageRoot
  66. }
  67. });
  68. child.on('error', (error) => {
  69. console.error('Error running install script:', error.message);
  70. process.exit(1);
  71. });
  72. child.on('exit', (code) => {
  73. process.exit(code || 0);
  74. });