-
-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor systemDetectionConfig for platform commands #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,10 @@ | |
|
|
||
| namespace Revolution\Laravel\Boost; | ||
|
|
||
| use Illuminate\Contracts\Filesystem\FileNotFoundException; | ||
| use Illuminate\Support\Facades\File; | ||
| use Illuminate\Support\Str; | ||
| use JsonException; | ||
| use Laravel\Boost\Contracts\Agent; | ||
| use Laravel\Boost\Contracts\McpClient; | ||
| use Laravel\Boost\Install\CodeEnvironment\CodeEnvironment; | ||
|
|
@@ -30,9 +32,14 @@ public function displayName(): string | |
| */ | ||
| public function systemDetectionConfig(Platform $platform): array | ||
| { | ||
| return [ | ||
| 'command' => 'command -v copilot', | ||
| ]; | ||
| return match ($platform) { | ||
| Platform::Darwin, Platform::Linux => [ | ||
| 'command' => 'command -v copilot', | ||
| ], | ||
| Platform::Windows => [ | ||
| 'command' => 'where copilot 2>nul', | ||
| ], | ||
| }; | ||
|
Comment on lines
+35
to
+42
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -43,7 +50,8 @@ public function systemDetectionConfig(Platform $platform): array | |
| public function projectDetectionConfig(): array | ||
| { | ||
| return [ | ||
| 'files' => ['.github/copilot-instructions.md'], | ||
| 'paths' => ['.github/instructions'], | ||
| 'files' => ['.github/copilot-instructions.md', '.github/instructions/laravel-boost.instructions.md', 'AGENTS.md', 'CLAUDE.md', 'GEMINI.md'], | ||
|
Comment on lines
+53
to
+54
|
||
| ]; | ||
|
Comment on lines
52
to
55
|
||
| } | ||
|
|
||
|
|
@@ -91,6 +99,9 @@ public function convertCommandToPhpPath(string $command): string | |
| * | ||
| * @param array<int, string> $args | ||
| * @param array<string, string> $env | ||
| * | ||
| * @throws FileNotFoundException | ||
| * @throws JsonException | ||
| */ | ||
| protected function installFileMcp(string $key, string $command, array $args = [], array $env = []): bool | ||
| { | ||
|
|
@@ -104,7 +115,7 @@ protected function installFileMcp(string $key, string $command, array $args = [] | |
| $config = []; | ||
| if (File::exists($path)) { | ||
| $existingContent = File::get($path); | ||
| $config = json_decode($existingContent, true) ?? []; | ||
| $config = json_decode($existingContent, true, 512, JSON_THROW_ON_ERROR) ?? []; | ||
| } | ||
|
|
||
| $phpPath = $this->convertCommandToPhpPath($command); | ||
|
|
@@ -128,7 +139,7 @@ protected function installFileMcp(string $key, string $command, array $args = [] | |
|
|
||
| // Remove empty arrays from existing config to avoid compatibility issues | ||
| $config = $this->removeEmptyArrays($config); | ||
| $json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); | ||
| $json = json_encode($config, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); | ||
| if ($json) { | ||
| $json = str_replace("\r\n", "\n", $json); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of Windows platform detection conflicts with the project's documented constraint that native Windows is not supported (only WSL). According to the README and project guidelines, this package explicitly does not support native Windows. The Windows-specific command 'where copilot 2>nul' should not be added, as it would incorrectly suggest Windows compatibility. Users on Windows should use WSL, which would be detected as Platform::Linux.