2026-01-18 04:50:46 +01:00
|
|
|
#!/usr/bin/env node
|
2026-01-21 08:37:35 +01:00
|
|
|
/**
|
|
|
|
|
* @fileoverview Claudeman CLI entry point
|
|
|
|
|
*
|
|
|
|
|
* This is the main executable entry point for the Claudeman CLI.
|
|
|
|
|
* It sets up global error handlers and invokes the CLI parser.
|
|
|
|
|
*
|
|
|
|
|
* @module index
|
|
|
|
|
*/
|
2026-01-18 04:50:46 +01:00
|
|
|
|
|
|
|
|
import { program } from './cli.js';
|
|
|
|
|
|
2026-02-12 14:41:27 +01:00
|
|
|
// Detect if we're running the web server (long-lived process)
|
|
|
|
|
// In web mode, we should NOT exit on transient errors — log and continue
|
|
|
|
|
const isWebMode = process.argv.includes('web');
|
|
|
|
|
|
2026-01-18 04:50:46 +01:00
|
|
|
// Handle uncaught errors
|
|
|
|
|
process.on('uncaughtException', (err) => {
|
|
|
|
|
console.error('Uncaught exception:', err.message);
|
2026-02-12 14:41:27 +01:00
|
|
|
if (isWebMode) {
|
|
|
|
|
// Log full stack trace for debugging but keep the server running
|
|
|
|
|
console.error('[RECOVERED] Server continuing after uncaught exception:', err.stack);
|
|
|
|
|
} else {
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
2026-01-18 04:50:46 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.on('unhandledRejection', (reason) => {
|
|
|
|
|
console.error('Unhandled rejection:', reason);
|
2026-02-12 14:41:27 +01:00
|
|
|
if (isWebMode) {
|
|
|
|
|
console.error('[RECOVERED] Server continuing after unhandled rejection');
|
|
|
|
|
} else {
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
2026-01-18 04:50:46 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Run CLI
|
|
|
|
|
program.parse();
|