Skip to content

Commit d5f75cd

Browse files
committed
Merge remote-tracking branch 'origin/1.x' into 1.x
# Conflicts: # src/Console/InstallCommand.php # src/Install/Agents/VsCode.php # src/Install/GuidelineWriter.php
2 parents e7f5121 + 9fb4eee commit d5f75cd

File tree

4 files changed

+41
-43
lines changed

4 files changed

+41
-43
lines changed

src/Console/InstallCommand.php

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function handle(Roster $roster): void
5656
{
5757
$this->agentsToInstallTo = collect();
5858
$this->roster = $roster;
59-
$this->colors = new class {
59+
$this->colors = new class
60+
{
6061
use Colors;
6162
};
6263

@@ -105,7 +106,6 @@ protected function enact()
105106
dump($this->idesToInstallTo);
106107
}
107108

108-
109109
if (in_array('other', $this->idesToInstallTo)) {
110110
$this->newLine();
111111
$this->line('Add to your mcp file: ./artisan boost:mcp'); // some ides require absolute
@@ -150,13 +150,13 @@ protected function compose(): string
150150
$composed->put('tests', $this->guideline('enforce-tests.md'));
151151
}
152152

153-
return $composed->whereNotNull()->map(fn($content, $key) => "# {$key}\n{$content}\n")
153+
return $composed->whereNotNull()->map(fn ($content, $key) => "# {$key}\n{$content}\n")
154154
->join("\n\n====\n\n");
155155
}
156156

