Skip to content

Commit a7a65cc

Browse files
committed
update ai theme descrition
1 parent 4a32ce3 commit a7a65cc

22 files changed

Lines changed: 1924 additions & 65 deletions

File tree

.agents/skills/inertia-react-development/SKILL.md

Lines changed: 524 additions & 0 deletions
Large diffs are not rendered by default.

.claude/skills/inertia-react-development/SKILL.md

Lines changed: 524 additions & 0 deletions
Large diffs are not rendered by default.

AGENTS.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
99

1010
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1111

12-
- php - 8.3
12+
- php - 8.4
1313
- inertiajs/inertia-laravel (INERTIA_LARAVEL) - v3
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
@@ -118,6 +118,13 @@ This project has domain-specific skills available in `**/skills/**`. You MUST ac
118118

119119
- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications.
120120

121+
=== herd rules ===
122+
123+
# Laravel Herd
124+
125+
- The application is served by Laravel Herd at `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs. Never run commands to serve the site. It is always available.
126+
- Use the `herd` CLI to manage services, PHP versions, and sites (e.g. `herd sites`, `herd services:start <service>`, `herd php:list`). Run `herd list` to discover all available commands.
127+
121128
=== tests rules ===
122129

123130
# Test Enforcement

CLAUDE.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
99

1010
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1111

12-
- php - 8.3
12+
- php - 8.4
1313
- inertiajs/inertia-laravel (INERTIA_LARAVEL) - v3
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
@@ -118,6 +118,13 @@ This project has domain-specific skills available in `**/skills/**`. You MUST ac
118118

119119
- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications.
120120

121+
=== herd rules ===
122+
123+
# Laravel Herd
124+
125+
- The application is served by Laravel Herd at `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs. Never run commands to serve the site. It is always available.
126+
- Use the `herd` CLI to manage services, PHP versions, and sites (e.g. `herd sites`, `herd services:start <service>`, `herd php:list`). Run `herd list` to discover all available commands.
127+
121128
=== tests rules ===
122129

123130
# Test Enforcement

GEMINI.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
99

1010
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1111

12-
- php - 8.3
12+
- php - 8.4
1313
- inertiajs/inertia-laravel (INERTIA_LARAVEL) - v3
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
@@ -118,6 +118,13 @@ This project has domain-specific skills available in `**/skills/**`. You MUST ac
118118

119119
- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications.
120120

121+
=== herd rules ===
122+
123+
# Laravel Herd
124+
125+
- The application is served by Laravel Herd at `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs. Never run commands to serve the site. It is always available.
126+
- Use the `herd` CLI to manage services, PHP versions, and sites (e.g. `herd sites`, `herd services:start <service>`, `herd php:list`). Run `herd list` to discover all available commands.
127+
121128
=== tests rules ===
122129

123130
# Test Enforcement

app/Http/Controllers/ThemesController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\Theme;
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Facades\Cache;
8+
use Illuminate\Support\Facades\DB;
89
use Illuminate\Support\Facades\Http;
910
use Illuminate\Support\Str;
1011
use Inertia\Inertia;
@@ -137,7 +138,7 @@ public function index()
137138
$availableTags = Cache::remember('themes:available_tags', 3600, function () {
138139
return Tag::query()
139140
->whereExists(function ($query) {
140-
$query->select(\Illuminate\Support\Facades\DB::raw(1))
141+
$query->select(DB::raw(1))
141142
->from('taggables')
142143
->whereColumn('taggables.tag_id', 'tags.id')
143144
->where('taggables.taggable_type', Theme::class);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Jobs;
4+
5+
use App\Models\Theme;
6+
use App\Services\AiService;
7+
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Foundation\Queue\Queueable;
9+
10+
class GenerateThemeMetadataJob implements ShouldQueue
11+
{
12+
use Queueable;
13+
14+
public function __construct(
15+
public Theme $theme,
16+
) {}
17+
18+
public function handle(AiService $ai): void
19+
{
20+
$theme = $this->theme->fresh();
21+
22+
if (! $theme) {
23+
return;
24+
}
25+
26+
try {
27+
$metadata = $ai->generateThemeMetadata(
28+
$theme->name,
29+
$theme->vars_light ?? [],
30+
);
31+
} catch (\Throwable) {
32+
return;
33+
}
34+
35+
$theme->updateQuietly(['description' => $metadata['description']]);
36+
37+
if (! empty($metadata['tags'])) {
38+
$theme->attachTags($metadata['tags']);
39+
}
40+
}
41+
}

app/Observers/ThemeObserver.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,21 @@
22

33
namespace App\Observers;
44

5+
use App\Jobs\GenerateThemeMetadataJob;
56
use App\Models\Theme;
6-
use App\Services\AiService;
77
use Illuminate\Support\Str;
88

99
class ThemeObserver
1010
{
11-
/**
12-
* @var array<string>
13-
*/
14-
protected static array $suggestedTagsMap = [];
15-
1611
public function creating(Theme $theme): void
1712
{
1813
if (! $theme->title) {
1914
$theme->title = Str::headline($theme->name);
2015
}
21-
22-
if (! $theme->description) {
23-
$ai = app(AiService::class);
24-
$metadata = $ai->generateThemeMetadata(
25-
$theme->name,
26-
$theme->vars_light ?? []
27-
);
28-
$theme->description = $metadata['description'];
29-
static::$suggestedTagsMap[$theme->name] = $metadata['tags'];
30-
}
3116
}
3217

