#!/usr/bin/env node
/**
 * Codewalkers CLI Entry Point
 *
 * Users can install globally via:
 * - npm link (during development)
 * - npm i -g codewalk-district (for release)
 */

import { runCli } from '../cli/index.js';
import { logger } from '../logger/index.js';

// Handle uncaught errors gracefully
process.on('uncaughtException', (error) => {
  logger.fatal({ err: error }, 'uncaught exception');
  console.error('Fatal error:', error.message);
  process.exit(1);
});

process.on('unhandledRejection', (reason) => {
  logger.fatal({ err: reason }, 'unhandled rejection');
  console.error('Unhandled promise rejection:', reason);
  process.exit(1);
});

// Run the CLI
runCli().catch((error) => {
  logger.fatal({ err: error }, 'CLI fatal error');
  console.error('CLI error:', error.message);
  process.exit(1);
});
