@famgia/omnify-laravel 0.0.88 → 0.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/{chunk-YVVAJA3T.js → chunk-2QSKZS63.js} +188 -12
  2. package/dist/chunk-2QSKZS63.js.map +1 -0
  3. package/dist/index.cjs +190 -11
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +48 -1
  6. package/dist/index.d.ts +48 -1
  7. package/dist/index.js +5 -1
  8. package/dist/plugin.cjs +186 -11
  9. package/dist/plugin.cjs.map +1 -1
  10. package/dist/plugin.js +1 -1
  11. package/package.json +5 -5
  12. package/scripts/postinstall.js +29 -36
  13. package/stubs/ai-guides/README.md.stub +95 -0
  14. package/stubs/ai-guides/claude-agents/architect.md.stub +150 -0
  15. package/stubs/ai-guides/claude-agents/developer.md.stub +190 -0
  16. package/stubs/ai-guides/claude-agents/reviewer.md.stub +134 -0
  17. package/stubs/ai-guides/claude-agents/tester.md.stub +196 -0
  18. package/stubs/ai-guides/claude-checklists/backend.md.stub +112 -0
  19. package/stubs/ai-guides/claude-omnify/antdesign-guide.md.stub +401 -0
  20. package/stubs/ai-guides/claude-omnify/config-guide.md.stub +253 -0
  21. package/stubs/ai-guides/claude-omnify/japan-guide.md.stub +186 -0
  22. package/stubs/ai-guides/claude-omnify/laravel-guide.md.stub +61 -0
  23. package/stubs/ai-guides/claude-omnify/react-form-guide.md.stub +259 -0
  24. package/stubs/ai-guides/claude-omnify/schema-guide.md.stub +115 -0
  25. package/stubs/ai-guides/claude-omnify/typescript-guide.md.stub +310 -0
  26. package/stubs/ai-guides/claude-rules/naming.md.stub +364 -0
  27. package/stubs/ai-guides/claude-rules/performance.md.stub +251 -0
  28. package/stubs/ai-guides/claude-rules/security.md.stub +159 -0
  29. package/stubs/ai-guides/claude-workflows/bug-fix.md.stub +201 -0
  30. package/stubs/ai-guides/claude-workflows/code-review.md.stub +164 -0
  31. package/stubs/ai-guides/claude-workflows/new-feature.md.stub +327 -0
  32. package/stubs/ai-guides/cursor/laravel-controller.mdc.stub +391 -0
  33. package/stubs/ai-guides/cursor/laravel-request.mdc.stub +112 -0
  34. package/stubs/ai-guides/cursor/laravel-resource.mdc.stub +73 -0
  35. package/stubs/ai-guides/cursor/laravel-review.mdc.stub +69 -0
  36. package/stubs/ai-guides/cursor/laravel-testing.mdc.stub +138 -0
  37. package/stubs/ai-guides/cursor/laravel.mdc.stub +82 -0
  38. package/stubs/ai-guides/cursor/omnify.mdc.stub +58 -0
  39. package/stubs/ai-guides/laravel/README.md.stub +59 -0
  40. package/stubs/ai-guides/laravel/architecture.md.stub +424 -0
  41. package/stubs/ai-guides/laravel/controller.md.stub +484 -0
  42. package/stubs/ai-guides/laravel/datetime.md.stub +334 -0
  43. package/stubs/ai-guides/laravel/openapi.md.stub +369 -0
  44. package/stubs/ai-guides/laravel/request.md.stub +450 -0
  45. package/stubs/ai-guides/laravel/resource.md.stub +516 -0
  46. package/stubs/ai-guides/laravel/service.md.stub +503 -0
  47. package/stubs/ai-guides/laravel/testing.md.stub +1504 -0
  48. package/ai-guides/laravel-guide.md +0 -461
  49. package/dist/chunk-YVVAJA3T.js.map +0 -1
