Skip to content

Commit 1a80964

Browse files
committed
refactor: rename CodingAgent to Agent, streamline detection methods, and remove unused MCP strategies
- Replaced `CodingAgent` interface with `Agent` and updated all references. - Removed redundant `mcpInstallationStrategy` and `frontmatter` methods in favor of simplified logic. - Improved `CodeEnvironment` with consolidated detection methods (`isCodingAgent` -> `IsAgent`). - Adjusted related classes, tests, and docblocks for consistency and clarity.
1 parent 7e51cf8 commit 1a80964

File tree

11 files changed

+64
-160
lines changed

11 files changed

+64
-160
lines changed

src/Console/InstallCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Support\Arr;
1010
use Illuminate\Support\Collection;
1111
use Illuminate\Support\Str;
12-
use Laravel\Boost\Contracts\CodingAgent;
12+
use Laravel\Boost\Contracts\Agent;
1313
use Laravel\Boost\Install\Cli\DisplayHelper;
1414
use Laravel\Boost\Install\CodeEnvironment\CodeEnvironment;
1515
use Laravel\Boost\Install\CodeEnvironmentsDetector;
@@ -297,7 +297,7 @@ private function selectCodeEnvironments(string $type, string $label): Collection
297297

298298
$availableEnvironments = $allEnvironments->filter(function (CodeEnvironment $environment) use ($type) {
299299
return ($type === 'ide' && $environment->isMcpClient()) ||
300-
($type === 'agent' && $environment->IsCodingAgent());
300+
($type === 'agent' && $environment->IsAgent());
301301
});
302302

