Skip to content

Commit e3c485e

Browse files
committed
guidelines: livewire: wip
1 parent 2f530cf commit e3c485e

File tree

9 files changed

+36
-48
lines changed

9 files changed

+36
-48
lines changed

.ai/livewire/3/core.blade.php

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,8 @@
1-
21
#### Key Changes from Livewire 2
2+
- These changed in Livewire 2, but may not have in this project. Verify this project's setup to ensure you conform with conventions.
33

4-
- **Namespace**: Components now use `App\Livewire` (not `App\Http\Livewire`)
5-
- **Events**: Use `$this->dispatch()` (not `emit` or `dispatchBrowserEvent`)
6-
- **Layout path**: `components.layouts.app` (not `layouts.app`)
7-
- **Deferred by default**: Use `wire:model.live` for real-time updates
8-
- **Alpine included**: Don't manually include Alpine.js
9-
10-
#### Livewire Best Practices
11-
12-
- **Single root element** in Blade components
13-
- **Add wire:key** in loops:
14-
15-
@verbatim
16-
```blade
17-
@foreach ($items as $item)
18-
<div wire:key="item-{{ $item->id }}">
19-
{{ $item->name }}
20-
</div>
21-
@endforeach
22-
```
23-
@endverbatim
24-
25-
- **Use attributes** for event listeners:
26-
27-
```php
28-
#[On('todo-created')]
29-
public function refreshList()
30-
{
31-
// ...
32-
}
33-
```
34-
35-
- **Loading states**: Use `wire:loading` and `wire:dirty`
36-
- **Confirmations**: Use `wire:confirm="Are you sure?"`
4+
- **Namespace**: Components now use `App\Livewire` (not `App\Http\Livewire`).
5+
- **Events**: Use `$this->dispatch()` (not `emit` or `dispatchBrowserEvent`).
6+
- **Layout path**: `components.layouts.app` (not `layouts.app`).
7+
- **Deferred by default**: Use `wire:model.live` for real-time updates.
8+
- **Alpine included**: Don't manually include Alpine.js.

.ai/livewire/core.blade.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
## Livewire Core
2+
- Use the `search-docs` tool to find exact version specific documentation for how to write Livewire.
3+
4+
5+
## Livewire Best Practices
6+
- **Single root element** in Blade components
7+
- **Loading states**: Use `wire:loading` and `wire:dirty`.
8+
- **Add wire:key** in loops:
9+
@verbatim
10+
```blade
11+
@foreach ($items as $item)
12+
<div wire:key="item-{{ $item->id }}">
13+
{{ $item->name }}
14+
</div>
15+
@endforeach
16+
```
17+
@endverbatim

.ai/tailwindcss/3/core.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
- Always use Tailwind CSS v3, verify you're using only supported classes.
2-
- Use the `search-docs` tool to find exactly what's supported in this project's Tailwind setup.

.ai/tailwindcss/4/core.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
- Always use Tailwind CSS v4, do not use the deprecated utilities.
2-
- Use the `search-docs` tool to find exactly what's supported in this project's Tailwind setup.
32
- In Tailwind v4 you import Tailwind using a regular CSS `@import` statement, not using the `@tailwind` directives used in v3:
43
@verbatim
54
<code-snippet name="Tailwind v4 import tailwind diff" lang="diff"

.ai/tailwindcss/core.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- Use Tailwind CSS classes to style HTML, check and use existing tailwind conventions within the project before writing your own.
22
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc..)
33
- Think through class placement, order, priority, and defaults - remove redundant classes, add classes to parent or child carefully to limit repetition, group elements logically
4+
- Use the `search-docs` tool to find exactly what's supported in this project's Tailwind setup.
45

56
## Spacing
67
- Use gap utilities for spacing, don't use margins

.ai/volt/core.blade.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ public function increment()
107107
$delete = fn(Product $product) => $product->delete();
108108
?>
109109

110-
<!-- UI here -->
110+
<!-- HTML here -->
111111
@endvolt
112112
</code-snippet>
113113
@endverbatim
114-
115114
@verbatim
116115
<code-snippet name="Real-time search with Volt" lang="php">
117116
<flux:input
@@ -120,8 +119,6 @@ public function increment()
120119
/>
121120
</code-snippet>
122121
@endverbatim
123-
124-
125122
@verbatim
126123
<code-snippet name="Loading states with Volt" lang="php">
127124
<flux:button wire:click="save" wire:loading.attr="disabled">

src/Mcp/Tools/SearchDocs.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,24 @@ class SearchDocs extends Tool
1616
{
1717
use MakesHttpRequests;
1818

19-
public function __construct(protected Roster $roster)
20-
{
21-
}
19+
public function __construct(protected Roster $roster) {}
2220

2321
public function description(): string
2422
{
25-
return 'Search for up-to-date version-specific documentation related to this project and its packages. This tool will search Laravel hosted documentation based on the packages installed and is perfect for all Laravel related packages. Laravel, inertia, pest, livewire, filament, nova, nightwatch, and more.'.PHP_EOL.'You must use this tool to search for Laravel-ecosystem docs before using other approaches.';
23+
return 'Search for up-to-date version-specific documentation related to this project and its packages. This tool will search Laravel hosted documentation based on the packages installed and is perfect for all Laravel related packages. Laravel, inertia, pest, livewire, filament, nova, nightwatch, and more.'.PHP_EOL.'You must use this tool to search for Laravel-ecosystem docs before using other approaches. The results provided are for this project\'s package version and does not cover all versions of the package.';
2624
}
2725

2826
public function schema(ToolInputSchema $schema): ToolInputSchema
2927
{
3028
return $schema
31-
->string('queries')
32-
->description('### separated list of queries to perform. Useful to pass multiple if you aren\'t sure if it is "toggle" or "switch", or "infinite scroll" or "infinite load", for example.')->required()
33-
29+
->raw('queries', [
30+
'description' => 'List of queries to perform, pass multiple if you aren\'t sure if it is "toggle" or "switch", for example',
31+
'type' => 'array',
32+
'items' => [
33+
'type' => 'string',
34+
'description' => 'Search query',
35+
],
36+
])->required()
3437
->raw('packages', [
3538
'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',
3639
'type' => 'array',
@@ -54,7 +57,7 @@ public function handle(array $arguments): ToolResult|Generator
5457
$packagesFilter = array_key_exists('packages', $arguments) ? $arguments['packages'] : null;
5558

5659
$queries = array_filter(
57-
array_map('trim', explode('###', $arguments['queries'])),
60+
array_map('trim', $arguments['queries']),
5861
fn ($query) => $query !== '' && $query !== '*'
5962
);
6063

@@ -90,6 +93,7 @@ public function handle(array $arguments): ToolResult|Generator
9093
'token_limit' => $tokenLimit,
9194
'format' => 'markdown',
9295
];
96+
9397
try {
9498
$response = $this->client()->asJson()->post($apiUrl, $payload);
9599

0 commit comments

Comments
 (0)