2025-04-23 01:04:34 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
2025-04-20 12:33:39 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-06-06 09:56:45 -07:00
|
|
|
import { main } from './src/gemini.js';
|
2025-11-21 08:31:47 -08:00
|
|
|
import { FatalError, writeToStderr } from '@google/gemini-cli-core';
|
|
|
|
|
import { runExitCleanup } from './src/utils/cleanup.js';
|
2025-06-06 09:56:45 -07:00
|
|
|
|
|
|
|
|
// --- Global Entry Point ---
|
2025-11-21 08:31:47 -08:00
|
|
|
main().catch(async (error) => {
|
|
|
|
|
await runExitCleanup();
|
|
|
|
|
|
2025-08-25 21:44:45 -07:00
|
|
|
if (error instanceof FatalError) {
|
|
|
|
|
let errorMessage = error.message;
|
|
|
|
|
if (!process.env['NO_COLOR']) {
|
|
|
|
|
errorMessage = `\x1b[31m${errorMessage}\x1b[0m`;
|
|
|
|
|
}
|
2025-11-21 08:31:47 -08:00
|
|
|
writeToStderr(errorMessage + '\n');
|
2025-08-25 21:44:45 -07:00
|
|
|
process.exit(error.exitCode);
|
|
|
|
|
}
|
2025-11-21 08:31:47 -08:00
|
|
|
writeToStderr('An unexpected critical error occurred:');
|
2025-06-06 09:56:45 -07:00
|
|
|
if (error instanceof Error) {
|
2025-11-21 08:31:47 -08:00
|
|
|
writeToStderr(error.stack + '\n');
|
2025-06-06 09:56:45 -07:00
|
|
|
} else {
|
2025-11-21 08:31:47 -08:00
|
|
|
writeToStderr(String(error) + '\n');
|
2025-06-06 09:56:45 -07:00
|
|
|
}
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|