3318
public function created(Theme $theme): void
3419
{
35-
if (isset(static::$suggestedTagsMap[$theme->name])) {
36-
$theme->attachTags(static::$suggestedTagsMap[$theme->name]);
37-
unset(static::$suggestedTagsMap[$theme->name]);
38-
}
20+
GenerateThemeMetadataJob::dispatch($theme);
3921
}
4022
}

app/Services/AiService.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public function generateThemeMetadata(string $name, array $colors): array
2323

2424
$prompt = "Generate metadata for a UI theme named \"{$name}\" that uses these colors: {$colorList}.
2525
Return the result in JSON format with two keys:
26-
1. \"description\": a short, engaging description (max 2 sentences) highlighting the mood or style.
26+
1. \"description\": a short, engaging description (max 2 sentences) highlighting the mood or style. The description must not start with a colon.
2727
2. \"tags\": an array of 2 to 6 relevant style tags (e.g., \"warm\", \"cold\", \"retro\", \"vintage\", \"punk\", \"nature\", \"tech\", \"bold\", \"minimal\", \"elegant\").";
2828

2929
$response = Http::withHeaders([
3030
'Authorization' => 'Bearer '.$apiKey,
3131
'HTTP-Referer' => config('app.url'),
3232
'X-Title' => config('app.name'),
33-
])->post('https://openrouter.ai/api/v1/chat/completions', [
33+
])->timeout(15)->post('https://openrouter.ai/api/v1/chat/completions', [
3434
'model' => config('services.openrouter.model'),
3535
'messages' => [
3636
[
@@ -49,8 +49,14 @@ public function generateThemeMetadata(string $name, array $colors): array
4949
$content = $data['choices'][0]['message']['content'] ?? '{}';
5050
$decoded = json_decode($content, true);
5151

52+
$description = $decoded['description'] ?? null;
53+
54+
if ($description) {
55+
$description = ltrim($description, ': ');
56+
}
57+
5258
return [
53-
'description' => $decoded['description'] ?? null,
59+
'description' => $description,
5460
'tags' => $decoded['tags'] ?? [],
5561
];
5662
}

boost.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"socialite-development",
1616
"wayfinder-development",
1717
"pest-testing",
18+
"inertia-react-development",
1819
"tailwindcss-development"
1920
]
2021
}

0 commit comments

Comments
 (0)