Skip to content

Commit d2333bd

Browse files
committed
Merge remote-tracking branch 'origin/1.x' into 1.x
# Conflicts: # src/Mcp/Tools/SearchDocs.php
2 parents 2009123 + e4f7f56 commit d2333bd

19 files changed

+123
-138
lines changed

src/Console/ChatCommand.php

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,55 @@ public function handle(): int
3434
protected function listTools(): int
3535
{
3636
$tools = ToolRegistry::getToolNames();
37-
37+
3838
$this->info('Available Boost MCP Tools:');
3939
$this->newLine();
40-
40+
4141
foreach ($tools as $name => $class) {
4242
$this->line(" <fg=green>{$name}</> - {$class}");
4343
}
44-
44+
4545
$this->newLine();
4646
$this->info('Usage: php artisan boost:chat --tool=ToolName --args=\'{"key":"value"}\'');
47-
47+
4848
return 0;
4949
}
5050

5151
protected function executeTool(): int
5252
{
5353
$toolName = $this->option('tool');
5454
$tools = ToolRegistry::getToolNames();
55-
56-
if (!isset($tools[$toolName])) {
55+
56+
if (! isset($tools[$toolName])) {
5757
$this->error("Tool '{$toolName}' not found.");
58-
$this->info('Available tools: ' . implode(', ', array_keys($tools)));
58+
$this->info('Available tools: '.implode(', ', array_keys($tools)));
59+
5960
return 1;
6061
}
61-
62+
6263
$toolClass = $tools[$toolName];
6364
$args = [];
64-
65+
6566
if ($this->option('args')) {
6667
$args = json_decode($this->option('args'), true);
6768
if (json_last_error() !== JSON_ERROR_NONE) {
68-
$this->error('Invalid JSON arguments: ' . json_last_error_msg());
69+
$this->error('Invalid JSON arguments: '.json_last_error_msg());
70+
6971
return 1;
7072
}
7173
}
72-
74+
7375
$this->info("Executing tool: {$toolName}");
74-
if (!empty($args)) {
75-
$this->info('Arguments: ' . json_encode($args, JSON_PRETTY_PRINT));
76+
if (! empty($args)) {
77+
$this->info('Arguments: '.json_encode($args, JSON_PRETTY_PRINT));
7678
}
7779
$this->newLine();
78-
80+
7981
$executor = app(ToolExecutor::class);
8082
$result = $executor->execute($toolClass, $args);
81-
83+
8284
$this->displayResult($result);
83-
85+
8486
return 0;
8587
}
8688

@@ -89,42 +91,44 @@ protected function interactiveChat(): int
8991
$this->info('🚀 Boost Interactive Chat');
9092
$this->info('Type a tool name to execute it, or "help" for commands.');
9193
$this->newLine();
92-
94+
9395
while (true) {
9496
$input = $this->ask('boost> ');
95-
97+
9698
if (empty($input)) {
9799
continue;
98100
}
99-
101+
100102
if (in_array(strtolower($input), ['exit', 'quit', 'q'])) {
101103
$this->info('Goodbye! 👋');
102104
break;
103105
}
104-
106+
105107
if (strtolower($input) === 'help') {
106108
$this->showHelp();
109+
107110
continue;
108111
}
109-
112+
110113
if (strtolower($input) === 'tools') {
111114
$this->listTools();
115+
112116
continue;
113117
}
114-
118+
115119
// Try to execute as a tool name
116120
$tools = ToolRegistry::getToolNames();
117-
121+
118122
if (isset($tools[$input])) {
119123
$this->executeInteractiveTool($tools[$input]);
120124
} else {
121125
$this->error("Unknown command or tool: {$input}");
122126
$this->info('Type "help" for available commands or "tools" to list available tools.');
123127
}
124-
128+
125129
$this->newLine();
126130
}
127-
131+
128132
return 0;
129133
}
130134

@@ -134,19 +138,20 @@ protected function executeInteractiveTool(string $toolClass): void
134138
// In the future, this could prompt for arguments interactively
135139
$executor = app(ToolExecutor::class);
136140
$result = $executor->execute($toolClass, []);
137-
141+
138142
$this->displayResult($result);
139143
}
140144

141145
protected function displayResult(ToolResult $result): void
142146
{
143147
if ($result->isError) {
144-
$this->error('Error: ' . $this->extractTextFromContent($result->content));
148+
$this->error('Error: '.$this->extractTextFromContent($result->content));
149+
145150
return;
146151
}
147152

148153
$text = $this->extractTextFromContent($result->content);
149-
154+
150155
// Try to detect if it's JSON
151156
$decoded = json_decode($text, true);
152157
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
@@ -165,6 +170,7 @@ protected function extractTextFromContent(array $content): string
165170
}
166171

