Skip to content

Commit c661579

Browse files
authored
Merge branch 'main' into fix/agents_selection
2 parents dc25619 + b93476f commit c661579

File tree

17 files changed

+786
-16
lines changed

17 files changed

+786
-16
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"require": {
1616
"php": "^8.1",
1717
"guzzlehttp/guzzle": "^7.9",
18-
"illuminate/console": "^10.49.0|^11.45.3|^12.28.1",
19-
"illuminate/contracts": "^10.49.0|^11.45.3|^12.28.1",
20-
"illuminate/routing": "^10.49.0|^11.45.3|^12.28.1",
21-
"illuminate/support": "^10.49.0|^11.45.3|^12.28.1",
22-
"laravel/mcp": "^0.4.1",
18+
"illuminate/console": "^10.49.0|^11.45.3|^12.41.1",
19+
"illuminate/contracts": "^10.49.0|^11.45.3|^12.41.1",
20+
"illuminate/routing": "^10.49.0|^11.45.3|^12.41.1",
21+
"illuminate/support": "^10.49.0|^11.45.3|^12.41.1",
22+
"laravel/mcp": "^0.5.1",
2323
"laravel/prompts": "0.1.25|^0.3.6",
2424
"laravel/roster": "^0.2.9"
2525
},

src/Concerns/ReadsLogs.php

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Laravel\Boost\Concerns;
66

7+
use Illuminate\Support\Arr;
78
use Illuminate\Support\Facades\Config;
89

910
trait ReadsLogs
@@ -45,11 +46,67 @@ protected function resolveLogFilePath(): string
4546
$channel = Config::get('logging.default');
4647
$channelConfig = Config::get("logging.channels.{$channel}");
4748

48-
if (($channelConfig['driver'] ?? null) === 'daily') {
49-
return storage_path('logs/laravel-'.date('Y-m-d').'.log');
49+
$channelConfig = $this->resolveChannelWithPath($channelConfig);
50+
51+
$baseLogPath = Arr::get($channelConfig, 'path', storage_path('logs/laravel.log'));
52+
53+
if (Arr::get($channelConfig, 'driver') === 'daily') {
54+
return $this->resolveDailyLogFilePath($baseLogPath);
55+
}
56+
57+
return $baseLogPath;
58+
}
59+
60+
/**
61+
* @param array<string, mixed>|null $channelConfig
62+
* @return array<string, mixed>|null
63+
*/
64+
protected function resolveChannelWithPath(?array $channelConfig, int $depth = 0): ?array
65+
{
66+
if ($channelConfig === null || $depth > 2) {
67+
return $channelConfig;
5068
}
5169

52-
return storage_path('logs/laravel.log');
70+
if (isset($channelConfig['path'])) {
71+
return $channelConfig;
72+
}
73+
74+
if (($channelConfig['driver'] ?? null) !== 'stack') {
75+
return $channelConfig;
76+
}
77+
78+
$firstValidLoggerConfig = collect($channelConfig['channels'] ?? [])
79+
->map(fn (string $name) => Config::get("logging.channels.{$name}"))
80+
->filter(fn ($config): bool => is_array($config))
81+
->map(fn (array $config) => $this->resolveChannelWithPath($config, $depth + 1))
82+
->first(fn (?array $config): bool => isset($config['path']));
83+
84+
return $firstValidLoggerConfig ?? $channelConfig;
85+
}
86+
87+
protected function resolveDailyLogFilePath(string $basePath): string
88+
{
89+
$pathInfo = pathinfo($basePath);
90+
$directory = $pathInfo['dirname'];
91+
$filename = $pathInfo['filename'];
92+
$extension = isset($pathInfo['extension']) ? '.'.$pathInfo['extension'] : '';
93+
94+
$todayLogFile = $directory.DIRECTORY_SEPARATOR.$filename.'-'.date('Y-m-d').$extension;
95+
96+
if (file_exists($todayLogFile)) {
97+
return $todayLogFile;
98+
}
99+
100+
$pattern = $directory.DIRECTORY_SEPARATOR.$filename.'-*'.$extension;
101+
$files = glob($pattern) ?: [];
102+
103+
$datePattern = '/^'.preg_quote($filename, '/').'-\d{4}-\d{2}-\d{2}'.preg_quote($extension, '/').'$/';
104+
$latestFile = collect($files)
105+
->filter(fn ($file): int|false => preg_match($datePattern, basename($file)))
106+
->sortDesc()
107+
->first();
108+
109+
return $latestFile ?? $todayLogFile;
53110
}
54111

55112
/**
@@ -130,7 +187,7 @@ protected function scanLogChunkForEntries(string $logFile, int $chunkSize): arra
130187
$offset = max($fileSize - $chunkSize, 0);
131188
fseek($handle, $offset);
132189

133-
// If we started mid-line, discard the partial line to align to next newline.
190+
// If we started mid-line, discard the partial line to align to the next newline.
134191
if ($offset > 0) {
135192
fgets($handle);
136193
}

src/Install/CodeEnvironment/ClaudeCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public function mcpConfigPath(): string
5353

5454
public function guidelinesPath(): string
5555
{
56-
return 'CLAUDE.md';
56+
return config('boost.code_environments.claude_code.guidelines_path', 'CLAUDE.md');
5757
}
5858
}

src/Install/CodeEnvironment/Codex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function projectDetectionConfig(): array
4343

4444
public function guidelinesPath(): string
4545
{
46-
return 'AGENTS.md';
46+
return config('boost.code_environments.codex.guidelines_path', 'AGENTS.md');
4747
}
4848

4949
public function mcpInstallationStrategy(): McpInstallationStrategy

src/Install/CodeEnvironment/Copilot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ public function mcpClientName(): ?string
4646

4747
public function guidelinesPath(): string
4848
{
49-
return '.github/copilot-instructions.md';
49+
return config('boost.code_environments.copilot.guidelines_path', '.github/copilot-instructions.md');
5050
}
5151
}

src/Install/CodeEnvironment/Cursor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function mcpConfigPath(): string
5656

5757
public function guidelinesPath(): string
5858
{
59-
return '.cursor/rules/laravel-boost.mdc';
59+
return config('boost.code_environments.cursor.guidelines_path', '.cursor/rules/laravel-boost.mdc');
6060
}
6161

6262
public function frontmatter(): bool

src/Install/CodeEnvironment/Gemini.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ public function mcpConfigPath(): string
4747

4848
public function guidelinesPath(): string
4949
{
50-
return 'GEMINI.md';
50+
return config('boost.code_environments.gemini.guidelines_path', 'GEMINI.md');
5151
}
5252
}

src/Install/CodeEnvironment/OpenCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function mcpConfigPath(): string
5252

5353
public function guidelinesPath(): string
5454
{
55-
return 'AGENTS.md';
55+
return config('boost.code_environments.opencode.guidelines_path', 'AGENTS.md');
5656
}
5757

5858
public function mcpConfigKey(): string

src/Install/CodeEnvironment/PhpStorm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ public function mcpConfigPath(): string
6565

6666
public function guidelinesPath(): string
6767
{
68-
return '.junie/guidelines.md';
68+
return config('boost.code_environments.phpstorm.guidelines_path', '.junie/guidelines.md');
6969
}
7070
}

0 commit comments

Comments
 (0)