Skip to content

Commit 3edec79

Browse files
committed
Allows package authors to publish guidelines
1 parent 642a3b6 commit 3edec79

File tree

15 files changed

+254
-27
lines changed

15 files changed

+254
-27
lines changed

.ai/foundation.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Laravel Boost Guidelines
1+
# Foundation (Recommended)
22

33
The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to enhance the user's satisfaction building Laravel applications.
44

.ai/inertia-react/2/forms.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
## Inertia + React Forms
2+
13
@php
24
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
35
@endphp
4-
## Inertia + React Forms
56

67
@if($assist->inertia()->hasFormComponent())
78
@boostsnippet("`<Form>` Component Example", "react")

.ai/inertia-svelte/2/forms.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
## Inertia + Svelte Forms
2+
13
@php
24
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
35
@endphp
4-
## Inertia + Svelte Forms
56

67
- There are critical differences between Svelte 4 and 5, use the `search-docs` tool for up-to-date guidance.
78

.ai/inertia-vue/2/forms.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
## Inertia + Vue Forms
2+
13
@php
24
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
35
@endphp
4-
## Inertia + Vue Forms
56

67
@if($assist->inertia()->hasFormComponent())
78
@boostsnippet("`<Form>` Component Example", "vue")

.ai/laravel/core.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Do Things the Laravel Way
1+
## Laravel
22

33
- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool.
44
- If you're creating a generic PHP class, use `artisan make:class`.

.ai/livewire/core.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Livewire Core
1+
## Livewire
22
- Use the `search-docs` tool to find exact version specific documentation for how to write Livewire & Livewire tests.
33
- Use the `php artisan make:livewire [Posts\\CreatePost]` artisan command to create new components
44
- State should live on the server, with the UI reflecting it.

.ai/phpunit/core.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## PHPUnit Core
1+
## PHPUnit
22

