Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/happy-cli/src/codex/codexMcpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,17 @@ export class CodexMcpClient {

if (mcpCommand === null) {
throw new Error(
'Codex CLI not found or not executable.\n' +
'Codex CLI is not installed\n' +
'\n' +
'To install codex:\n' +
'Please install Codex CLI using one of these methods:\n' +
'\n' +
'Option 1 - npm (recommended):\n' +
' npm install -g @openai/codex\n' +
'\n' +
'Alternatively, use Claude:\n' +
'Option 2 - Homebrew (macOS):\n' +
' brew install --cask codex\n' +
'\n' +
'Alternatively, use Claude Code:\n' +
' happy claude'
);
}
Expand Down
16 changes: 16 additions & 0 deletions packages/happy-cli/src/codex/runCodex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CodexPermissionHandler } from './utils/permissionHandler';
import { ReasoningProcessor } from './utils/reasoningProcessor';
import { DiffProcessor } from './utils/diffProcessor';
import { randomUUID } from 'node:crypto';
import { execSync } from 'node:child_process';
import { logger } from '@/ui/logger';
import { Credentials, readSettings } from '@/persistence';
import { initialMachineMetadata } from '@/daemon/run';
Expand Down Expand Up @@ -70,6 +71,21 @@ export async function runCodex(opts: {
startedBy?: 'daemon' | 'terminal';
noSandbox?: boolean;
}): Promise<void> {
// Early check: ensure Codex CLI is installed before proceeding
try {
execSync('codex --version', { encoding: 'utf8', stdio: 'pipe' });
} catch {
console.error('\n\x1b[1m\x1b[33mCodex CLI is not installed\x1b[0m\n');
console.error('Please install Codex CLI using one of these methods:\n');
console.error('\x1b[1mOption 1 - npm (recommended):\x1b[0m');
console.error(' \x1b[36mnpm install -g @openai/codex\x1b[0m\n');
console.error('\x1b[1mOption 2 - Homebrew (macOS):\x1b[0m');
console.error(' \x1b[36mbrew install --cask codex\x1b[0m\n');
console.error('Alternatively, use Claude Code:');
console.error(' \x1b[36mhappy claude\x1b[0m\n');
process.exit(1);
}

// Use shared PermissionMode type for cross-agent compatibility
type PermissionMode = import('@/api/types').PermissionMode;
interface EnhancedMode {
Expand Down