303303
if ($availableEnvironments->isEmpty()) {
@@ -372,7 +372,7 @@ protected function enactGuidelines(): void
372372
$agentName = $agent->agentName();
373373
$displayAgentName = str_pad($agentName, $longestAgentName);
374374
$this->output->write(" {$displayAgentName}... ");
375-
/** @var CodingAgent $agent */
375+
/** @var Agent $agent */
376376
try {
377377
(new GuidelineWriter($agent))
378378
->write($composedAiGuidelines);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Agent contract for AI coding assistants that receive guidelines.
99
*/
10-
interface CodingAgent
10+
interface Agent
1111
{
1212
/**
1313
* Get the file path where AI guidelines should be written.

src/Install/CodeEnvironment/ClaudeCode.php

Lines changed: 2 additions & 7 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\CodingAgent;
7+
use Laravel\Boost\Contracts\Agent;
88
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 CodingAgent, McpClient
12+
class ClaudeCode extends CodeEnvironment implements McpClient, Agent
1313
{
1414
public function name(): string
1515
{
@@ -55,9 +55,4 @@ public function guidelinesPath(): string
5555
{
5656
return 'CLAUDE.md';
5757
}
58-
59-
public function frontmatter(): bool
60-
{
61-
return false;
62-
}
6358
}

src/Install/CodeEnvironment/CodeEnvironment.php

Lines changed: 25 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,47 @@
77
use Illuminate\Contracts\Filesystem\FileNotFoundException;
88
use Illuminate\Support\Facades\File;
99
use Illuminate\Support\Facades\Process;
10-
use Laravel\Boost\Contracts\CodingAgent;
10+
use Laravel\Boost\Contracts\Agent;
1111
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;
1515

1616
abstract class CodeEnvironment
1717
{
18-
public function __construct(
19-
protected readonly DetectionStrategyFactory $strategyFactory
20-
) {
18+
public function __construct(protected readonly DetectionStrategyFactory $strategyFactory)
19+
{
2120
}
2221

23-
/**
24-
* Get the internal identifier name for this code environment.
25-
*
26-
* @return string
27-
*/
2822
abstract public function name(): string;
2923

30-
/**
31-
* Get the human-readable display name for this code environment.
32-
*
33-
* @return string
34-
*/
3524
abstract public function displayName(): string;
3625

26+
public function agentName(): ?string
27+
{
28+
return $this->name();
29+
}
30+
31+
public function ideName(): ?string
32+
{
33+
return $this->name();
34+
}
35+
3736
/**
3837
* Get the detection configuration for system-wide installation detection.
3938
*
4039
* @param Platform $platform
41-
* @return array
40+
* @return array{paths?: string[], command?: string, files?: string[]}
4241
*/
4342
abstract public function systemDetectionConfig(Platform $platform): array;
4443

4544
/**
4645
* Get the detection configuration for project-specific detection.
4746
*
48-
* @return array
47+
* @return array{paths?: string[], files?: string[]}
4948
*/
5049
abstract public function projectDetectionConfig(): array;
5150

52-
/**
53-
* Determine if this code environment is installed on the system.
54-
*
55-
* @param Platform $platform
56-
* @return bool
57-
*/
5851
public function detectOnSystem(Platform $platform): bool
5952
{
6053
$config = $this->systemDetectionConfig($platform);
@@ -63,12 +56,6 @@ public function detectOnSystem(Platform $platform): bool
6356
return $strategy->detect($config, $platform);
6457
}
6558

66-
/**
67-
* Determine if this code environment is being used in a specific project.
68-
*
69-
* @param string $basePath
70-
* @return bool
71-
*/
7259
public function detectInProject(string $basePath): bool
7360
{
7461
$config = array_merge($this->projectDetectionConfig(), ['basePath' => $basePath]);
@@ -77,81 +64,36 @@ public function detectInProject(string $basePath): bool
7764
return $strategy->detect($config);
7865
}
7966

80-
/**
81-
* Override this method if the agent name is different from the environment name.
82-
*
83-
* @return ?string
84-
*/
85-
public function agentName(): ?string
67+
public function IsAgent(): bool
8668
{
87-
return $this->name();
69+
return $this->agentName() && $this instanceof Agent;
8870
}
8971

90-
/**
91-
* Override this method if the IDE name is different from the environment name.
92-
*
93-
* @return ?string
94-
*/
95-
public function ideName(): ?string
96-
{
97-
return $this->name();
98-
}
99-
100-
/**
101-
* Determine if this environment supports Agent/Guidelines functionality.
102-
*
103-
* @return bool
104-
*/
105-
public function IsCodingAgent(): bool
106-
{
107-
return $this->agentName() !== null && $this instanceof CodingAgent;
108-
}
109-
110-
/**
111-
* Determine if this environment supports IDE/MCP functionality.
112-
*
113-
* @return bool
114-
*/
11572
public function isMcpClient(): bool
11673
{
117-
return $this->ideName() !== null && $this instanceof McpClient;
74+
return $this->ideName() && $this instanceof McpClient;
11875
}
11976

120-
/**
121-
* Get the MCP installation strategy for this environment.
122-
*
123-
* @return McpInstallationStrategy
124-
*/
12577
public function mcpInstallationStrategy(): McpInstallationStrategy
12678
{
127-
return McpInstallationStrategy::None;
79+
return McpInstallationStrategy::File;
12880
}
12981

130-
/**
131-
* Get the shell command for MCP installation (shell strategy).
132-
*
133-
* @return ?string
134-
*/
13582
public function shellMcpCommand(): ?string
13683
{
13784
return null;
13885
}
13986

140-
/**
141-
* Get the path to an MCP configuration file (file strategy).
142-
*
143-
* @return ?string
144-
*/
14587
public function mcpConfigPath(): ?string
14688
{
14789
return null;
14890
}
14991

150-
/**
151-
* Get the JSON key for MCP servers in the config file (file strategy).
152-
*
153-
* @return string
154-
*/
92+
public function frontmatter(): bool
93+
{
94+
return false;
95+
}
96+
15597
public function mcpConfigKey(): string
15698
{
15799
return 'mcpServers';
@@ -173,7 +115,7 @@ public function installMcp(string $key, string $command, array $args = [], array
173115
return match($this->mcpInstallationStrategy()) {
174116
McpInstallationStrategy::Shell => $this->installShellMcp($key, $command, $args, $env),
175117
McpInstallationStrategy::File => $this->installFileMcp($key, $command, $args, $env),
176-
McpInstallationStrategy::None => false,
118+
McpInstallationStrategy::None => false
177119
};
178120
}
179121

src/Install/CodeEnvironment/Copilot.php

Lines changed: 2 additions & 7 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\CodingAgent;
7+
use Laravel\Boost\Contracts\Agent;
88
use Laravel\Boost\Install\Enums\Platform;
99

10-
class Copilot extends CodeEnvironment implements CodingAgent
10+
class Copilot extends CodeEnvironment implements Agent
1111
{
1212
public function name(): string
1313
{
@@ -48,9 +48,4 @@ public function guidelinesPath(): string
4848
{
4949
return '.github/copilot-instructions.md';
5050
}
51-
52-
public function frontmatter(): bool
53-
{
54-
return false;
55-
}
5651
}

src/Install/CodeEnvironment/Cursor.php

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

55
namespace Laravel\Boost\Install\CodeEnvironment;
66

7-
use Laravel\Boost\Contracts\CodingAgent;
7+
use Laravel\Boost\Contracts\Agent;
88
use Laravel\Boost\Contracts\McpClient;
9-
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
109
use Laravel\Boost\Install\Enums\Platform;
1110

12-
class Cursor extends CodeEnvironment implements CodingAgent, McpClient
11+
class Cursor extends CodeEnvironment implements Agent, McpClient
1312
{
1413
public function name(): string
1514
{
@@ -50,11 +49,6 @@ public function projectDetectionConfig(): array
5049
];
5150
}
5251

53-
public function mcpInstallationStrategy(): McpInstallationStrategy
54-
{
55-
return McpInstallationStrategy::File;
56-
}
57-
5852
public function mcpConfigPath(): string
5953
{
6054
return '.cursor/mcp.json';

src/Install/CodeEnvironment/PhpStorm.php

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

55
namespace Laravel\Boost\Install\CodeEnvironment;
66

7-
use Laravel\Boost\Contracts\CodingAgent;
7+
use Laravel\Boost\Contracts\Agent;
88
use Laravel\Boost\Contracts\McpClient;
9-
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
109
use Laravel\Boost\Install\Enums\Platform;
1110

12-
class PhpStorm extends CodeEnvironment implements CodingAgent, McpClient
11+
class PhpStorm extends CodeEnvironment implements Agent, McpClient
1312
{
1413
public function name(): string
1514
{
@@ -56,11 +55,6 @@ public function agentName(): string
5655
return 'junie';
5756
}
5857

59-
public function mcpInstallationStrategy(): McpInstallationStrategy
60-
{
61-
return McpInstallationStrategy::File;
62-
}
63-
6458
public function mcpConfigPath(): string
6559
{
6660
return '.junie/mcp/mcp.json';
@@ -70,9 +64,4 @@ public function guidelinesPath(): string
7064
{
7165
return '.junie/guidelines.md';
7266
}
73-
74-
public function frontmatter(): bool
75-
{
76-
return false;
77-
}
7867
}

src/Install/CodeEnvironment/VSCode.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Laravel\Boost\Install\CodeEnvironment;
66

77
use Laravel\Boost\Contracts\McpClient;
8-
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
98
use Laravel\Boost\Install\Enums\Platform;
109

1110
class VSCode extends CodeEnvironment implements McpClient
@@ -50,11 +49,6 @@ public function agentName(): ?string
5049
return null;
5150
}
5251

53-
public function mcpInstallationStrategy(): McpInstallationStrategy
54-
{
55-
return McpInstallationStrategy::File;
56-
}
57-
5852
public function mcpConfigPath(): string
5953
{
6054
return '.vscode/mcp.json';

src/Install/CodeEnvironment/Zed.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Laravel\Boost\Install\CodeEnvironment;
66

77
use Laravel\Boost\Contracts\McpClient;
8-
use Laravel\Boost\Install\Enums\McpInstallationStrategy;
98
use Laravel\Boost\Install\Enums\Platform;
109

1110
class Zed extends CodeEnvironment implements McpClient
@@ -54,11 +53,6 @@ public function agentName(): ?string
5453
return null;
5554
}
5655

57-
public function mcpInstallationStrategy(): McpInstallationStrategy
58-
{
59-
return McpInstallationStrategy::File;
60-
}
61-
6256
public function mcpConfigPath(): string
6357
{
6458
return '.zed/mcp.json';

0 commit comments

Comments
 (0)