@@ -0,0 +1,159 @@
1
+ # Security Rules
2
+
3
+ > **Non-negotiable rules** for Laravel security. Violations = vulnerabilities.
4
+
5
+ ## 🔴 Mass Assignment Vulnerability
6
+
7
+ **ALWAYS define `$fillable` in Models.**
8
+
9
+ ```php
10
+ // ❌ CRITICAL ERROR: No $fillable = mass assignment vulnerability
11
+ class User extends Model
12
+ {
13
+ // Missing $fillable!
14
+ }
15
+
16
+ // ❌ DANGEROUS: Using $request->all()
17
+ User::create($request->all()); // Attacker can set is_admin=true
18
+
19
+ // ✅ CORRECT: Define $fillable explicitly
20
+ class User extends Model
21
+ {
22
+ protected $fillable = [
23
+ 'name_lastname',
24
+ 'name_firstname',
25
+ 'email',
26
+ 'password',
27
+ ];
28
+
29
+ // $guarded is alternative but $fillable is preferred (explicit)
30
+ }
31
+
32
+ // ✅ CORRECT: Use validated data only
33
+ User::create($request->validated());
34
+ ```
35
+
36
+ | Rule | Description |
37
+ | --------------------------------------------- | ------------------------------------------------------ |
38
+ | **Always define `$fillable`** | Explicitly list assignable fields |
39
+ | **Never use `$request->all()`** | Use `$request->validated()` or `$request->only([...])` |
40
+ | **Prefer `$fillable` over `$guarded`** | Whitelist is safer than blacklist |
41
+ | **Never put sensitive fields in `$fillable`** | `is_admin`, `role`, `balance` must NOT be fillable |
42
+
43
+ ---
44
+
45
+ ## 🔴 SQL Injection Prevention
46
+
47
+ **NEVER use raw user input in queries.**
48
+
49
+ ```php
50
+ // ❌ CRITICAL ERROR: SQL Injection vulnerability
51
+ $email = $request->input('email');
52
+ DB::select("SELECT * FROM users WHERE email = '$email'"); // DANGEROUS!
53
+
54
+ // ❌ DANGEROUS: String interpolation in whereRaw
55
+ User::whereRaw("email = '$email'")->get(); // DANGEROUS!
56
+
57
+ // ✅ CORRECT: Use parameter binding
58
+ DB::select("SELECT * FROM users WHERE email = ?", [$email]);
59
+
60
+ // ✅ CORRECT: Use Query Builder (auto-escapes)
61
+ User::where('email', $email)->get();
62
+
63
+ // ✅ CORRECT: Parameter binding in whereRaw
64
+ User::whereRaw('email = ?', [$email])->get();
65
+ ```
66
+
67
+ | Rule | Description |
68
+ | -------------------------------- | ---------------------------------- |
69
+ | **Use Query Builder** | Eloquent auto-escapes values |
70
+ | **Use parameter binding** | `?` placeholders with array values |
71
+ | **Never concatenate user input** | No string interpolation in SQL |
72
+ | **Validate sort fields** | Whitelist allowed sort columns |
73
+
74
+ ```php
75
+ // ✅ CORRECT: Whitelist sort fields to prevent SQL injection
76
+ $allowedSorts = ['id', 'name', 'email', 'created_at'];
77
+ $sortBy = in_array($request->sort_by, $allowedSorts)
78
+ ? $request->sort_by
79
+ : 'id';
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 🔴 XSS Prevention
85
+
86
+ **Always escape output in Blade templates.**
87
+
88
+ ```php
89
+ // ❌ DANGEROUS: Raw HTML output
90
+ {!! $user->bio !!} // XSS if bio contains <script>
91
+
92
+ // ✅ CORRECT: Escaped output (default)
93
+ {{ $user->bio }} // Auto-escapes HTML entities
94
+
95
+ // ✅ CORRECT: Only use {!! !!} for trusted HTML
96
+ {!! $trustedHtml !!} // Only for admin-generated content
97
+ ```
98
+
99
+ ---
100
+
101
+ ## 🔴 CSRF Protection
102
+
103
+ **Never disable CSRF for web routes.**
104
+
105
+ ```php
106
+ // ❌ DANGEROUS: Disabling CSRF
107
+ // In VerifyCsrfToken middleware
108
+ protected $except = ['*']; // NEVER do this!
109
+
110
+ // ✅ CORRECT: CSRF is enabled by default for web routes
111
+ // API routes use Sanctum tokens instead
112
+ ```
113
+
114
+ ---
115
+
116
+ ## 🔴 Sensitive Data Exposure
117
+
118
+ **Hide sensitive fields from JSON responses.**
119
+
120
+ ```php
121
+ // ❌ ERROR: Password exposed in API response
122
+ return response()->json($user); // Includes password!
123
+
124
+ // ✅ CORRECT: Use $hidden in Model
125
+ class User extends Model
126
+ {
127
+ protected $hidden = [
128
+ 'password',
129
+ 'remember_token',
130
+ 'two_factor_secret',
131
+ ];
132
+ }
133
+
134
+ // ✅ CORRECT: Use Resource to control output
135
+ class UserResource extends JsonResource
136
+ {
137
+ public function toArray($request): array
138
+ {
139
+ return [
140
+ 'id' => $this->id,
141
+ 'name' => $this->name,
142
+ // password NOT included
143
+ ];
144
+ }
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Quick Reference
151
+
152
+ | ❌ Never Do | ✅ Always Do |
153
+ | ----------------------- | --------------------------------- |
154
+ | `$request->all()` | `$request->validated()` |
155
+ | Raw SQL with user input | Query Builder / parameter binding |
156
+ | Missing `$fillable` | Define `$fillable` explicitly |
157
+ | Missing `$hidden` | Hide sensitive fields |
158
+ | Disable CSRF | Keep CSRF enabled |
159
+ | `{!! $userInput !!}` | `{{ $userInput }}` |
@@ -0,0 +1,201 @@
1
+ # Bug Fix Workflow
2
+
3
+ > Step-by-step guide for fixing bugs.
4
+
5
+ ## Overview
6
+
7
+ ```mermaid
8
+ flowchart LR
9
+ Reproduce --> Locate --> Fix --> Test --> PR
10
+ ```
11
+
12
+ | Step | Action | Output |
13
+ | ---- | --------------------- | ------------------------------ |
14
+ | 1 | Reproduce the bug | Clear reproduction steps |
15
+ | 2 | Locate the cause | File(s) and line(s) identified |
16
+ | 3 | Write failing test | Test that reproduces bug |
17
+ | 4 | Fix the bug | Code changes |
18
+ | 5 | Verify test passes | `./artisan test` |
19
+ | 6 | Check for regressions | All tests pass |
20
+ | 7 | Create PR | Pull request |
21
+
22
+ ---
23
+
24
+ ## Step 1: Reproduce
25
+
26
+ Before fixing, confirm you can reproduce:
27
+
28
+ ```bash
29
+ # Check logs
30
+ tail -f backend/storage/logs/laravel.log
31
+
32
+ # Test the endpoint
33
+ curl -X GET https://api.boilerplate.app/api/users
34
+ ```
35
+
36
+ **Document:**
37
+ - Steps to reproduce
38
+ - Expected behavior
39
+ - Actual behavior
40
+ - Error message/stack trace
41
+
42
+ ---
43
+
44
+ ## Step 2: Locate the Cause
45
+
46
+ ### Common Locations
47
+
48
+ | Symptom | Check |
49
+ | ------------------- | -------------------------------- |
50
+ | 500 error | `storage/logs/laravel.log` |
51
+ | 422 validation | `*Request.php` rules |
52
+ | Wrong data returned | `*Resource.php` |
53
+ | 404 not found | `routes/api.php` + model binding |
54
+ | N+1 queries | Missing `with()` in controller |
55
+ | Date format wrong | Missing `->toISOString()` |
56
+
57
+ ### Debug Commands
58
+
59
+ ```bash
60
+ # Check route exists
61
+ ./artisan route:list | grep users
62
+
63
+ # Check model
64
+ ./artisan tinker
65
+ >>> User::find(1)
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Step 3: Write Failing Test
71
+
72
+ **ALWAYS write a test that reproduces the bug first.**
73
+
74
+ ```php
75
+ // tests/Feature/Api/UserControllerTest.php
76
+
77
+ it('異常: bug #123 - returns 500 when name is null', function () {
78
+ // This should NOT happen but currently does
79
+ $response = $this->postJson('/api/users', [
80
+ 'email' => 'test@example.com',
81
+ 'password' => 'password123',
82
+ // name is missing - should return 422, not 500
83
+ ]);
84
+
85
+ $response->assertUnprocessable(); // Currently fails with 500
86
+ });
87
+ ```
88
+
89
+ Run test to confirm it fails:
90
+
91
+ ```bash
92
+ ./artisan test --filter="bug #123"
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Step 4: Fix the Bug
98
+
99
+ Make the minimal change to fix the issue.
100
+
101
+ **Don't:**
102
+ - Refactor unrelated code
103
+ - Add features
104
+ - Change coding style
105
+
106
+ **Do:**
107
+ - Fix only the bug
108
+ - Keep changes focused
109
+ - Follow existing patterns
110
+
111
+ ---
112
+
113
+ ## Step 5: Verify Fix
114
+
115
+ ```bash
116
+ # Run the specific test
117
+ ./artisan test --filter="bug #123"
118
+
119
+ # Run all tests for the affected controller
120
+ ./artisan test --filter=UserControllerTest
121
+
122
+ # Run all tests
123
+ ./artisan test
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Step 6: Check for Regressions
129
+
130
+ ```bash
131
+ # All backend tests
132
+ ./artisan test
133
+
134
+ # Specific test file
135
+ ./artisan test tests/Feature/Api/UserControllerTest.php
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Step 7: Create PR
141
+
142
+ ### PR Title Format
143
+
144
+ ```
145
+ fix: [#issue] brief description
146
+ ```
147
+
148
+ Example: `fix: [#123] return 422 instead of 500 when name is missing`
149
+
150
+ ### PR Description
151
+
152
+ ```markdown
153
+ ## Bug
154
+
155
+ [Link to issue or description]
156
+
157
+ ## Root Cause
158
+
159
+ [Explanation of what caused the bug]
160
+
161
+ ## Fix
162
+
163
+ [Description of the fix]
164
+
165
+ ## Test
166
+
167
+ - [ ] Added test that reproduces bug
168
+ - [ ] Test passes after fix
169
+ - [ ] All existing tests pass
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Debugging Tips
175
+
176
+ ### Laravel Logs
177
+
178
+ ```php
179
+ // Add temporary logging
180
+ Log::info('Debug', ['user' => $user, 'request' => $request->all()]);
181
+ ```
182
+
183
+ ### Database Queries
184
+
185
+ ```php
186
+ // Enable query log
187
+ DB::enableQueryLog();
188
+
189
+ // ... your code ...
190
+
191
+ // Dump queries
192
+ dd(DB::getQueryLog());
193
+ ```
194
+
195
+ ### Tinker
196
+
197
+ ```bash
198
+ ./artisan tinker
199
+ >>> User::where('email', 'test@example.com')->first()
200
+ >>> app(UserService::class)->someMethod()
201
+ ```
@@ -0,0 +1,164 @@
1
+ # Code Review Workflow
2
+
3
+ > Checklist for reviewing pull requests.
4
+
5
+ ## Overview
6
+
7
+ ```mermaid
8
+ flowchart LR
9
+ Read --> Security --> Performance --> Quality --> Test --> Approve
10
+ ```
11
+
12
+ ---
13
+
14
+ ## 1. Understand the Change
15
+
16
+ - [ ] Read PR description
17
+ - [ ] Understand the purpose
18
+ - [ ] Check linked issue/ticket
19
+
20
+ ---
21
+
22
+ ## 2. Security Review
23
+
24
+ > **Reference:** [/rules/security.md](../rules/security.md)
25
+
26
+ ### Must Check
27
+
28
+ | Item | Look For |
29
+ | --------------- | --------------------------------------------------- |
30
+ | Mass Assignment | Using `$request->validated()` not `$request->all()` |
31
+ | SQL Injection | No raw SQL with user input |
32
+ | `$fillable` | Defined in models, no sensitive fields |
33
+ | `$hidden` | Password and tokens hidden |
34
+ | XSS | No `{!! $userInput !!}` in Blade |
35
+
36
+ ### Code Review
37
+
38
+ ```php
39
+ // ❌ REJECT: Mass assignment vulnerability
40
+ User::create($request->all());
41
+
42
+ // ✅ APPROVE: Using validated data
43
+ User::create($request->validated());
44
+ ```
45
+
46
+ ---
47
+
48
+ ## 3. Performance Review
49
+
50
+ > **Reference:** [/rules/performance.md](../rules/performance.md)
51
+
52
+ ### Must Check
53
+
54
+ | Item | Look For |
55
+ | ------------- | -------------------------------- |
56
+ | N+1 Queries | `with()` used for relationships |
57
+ | Pagination | List endpoints use `paginate()` |
58
+ | Resources | `whenLoaded()` for relationships |
59
+ | Eager Loading | No lazy loading in loops |
60
+
61
+ ### Code Review
62
+
63
+ ```php
64
+ // ❌ REJECT: N+1 problem
65
+ $posts = Post::all();
66
+ foreach ($posts as $post) {
67
+ echo $post->author->name;
68
+ }
69
+
70
+ // ✅ APPROVE: Eager loaded
71
+ $posts = Post::with('author')->get();
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 4. Code Quality Review
77
+
78
+ ### Must Check
79
+
80
+ | Item | Look For |
81
+ | ------------- | ---------------------------------- |
82
+ | Validation | FormRequest not inline validation |
83
+ | Response | Resource not raw model |
84
+ | Route binding | `User $user` not `findOrFail($id)` |
85
+ | Dates | `->toISOString()` in Resources |
86
+ | Types | Return type hints on methods |
87
+
88
+ ### Naming
89
+
90
+ > **Reference:** [/rules/naming.md](../rules/naming.md)
91
+
92
+ | Type | Pattern |
93
+ | ---------- | ------------------------ |
94
+ | Controller | `{Model}Controller` |
95
+ | Request | `{Model}{Action}Request` |
96
+ | Resource | `{Model}Resource` |
97
+ | Test | `{Model}ControllerTest` |
98
+
99
+ ---
100
+
101
+ ## 5. Test Review
102
+
103
+ ### Must Have
104
+
105
+ | Endpoint | 正常系 | 異常系 |
106
+ | -------- | ------------------ | --------------------- |
107
+ | index | List, filter, sort | Empty, invalid params |
108
+ | store | Creates → 201 | 422 (validation) |
109
+ | show | Returns → 200 | 404 |
110
+ | update | Updates → 200 | 404, 422 |
111
+ | destroy | Deletes → 204 | 404 |
112
+
113
+ ### Test Naming
114
+
115
+ ```php
116
+ // ✅ Good naming
117
+ it('正常: creates user with valid data')
118
+ it('異常: fails to create user with invalid email')
119
+ it('異常: returns 404 when user not found')
120
+ ```
121
+
122
+ ---
123
+
124
+ ## 6. Final Checks
125
+
126
+ - [ ] All tests pass
127
+ - [ ] No debug code (`dd()`, `dump()`, `Log::debug()`)
128
+ - [ ] No commented-out code
129
+ - [ ] No console.log or debug statements
130
+ - [ ] Follows existing patterns in codebase
131
+
132
+ ---
133
+
134
+ ## Review Decision
135
+
136
+ ### ✅ Approve If
137
+
138
+ - All security checks pass
139
+ - All performance checks pass
140
+ - Tests cover 正常系 + 異常系
141
+ - Code follows conventions
142
+
143
+ ### 🔄 Request Changes If
144
+
145
+ - Security vulnerability found
146
+ - Performance issue (N+1, no pagination)
147
+ - Missing tests
148
+ - Naming/pattern violations
149
+
150
+ ### Example Comments
151
+
152
+ ```markdown
153
+ ## Security Issue
154
+ ❌ Line 45: Using `$request->all()` - please use `$request->validated()`
155
+
156
+ ## Performance Issue
157
+ ❌ Line 23: Missing `with('author')` - will cause N+1 queries
158
+
159
+ ## Missing Test
160
+ ❌ No test for 422 validation error case
161
+
162
+ ## Naming
163
+ ❌ `UserCreateRequest` should be `UserStoreRequest` (Laravel convention)
164
+ ```