From cfd64e3843325633e90cd4538652e817495fe490 Mon Sep 17 00:00:00 2001 From: KietNT <113796420+TanNhatCMS@users.noreply.github.com> Date: Sat, 20 Dec 2025 01:33:13 +0700 Subject: [PATCH 1/2] Refactor systemDetectionConfig for platform commands --- src/CopilotCli.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/CopilotCli.php b/src/CopilotCli.php index ba0a7dd..c9c8b63 100644 --- a/src/CopilotCli.php +++ b/src/CopilotCli.php @@ -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', + ], + }; } /** @@ -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'], ]; } From 56d5f196588ce7d9614076d66a8748b07a676207 Mon Sep 17 00:00:00 2001 From: KietNT <113796420+TanNhatCMS@users.noreply.github.com> Date: Sat, 20 Dec 2025 01:42:14 +0700 Subject: [PATCH 2/2] Enhance JSON handling with error throwing --- src/CopilotCli.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CopilotCli.php b/src/CopilotCli.php index c9c8b63..25bfbae 100644 --- a/src/CopilotCli.php +++ b/src/CopilotCli.php @@ -99,6 +99,9 @@ public function convertCommandToPhpPath(string $command): string * * @param array $args * @param array $env + * + * @throws FileNotFoundException + * @throws JsonException */ protected function installFileMcp(string $key, string $command, array $args = [], array $env = []): bool { @@ -112,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); @@ -136,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);