167172
$firstContent = $content[0] ?? [];
173+
168174
return $firstContent['text'] ?? '';
169175
}
170176

@@ -179,4 +185,4 @@ protected function showHelp(): void
179185
$this->info('You can also use command line options:');
180186
$this->line(' --tool=ToolName --args=\'{"key":"value"}\'');
181187
}
182-
}
188+
}

src/Console/ExecuteToolCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ public function handle(): int
2020
$argumentsEncoded = $this->argument('arguments');
2121

2222
// Validate the tool is registered
23-
if (!ToolRegistry::isToolAllowed($toolClass)) {
23+
if (! ToolRegistry::isToolAllowed($toolClass)) {
2424
$this->error("Tool not registered or not allowed: {$toolClass}");
25+
2526
return 1;
2627
}
2728

2829
// Decode arguments
2930
$arguments = json_decode(base64_decode($argumentsEncoded), true);
3031
if (json_last_error() !== JSON_ERROR_NONE) {
31-
$this->error('Invalid arguments format: ' . json_last_error_msg());
32+
$this->error('Invalid arguments format: '.json_last_error_msg());
33+
3234
return 1;
3335
}
3436

@@ -39,16 +41,15 @@ public function handle(): int
3941

4042
// Output the result as JSON for the parent process
4143
echo json_encode($result->toArray());
42-
44+
4345
return 0;
4446

4547
} catch (\Throwable $e) {
4648
// Output error result
4749
$errorResult = ToolResult::error("Tool execution failed: {$e->getMessage()}");
4850
echo json_encode($errorResult->toArray());
49-
51+
5052
return 1;
5153
}
5254
}
53-
54-
}
55+
}

src/Console/InstallCommand.php

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
use Illuminate\Support\Arr;
99
use Illuminate\Support\Facades\Process;
1010
use Illuminate\Support\Str;
11-
use Laravel\Boost\Install\InstallPrompt;
1211
use Laravel\Prompts\Concerns\Colors;
13-
use Laravel\Prompts\Prompt;
1412
use Symfony\Component\Console\Attribute\AsCommand;
1513
use Symfony\Component\Finder\Finder;
1614

@@ -32,18 +30,25 @@ class InstallCommand extends Command
3230

3331
/** @var string[] */
3432
protected array $installedIdes = [];
33+
3534
protected array $detectedProjectIdes = [];
3635

3736
protected bool $enforceTests = true;
37+
3838
protected array $idesToInstallTo = ['other'];
39+
3940
protected array $boostToInstall = [];
41+
4042
protected array $boostToolsToDisable = [];
43+
4144
protected array $detectedProjectAgents = [];
45+
4246
protected array $agentsToInstallTo = [];
4347

