From f71f89d5c4418348a5781e01b14fa32b093b5d23 Mon Sep 17 00:00:00 2001 From: "Jorge Thomas (Akrista)" <23145794+Akrista@users.noreply.github.com> Date: Sat, 4 Oct 2025 21:00:21 -0400 Subject: [PATCH] fix: update copilot instructions generation to be in .github/instructions/laravel-boost.instructions.md with frontmatter support --- src/Install/CodeEnvironment/Copilot.php | 9 +++++++-- src/Install/GuidelineWriter.php | 7 ++++++- tests/Unit/Install/CodeEnvironmentsDetectorTest.php | 7 ++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Install/CodeEnvironment/Copilot.php b/src/Install/CodeEnvironment/Copilot.php index 2219539e..a37b9dd2 100644 --- a/src/Install/CodeEnvironment/Copilot.php +++ b/src/Install/CodeEnvironment/Copilot.php @@ -30,7 +30,7 @@ public function systemDetectionConfig(Platform $platform): array public function projectDetectionConfig(): array { return [ - 'files' => ['.github/copilot-instructions.md'], + 'files' => ['.github/instructions/laravel-boost.instructions.md'], ]; } @@ -46,6 +46,11 @@ public function mcpClientName(): ?string public function guidelinesPath(): string { - return '.github/copilot-instructions.md'; + return '.github/instructions/laravel-boost.instructions.md'; + } + + public function frontmatter(): bool + { + return true; } } diff --git a/src/Install/GuidelineWriter.php b/src/Install/GuidelineWriter.php index 805caa68..22eba8b7 100644 --- a/src/Install/GuidelineWriter.php +++ b/src/Install/GuidelineWriter.php @@ -5,6 +5,7 @@ namespace Laravel\Boost\Install; use Laravel\Boost\Contracts\Agent; +use Laravel\Boost\Install\CodeEnvironment\Copilot; use RuntimeException; class GuidelineWriter @@ -60,7 +61,11 @@ public function write(string $guidelines): int // No existing Boost guidelines found, append to end of existing file $frontMatter = ''; if ($this->agent->frontmatter() && ! str_contains($content, "\n---\n")) { - $frontMatter = "---\nalwaysApply: true\n---\n"; + if ($this->agent instanceof Copilot) { + $frontMatter = "---\napplyTo: \"**\"\n---\n"; + } else { + $frontMatter = "---\nalwaysApply: true\n---\n"; + } } $existingContent = rtrim($content); diff --git a/tests/Unit/Install/CodeEnvironmentsDetectorTest.php b/tests/Unit/Install/CodeEnvironmentsDetectorTest.php index cf80d842..fe828220 100644 --- a/tests/Unit/Install/CodeEnvironmentsDetectorTest.php +++ b/tests/Unit/Install/CodeEnvironmentsDetectorTest.php @@ -144,15 +144,16 @@ test('discoverProjectInstalledCodeEnvironments detects copilot with nested file path', function (): void { $tempDir = sys_get_temp_dir().'/boost_test_'.uniqid(); mkdir($tempDir); - mkdir($tempDir.'/.github'); - file_put_contents($tempDir.'/.github/copilot-instructions.md', 'test'); + mkdir($tempDir.'/.github/instructions', recursive: true); + file_put_contents($tempDir.'/.github/instructions/laravel-boost.instructions.md', 'test'); $detected = $this->detector->discoverProjectInstalledCodeEnvironments($tempDir); expect($detected)->toContain('copilot'); // Cleanup - unlink($tempDir.'/.github/copilot-instructions.md'); + unlink($tempDir.'/.github/instructions/laravel-boost.instructions.md'); + rmdir($tempDir.'/.github/instructions'); rmdir($tempDir.'/.github'); rmdir($tempDir); });