Skip to content

Commit 8b67253

Browse files
committed
Update InstallCommand.php
1 parent 9a0e325 commit 8b67253

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

src/Console/InstallCommand.php

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class InstallCommand extends Command
3434
{
3535
use Colors;
3636

37-
/** @var string */
38-
protected $signature = 'boost:install {--ignore-guidelines : Skip installing AI guidelines} {--ignore-mcp : Skip installing MCP server configuration}';
37+
protected string $signature = 'boost:install {--ignore-guidelines : Skip installing AI guidelines} {--ignore-mcp : Skip installing MCP server configuration}';
3938

4039
private CodeEnvironmentsDetector $codeEnvironmentsDetector;
4140

@@ -70,6 +69,10 @@ class InstallCommand extends Command
7069

7170
private string $redCross;
7271

72+
private bool $installGuidelines;
73+
74+
private bool $installMcpConfig;
75+
7376
public function __construct(protected Config $config)
7477
{
7578
parent::__construct();
@@ -80,39 +83,25 @@ public function handle(
8083
Herd $herd,
8184
Terminal $terminal,
8285
): int {
83-
[$guidelines, $mcp] = $this->validateOptions();
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.');
8491

85-
if (! $guidelines && ! $mcp) {
8692
return self::FAILURE;
8793
}
8894

8995
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
9096
$this->displayBoostHeader();
9197
$this->discoverEnvironment();
92-
$this->collectInstallationPreferences($guidelines, $mcp);
93-
$this->performInstallation($guidelines, $mcp);
98+
$this->collectInstallationPreferences();
99+
$this->performInstallation();
94100
$this->outro();
95101

96102
return self::SUCCESS;
97103
}
98104

99-
/**
100-
* @return array{bool, bool}
101-
*/
102-
protected function validateOptions(): array
103-
{
104-
$guidelines = ! $this->option('ignore-guidelines');
105-
$mcp = ! $this->option('ignore-mcp');
106-
107-
if (! $guidelines && ! $mcp) {
108-
$this->error('You cannot ignore both guidelines and MCP config. Please select at least one option to proceed.');
109-
110-
return [false, false];
111-
}
112-
113-
return [$guidelines, $mcp];
114-
}
115-
116105
protected function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
117106
{
118107
$this->codeEnvironmentsDetector = $codeEnvironmentsDetector;
@@ -156,24 +145,24 @@ protected function discoverEnvironment(): void
156145
$this->projectInstalledCodeEnvironments = $this->codeEnvironmentsDetector->discoverProjectInstalledCodeEnvironments(base_path());
157146
}
158147

159-
protected function collectInstallationPreferences(bool $guidelines, bool $mcp): void
148+
protected function collectInstallationPreferences(): void
160149
{
161-
$this->selectedBoostFeatures = $mcp ? $this->selectBoostFeatures() : collect();
162-
$this->selectedAiGuidelines = $guidelines ? $this->selectAiGuidelines() : collect();
163-
$this->selectedTargetMcpClient = $mcp ? $this->selectTargetMcpClients() : collect();
164-
$this->selectedTargetAgents = $guidelines ? $this->selectTargetAgents() : collect();
165-
$this->enforceTests = $guidelines && $this->determineTestEnforcement();
150+
$this->selectedBoostFeatures = $this->selectBoostFeatures();
151+
$this->selectedAiGuidelines = $this->selectAiGuidelines();
152+
$this->selectedTargetMcpClient = $this->selectTargetMcpClients();
153+
$this->selectedTargetAgents = $this->selectTargetAgents();
154+
$this->enforceTests = $this->determineTestEnforcement();
166155
}
167156

168-
protected function performInstallation(bool $guidelines, bool $mcp): void
157+
protected function performInstallation(): void
169158
{
170-
if ($guidelines) {
171-
$this->installGuidelines($mcp);
159+
if ($this->installGuidelines) {
160+
$this->installGuidelines();
172161
}
173162

174163
usleep(750000);
175164

176-
if ($mcp && $this->selectedTargetMcpClient->isNotEmpty()) {
165+
if ($this->installMcpConfig && $this->selectedTargetMcpClient->isNotEmpty()) {
177166
$this->installMcpServerConfig();
178167
}
179168
}
@@ -243,6 +232,10 @@ protected function hyperlink(string $label, string $url): string
243232
*/
244233
protected function determineTestEnforcement(): bool
245234
{
235+
if (! $this->installGuidelines) {
236+
return false;
237+
}
238+
246239
$hasMinimumTests = false;
247240

248241
if (file_exists(base_path('vendor/bin/phpunit'))) {
@@ -265,6 +258,10 @@ protected function determineTestEnforcement(): bool
265258
*/
266259
protected function selectBoostFeatures(): Collection
267260
{
261+
if (! $this->installMcpConfig) {
262+
return collect();
263+
}
264+
268265
$features = collect(['mcp_server', 'ai_guidelines']);
269266

270267
if ($this->herd->isMcpAvailable() && $this->shouldConfigureHerdMcp()) {
@@ -301,6 +298,10 @@ protected function shouldConfigureHerdMcp(): bool
301298
*/
302299
protected function selectAiGuidelines(): Collection
303300
{
301+
if (! $this->installGuidelines) {
302+
return collect();
303+
}
304+
304305
$options = app(GuidelineComposer::class)->guidelines()
305306
->reject(fn (array $guideline): bool => $guideline['third_party'] === false);
306307

@@ -327,6 +328,10 @@ protected function selectAiGuidelines(): Collection
327328
*/
328329
protected function selectTargetMcpClients(): Collection
329330
{
331+
if (! $this->installMcpConfig) {
332+
return collect();
333+
}
334+
330335
return $this->selectCodeEnvironments(
331336
McpClient::class,
332337
sprintf('Which code editors do you use to work on %s?', $this->projectName),
@@ -339,6 +344,10 @@ protected function selectTargetMcpClients(): Collection
339344
*/
340345
protected function selectTargetAgents(): Collection
341346
{
347+
if (! $this->installGuidelines) {
348+
return collect();
349+
}
350+
342351
return $this->selectCodeEnvironments(
343352
Agent::class,
344353
sprintf('Which agents need AI guidelines for %s?', $this->projectName),
@@ -419,7 +428,7 @@ protected function selectCodeEnvironments(string $contractClass, string $label,
419428
)->filter()->values();
420429
}
421430

422-
protected function installGuidelines(bool $mcp): void
431+
protected function installGuidelines(): void
423432
{
424433
if ($this->selectedTargetAgents->isEmpty()) {
425434
$this->info(' No agents selected for guideline installation.');
@@ -483,7 +492,7 @@ protected function installGuidelines(bool $mcp): void
483492
}
484493
}
485494

486-
if ($mcp) {
495+
if ($this->installMcpConfig) {
487496
$this->config->setSail(
488497
$this->shouldUseSail()
489498
);
@@ -571,7 +580,6 @@ protected function installMcpServerConfig(): void
571580
)->toArray()
572581
);
573582

574-
/** @var McpClient $mcpClient */
575583
foreach ($this->selectedTargetMcpClient as $mcpClient) {
576584
$ideName = $mcpClient->mcpClientName();
577585
$ideDisplay = str_pad((string) $ideName, $longestIdeName);

0 commit comments

Comments
 (0)