4448
public function handle(): void
4549
{
46-
$this->colors = new class {
50+
$this->colors = new class
51+
{
4752
use Colors;
4853
};
4954

@@ -59,7 +64,7 @@ protected function detect()
5964
{
6065
$this->installedIdes = $this->detectInstalledIdes();
6166
$this->detectedProjectIdes = $this->detectIdesUsedInProject();
62-
// $this->detectedProjectAgents = $this->detectProjectAgents(); // TODO: Roo, Cline, Copilot
67+
// $this->detectedProjectAgents = $this->detectProjectAgents(); // TODO: Roo, Cline, Copilot
6368
}
6469

6570
protected function query()
@@ -71,8 +76,7 @@ protected function query()
7176
7277
// Which parts of boost should we install
7378
$this->boostToInstall = $this->boostToInstall();
74-
// $this->boostToolsToDisable = $this->boostToolsToDisable(); // Not useful to start
75-
79+
// $this->boostToolsToDisable = $this->boostToolsToDisable(); // Not useful to start
7680

7781
}
7882

@@ -152,7 +156,7 @@ protected function discoverTools(): array
152156
->name('*.php');
153157

154158
foreach ($finder as $toolFile) {
155-
$fqdn = 'Laravel\\Boost\\Mcp\\Tools\\' . $toolFile->getBasename('.php');
159+
$fqdn = 'Laravel\\Boost\\Mcp\\Tools\\'.$toolFile->getBasename('.php');
156160
if (class_exists($fqdn)) {
157161
$tools[$fqdn] = Str::headline($toolFile->getBasename('.php'));
158162
}
@@ -166,7 +170,7 @@ protected function discoverTools(): array
166170
public function getHomePath(): string
167171
{
168172
if (PHP_OS_FAMILY === 'Windows') {
169-
if (!isset($_SERVER['HOME'])) {
173+
if (! isset($_SERVER['HOME'])) {
170174
$_SERVER['HOME'] = $_SERVER['USERPROFILE'];
171175
}
172176

@@ -180,22 +184,22 @@ protected function isHerdInstalled(): bool
180184
{
181185
$isWindows = PHP_OS_FAMILY === 'Windows';
182186

183-
if (!$isWindows) {
187+
if (! $isWindows) {
184188
return file_exists('/Applications/Herd.app/Contents/MacOS/Herd');
185189
}
186190

187-
return is_dir($this->getHomePath() . '/.config/herd');
191+
return is_dir($this->getHomePath().'/.config/herd');
188192
}
189193

190194
protected function isHerdMCPAvailable(): bool
191195
{
192196
$isWindows = PHP_OS_FAMILY === 'Windows';
193197

194198
if ($isWindows) {
195-
return file_exists($this->getHomePath() . '/.config/herd/bin/herd-mcp.phar');
199+
return file_exists($this->getHomePath().'/.config/herd/bin/herd-mcp.phar');
196200
}
197201

198-
return file_exists($this->getHomePath() . '/Library/Application Support/Herd/bin/herd-mcp.phar');
202+
return file_exists($this->getHomePath().'/Library/Application Support/Herd/bin/herd-mcp.phar');
199203
}
200204

201205
/*
@@ -222,7 +226,7 @@ private function intro()
222226
HEADER
223227
);
224228
intro('✦ Laravel Boost :: Install :: We Must Ship ✦');
225-
$this->line(' Let\'s setup Laravel Boost in your IDEs for ' . $this->colors->bgYellow($this->colors->black($this->projectName)));
229+
$this->line(' Let\'s setup Laravel Boost in your IDEs for '.$this->colors->bgYellow($this->colors->black($this->projectName)));
226230
}
227231

228232
protected function projectPurpose(): string
@@ -243,17 +247,17 @@ protected function projectPurpose(): string
243247
protected function shouldEnforceTests(bool $ask = true): bool
244248
{
245249
$enforce = Finder::create()
246-
->in(base_path('tests'))
247-
->files()
248-
->name('*.php')
249-
->count() > 6;
250+
->in(base_path('tests'))
251+
->files()
252+
->name('*.php')
253+
->count() > 6;
250254

251255
if ($enforce === false && $ask === true) {
252256
$enforce = select(
253-
label: 'Should AI always create tests?',
254-
options: ['Yes', 'No'],
255-
default: 'Yes'
256-
) === 'Yes';
257+
label: 'Should AI always create tests?',
258+
options: ['Yes', 'No'],
259+
default: 'Yes'
260+
) === 'Yes';
257261
}
258262

259263
return $enforce;
@@ -271,7 +275,7 @@ protected function idesToInstallTo(): array
271275
];
272276

273277
// Tell API which ones?
274-
$autoDetectedIdesString = Arr::join(array_map(fn(string $ideKey) => $ideOptions[$ideKey] ?? '', $this->detectedProjectIdes), ', ', ' & ');
278+
$autoDetectedIdesString = Arr::join(array_map(fn (string $ideKey) => $ideOptions[$ideKey] ?? '', $this->detectedProjectIdes), ', ', ' & ');
275279

276280
return multiselect(
277281
label: sprintf('Which IDEs do you use in %s? (space to select)', $this->projectName),
@@ -316,14 +320,8 @@ protected function boostToolsToDisable(): array
316320
);
317321
}
318322

319-
protected function detectProjectAgents(): array
320-
{
321-
322-
}
323+
protected function detectProjectAgents(): array {}
323324

324-
/**
325-
* @return array
326-
*/
327325
protected function agentsToInstallTo(): array
328326
{
329327
return [];

src/Contracts/Agent.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ interface Agent
1010
* Install the rules into the agent's rules if needed.
1111
* Should be safe to re-run without causing problems.
1212
* Should work well with others.
13-
*
14-
* @param string $rules
15-
* @return bool
1613
*/
1714
public function rules(string $rules): bool;
1815
}

src/Contracts/Ide.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
interface Ide
77
{
88
// Things to note: supports relative (absolute path required)? global mcp only? Prefer local file, but if global only we have to add the project name to the server name
9-
9+
1010
/**
1111
* Install MCP server to this IDE.
1212
* Should be safe to re-run.
1313
* Should work well with others.
14-
*
15-
* @param string $command
16-
* @param array $args
17-
* @return bool
1814
*/
1915
public function install(string $command, array $args): bool;
2016
}

0 commit comments

Comments
 (0)