157157
protected function guidelines(string $dirPath, array $replacements = []): ?string
158158
{
159-
$dirPath = str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/../../.ai/' . $dirPath);
159+
$dirPath = str_replace('/', DIRECTORY_SEPARATOR, __DIR__.'/../../.ai/'.$dirPath);
160160
try {
161161
$finder = Finder::create()
162162
->files()
@@ -176,11 +176,11 @@ protected function guidelines(string $dirPath, array $replacements = []): ?strin
176176

177177
protected function guideline(string $path, array $replacements = []): ?string
178178
{
179-
if (!file_exists($path)) {
180-
$path = str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/../../.ai/' . $path);
179+
if (! file_exists($path)) {
180+
$path = str_replace('/', DIRECTORY_SEPARATOR, __DIR__.'/../../.ai/'.$path);
181181
}
182182

183-
if (!file_exists($path)) {
183+
if (! file_exists($path)) {
184184
return null;
185185
}
186186

@@ -258,7 +258,7 @@ protected function discoverTools(): array
258258
->name('*.php');
259259

260260
foreach ($finder as $toolFile) {
261-
$fqdn = 'Laravel\\Boost\\Mcp\\Tools\\' . $toolFile->getBasename('.php');
261+
$fqdn = 'Laravel\\Boost\\Mcp\\Tools\\'.$toolFile->getBasename('.php');
262262
if (class_exists($fqdn)) {
263263
$tools[$fqdn] = Str::headline($toolFile->getBasename('.php'));
264264
}
@@ -272,7 +272,7 @@ protected function discoverTools(): array
272272
public function getHomePath(): string
273273
{
274274
if (PHP_OS_FAMILY === 'Windows') {
275-
if (!isset($_SERVER['HOME'])) {
275+
if (! isset($_SERVER['HOME'])) {
276276
$_SERVER['HOME'] = $_SERVER['USERPROFILE'];
277277
}
278278

@@ -286,22 +286,22 @@ protected function isHerdInstalled(): bool
286286
{
287287
$isWindows = PHP_OS_FAMILY === 'Windows';
288288

289-
if (!$isWindows) {
289+
if (! $isWindows) {
290290
return file_exists('/Applications/Herd.app/Contents/MacOS/Herd');
291291
}
292292

293-
return is_dir($this->getHomePath() . '/.config/herd');
293+
return is_dir($this->getHomePath().'/.config/herd');
294294
}
295295

296296
protected function isHerdMCPAvailable(): bool
297297
{
298298
$isWindows = PHP_OS_FAMILY === 'Windows';
299299

300300
if ($isWindows) {
301-
return file_exists($this->getHomePath() . '/.config/herd/bin/herd-mcp.phar');
301+
return file_exists($this->getHomePath().'/.config/herd/bin/herd-mcp.phar');
302302
}
303303

304-
return file_exists($this->getHomePath() . '/Library/Application Support/Herd/bin/herd-mcp.phar');
304+
return file_exists($this->getHomePath().'/Library/Application Support/Herd/bin/herd-mcp.phar');
305305
}
306306

307307
/*
@@ -328,7 +328,7 @@ private function intro()
328328
HEADER
329329
);
330330
intro('✦ Laravel Boost :: Install :: We Must Ship ✦');
331-
$this->line(' Let\'s give ' . $this->colors->bgYellow($this->colors->black($this->projectName)) . ' a Boost');
331+
$this->line(' Let\'s give '.$this->colors->bgYellow($this->colors->black($this->projectName)) . ' a Boost');
332332
}
333333

334334
protected function projectPurpose(): string
@@ -349,17 +349,17 @@ protected function projectPurpose(): string
349349
protected function shouldEnforceTests(bool $ask = true): bool
350350
{
351351
$enforce = Finder::create()
352-
->in(base_path('tests'))
353-
->files()
354-
->name('*.php')
355-
->count() > 6;
352+
->in(base_path('tests'))
353+
->files()
354+
->name('*.php')
355+
->count() > 6;
356356

357357
if ($enforce === false && $ask === true) {
358358
$enforce = select(
359-
label: 'Should AI always create tests?',
360-
options: ['Yes', 'No'],
361-
default: 'Yes'
362-
) === 'Yes';
359+
label: 'Should AI always create tests?',
360+
options: ['Yes', 'No'],
361+
default: 'Yes'
362+
) === 'Yes';
363363
}
364364

365365
return $enforce;
@@ -377,7 +377,7 @@ protected function idesToInstallTo(): array
377377
];
378378

379379
// Tell API which ones?
380-
$autoDetectedIdesString = Arr::join(array_map(fn(string $ideKey) => $ideOptions[$ideKey] ?? '', $this->detectedProjectIdes), ', ', ' & ');
380+
$autoDetectedIdesString = Arr::join(array_map(fn (string $ideKey) => $ideOptions[$ideKey] ?? '', $this->detectedProjectIdes), ', ', ' & ');
381381

382382
return multiselect(
383383
label: sprintf('Which IDEs do you use in %s? (space to select)', $this->projectName),
@@ -433,7 +433,7 @@ protected function detectProjectAgents(): array
433433
protected function agentsToInstallTo(): Collection
434434
{
435435
$agents = [];
436-
if (!$this->installingGuidelines()) {
436+
if (! $this->installingGuidelines()) {
437437
return collect();
438438
}
439439

@@ -445,7 +445,7 @@ protected function agentsToInstallTo(): Collection
445445
->name('*.php');
446446

447447
foreach ($finder as $agentFile) {
448-
$className = 'Laravel\\Boost\\Install\\Agents\\' . $agentFile->getBasename('.php');
448+
$className = 'Laravel\\Boost\\Install\\Agents\\'.$agentFile->getBasename('.php');
449449

450450
if (class_exists($className)) {
451451
$reflection = new \ReflectionClass($className);
@@ -461,21 +461,22 @@ protected function agentsToInstallTo(): Collection
461461
$selectedAgentClasses = collect(multiselect(
462462
label: sprintf('Which agents need AI guidelines for %s?', $this->projectName),
463463
options: $agents,
464-
default: ['Laravel\\Boost\\Install\\Agents\\ClaudeCode'],//array_keys($agents),
464+
default: ['Laravel\\Boost\\Install\\Agents\\ClaudeCode'],// array_keys($agents),
465465
scroll: 4, // TODO: use detection to auto-select
466466
));
467467

468-
return $selectedAgentClasses->map(fn($agentClass) => new $agentClass());
468+
return $selectedAgentClasses->map(fn ($agentClass) => new $agentClass);
469469
}
470470

471471
protected function enactGuidelines(string $composedAiGuidelines): void
472472
{
473-
if (!$this->installingGuidelines()) {
473+
if (! $this->installingGuidelines()) {
474474
return;
475475
}
476476

477477
if ($this->agentsToInstallTo->isEmpty()) {
478478
$this->info('No agents selected for guideline installation.');
479+
479480
return;
480481
}
481482

src/Install/Agents/Cursor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Laravel\Boost\Install\Agents;
44

55
use Laravel\Boost\Contracts\Agent;
6-
use Laravel\Boost\Contracts\Ide;
76

87
class Cursor extends FileMcpIde implements Agent
98
{

src/Install/GuidelineWriter.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ class GuidelineWriter
1111
public const FAILED = 2;
1212
public const NOOP = 3;
1313

14-
public function __construct(protected Agent $agent)
15-
{
16-
}
14+
public function __construct(protected Agent $agent) {}
1715

1816
/**
1917
* @param string $guidelines
@@ -28,14 +26,14 @@ public function write(string $guidelines): int
2826
$filePath = $this->agent->guidelinesPath();
2927

3028
$directory = dirname($filePath);
31-
if (!is_dir($directory)) {
32-
if (!mkdir($directory, 0755, true)) {
29+
if (! is_dir($directory)) {
30+
if (! mkdir($directory, 0755, true)) {
3331
throw new \RuntimeException("Failed to create directory: {$directory}");
3432
}
3533
}
3634

3735
$handle = fopen($filePath, 'c+');
38-
if (!$handle) {
36+
if (! $handle) {
3937
throw new \RuntimeException("Failed to open file: {$filePath}");
4038
}
4139

@@ -49,7 +47,7 @@ public function write(string $guidelines): int
4947

5048
// Check if guidelines already exist
5149
$pattern = '/<laravel-boost-guidelines>.*?<\/laravel-boost-guidelines>/s';
52-
$replacement = "<laravel-boost-guidelines>\n" . $guidelines . "\n</laravel-boost-guidelines>";
50+
$replacement = "<laravel-boost-guidelines>\n".$guidelines."\n</laravel-boost-guidelines>";
5351
$replaced = false;
5452

5553
if (preg_match($pattern, $content)) {
@@ -61,11 +59,11 @@ public function write(string $guidelines): int
6159
} else {
6260
// No existing guidelines found, append to end
6361
$frontMatter = '';
64-
if ($this->agent->frontmatter() && !str_contains($content, "\n---\n")) {
62+
if ($this->agent->frontmatter() && ! str_contains($content, "\n---\n")) {
6563
$frontMatter = "---\nalwaysApply: true\n---\n";
6664
}
6765

68-
$newContent = $frontMatter . rtrim($content) . "\n\n\n" . $replacement;
66+
$newContent = $frontMatter.rtrim($content)."\n\n\n".$replacement;
6967
}
7068

7169
if (ftruncate($handle, 0) === false || fseek($handle, 0) === -1) {
@@ -101,7 +99,7 @@ private function acquireLockWithRetry(mixed $handle, string $filePath, int $maxR
10199
}
102100

103101
// Exponential backoff with jitter
104-
$jitter = rand(0, (int)($delay * 0.1));
102+
$jitter = rand(0, (int) ($delay * 0.1));
105103
usleep($delay + $jitter);
106104
$delay *= 2;
107105
}

tests/Unit/Install/GuidelineWriterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
});
1717

1818
test('it creates directory when it does not exist', function () {
19-
$tempDir = sys_get_temp_dir() . '/boost_test_' . uniqid();
20-
$filePath = $tempDir . '/subdir/test.md';
19+
$tempDir = sys_get_temp_dir().'/boost_test_'.uniqid();
20+
$filePath = $tempDir.'/subdir/test.md';
2121

2222
$agent = Mockery::mock(Agent::class);
2323
$agent->shouldReceive('guidelinesPath')->andReturn($filePath);
@@ -45,7 +45,7 @@
4545

4646
$writer = new GuidelineWriter($agent);
4747

48-
expect(fn() => $writer->write('test guidelines'))
48+
expect(fn () => $writer->write('test guidelines'))
4949
->toThrow(RuntimeException::class, 'Failed to create directory: /root/boost_test');
5050
});
5151

@@ -148,7 +148,7 @@
148148

149149
$writer = new GuidelineWriter($agent);
150150

151-
expect(fn() => $writer->write('test guidelines'))
151+
expect(fn () => $writer->write('test guidelines'))
152152
->toThrow(RuntimeException::class, "Failed to open file: {$dirPath}");
153153
});
154154

0 commit comments

Comments
 (0)