Skip to content

Commit ca6a45e

Browse files
committed
refactor: replace Agent and Ide contracts with CodingAgent and McpClient
- Removed `Agent` and `Ide` contracts, introducing `CodingAgent` and `McpClient` interfaces. - Updated `CodeEnvironment` subclasses to implement the new contracts. - Renamed and adjusted methods in `CodeEnvironment` for better clarity (`supportsAgent` -> `isCodingAgent`, `supportsIde` -> `isMcpClient`). - Updated `GuidelineWriter` and related tests to use `CodingAgent`. - Simplified `InstallCommand` filtering logic by adopting new contract methods.
1 parent ee75632 commit ca6a45e

File tree

14 files changed

+91
-79
lines changed

14 files changed

+91
-79
lines changed

src/Console/InstallCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,19 @@ private function selectCodeEnvironments(string $type, string $label): Collection
294294
{
295295
$allEnvironments = $this->codeEnvironmentsDetector->getCodeEnvironments();
296296

297-
// Filter by type capability
298297
$availableEnvironments = $allEnvironments->filter(function (CodeEnvironment $environment) use ($type) {
299-
return ($type === 'ide' && $environment->supportsIde()) ||
300-
($type === 'agent' && $environment->supportsAgent());
298+
return ($type === 'ide' && $environment->isMcpClient()) ||
299+
($type === 'agent' && $environment->IsCodingAgent());
301300
});
302301

303302
if ($availableEnvironments->isEmpty()) {
304303
return collect();
305304
}
306305

307-
// Build options for multiselect
308306
$options = $availableEnvironments->mapWithKeys(function (CodeEnvironment $environment) {
309307
return [get_class($environment) => $environment->displayName()];
310308
})->sort();
311309

312-
// Auto-detect installed environments
313310
$detectedClasses = [];
314311
$installedEnvNames = array_unique(array_merge(
315312
$this->projectInstalledCodeEnvironments,

src/Contracts/Agent.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Contracts/CodingAgent.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravel\Boost\Contracts;
6+
7+
/**
8+
* Agent contract for AI coding assistants that receive guidelines.
9+
*/
10+
interface CodingAgent
11+
{
12+
/**
13+
* Get the file path where AI guidelines should be written.
14+
*
15+
* @return string The relative or absolute path to the guideline file
16+
*/
17+
public function guidelinesPath(): string;
18+
19+
/**
20+
* Determine if the guideline file requires frontmatter.
21+
*
22+
* @return bool
23+
*/
24+
public function frontmatter(): bool;
25+
}

src/Contracts/Ide.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Contracts/McpClient.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravel\Boost\Contracts;
6+
7+
/**
8+
* Contract for code editors that support MCP (Model Context Protocol).
9+
*/
10+
interface McpClient
11+
{
12+
/**
13+
* Install an MCP server configuration in this IDE.
14+
*
15+
* @param string $key Server identifier/name
16+
* @param string $command Executable command to run the MCP server
17+
* @param array<int, string> $args Command line arguments
18+
* @param array<string, string> $env Environment variables
19+
* @return bool True if installation succeeded, false otherwise
20+
*/
21+
public function installMcp(string $key, string $command, array $args = [], array $env = []): bool;
22+
}

src/Install/CodeEnvironment/ClaudeCode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Laravel\Boost\Install\CodeEnvironment;
66

7-
use Laravel\Boost\Contracts\Agent;
8-
use Laravel\Boost\Contracts\Ide;
7+
use Laravel\Boost\Contracts\CodingAgent;
8+
use Laravel\Boost\Contracts\McpClient;
99
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
1010
use Laravel\Boost\Install\Enums\Platform;
1111

12-
class ClaudeCode extends CodeEnvironment implements Agent, Ide
12+
class ClaudeCode extends CodeEnvironment implements CodingAgent, McpClient
1313
{
1414
public function name(): string
1515
{

src/Install/CodeEnvironment/CodeEnvironment.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Illuminate\Contracts\Filesystem\FileNotFoundException;
88
use Illuminate\Support\Facades\File;
99
use Illuminate\Support\Facades\Process;
10-
use Laravel\Boost\Contracts\Agent;
11-
use Laravel\Boost\Contracts\Ide;
10+
use Laravel\Boost\Contracts\CodingAgent;
11+
use Laravel\Boost\Contracts\McpClient;
1212
use Laravel\Boost\Install\Detection\DetectionStrategyFactory;
1313
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
1414
use Laravel\Boost\Install\Enums\Platform;
@@ -102,19 +102,19 @@ public function ideName(): ?string
102102
*
103103
* @return bool
104104
*/
105-
public function supportsAgent(): bool
105+
public function IsCodingAgent(): bool
106106
{
107-
return $this->agentName() !== null && $this instanceof Agent;
107+
return $this->agentName() !== null && $this instanceof CodingAgent;
108108
}
109109

110110
/**
111111
* Determine if this environment supports IDE/MCP functionality.
112112
*
113113
* @return bool
114114
*/
115-
public function supportsIde(): bool
115+
public function isMcpClient(): bool
116116
{
117-
return $this->ideName() !== null && $this instanceof Ide;
117+
return $this->ideName() !== null && $this instanceof McpClient;
118118
}
119119

120120
/**
@@ -236,10 +236,8 @@ protected function installFileMcp(string $key, string $command, array $args = []
236236
return false;
237237
}
238238

239-
// Ensure directory exists
240239
File::ensureDirectoryExists(dirname($path));
241240

242-
// Load existing configuration
243241
$config = File::exists($path)
244242
? json_decode(File::get($path), true) ?: []
245243
: [];

src/Install/CodeEnvironment/Copilot.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Laravel\Boost\Install\CodeEnvironment;
66

7-
use Laravel\Boost\Contracts\Agent;
7+
use Laravel\Boost\Contracts\CodingAgent;
88
use Laravel\Boost\Install\Enums\Platform;
99

10-
class Copilot extends CodeEnvironment implements Agent
10+
class Copilot extends CodeEnvironment implements CodingAgent
1111
{
1212
public function name(): string
1313
{

src/Install/CodeEnvironment/Cursor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Laravel\Boost\Install\CodeEnvironment;
66

7-
use Laravel\Boost\Contracts\Agent;
8-
use Laravel\Boost\Contracts\Ide;
7+
use Laravel\Boost\Contracts\CodingAgent;
8+
use Laravel\Boost\Contracts\McpClient;
99
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
1010
use Laravel\Boost\Install\Enums\Platform;
1111

12-
class Cursor extends CodeEnvironment implements Agent, Ide
12+
class Cursor extends CodeEnvironment implements CodingAgent, McpClient
1313
{
1414
public function name(): string
1515
{

src/Install/CodeEnvironment/PhpStorm.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Laravel\Boost\Install\CodeEnvironment;
66

7-
use Laravel\Boost\Contracts\Agent;
8-
use Laravel\Boost\Contracts\Ide;
7+
use Laravel\Boost\Contracts\CodingAgent;
8+
use Laravel\Boost\Contracts\McpClient;
99
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
1010
use Laravel\Boost\Install\Enums\Platform;
1111

12-
class PhpStorm extends CodeEnvironment implements Agent, Ide
12+
class PhpStorm extends CodeEnvironment implements CodingAgent, McpClient
1313
{
1414
public function name(): string
1515
{

0 commit comments

Comments
 (0)