Skip to content

Commit 9fb4eee

Browse files
ashleyhindlegithub-actions[bot]
authored andcommitted
Fix code styling
1 parent b549392 commit 9fb4eee

File tree

5 files changed

+51
-52
lines changed

5 files changed

+51
-52
lines changed

src/Console/InstallCommand.php

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

@@ -95,7 +96,7 @@ protected function enact()
9596
if ($this->installingGuidelines()) {
9697
$this->enactGuidelines($composedAiGuidelines);
9798
}
98-
// $this->enactMcp();
99+
// $this->enactMcp();
99100

100101
if (in_array('other', $this->idesToInstallTo)) {
101102
$this->newLine();
@@ -126,13 +127,14 @@ protected function compose(): string
126127
if ($this->shouldEnforceTests()) {
127128
$composed->put('tests', $this->guideline('enforce-tests.md'));
128129
}
129-
return $composed->map(fn($content, $key) => "# {$key}\n{$content}\n")
130+
131+
return $composed->map(fn ($content, $key) => "# {$key}\n{$content}\n")
130132
->join("\n\n====\n\n");
131133
}
132134

133135
protected function guidelines(string $dirPath, array $replacements = []): string
134136
{
135-
$dirPath = str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/../../.ai/' . $dirPath);
137+
$dirPath = str_replace('/', DIRECTORY_SEPARATOR, __DIR__.'/../../.ai/'.$dirPath);
136138
$finder = Finder::create()
137139
->files()
138140
->in($dirPath)
@@ -148,11 +150,11 @@ protected function guidelines(string $dirPath, array $replacements = []): string
148150

149151
protected function guideline(string $path, array $replacements = []): string
150152
{
151-
if (!file_exists($path)) {
152-
$path = str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/../../.ai/' . $path);
153+
if (! file_exists($path)) {
154+
$path = str_replace('/', DIRECTORY_SEPARATOR, __DIR__.'/../../.ai/'.$path);
153155
}
154156

155-
if (!file_exists($path)) {
157+
if (! file_exists($path)) {
156158
throw new \Exception("$path does not exist");
157159
}
158160

@@ -230,7 +232,7 @@ protected function discoverTools(): array
230232
->name('*.php');
231233

232234
foreach ($finder as $toolFile) {
233-
$fqdn = 'Laravel\\Boost\\Mcp\\Tools\\' . $toolFile->getBasename('.php');
235+
$fqdn = 'Laravel\\Boost\\Mcp\\Tools\\'.$toolFile->getBasename('.php');
234236
if (class_exists($fqdn)) {
235237
$tools[$fqdn] = Str::headline($toolFile->getBasename('.php'));
236238
}
@@ -244,7 +246,7 @@ protected function discoverTools(): array
244246
public function getHomePath(): string
245247
{
246248
if (PHP_OS_FAMILY === 'Windows') {
247-
if (!isset($_SERVER['HOME'])) {
249+
if (! isset($_SERVER['HOME'])) {
248250
$_SERVER['HOME'] = $_SERVER['USERPROFILE'];
249251
}
250252

@@ -258,22 +260,22 @@ protected function isHerdInstalled(): bool
258260
{
259261
$isWindows = PHP_OS_FAMILY === 'Windows';
260262

261-
if (!$isWindows) {
263+
if (! $isWindows) {
262264
return file_exists('/Applications/Herd.app/Contents/MacOS/Herd');
263265
}
264266

265-
return is_dir($this->getHomePath() . '/.config/herd');
267+
return is_dir($this->getHomePath().'/.config/herd');
266268
}
267269

268270
protected function isHerdMCPAvailable(): bool
269271
{
270272
$isWindows = PHP_OS_FAMILY === 'Windows';
271273

272274
if ($isWindows) {
273-
return file_exists($this->getHomePath() . '/.config/herd/bin/herd-mcp.phar');
275+
return file_exists($this->getHomePath().'/.config/herd/bin/herd-mcp.phar');
274276
}
275277

276-
return file_exists($this->getHomePath() . '/Library/Application Support/Herd/bin/herd-mcp.phar');
278+
return file_exists($this->getHomePath().'/Library/Application Support/Herd/bin/herd-mcp.phar');
277279
}
278280

279281
/*
@@ -300,7 +302,7 @@ private function intro()
300302
HEADER
301303
);
302304
intro('✦ Laravel Boost :: Install :: We Must Ship ✦');
303-
$this->line(' Let\'s setup Laravel Boost in your IDEs for ' . $this->colors->bgYellow($this->colors->black($this->projectName)));
305+
$this->line(' Let\'s setup Laravel Boost in your IDEs for '.$this->colors->bgYellow($this->colors->black($this->projectName)));
304306
}
305307

306308
protected function projectPurpose(): string
@@ -321,17 +323,17 @@ protected function projectPurpose(): string
321323
protected function shouldEnforceTests(bool $ask = true): bool
322324
{
323325
$enforce = Finder::create()
324-
->in(base_path('tests'))
325-
->files()
326-
->name('*.php')
327-
->count() > 6;
326+
->in(base_path('tests'))
327+
->files()
328+
->name('*.php')
329+
->count() > 6;
328330

329331
if ($enforce === false && $ask === true) {
330332
$enforce = select(
331-
label: 'Should AI always create tests?',
332-
options: ['Yes', 'No'],
333-
default: 'Yes'
334-
) === 'Yes';
333+
label: 'Should AI always create tests?',
334+
options: ['Yes', 'No'],
335+
default: 'Yes'
336+
) === 'Yes';
335337
}
336338

337339
return $enforce;
@@ -349,7 +351,7 @@ protected function idesToInstallTo(): array
349351
];
350352

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

354356
return multiselect(
355357
label: sprintf('Which IDEs do you use in %s? (space to select)', $this->projectName),
@@ -405,7 +407,7 @@ protected function detectProjectAgents(): array
405407
protected function agentsToInstallTo(): Collection
406408
{
407409
$agents = [];
408-
if (!$this->installingGuidelines()) {
410+
if (! $this->installingGuidelines()) {
409411
return collect();
410412
}
411413

@@ -417,7 +419,7 @@ protected function agentsToInstallTo(): Collection
417419
->name('*.php');
418420

419421
foreach ($finder as $agentFile) {
420-
$className = 'Laravel\\Boost\\Install\\Agents\\' . $agentFile->getBasename('.php');
422+
$className = 'Laravel\\Boost\\Install\\Agents\\'.$agentFile->getBasename('.php');
421423

422424
if (class_exists($className)) {
423425
$reflection = new \ReflectionClass($className);
@@ -433,21 +435,22 @@ protected function agentsToInstallTo(): Collection
433435
$selectedAgentClasses = collect(multiselect(
434436
label: 'Which agents need AI guidelines?',
435437
options: $agents,
436-
default: ['Laravel\\Boost\\Install\\Agents\\ClaudeCode'],//array_keys($agents),
438+
default: ['Laravel\\Boost\\Install\\Agents\\ClaudeCode'],// array_keys($agents),
437439
scroll: 4, // TODO: use detection to auto-select
438440
));
439441

440-
return $selectedAgentClasses->map(fn($agentClass) => new $agentClass());
442+
return $selectedAgentClasses->map(fn ($agentClass) => new $agentClass);
441443
}
442444

443445
protected function enactGuidelines(string $composedAiGuidelines): void
444446
{
445-
if (!$this->installingGuidelines()) {
447+
if (! $this->installingGuidelines()) {
446448
return;
447449
}
448450

449451
if ($this->agentsToInstallTo->isEmpty()) {
450452
$this->info('No agents selected for guideline installation.');
453+
451454
return;
452455
}
453456

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 implements Agent
98
{

src/Install/Agents/VsCode.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class VsCode implements Ide
88
{
9-
109
public function installMcp(string $command, array $args): bool
1110
{
1211
return true;

src/Install/GuidelineWriter.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
class GuidelineWriter
88
{
9-
public function __construct(protected Agent $agent)
10-
{
11-
}
9+
public function __construct(protected Agent $agent) {}
1210

1311
public function write(string $guidelines): void
1412
{
@@ -19,14 +17,14 @@ public function write(string $guidelines): void
1917
$filePath = $this->agent->path();
2018

2119
$directory = dirname($filePath);
22-
if (!is_dir($directory)) {
23-
if (!mkdir($directory, 0755, true)) {
20+
if (! is_dir($directory)) {
21+
if (! mkdir($directory, 0755, true)) {
2422
throw new \RuntimeException("Failed to create directory: {$directory}");
2523
}
2624
}
2725

2826
$handle = fopen($filePath, 'c+');
29-
if (!$handle) {
27+
if (! $handle) {
3028
throw new \RuntimeException("Failed to open file: {$filePath}");
3129
}
3230

@@ -40,7 +38,7 @@ public function write(string $guidelines): void
4038

4139
// Check if guidelines already exist
4240
$pattern = '/<laravel-boost-guidelines>.*?<\/laravel-boost-guidelines>/s';
43-
$replacement = "<laravel-boost-guidelines>\n" . $guidelines . "\n</laravel-boost-guidelines>";
41+
$replacement = "<laravel-boost-guidelines>\n".$guidelines."\n</laravel-boost-guidelines>";
4442

4543
if (preg_match($pattern, $content)) {
4644
// Replace ALL existing boost guidelines blocks in-place
@@ -50,11 +48,11 @@ public function write(string $guidelines): void
5048
} else {
5149
// No existing guidelines found, append to end
5250
$frontMatter = '';
53-
if ($this->agent->frontmatter() && !str_contains($content, "\n---\n")) {
51+
if ($this->agent->frontmatter() && ! str_contains($content, "\n---\n")) {
5452
$frontMatter = "---\nalwaysApply: true\n---\n";
5553
}
5654

57-
$newContent = $frontMatter . rtrim($content) . "\n\n\n" . $replacement;
55+
$newContent = $frontMatter.rtrim($content)."\n\n\n".$replacement;
5856
}
5957

6058
if (ftruncate($handle, 0) === false || fseek($handle, 0) === -1) {
@@ -88,7 +86,7 @@ private function acquireLockWithRetry(mixed $handle, string $filePath, int $maxR
8886
}
8987

9088
// Exponential backoff with jitter
91-
$jitter = rand(0, (int)($delay * 0.1));
89+
$jitter = rand(0, (int) ($delay * 0.1));
9290
usleep($delay + $jitter);
9391
$delay *= 2;
9492
}

tests/Unit/Install/GuidelineWriterTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
$agent->shouldReceive('path')->andReturn('/tmp/test.md');
1111

1212
$writer = new GuidelineWriter($agent);
13-
13+
1414
// Should not throw any exception
1515
$writer->write('');
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('path')->andReturn($filePath);
@@ -28,7 +28,7 @@
2828

2929
expect(is_dir(dirname($filePath)))->toBeTrue();
3030
expect(file_exists($filePath))->toBeTrue();
31-
31+
3232
// Cleanup
3333
unlink($filePath);
3434
rmdir(dirname($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

@@ -235,17 +235,17 @@
235235
$writer->write('updated guidelines from boost');
236236

237237
$content = file_get_contents($tempFile);
238-
238+
239239
// Verify guidelines were replaced in-place
240240
expect($content)->toContain('<laravel-boost-guidelines>');
241241
expect($content)->toContain('updated guidelines from boost');
242-
242+
243243
// Verify user content after guidelines is preserved
244244
expect($content)->toContain('# User Added Section');
245245
expect($content)->toContain('This content was added by the user after the guidelines.');
246246
expect($content)->toContain('## Another user section');
247247
expect($content)->toContain('More content here.');
248-
248+
249249
// Verify exact structure
250250
expect($content)->toBe("# My Project\n\n<laravel-boost-guidelines>\nupdated guidelines from boost\n</laravel-boost-guidelines>\n\n# User Added Section\nThis content was added by the user after the guidelines.\n\n## Another user section\nMore content here.");
251251

@@ -254,7 +254,7 @@
254254

255255
test('it retries file locking on contention', function () {
256256
$tempFile = tempnam(sys_get_temp_dir(), 'boost_test_');
257-
257+
258258
// Create a process that holds the lock
259259
$lockingProcess = proc_open("php -r \"
260260
\$handle = fopen('$tempFile', 'c+');
@@ -271,7 +271,7 @@
271271
$agent->shouldReceive('frontmatter')->andReturn(false);
272272

273273
$writer = new GuidelineWriter($agent);
274-
274+
275275
// This should succeed after the lock is released
276276
$writer->write('test guidelines');
277277

@@ -332,4 +332,4 @@
332332
expect($content)->toBe("# Existing content\n\nSome text here.\n\n\n<laravel-boost-guidelines>\nnew guidelines\n</laravel-boost-guidelines>");
333333

334334
unlink($tempFile);
335-
});
335+
});

0 commit comments

Comments
 (0)