Skip to content

Commit d50bd5f

Browse files
authored
Merge pull request #33 from laravel/ai-68-how-can-we-work-around-requiring-absolute-paths-needed-for
Use absolute path for PHPStorm and relative paths for others
2 parents 7b07d2f + 6b8088a commit d50bd5f

File tree

7 files changed

+20
-97
lines changed

7 files changed

+20
-97
lines changed

.ai/boost/core.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Pest, Nova, Nightwatch, etc.
2323
- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches.
2424
- Search the documentation before making code changes to ensure we are taking the correct approach.
25-
- Use multiple, broad, simple, topic based queries to start. For example: `rate limiting##routing rate limiting##routing`.
25+
- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
2626

2727
### Available Search Syntax
2828
- You can and should pass multiple queries at once. The most relevant results will be returned first.

src/Console/InstallCommand.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,12 @@ private function selectCodeEnvironments(string $contractClass, string $label): C
317317
return collect();
318318
}
319319

320-
$options = $availableEnvironments
321-
->filter(function (CodeEnvironment $environment) {
322-
// We only show Zed if it's actually installed
323-
if ($environment->name() === 'zed' && ! in_array('zed', $this->systemInstalledCodeEnvironments)) {
324-
return false;
325-
}
326-
327-
return true;
328-
})
329-
->mapWithKeys(function (CodeEnvironment $environment) use ($config) {
330-
$displayMethod = $config['displayMethod'];
331-
$displayText = $environment->{$displayMethod}();
320+
$options = $availableEnvironments->mapWithKeys(function (CodeEnvironment $environment) use ($config) {
321+
$displayMethod = $config['displayMethod'];
322+
$displayText = $environment->{$displayMethod}();
332323

333-
return [get_class($environment) => $displayText];
334-
})->sort();
324+
return [get_class($environment) => $displayText];
325+
})->sort();
335326

