Skip to content

Commit a616134

Browse files
committed
refactor: rename ideName to mcpClientName and enhance MCP client handling
- Replaced `ideName` references with `mcpClientName` for clarity. - Updated `InstallCommand` to use specific type hints (`Agent`, `McpClient`) for better consistency and readability. - Added docblocks and exceptions for improved code documentation and error handling. - Adjusted tests to reflect the `McpClient` changes and renamed corresponding test cases. - Minor updates in `VSCode` and contract interfaces to align with the new naming convention.
1 parent a8290fb commit a616134

File tree

7 files changed

+29
-19
lines changed

7 files changed

+29
-19
lines changed

src/Console/InstallCommand.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\Collection;
1111
use Illuminate\Support\Str;
1212
use Laravel\Boost\Contracts\Agent;
13+
use Laravel\Boost\Contracts\McpClient;
1314
use Laravel\Boost\Install\Cli\DisplayHelper;
1415
use Laravel\Boost\Install\CodeEnvironment\CodeEnvironment;
1516
use Laravel\Boost\Install\CodeEnvironmentsDetector;
@@ -38,10 +39,10 @@ class InstallCommand extends Command
3839

3940
private Terminal $terminal;
4041

41-
/** @var Collection<int, CodeEnvironment> */
42+
/** @var Collection<int, Agent> */
4243
private Collection $selectedTargetAgents;
4344

44-
/** @var Collection<int, CodeEnvironment> */
45+
/** @var Collection<int, McpClient> */
4546
private Collection $selectedTargetMcpClient;
4647

4748
/** @var Collection<int, string> */
@@ -157,11 +158,11 @@ private function outro(): void
157158
{
158159
$label = 'https://boost.laravel.com/installed';
159160

160-
$ideNames = $this->selectedTargetMcpClient->map(fn ($ide) => 'i:'.$ide->ideName())->toArray();
161-
$agentNames = $this->selectedTargetAgents->map(fn ($agent) => 'a:'.$agent->agentName())->toArray();
161+
$ideNames = $this->selectedTargetMcpClient->map(fn (McpClient $mcpClient) => 'i:'.$mcpClient->mcpClientName())
162+
->toArray();
163+
$agentNames = $this->selectedTargetAgents->map(fn (Agent $agent) => 'a:'.$agent->agentName())->toArray();
162164
$boostFeatures = $this->selectedBoostFeatures->map(fn ($feature) => 'b:'.$feature)->toArray();
163165

164-
// Guidelines installed (prefix: g)
165166
$guidelines = [];
166167
if ($this->shouldInstallAiGuidelines()) {
167168
$guidelines[] = 'g:ai';
@@ -436,12 +437,12 @@ private function installMcpServerConfig(): void
436437
$longestIdeName = max(
437438
1,
438439
...$this->selectedTargetMcpClient->map(
439-
fn ($mcpClient) => Str::length($mcpClient->ideName())
440+
fn (McpClient $mcpClient) => Str::length($mcpClient->mcpClientName())
440441
)->toArray()
441442
);
442443

443444
foreach ($this->selectedTargetMcpClient as $mcpClient) {
444-
$ideName = $mcpClient->ideName();
445+
$ideName = $mcpClient->mcpClientName();
445446
$ideDisplay = str_pad($ideName, $longestIdeName);
446447
$this->output->write(" {$ideDisplay}... ");
447448
$results = [];

src/Contracts/Agent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
*/
1010
interface Agent
1111
{
12+
/**
13+
* Get the display name of the Agent.
14+
*
15+
* @return string|null
16+
*/
17+
public function agentName(): ?string;
18+
1219
/**
1320
* Get the file path where AI guidelines should be written.
1421
*

src/Contracts/McpClient.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
*/
1010
interface McpClient
1111
{
12+
/**
13+
* Get the display name of the MCP (Model Context Protocol) client.
14+
*
15+
* @return string|null
16+
*/
17+
public function mcpClientName(): ?string;
18+
1219
/**
1320
* Install an MCP server configuration in this IDE.
1421
*

src/Install/CodeEnvironment/CodeEnvironment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function agentName(): ?string
2828
return $this->name();
2929
}
3030

31-
public function ideName(): ?string
31+
public function mcpClientName(): ?string
3232
{
3333
return $this->name();
3434
}
@@ -71,7 +71,7 @@ public function IsAgent(): bool
7171

7272
public function isMcpClient(): bool
7373
{
74-
return $this->ideName() && $this instanceof McpClient;
74+
return $this->mcpClientName() && $this instanceof McpClient;
7575
}
7676

7777
public function mcpInstallationStrategy(): McpInstallationStrategy

src/Install/CodeEnvironment/Copilot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function detectOnSystem(Platform $platform): bool
3939
return false;
4040
}
4141

42-
public function ideName(): ?string
42+
public function mcpClientName(): ?string
4343
{
4444
return null;
4545
}

src/Install/CodeEnvironment/VSCode.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function name(): string
1616

1717
public function displayName(): string
1818
{
19-
return 'Visual Studio Code';
19+
return 'Vs Code';
2020
}
2121

2222
public function systemDetectionConfig(Platform $platform): array
@@ -44,11 +44,6 @@ public function projectDetectionConfig(): array
4444
];
4545
}
4646

47-
public function agentName(): ?string
48-
{
49-
return null;
50-
}
51-
5247
public function mcpConfigPath(): string
5348
{
5449
return '.vscode/mcp.json';

tests/Unit/Install/CodeEnvironment/CodeEnvironmentTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ public function mcpConfigPath(): string
128128
expect($environment->agentName())->toBe('test');
129129
});
130130

131-
test('ideName returns name by default', function () {
131+
test('mcpClientName returns name by default', function () {
132132
$environment = new TestCodeEnvironment($this->strategyFactory);
133133

134-
expect($environment->ideName())->toBe('test');
134+
expect($environment->mcpClientName())->toBe('test');
135135
});
136136

137137
test('IsAgent returns true when implements Agent interface and has agentName', function () {
@@ -146,7 +146,7 @@ public function mcpConfigPath(): string
146146
expect($environment->IsAgent())->toBe(false);
147147
});
148148

149-
test('isMcpClient returns true when implements McpClient interface and has ideName', function () {
149+
test('isMcpClient returns true when implements McpClient interface and has mcpClientName', function () {
150150
$mcpClient = new TestMcpClient($this->strategyFactory);
151151

152152
expect($mcpClient->isMcpClient())->toBe(true);

0 commit comments

Comments
 (0)