Skip to content
Merged
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
46 changes: 46 additions & 0 deletions src/Install/CodeEnvironment/Codex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Laravel\Boost\Install\CodeEnvironment;

use Laravel\Boost\Contracts\Agent;
use Laravel\Boost\Install\Enums\Platform;

class Codex extends CodeEnvironment implements Agent
{
public function name(): string
{
return 'codex';
}

public function displayName(): string
{
return 'Codex';
}

public function systemDetectionConfig(Platform $platform): array
{
return match ($platform) {
Platform::Darwin, Platform::Linux => [
'command' => 'which codex',
],
Platform::Windows => [
'command' => 'where codex 2>nul',
],
};
}

public function projectDetectionConfig(): array
{
return [
'paths' => ['.codex'],
'files' => ['AGENTS.md'],
];
}

public function guidelinesPath(): string
{
return 'AGENTS.md';
}
}
2 changes: 2 additions & 0 deletions src/Install/CodeEnvironmentsDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Collection;
use Laravel\Boost\Install\CodeEnvironment\ClaudeCode;
use Laravel\Boost\Install\CodeEnvironment\CodeEnvironment;
use Laravel\Boost\Install\CodeEnvironment\Codex;
use Laravel\Boost\Install\CodeEnvironment\Copilot;
use Laravel\Boost\Install\CodeEnvironment\Cursor;
use Laravel\Boost\Install\CodeEnvironment\PhpStorm;
Expand All @@ -22,6 +23,7 @@ class CodeEnvironmentsDetector
'vscode' => VSCode::class,
'cursor' => Cursor::class,
'claudecode' => ClaudeCode::class,
'codex' => Codex::class,
'copilot' => Copilot::class,
];

Expand Down
30 changes: 28 additions & 2 deletions tests/Unit/Install/CodeEnvironmentsDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
$container->bind(\Laravel\Boost\Install\CodeEnvironment\VSCode::class, fn () => $program2);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Cursor::class, fn () => $program3);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\ClaudeCode::class, fn () => $otherProgram);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Codex::class, fn () => $otherProgram);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Copilot::class, fn () => $otherProgram);

$detector = new CodeEnvironmentsDetector($container);
Expand All @@ -64,6 +65,7 @@
$container->bind(\Laravel\Boost\Install\CodeEnvironment\VSCode::class, fn () => $otherProgram);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Cursor::class, fn () => $otherProgram);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\ClaudeCode::class, fn () => $otherProgram);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Codex::class, fn () => $otherProgram);
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Copilot::class, fn () => $otherProgram);

$detector = new CodeEnvironmentsDetector($container);
Expand Down Expand Up @@ -139,7 +141,6 @@

expect($detected)->toContain('claudecode');

// Cleanup
unlink($tempDir.'/CLAUDE.md');
rmdir($tempDir);
});
Expand Down Expand Up @@ -169,7 +170,6 @@

expect($detected)->toContain('claudecode');

// Cleanup
rmdir($tempDir.'/.claude');
rmdir($tempDir);
});
Expand Down Expand Up @@ -216,6 +216,32 @@
rmdir($tempDir);
});

test('discoverProjectInstalledCodeEnvironments detects codex with codex directory', function () {
$tempDir = sys_get_temp_dir().'/boost_test_'.uniqid();
mkdir($tempDir);
mkdir($tempDir.'/.codex');

$detected = $this->detector->discoverProjectInstalledCodeEnvironments($tempDir);

expect($detected)->toContain('codex');

rmdir($tempDir.'/.codex');
rmdir($tempDir);
});

test('discoverProjectInstalledCodeEnvironments detects codex with AGENTS.md file', function () {
$tempDir = sys_get_temp_dir().'/boost_test_'.uniqid();
mkdir($tempDir);
file_put_contents($tempDir.'/AGENTS.md', 'test');

$detected = $this->detector->discoverProjectInstalledCodeEnvironments($tempDir);

expect($detected)->toContain('codex');

unlink($tempDir.'/AGENTS.md');
rmdir($tempDir);
});

test('discoverProjectInstalledCodeEnvironments handles multiple detections', function () {
$tempDir = sys_get_temp_dir().'/boost_test_'.uniqid();
mkdir($tempDir);
Expand Down
Loading