Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected function selectBoostFeatures(): Collection
protected function selectAiGuidelines(): Collection
{
$options = app(GuidelineComposer::class)->guidelines()
->reject(fn (array $guideline) => $guideline['third_party'] === false);
->reject(fn (array $guideline): bool => $guideline['third_party'] === false);

if ($options->isEmpty()) {
return collect();
Expand All @@ -270,7 +270,7 @@ protected function selectAiGuidelines(): Collection
return collect(multiselect(
label: 'Which third-party AI guidelines do you want to install?',
// @phpstan-ignore-next-line
options: $options->mapWithKeys(function (array $guideline, string $name) {
options: $options->mapWithKeys(function (array $guideline, string $name): array {
$humanName = str_replace('/core', '', $name);

return [$name => "{$humanName} (~{$guideline['tokens']} tokens) {$guideline['description']}"];
Expand Down Expand Up @@ -447,11 +447,11 @@ protected function installGuidelines(): void
);

$this->config->setEditors(
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient) => $mcpClient->name())->values()->toArray()
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
);

$this->config->setAgents(
$this->selectedTargetAgents->map(fn (Agent $agent) => $agent->name())->values()->toArray()
$this->selectedTargetAgents->map(fn (Agent $agent): string => $agent->name())->values()->toArray()
);

$this->config->setGuidelines(
Expand Down
4 changes: 2 additions & 2 deletions src/Mcp/Tools/SearchDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function schema(JsonSchema $schema): array
->items($schema->string()->description("The composer package name (e.g., 'symfony/console')"))
->description('Package names to limit searching to from application-info. Useful if you know the package(s) you need. i.e. laravel/framework, inertiajs/inertia-laravel, @inertiajs/react'),
'token_limit' => $schema->integer()
->description('Maximum number of tokens to return in the response. Defaults to 10,000 tokens, maximum 1,000,000 tokens.'),
->description('Maximum number of tokens to return in the response. Defaults to 3,000 tokens, maximum 1,000,000 tokens. If results are truncated, or you need more complete documentation, increase this value (e.g.5000, 10000)'),
];
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public function handle(Request $request): Response|Generator
return Response::error('Failed to get packages: '.$throwable->getMessage());
}

$tokenLimit = $request->get('token_limit') ?? 10000;
$tokenLimit = $request->get('token_limit') ?? 3000;
$tokenLimit = min($tokenLimit, 1000000); // Cap at 1M tokens

$payload = [
Expand Down
10 changes: 5 additions & 5 deletions src/Support/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Composer
public static function packagesDirectories(): array
{
return collect(static::packages())
->mapWithKeys(fn (string $key, string $package) => [$package => implode(DIRECTORY_SEPARATOR, [
->mapWithKeys(fn (string $key, string $package): array => [$package => implode(DIRECTORY_SEPARATOR, [
base_path('vendor'),
str_replace('/', DIRECTORY_SEPARATOR, $package),
])])
->filter(fn (string $path) => is_dir($path))
->filter(fn (string $path): bool => is_dir($path))
->toArray();
}

Expand All @@ -33,19 +33,19 @@ public static function packages(): array

return collect($composerData['require'] ?? [])
->merge($composerData['require-dev'] ?? [])
->mapWithKeys(fn (string $key, string $package) => [$package => $key])
->mapWithKeys(fn (string $key, string $package): array => [$package => $key])
->toArray();
}

public static function packagesDirectoriesWithBoostGuidelines(): array
{
return collect(Composer::packagesDirectories())
->map(fn (string $path) => implode(DIRECTORY_SEPARATOR, [
->map(fn (string $path): string => implode(DIRECTORY_SEPARATOR, [
$path,
'resources',
'boost',
'guidelines',
]))->filter(fn (string $path) => is_dir($path))
]))->filter(fn (string $path): bool => is_dir($path))
->toArray();
}
}
6 changes: 3 additions & 3 deletions tests/Feature/Mcp/Tools/SearchDocsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
['name' => 'laravel/framework', 'version' => '11.x'],
['name' => 'pestphp/pest', 'version' => '2.x'],
] &&
$request->data()['token_limit'] === 10000 &&
$request->data()['token_limit'] === 3000 &&
$request->data()['format'] === 'markdown');
});

Expand Down Expand Up @@ -79,7 +79,7 @@
Http::assertSent(fn ($request): bool => $request->url() === 'https://boost.laravel.com/api/docs' &&
$request->data()['queries'] === ['test'] &&
empty($request->data()['packages']) &&
$request->data()['token_limit'] === 10000);
$request->data()['token_limit'] === 3000);
});

test('it formats package data correctly', function (): void {
Expand All @@ -104,7 +104,7 @@
Http::assertSent(fn ($request): bool => $request->data()['packages'] === [
['name' => 'laravel/framework', 'version' => '11.x'],
['name' => 'livewire/livewire', 'version' => '3.x'],
] && $request->data()['token_limit'] === 10000);
] && $request->data()['token_limit'] === 3000);
});

test('it handles empty results', function (): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Mcp/Tools/TinkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@

app()->detectEnvironment(fn (): string => 'local');

expect($tool->eligibleForRegistration(Mockery::mock(Request::class)))->toBeTrue();
expect($tool->eligibleForRegistration())->toBeTrue();
});
2 changes: 1 addition & 1 deletion tests/Unit/Support/ComposerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Laravel\Boost\Support\Config;

afterEach(function () {
afterEach(function (): void {
(new Config(__DIR__))->flush();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Support/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Laravel\Boost\Support\Config;

afterEach(function () {
afterEach(function (): void {
(new Config)->flush();
});

Expand Down