77use Illuminate \Contracts \Filesystem \FileNotFoundException ;
88use Illuminate \Support \Facades \File ;
99use Illuminate \Support \Facades \Process ;
10- use Laravel \Boost \Contracts \CodingAgent ;
10+ use Laravel \Boost \Contracts \Agent ;
1111use Laravel \Boost \Contracts \McpClient ;
1212use Laravel \Boost \Install \Detection \DetectionStrategyFactory ;
1313use Laravel \Boost \Install \Enums \McpInstallationStrategy ;
1414use Laravel \Boost \Install \Enums \Platform ;
1515
1616abstract 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
0 commit comments