Skip to content

Commit 2c4580e

Browse files
Ignore MCP config update in boost:update (#334)
* Add an option to ignore guidelines and mcp related questions Signed-off-by: Pushpak Chhajed <[email protected]> * ignore mcp config update in boost:update Signed-off-by: Pushpak Chhajed <[email protected]> * Update option for ignoring MCP configuration Signed-off-by: Pushpak Chhajed <[email protected]> * Refactor `InstallCommand` to reorder bootstrap invocation Signed-off-by: Pushpak Chhajed <[email protected]> * Add type annotation for `$signature` in `InstallCommand` Signed-off-by: Pushpak Chhajed <[email protected]> * Simplify conditions Signed-off-by: Pushpak Chhajed <[email protected]> * Update InstallCommand.php * Update InstallCommand.php --------- Signed-off-by: Pushpak Chhajed <[email protected]> Co-authored-by: Joe Tannenbaum <[email protected]>
1 parent cba9397 commit 2c4580e

File tree

2 files changed

+58
-17
lines changed

2 files changed

+58
-17
lines changed

src/Console/InstallCommand.php

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Laravel\Boost\Support\Config;
2323
use Laravel\Prompts\Concerns\Colors;
2424
use Laravel\Prompts\Terminal;
25-
use Symfony\Component\Console\Attribute\AsCommand;
2625
use Symfony\Component\Finder\Finder;
2726
use Symfony\Component\Process\Process;
2827

@@ -31,11 +30,12 @@
3130
use function Laravel\Prompts\multiselect;
3231
use function Laravel\Prompts\note;
3332

34-
#[AsCommand('boost:install', 'Install Laravel Boost')]
3533
class InstallCommand extends Command
3634
{
3735
use Colors;
3836

37+
protected $signature = 'boost:install {--ignore-guidelines : Skip installing AI guidelines} {--ignore-mcp : Skip installing MCP server configuration}';
38+
3939
private CodeEnvironmentsDetector $codeEnvironmentsDetector;
4040

4141
private Herd $herd;
@@ -69,20 +69,37 @@ class InstallCommand extends Command
6969

7070
private string $redCross;
7171

72+
private bool $installGuidelines;
73+
74+
private bool $installMcpConfig;
75+
7276
public function __construct(protected Config $config)
7377
{
7478
parent::__construct();
7579
}
7680

77-
public function handle(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
78-
{
79-
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
81+
public function handle(
82+
CodeEnvironmentsDetector $codeEnvironmentsDetector,
83+
Herd $herd,
84+
Terminal $terminal,
85+
): int {
86+
$this->installGuidelines = ! $this->option('ignore-guidelines');
87+
$this->installMcpConfig = ! $this->option('ignore-mcp');
88+
89+
if (! $this->installGuidelines && ! $this->installMcpConfig) {
90+
$this->error('You cannot ignore both guidelines and MCP config. Please select at least one option to proceed.');
91+
92+
return self::FAILURE;
93+
}
8094

95+
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
8196
$this->displayBoostHeader();
8297
$this->discoverEnvironment();
8398
$this->collectInstallationPreferences();
8499
$this->performInstallation();
85100
$this->outro();
101+
102+
return self::SUCCESS;
86103
}
87104

88105
protected function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
@@ -139,11 +156,13 @@ protected function collectInstallationPreferences(): void
139156

140157
protected function performInstallation(): void
141158
{
142-
$this->installGuidelines();
159+
if ($this->installGuidelines) {
160+
$this->installGuidelines();
161+
}
143162

144163
usleep(750000);
145164

146-
if ($this->selectedTargetMcpClient->isNotEmpty()) {
165+
if ($this->installMcpConfig && $this->selectedTargetMcpClient->isNotEmpty()) {
147166
$this->installMcpServerConfig();
148167
}
149168
}
@@ -213,6 +232,10 @@ protected function hyperlink(string $label, string $url): string
213232
*/
214233
protected function determineTestEnforcement(): bool
215234
{
235+
if (! $this->installGuidelines) {
236+
return false;
237+
}
238+
216239
$hasMinimumTests = false;
217240

218241
if (file_exists(base_path('vendor/bin/phpunit'))) {
@@ -235,6 +258,10 @@ protected function determineTestEnforcement(): bool
235258
*/
236259
protected function selectBoostFeatures(): Collection
237260
{
261+
if (! $this->installMcpConfig) {
262+
return collect();
263+
}
264+
238265
$features = collect(['mcp_server', 'ai_guidelines']);
239266

240267
if ($this->herd->isMcpAvailable() && $this->shouldConfigureHerdMcp()) {
@@ -271,6 +298,10 @@ protected function shouldConfigureHerdMcp(): bool
271298
*/
272299
protected function selectAiGuidelines(): Collection
273300
{
301+
if (! $this->installGuidelines) {
302+
return collect();
303+
}
304+
274305
$options = app(GuidelineComposer::class)->guidelines()
275306
->reject(fn (array $guideline): bool => $guideline['third_party'] === false);
276307

@@ -297,6 +328,10 @@ protected function selectAiGuidelines(): Collection
297328
*/
298329
protected function selectTargetMcpClients(): Collection
299330
{
331+
if (! $this->installMcpConfig) {
332+
return collect();
333+
}
334+
300335
return $this->selectCodeEnvironments(
301336
McpClient::class,
302337
sprintf('Which code editors do you use to work on %s?', $this->projectName),
@@ -309,6 +344,10 @@ protected function selectTargetMcpClients(): Collection
309344
*/
310345
protected function selectTargetAgents(): Collection
311346
{
347+
if (! $this->installGuidelines) {
348+
return collect();
349+
}
350+
312351
return $this->selectCodeEnvironments(
313352
Agent::class,
314353
sprintf('Which agents need AI guidelines for %s?', $this->projectName),
@@ -453,17 +492,19 @@ protected function installGuidelines(): void
453492
}
454493
}
455494

456-
$this->config->setSail(
457-
$this->shouldUseSail()
458-
);
495+
if ($this->installMcpConfig) {
496+
$this->config->setSail(
497+
$this->shouldUseSail()
498+
);
459499

460-
$this->config->setHerdMcp(
461-
$this->shouldInstallHerdMcp()
462-
);
500+
$this->config->setHerdMcp(
501+
$this->shouldInstallHerdMcp()
502+
);
463503

464-
$this->config->setEditors(
465-
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
466-
);
504+
$this->config->setEditors(
505+
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
506+
);
507+
}
467508

468509
$this->config->setAgents(
469510
$this->selectedTargetAgents->map(fn (Agent $agent): string => $agent->name())->values()->toArray()
@@ -539,7 +580,6 @@ protected function installMcpServerConfig(): void
539580
)->toArray()
540581
);
541582

542-
/** @var McpClient $mcpClient */
543583
foreach ($this->selectedTargetMcpClient as $mcpClient) {
544584
$ideName = $mcpClient->mcpClientName();
545585
$ideDisplay = str_pad((string) $ideName, $longestIdeName);

src/Console/UpdateCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function handle(): void
1414
{
1515
$this->callSilently(InstallCommand::class, [
1616
'--no-interaction' => true,
17+
'--ignore-mcp' => true,
1718
]);
1819

1920
$this->components->info('Boost guidelines updated successfully.');

0 commit comments

Comments
 (0)