33
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit <name>` to create a new test.
44
- If you see a test using "Pest", convert it to PHPUnit.

.ai/pint/core.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Laravel Pint Code Formatter
1+
## Laravel Pint
22

33
- You must run `vendor/bin/pint --dirty` before finalizing changes to ensure your code matches the project's expected style.
44
- Do not run `vendor/bin/pint --test`, simply run `vendor/bin/pint` to fix any formatting issues.

.ai/tailwindcss/core.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Tailwind Core
1+
## Tailwind
22

33
- Use Tailwind CSS classes to style HTML, check and use existing tailwind conventions within the project before writing your own.
44
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc..)

src/Console/InstallCommand.php

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Laravel\Boost\Install\GuidelineConfig;
2020
use Laravel\Boost\Install\GuidelineWriter;
2121
use Laravel\Boost\Install\Herd;
22+
use Laravel\Boost\Support\Config;
2223
use Laravel\Prompts\Concerns\Colors;
2324
use Laravel\Prompts\Terminal;
2425
use Symfony\Component\Console\Attribute\AsCommand;
@@ -50,6 +51,9 @@ class InstallCommand extends Command
5051
/** @var Collection<int, string> */
5152
private Collection $selectedBoostFeatures;
5253

54+
/** @var Collection<int, string> */
55+
private Collection $selectedAiGuidelines;
56+
5357
private string $projectName;
5458

5559
/** @var array<non-empty-string> */
@@ -65,6 +69,11 @@ class InstallCommand extends Command
6569

6670
private string $redCross;
6771

72+
public function __construct(protected Config $config)
73+
{
74+
parent::__construct();
75+
}
76+
6877
public function handle(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
6978
{
7079
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
@@ -122,6 +131,7 @@ protected function discoverEnvironment(): void
122131
protected function collectInstallationPreferences(): void
123132
{
124133
$this->selectedBoostFeatures = $this->selectBoostFeatures();
134+
$this->selectedAiGuidelines = $this->selectAiGuidelines();
125135
$this->selectedTargetMcpClient = $this->selectTargetMcpClients();
126136
$this->selectedTargetAgents = $this->selectTargetAgents();
127137
$this->enforceTests = $this->determineTestEnforcement(ask: false);
@@ -232,24 +242,57 @@ protected function determineTestEnforcement(bool $ask = true): bool
232242
*/
233243
protected function selectBoostFeatures(): Collection
234244
{
235-
$defaultInstallOptions = ['mcp_server', 'ai_guidelines'];
245+
$defaultInstallOptions = [
246+
'mcp_server',
247+
...$this->config->exists() === false || $this->config->getAiGuidelines() !== [] ? ['ai_guidelines'] : [],
248+
];
249+
236250
$installOptions = [
237251
'mcp_server' => 'Boost MCP Server (with 15+ tools)',
238252
'ai_guidelines' => 'Boost AI Guidelines (for Laravel, Inertia, and more)',
239253
];
240254

241255
if ($this->herd->isMcpAvailable()) {
242256
$installOptions['herd_mcp'] = 'Herd MCP Server';
257+
}
243258

244-
return collect(multiselect(
245-
label: 'What do you want to install?',
246-
options: $installOptions,
247-
default: $defaultInstallOptions,
248-
required: true,
249-
));
259+
return collect(multiselect(
260+
label: 'What do you want to install?',
261+
options: $installOptions,
262+
default: $defaultInstallOptions,
263+
required: true,
264+
));
265+
}
266+
267+
/**
268+
* @return Collection<int, string>
269+
*/
270+
protected function selectAiGuidelines(): Collection
271+
{
272+
if (! $this->shouldInstallAiGuidelines()) {
273+
return collect();
274+
}
275+
276+
$aiGuidelines = collect($this->config->getAiGuidelines());
277+
278+
$options = app(GuidelineComposer::class)->guidelines();
279+
$defaults = $aiGuidelines->isNotEmpty()
280+
? $aiGuidelines
281+
: $options->reject(fn (array $guideline) => $guideline['third_party'])->keys();
282+
283+
if ($options->isEmpty()) {
284+
return collect();
250285
}
251286

252-
return collect(['mcp_server', 'ai_guidelines']);
287+
return collect(multiselect(
288+
label: 'Which AI guidelines do you want to install?',
289+
// @phpstan-ignore-next-line
290+
options: $options->mapWithKeys(fn (array $guideline, string $name) => [$name => "{$name} (~{$guideline['tokens']} tokens) {$guideline['description']}"]),
291+
default: $defaults,
292+
scroll: 10,
293+
hint: 'You can add or remove them later by running this command again',
294+
required: true,
295+
));
253296
}
254297

255298
/**
@@ -265,10 +308,6 @@ protected function boostToolsToDisable(): array
265308
);
266309
}
267310

268-
/**
269-
* @return array<int, string>
270-
*/
271-
272311
/**
273312
* @return Collection<int, CodeEnvironment>
274313
*/
@@ -369,6 +408,8 @@ protected function selectCodeEnvironments(string $contractClass, string $label):
369408
protected function installGuidelines(): void
370409
{
371410
if (! $this->shouldInstallAiGuidelines()) {
411+
$this->config->setAiGuidelines([]);
412+
372413
return;
373414
}
374415

@@ -383,6 +424,7 @@ protected function installGuidelines(): void
383424
$guidelineConfig->laravelStyle = $this->shouldInstallStyleGuidelines();
384425
$guidelineConfig->caresAboutLocalization = $this->detectLocalization();
385426
$guidelineConfig->hasAnApi = false;
427+
$guidelineConfig->aiGuidelines = $this->selectedAiGuidelines->values()->toArray();
386428

387429
$composer = app(GuidelineComposer::class)->config($guidelineConfig);
388430
$guidelines = $composer->guidelines();
@@ -432,6 +474,10 @@ protected function installGuidelines(): void
432474
$this->line(" - {$agentName}: {$error}");
433475
}
434476
}
477+
478+
$this->config->setAiGuidelines(
479+
$this->selectedAiGuidelines->values()->toArray()
480+
);
435481
}
436482

437483
protected function shouldInstallAiGuidelines(): bool

0 commit comments

Comments
 (0)