From 784bef0e5f57aeb54578e4e87b81d2e5e8aeb398 Mon Sep 17 00:00:00 2001 From: Pushpak Chhajed Date: Fri, 10 Oct 2025 12:30:37 +0530 Subject: [PATCH 1/2] fix: update token limit default to 7000 in SearchDocs Signed-off-by: Pushpak Chhajed --- src/Console/InstallCommand.php | 8 ++++---- src/Mcp/Tools/SearchDocs.php | 4 ++-- src/Support/Composer.php | 10 +++++----- tests/Feature/Mcp/Tools/SearchDocsTest.php | 6 +++--- tests/Feature/Mcp/Tools/TinkerTest.php | 2 +- tests/Unit/Support/ComposerTest.php | 2 +- tests/Unit/Support/ConfigTest.php | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 212ec264..4a08227a 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -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(); @@ -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']}"]; @@ -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( diff --git a/src/Mcp/Tools/SearchDocs.php b/src/Mcp/Tools/SearchDocs.php index 682a47de..64607832 100644 --- a/src/Mcp/Tools/SearchDocs.php +++ b/src/Mcp/Tools/SearchDocs.php @@ -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 7,000 tokens, maximum 1,000,000 tokens.'), ]; } @@ -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') ?? 7000; $tokenLimit = min($tokenLimit, 1000000); // Cap at 1M tokens $payload = [ diff --git a/src/Support/Composer.php b/src/Support/Composer.php index 25994027..57dcafd4 100644 --- a/src/Support/Composer.php +++ b/src/Support/Composer.php @@ -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(); } @@ -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(); } } diff --git a/tests/Feature/Mcp/Tools/SearchDocsTest.php b/tests/Feature/Mcp/Tools/SearchDocsTest.php index 746489d9..f062395b 100644 --- a/tests/Feature/Mcp/Tools/SearchDocsTest.php +++ b/tests/Feature/Mcp/Tools/SearchDocsTest.php @@ -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'] === 7000 && $request->data()['format'] === 'markdown'); }); @@ -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'] === 7000); }); test('it formats package data correctly', function (): void { @@ -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'] === 7000); }); test('it handles empty results', function (): void { diff --git a/tests/Feature/Mcp/Tools/TinkerTest.php b/tests/Feature/Mcp/Tools/TinkerTest.php index c6419a66..ec8bb314 100644 --- a/tests/Feature/Mcp/Tools/TinkerTest.php +++ b/tests/Feature/Mcp/Tools/TinkerTest.php @@ -136,5 +136,5 @@ app()->detectEnvironment(fn (): string => 'local'); - expect($tool->eligibleForRegistration(Mockery::mock(Request::class)))->toBeTrue(); + expect($tool->eligibleForRegistration())->toBeTrue(); }); diff --git a/tests/Unit/Support/ComposerTest.php b/tests/Unit/Support/ComposerTest.php index 04def20b..ead59d86 100644 --- a/tests/Unit/Support/ComposerTest.php +++ b/tests/Unit/Support/ComposerTest.php @@ -2,7 +2,7 @@ use Laravel\Boost\Support\Config; -afterEach(function () { +afterEach(function (): void { (new Config(__DIR__))->flush(); }); diff --git a/tests/Unit/Support/ConfigTest.php b/tests/Unit/Support/ConfigTest.php index 4c979077..69f86fac 100644 --- a/tests/Unit/Support/ConfigTest.php +++ b/tests/Unit/Support/ConfigTest.php @@ -2,7 +2,7 @@ use Laravel\Boost\Support\Config; -afterEach(function () { +afterEach(function (): void { (new Config)->flush(); }); From cb6cfd1c8d331cb445858b6451197d31e0e94956 Mon Sep 17 00:00:00 2001 From: Pushpak Chhajed Date: Fri, 10 Oct 2025 15:33:53 +0530 Subject: [PATCH 2/2] fix: update token limit default to 3000 in SearchDocs Signed-off-by: Pushpak Chhajed --- src/Mcp/Tools/SearchDocs.php | 4 ++-- tests/Feature/Mcp/Tools/SearchDocsTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mcp/Tools/SearchDocs.php b/src/Mcp/Tools/SearchDocs.php index 64607832..510dc8e5 100644 --- a/src/Mcp/Tools/SearchDocs.php +++ b/src/Mcp/Tools/SearchDocs.php @@ -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 7,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)'), ]; } @@ -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') ?? 7000; + $tokenLimit = $request->get('token_limit') ?? 3000; $tokenLimit = min($tokenLimit, 1000000); // Cap at 1M tokens $payload = [ diff --git a/tests/Feature/Mcp/Tools/SearchDocsTest.php b/tests/Feature/Mcp/Tools/SearchDocsTest.php index f062395b..6c76cb28 100644 --- a/tests/Feature/Mcp/Tools/SearchDocsTest.php +++ b/tests/Feature/Mcp/Tools/SearchDocsTest.php @@ -36,7 +36,7 @@ ['name' => 'laravel/framework', 'version' => '11.x'], ['name' => 'pestphp/pest', 'version' => '2.x'], ] && - $request->data()['token_limit'] === 7000 && + $request->data()['token_limit'] === 3000 && $request->data()['format'] === 'markdown'); }); @@ -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'] === 7000); + $request->data()['token_limit'] === 3000); }); test('it formats package data correctly', function (): void { @@ -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'] === 7000); + ] && $request->data()['token_limit'] === 3000); }); test('it handles empty results', function (): void {