336327
$detectedClasses = [];
337328
$installedEnvNames = array_unique(array_merge(
@@ -341,7 +332,7 @@ private function selectCodeEnvironments(string $contractClass, string $label): C
341332

342333
foreach ($installedEnvNames as $envKey) {
343334
$matchingEnv = $availableEnvironments->first(fn (CodeEnvironment $env) => strtolower($envKey) === strtolower($env->name()));
344-
if ($matchingEnv && ($options->contains($matchingEnv->displayName() || $options->contains($matchingEnv->agentName())))) {
335+
if ($matchingEnv) {
345336
$detectedClasses[] = get_class($matchingEnv);
346337
}
347338
}
@@ -471,6 +462,7 @@ private function installMcpServerConfig(): void
471462
)->toArray()
472463
);
473464

465+
/** @var CodeEnvironment $mcpClient */
474466
foreach ($this->selectedTargetMcpClient as $mcpClient) {
475467
$ideName = $mcpClient->mcpClientName();
476468
$ideDisplay = str_pad($ideName, $longestIdeName);
@@ -479,7 +471,8 @@ private function installMcpServerConfig(): void
479471

480472
if ($this->shouldInstallMcp()) {
481473
try {
482-
$result = $mcpClient->installMcp('laravel-boost', 'php', ['./artisan', 'boost:mcp']);
474+
$artisan = $mcpClient->useAbsolutePathForMcp ? base_path('artisan') : './artisan';
475+
$result = $mcpClient->installMcp('laravel-boost', 'php', [$artisan, 'boost:mcp']);
483476

484477
if ($result) {
485478
$results[] = $this->greenTick.' Boost';

src/Install/CodeEnvironment/CodeEnvironment.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
abstract class CodeEnvironment
1717
{
18+
public bool $useAbsolutePathForMcp = false;
19+
1820
public function __construct(protected readonly DetectionStrategyFactory $strategyFactory)
1921
{
2022
}
@@ -36,7 +38,6 @@ public function mcpClientName(): ?string
3638
/**
3739
* Get the detection configuration for system-wide installation detection.
3840
*
39-
* @param Platform $platform
4041
* @return array{paths?: string[], command?: string, files?: string[]}
4142
*/
4243
abstract public function systemDetectionConfig(Platform $platform): array;
@@ -102,17 +103,14 @@ public function mcpConfigKey(): string
102103
/**
103104
* Install MCP server using the appropriate strategy.
104105
*
105-
* @param string $key
106-
* @param string $command
107106
* @param array<int, string> $args
108107
* @param array<string, string> $env
109-
* @return bool
110108
*
111109
* @throws FileNotFoundException
112110
*/
113111
public function installMcp(string $key, string $command, array $args = [], array $env = []): bool
114112
{
115-
return match($this->mcpInstallationStrategy()) {
113+
return match ($this->mcpInstallationStrategy()) {
116114
McpInstallationStrategy::SHELL => $this->installShellMcp($key, $command, $args, $env),
117115
McpInstallationStrategy::FILE => $this->installFileMcp($key, $command, $args, $env),
118116
McpInstallationStrategy::NONE => false
@@ -122,11 +120,8 @@ public function installMcp(string $key, string $command, array $args = [], array
122120
/**
123121
* Install MCP server using a shell command strategy.
124122
*
125-
* @param string $key
126-
* @param string $command
127123
* @param array<int, string> $args
128124
* @param array<string, string> $env
129-
* @return bool
130125
*/
131126
protected function installShellMcp(string $key, string $command, array $args = [], array $env = []): bool
132127
{
@@ -163,11 +158,8 @@ protected function installShellMcp(string $key, string $command, array $args = [
163158
/**
164159
* Install MCP server using a file-based configuration strategy.
165160
*
166-
* @param string $key
167-
* @param string $command
168161
* @param array<int, string> $args
169162
* @param array<string, string> $env
170-
* @return bool
171163
*
172164
* @throws FileNotFoundException
173165
*/

src/Install/CodeEnvironment/PhpStorm.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
class PhpStorm extends CodeEnvironment implements Agent, McpClient
1212
{
13+
public bool $useAbsolutePathForMcp = true;
14+
1315
public function name(): string
1416
{
1517
return 'phpstorm';

src/Install/CodeEnvironment/Zed.php

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

src/Install/CodeEnvironmentsDetector.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Laravel\Boost\Install\CodeEnvironment\Cursor;
1313
use Laravel\Boost\Install\CodeEnvironment\PhpStorm;
1414
use Laravel\Boost\Install\CodeEnvironment\VSCode;
15-
use Laravel\Boost\Install\CodeEnvironment\Zed;
1615
use Laravel\Boost\Install\Enums\Platform;
1716

1817
class CodeEnvironmentsDetector
@@ -23,7 +22,6 @@ class CodeEnvironmentsDetector
2322
'vscode' => VSCode::class,
2423
'cursor' => Cursor::class,
2524
'claudecode' => ClaudeCode::class,
26-
'zed' => Zed::class,
2725
'copilot' => Copilot::class,
2826
];
2927

tests/Unit/Install/CodeEnvironmentsDetectorTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Laravel\Boost\Install\Enums\Platform;
88

99
beforeEach(function () {
10-
$this->container = new \Illuminate\Container\Container();
10+
$this->container = new \Illuminate\Container\Container;
1111
$this->detector = new CodeEnvironmentsDetector($this->container);
1212
});
1313

@@ -35,12 +35,11 @@
3535
$otherProgram->shouldReceive('name')->andReturn('other');
3636

3737
// Bind mocked programs to container
38-
$container = new \Illuminate\Container\Container();
38+
$container = new \Illuminate\Container\Container;
3939
$container->bind(\Laravel\Boost\Install\CodeEnvironment\PhpStorm::class, fn () => $program1);
4040
$container->bind(\Laravel\Boost\Install\CodeEnvironment\VSCode::class, fn () => $program2);
4141
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Cursor::class, fn () => $program3);
4242
$container->bind(\Laravel\Boost\Install\CodeEnvironment\ClaudeCode::class, fn () => $otherProgram);
43-
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Zed::class, fn () => $otherProgram);
4443
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Copilot::class, fn () => $otherProgram);
4544

4645
$detector = new CodeEnvironmentsDetector($container);
@@ -60,12 +59,11 @@
6059
$otherProgram->shouldReceive('name')->andReturn('other');
6160

6261
// Bind mocked program to container
63-
$container = new \Illuminate\Container\Container();
62+
$container = new \Illuminate\Container\Container;
6463
$container->bind(\Laravel\Boost\Install\CodeEnvironment\PhpStorm::class, fn () => $program1);
6564
$container->bind(\Laravel\Boost\Install\CodeEnvironment\VSCode::class, fn () => $otherProgram);
6665
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Cursor::class, fn () => $otherProgram);
6766
$container->bind(\Laravel\Boost\Install\CodeEnvironment\ClaudeCode::class, fn () => $otherProgram);
68-
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Zed::class, fn () => $otherProgram);
6967
$container->bind(\Laravel\Boost\Install\CodeEnvironment\Copilot::class, fn () => $otherProgram);
7068

7169
$detector = new CodeEnvironmentsDetector($container);
@@ -90,7 +88,7 @@
9088
$program3->shouldReceive('name')->andReturn('claudecode');
9189

9290
// Bind mocked programs to container
93-
$container = new \Illuminate\Container\Container();
91+
$container = new \Illuminate\Container\Container;
9492
$container->bind(\Laravel\Boost\Install\CodeEnvironment\VSCode::class, fn () => $program1);
9593
$container->bind(\Laravel\Boost\Install\CodeEnvironment\PhpStorm::class, fn () => $program2);
9694
$container->bind(\Laravel\Boost\Install\CodeEnvironment\ClaudeCode::class, fn () => $program3);
@@ -109,7 +107,7 @@
109107
$program1->shouldReceive('name')->andReturn('vscode');
110108

111109
// Bind mocked program to container
112-
$container = new \Illuminate\Container\Container();
110+
$container = new \Illuminate\Container\Container;
113111
$container->bind(\Laravel\Boost\Install\CodeEnvironment\VSCode::class, fn () => $program1);
114112

115113
$detector = new CodeEnvironmentsDetector($container);

0 commit comments

Comments
 (0)