Skip to content

Commit a73a999

Browse files
committed
wip mess, scared of losing code though - apologies git overlords
Make Hugo unhappy Part way through install, post refactor to processes
1 parent d36d4d8 commit a73a999

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1328
-80
lines changed

.ai/boost/core.md

Whitespace-only changes.

.ai/inertiajs-laravel/core.md

Whitespace-only changes.

.ai/laravel/core.md

Whitespace-only changes.

.ai/laravel/style.md

Whitespace-only changes.

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
<a href="https://packagist.org/packages/laravel/boost"><img src="https://img.shields.io/packagist/l/boost" alt="License"></a>
88
</p>
99

10-
> This is a template repository for new Laravel AI Assistants. [Start a new repo with this](https://github.com/laravel/boost/generate), clone it locally and search & replace the relevant things below:
10+
> This is a template repository for new Laravel AI
11+
> Assistants. [Start a new repo with this](https://github.com/laravel/boost/generate), clone it locally and search &
12+
> replace the relevant things below:
1113
>
1214
> - `Laravel AI Assistant` with the package name (e.g. `Laravel Horizon`)
1315
> - `boost` references to the vendor name / GitHub url (e.g. `laravel/horizon`) (*)
@@ -17,7 +19,7 @@
1719
> - `BOOST_` references to the env variable names (e.g. `HORIZON`) (*)
1820
>
1921
> (*) Name cannot contain spaces.
20-
>
22+
>
2123
> After replacing keywords, take the following steps:
2224
>
2325
> 1. Rename any `Boost` prefixes in `.php` file names in [`src`](./src) to the package name (e.g. `Horizon`)
@@ -35,22 +37,26 @@
3537
## Introduction
3638

3739
Package introduction...
40+
./artisan vendor:publish --tag=boost-config
3841

3942
## Official Documentation
4043

4144
Documentation for Boost can be found on the [Laravel website](https://laravel.com/docs).
4245

4346
## Contributing
4447

45-
Thank you for considering contributing to Boost! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
48+
Thank you for considering contributing to Boost! The contribution guide can be found in
49+
the [Laravel documentation](https://laravel.com/docs/contributions).
4650

4751
## Code of Conduct
4852

49-
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
53+
In order to ensure that the Laravel community is welcoming to all, please review and abide by
54+
the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
5055

5156
## Security Vulnerabilities
5257

53-
Please review [our security policy](https://github.com/laravel/envoy/security/policy) on how to report security vulnerabilities.
58+
Please review [our security policy](https://github.com/laravel/envoy/security/policy) on how to report security
59+
vulnerabilities.
5460

5561
## License
5662

config/boost.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
return [
46
'hosted' => [
7+
'api_url' => env('BOOST_HOSTED_API_URL', 'https://boost.laravel.com'),
58
'token' => env('BOOST_HOSTED_TOKEN'),
69
],
10+
'chat' => [
11+
'openai_api_key' => env('BOOST_OPENAI_API_KEY', env('OPENAI_API_KEY')),
12+
],
13+
'process_isolation' => [
14+
'enabled' => env('BOOST_PROCESS_ISOLATION', true), // Enable by default for development
15+
'timeout' => env('BOOST_PROCESS_TIMEOUT', 180), // 3 minutes
16+
'max_concurrent' => env('BOOST_PROCESS_MAX_CONCURRENT', 5),
17+
],
718
'mcp' => [
819
'tools' => [
920
'exclude' => [ // Exclude built-in tools
10-
\Laravel\Boost\Mcp\Tools\LastError::class,
21+
// \Laravel\Boost\Mcp\Tools\LastError::class,
1122
],
1223
'include' => [ // Include your own tools
13-
\Laravel\Boost\Mcp\Tools\LastError::class,
24+
// \Laravel\Boost\Mcp\Tools\LastError::class,
1425
],
1526
],
1627
'resources' => [

resources/mcp_resources/laravel-best-practices.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/BoostServiceProvider.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Laravel\Boost;
46

7+
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Log;
9+
use Illuminate\Support\Facades\Response;
10+
use Illuminate\Support\Facades\Route;
511
use Illuminate\Support\ServiceProvider;
612
use Laravel\Boost\Mcp\Boost;
713
use Laravel\Mcp\Server\Facades\Mcp;
@@ -42,11 +48,17 @@ public function register(): void
4248

4349
public function boot(): void
4450
{
51+
if (! app()->environment('local', 'testing')) {
52+
return;
53+
}
54+
4555
/* @phpstan-ignore-next-line */
4656
Mcp::local('laravel-boost', Boost::class);
4757

4858
$this->registerPublishing();
4959
$this->registerCommands();
60+
$this->registerRoutes();
61+
// $this->hookIntoResponses(); // TODO: Only if not disabled in config
5062
}
5163

5264
protected function registerPublishing(): void
@@ -64,7 +76,95 @@ protected function registerCommands(): void
6476
$this->commands([
6577
Console\StartCommand::class,
6678
Console\InstallCommand::class,
79+
Console\ExecuteToolCommand::class,
80+
Console\ChatCommand::class,
6781
]);
6882
}
6983
}
84+
85+
private function registerRoutes()
86+
{
87+
Route::post('/_boost/browser-logs', function (Request $request) {
88+
Log::write($request->input('type'), $request->input('message'));
89+
90+
return response()->json(['status' => 'logged']);
91+
})->name('boost.browser-logs');
92+
}
93+
94+
private function hookIntoResponses()
95+
{
96+
Response::macro('injectBoostBrowserLogger', function () {
97+
$content = $this->getContent();
98+
99+
if ($this->shouldInject($content)) {
100+
$injectedContent = $this->injectScript($content);
101+
$this->setContent($injectedContent);
102+
}
103+
104+
return $this;
105+
});
106+
107+
// Register response middleware
108+
109+
app('router')->pushMiddlewareToGroup('web', function ($request, $next) {
110+
$response = $next($request);
111+
112+
if (method_exists($response, 'injectBoostBrowserLogger')) {
113+
$response->injectBoostBrowserLogger();
114+
}
115+
116+
return $response;
117+
});
118+
}
119+
120+
private function shouldInject(string $content): bool
121+
{
122+
// Check if it's HTML
123+
if (! str_contains($content, '<html') && ! str_contains($content, '<head')) {
124+
return false;
125+
}
126+
127+
// Check if already injected
128+
if (str_contains($content, 'browser-logger-active')) {
129+
return false;
130+
}
131+
132+
return true;
133+
}
134+
135+
private function injectScript(string $content): string
136+
{
137+
$script = $this->getBrowserLoggerScript();
138+
139+
// Try to inject before closing </head>
140+
if (str_contains($content, '</head>')) {
141+
return str_replace('</head>', $script."\n</head>", $content);
142+
}
143+
144+
// Fallback: inject before closing </body>
145+
if (str_contains($content, '</body>')) {
146+
return str_replace('</body>', $script."\n</body>", $content);
147+
}
148+
149+
return $content.$script;
150+
}
151+
152+
private function getBrowserLoggerScript(): string
153+
{
154+
$endpoint = route('boost.browser-logs');
155+
$csrfToken = csrf_token();
156+
157+
return <<<HTML
158+
<script id="browser-logger-active">
159+
(function() {
160+
const ENDPOINT = '{$endpoint}';
161+
const CSRF_TOKEN = '{$csrfToken}';
162+
163+
// [Same script content as before]
164+
165+
console.log('🔍 Browser logger active (MCP server detected)');
166+
})();
167+
</script>
168+
HTML;
169+
}
70170
}

src/Concerns/ReadsLogs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Laravel\Boost\Concerns;
46

57
use Illuminate\Support\Facades\Config;

src/Console/AddBoostTool.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Laravel\Boost\Console;
46

57
use Illuminate\Console\Command;

0 commit comments

Comments
 (0)