Skip to content

Commit 9a1b845

Browse files
authored
[1.x] Update token limit default to 3000 tokens in SearchDocs (#293)
* fix: update token limit default to 7000 in SearchDocs Signed-off-by: Pushpak Chhajed <[email protected]> * fix: update token limit default to 3000 in SearchDocs Signed-off-by: Pushpak Chhajed <[email protected]> --------- Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent fcf9549 commit 9a1b845

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

src/Console/InstallCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected function selectBoostFeatures(): Collection
261261
protected function selectAiGuidelines(): Collection
262262
{
263263
$options = app(GuidelineComposer::class)->guidelines()
264-
->reject(fn (array $guideline) => $guideline['third_party'] === false);
264+
->reject(fn (array $guideline): bool => $guideline['third_party'] === false);
265265

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

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

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

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

457457
$this->config->setGuidelines(

src/Mcp/Tools/SearchDocs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function schema(JsonSchema $schema): array
4141
->items($schema->string()->description("The composer package name (e.g., 'symfony/console')"))
4242
->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'),
4343
'token_limit' => $schema->integer()
44-
->description('Maximum number of tokens to return in the response. Defaults to 10,000 tokens, maximum 1,000,000 tokens.'),
44+
->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)'),
4545
];
4646
}
4747

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

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

8787
$payload = [

src/Support/Composer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class Composer
99
public static function packagesDirectories(): array
1010
{
1111
return collect(static::packages())
12-
->mapWithKeys(fn (string $key, string $package) => [$package => implode(DIRECTORY_SEPARATOR, [
12+
->mapWithKeys(fn (string $key, string $package): array => [$package => implode(DIRECTORY_SEPARATOR, [
1313
base_path('vendor'),
1414
str_replace('/', DIRECTORY_SEPARATOR, $package),
1515
])])
16-
->filter(fn (string $path) => is_dir($path))
16+
->filter(fn (string $path): bool => is_dir($path))
1717
->toArray();
1818
}
1919

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

3434
return collect($composerData['require'] ?? [])
3535
->merge($composerData['require-dev'] ?? [])
36-
->mapWithKeys(fn (string $key, string $package) => [$package => $key])
36+
->mapWithKeys(fn (string $key, string $package): array => [$package => $key])
3737
->toArray();
3838
}
3939

4040
public static function packagesDirectoriesWithBoostGuidelines(): array
4141
{
4242
return collect(Composer::packagesDirectories())
43-
->map(fn (string $path) => implode(DIRECTORY_SEPARATOR, [
43+
->map(fn (string $path): string => implode(DIRECTORY_SEPARATOR, [
4444
$path,
4545
'resources',
4646
'boost',
4747
'guidelines',
48-
]))->filter(fn (string $path) => is_dir($path))
48+
]))->filter(fn (string $path): bool => is_dir($path))
4949
->toArray();
5050
}
5151
}

tests/Feature/Mcp/Tools/SearchDocsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
['name' => 'laravel/framework', 'version' => '11.x'],
3737
['name' => 'pestphp/pest', 'version' => '2.x'],
3838
] &&
39-
$request->data()['token_limit'] === 10000 &&
39+
$request->data()['token_limit'] === 3000 &&
4040
$request->data()['format'] === 'markdown');
4141
});
4242

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

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

110110
test('it handles empty results', function (): void {

tests/Feature/Mcp/Tools/TinkerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@
136136

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

139-
expect($tool->eligibleForRegistration(Mockery::mock(Request::class)))->toBeTrue();
139+
expect($tool->eligibleForRegistration())->toBeTrue();
140140
});

tests/Unit/Support/ComposerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Laravel\Boost\Support\Config;
44

5-
afterEach(function () {
5+
afterEach(function (): void {
66
(new Config(__DIR__))->flush();
77
});
88

tests/Unit/Support/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Laravel\Boost\Support\Config;
44

5-
afterEach(function () {
5+
afterEach(function (): void {
66
(new Config)->flush();
77
});
88

0 commit comments

Comments
 (0)