create-prisma-php-app 5.0.0-alpha.14 → 5.0.0-alpha.16

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.
package/dist/AGENTS.md CHANGED
@@ -2,88 +2,76 @@
2
2
 
3
3
  # Prisma PHP AI Agent Rules
4
4
 
5
- Before generating, editing, or reviewing Prisma PHP code, read the installed Prisma PHP docs for the current project version, read the project manifest, and only inspect framework internals when the docs do not answer the task.
5
+ This repository is the Prisma PHP package and docs workspace, not a generated Prisma PHP application.
6
6
 
7
- Do not guess framework behavior from Laravel, Next.js, React, Vue, Livewire, Alpine, or generic PHP habits. The installed Prisma PHP docs and the local project configuration are the source of truth.
7
+ Treat `dist/docs/index.md` as the entry point for Prisma PHP guidance in this repo, then read the matching document in `dist/docs` before generating, editing, reviewing, or documenting framework-specific behavior.
8
8
 
9
- ## Source of truth priority
9
+ Do not guess framework behavior from Laravel, Next.js, React, Vue, Livewire, Alpine, Symfony, Socket.IO, or generic PHP habits. Prisma PHP's local docs and the current repository context are the source of truth.
10
10
 
11
- Use this order of truth when working in a Prisma PHP project:
11
+ ## Repository mode vs app mode
12
12
 
13
- 1. The user’s explicit request
14
- 2. `./prisma-php.json`
15
- 3. Installed Prisma PHP docs in `node_modules/prisma-php/dist/docs`
16
- 4. Project-local conventions and existing project files
17
- 5. Prisma PHP core internals in `vendor/tsnc/prisma-php/src`
18
- 6. General framework knowledge
19
-
20
- If a documented Prisma PHP rule conflicts with a habit from another framework, follow Prisma PHP.
13
+ There are two valid Prisma PHP contexts, and AI must not mix them up.
21
14
 
22
- ## Installed docs location
15
+ ### 1. Package/docs repo mode
23
16
 
24
- The installed Prisma PHP documentation for the active project lives in:
17
+ This workspace is package/docs repo mode.
25
18
 
26
- ```txt
27
- node_modules/prisma-php/dist/docs
28
- ```
19
+ In this repo, use this order first:
29
20
 
30
- AI agents must treat this directory as the primary documentation source for Prisma PHP behavior, routing, file conventions, features, helpers, and usage patterns for the installed version.
21
+ 1. the user's explicit request
22
+ 2. `dist/docs/index.md`
23
+ 3. the relevant document in `dist/docs`
24
+ 4. `.github/copilot-instructions.md`
25
+ 5. `package.json` and nearby repo files
26
+ 6. Prisma PHP core internals only when the docs still leave a gap
27
+ 7. general framework knowledge as the last fallback
31
28
 
32
- Before writing framework-specific code, inspect the relevant documentation files in this directory.
29
+ Important repo-mode rules:
33
30
 
34
- ## Read `prisma-php.json` first
31
+ - do not assume `./prisma-php.json` exists in this repository
32
+ - do not assume `node_modules/prisma-php/dist/docs` is the active docs location for this workspace
33
+ - do not assume `vendor/tsnc/prisma-php/src` exists locally in this workspace unless the task explicitly provides or references it
34
+ - when editing or improving Prisma PHP guidance in this repo, keep `AGENTS.md`, `.github/copilot-instructions.md`, and `dist/docs` aligned with each other
35
35
 
36
- Before generating code or making framework decisions, read:
36
+ ### 2. Consumer app mode
37
37
 
38
- ```txt
39
- ./prisma-php.json
40
- ```
38
+ When a task is about a generated Prisma PHP application rather than this package repo, use this app-mode order:
41
39
 
42
- Treat it as the capability manifest for the current app.
43
-
44
- Use it to verify whether the project has features such as:
45
-
46
- - `tailwindcss`
47
- - `backendOnly`
48
- - `swaggerDocs`
49
- - `websocket`
50
- - `mcp`
51
- - `prisma`
52
- - `typescript`
53
-
54
- Also use it to confirm environment-specific project details such as:
55
-
56
- - project root path
57
- - PHP executable path
58
- - BrowserSync target and path rewrite rules
59
- - component scan directories
60
- - excluded files
61
-
62
- Do not assume a feature is enabled unless it is present and enabled in `prisma-php.json`.
40
+ 1. the user's explicit request
41
+ 2. `./prisma-php.json`
42
+ 3. installed Prisma PHP docs in `node_modules/prisma-php/dist/docs`
43
+ 4. project-local conventions and existing app files
44
+ 5. Prisma PHP core internals in `vendor/tsnc/prisma-php/src`
45
+ 6. general framework knowledge
63
46
 
64
- ## Framework-managed generated files
47
+ If a documented Prisma PHP rule conflicts with a habit from another framework, follow Prisma PHP.
65
48
 
66
- Prisma PHP automatically generates and maintains certain framework files.
49
+ ## Source of truth in this repo
67
50
 
68
- ### `files-list.json`
51
+ The Prisma PHP docs shipped in this repository live in:
69
52
 
70
- Do **not** create, edit, reorder, or manually maintain `files-list.json`.
53
+ ```txt
54
+ dist/docs
55
+ ```
71
56
 
72
- Treat `files-list.json` as a **framework-generated file** for route discovery and internal bookkeeping. When creating, renaming, or removing routes, make the change in the actual route folders and route files under `src/app` and let Prisma PHP regenerate `files-list.json` automatically.
57
+ The current docs entry point in this repository is:
73
58
 
74
- If a route task appears to require editing `files-list.json`, that is almost certainly the wrong approach. The correct workflow is:
59
+ ```txt
60
+ dist/docs/index.md
61
+ ```
75
62
 
76
- 1. create or update the route folder/file in `src/app`
77
- 2. do **not** touch `files-list.json`
78
- 3. let Prisma PHP regenerate framework-managed route metadata
63
+ When updating AI guidance for Prisma PHP itself, treat `dist/docs` as the authoritative local documentation surface for this workspace.
79
64
 
80
65
  ## Required doc-routing map
81
66
 
82
- Before generating code, choose the documentation file based on the task.
67
+ Before generating code, examples, instructions, or reviews, choose the documentation file based on the task.
83
68
 
84
69
  ### Read these docs first for these tasks
85
70
 
86
- - **Project setup, folder placement, route file choice, or overall file conventions**
71
+ - **Framework orientation, repo-wide guidance, or the high-level AI quick start**
72
+ Read `index.md`
73
+
74
+ - **Project setup, folder placement, route file choice, feature placement, or overall file conventions**
87
75
  Read `project-structure.md`
88
76
 
89
77
  - **Creating a page, layout, nested route, dynamic route, or normal UI route**
@@ -92,14 +80,29 @@ Before generating code, choose the documentation file based on the task.
92
80
  - **Creating, editing, composing, or reviewing PHPX components, props, children, fragments, icons, buttons, accordions, or component file placement**
93
81
  Read `components.md`
94
82
 
95
- - **File uploads, `multipart/form-data`, `$_FILES`, `PP\FileManager\UploadFile`, rename flows, delete flows, allowed file types, upload size rules, or file manager UI behavior**
96
- Read `file-manager.md`, then verify the official File Manager docs at `vendor/tsnc/prisma-php/src/FileManager/UploadFile.php`
83
+ - **Loading data, calling backend logic from the frontend, `pp.fetchFunction(...)`, `#[Exposed]`, route-local mutations, streaming responses, or interactive backend validation**
84
+ Read `fetching-data.md`
97
85
 
98
- - **Authentication strategy, `AuthConfig.php`, route privacy model, sign-in, sign-out, JWT session lifecycle, `refreshUserSession`, RBAC, credentials auth, OAuth, social login, or auth state manager usage**
99
- Read `authentication.md`, then verify the matching official docs in this order: `auth-get-started`, `credentials`, and `state-manager-auth`
86
+ - **PulsePoint runtime behavior such as `pp.state`, `pp.effect`, `pp-for`, `pp-spread`, or `pp-ref`**
87
+ Read `pulsepoint.md`
100
88
 
101
- - **Loading data, calling backend logic from the frontend, `pp.fetchFunction(...)`, `#[Exposed]`, or interactive backend validation**
102
- Read `fetching-data.md`
89
+ - **Validation, sanitization, `PP\Validator`, `PP\Rule`, field validation, form validation, live validation, or request validation rules**
90
+ Read `validator.md`, then apply the relevant local guidance from `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
91
+
92
+ - **File uploads, `multipart/form-data`, `$_FILES`, `PP\FileManager\UploadFile`, rename flows, replace flows, delete flows, allowed file types, upload size rules, or file manager UI behavior**
93
+ Read `file-manager.md`, then verify the official File Manager docs and, when internals matter, the core upload file at `vendor/tsnc/prisma-php/src/FileManager/UploadFile.php`
94
+
95
+ - **SMTP setup, `.env` mail variables, `PP\PHPMailer\Mailer`, HTML bodies, plain-text bodies, recipients, reply-to, CC, BCC, or attachments**
96
+ Read `email.md`, then verify the official email docs at `email-get-started`
97
+
98
+ - **Ratchet websocket setup, `IoServer`, `HttpServer`, `WsServer`, `ConnectionManager`, browser `WebSocket`, or realtime route behavior**
99
+ Read `websocket.md`, then verify the official websocket docs in this order: `websocket-get-started`, `websocket-chat-app`
100
+
101
+ - **MCP support, `#[McpTool]`, `#[Schema]`, `PhpMcp\Server\Server`, `StreamableHttpServerTransport`, AI tool endpoints, or `src/Lib/MCP/mcp-server.php`**
102
+ Read `mcp.md`, then verify the official MCP docs in this order: `prisma-php-ai-mcp`, `ai-tools`
103
+
104
+ - **Authentication strategy, `AuthConfig.php`, route privacy model, sign-in, sign-out, JWT session lifecycle, `refreshUserSession`, RBAC, credentials auth, OAuth, social login, or auth state manager usage**
105
+ Read `authentication.md`, then verify the matching official docs in this order: `auth-get-started`, `credentials`, `state-manager-auth`
103
106
 
104
107
  - **Cache behavior, route caching, invalidation, or `CacheHandler`**
105
108
  Read `caching.md`
@@ -110,38 +113,67 @@ Before generating code, choose the documentation file based on the task.
110
113
  - **Expected errors, uncaught exceptions, `error.php`, `not-found.php`, `ErrorHandler`, or validation failures as expected errors**
111
114
  Read `error-handling.md`
112
115
 
113
- - **Metadata, title, description, head scripts, favicon, icon, or `MainLayout` metadata behavior**
116
+ - **Metadata, title, description, custom head tags, favicon, icon, apple icon, or `MainLayout` metadata behavior**
114
117
  Read `metadata-and-og-images.md`
115
118
 
116
- - **API-style routes, JSON responses, handlers, form-processing endpoints, `route.php`, or request validation in handlers**
119
+ - **API-style routes, JSON responses, handlers, webhooks, form-processing endpoints, `route.php`, or request validation in handlers**
117
120
  Read `route-handlers.md`
118
121
 
119
- - **PulsePoint runtime behavior such as `pp.state`, `pp.effect`, `pp.ref`, `pp-for`, `pp-spread`, or `pp-ref`**
120
- Read `pulsepoint.md`
121
-
122
- - **Sanitization, `PP\Validator`, `PP\Rule`, field validation, form validation, live validation, or backend validation rules**
123
- Read `validator.md`, then apply the relevant local guidance from `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
124
-
125
122
  - **Upgrading Prisma PHP, enabling features, syncing framework-managed project files, or running project updates**
126
123
  Read `upgrading.md`
127
124
 
128
125
  - **First-time project installation or app creation flow**
129
126
  Read `installation.md`
130
127
 
131
- - **General doc entry point and framework orientation**
132
- Read `index.md`
128
+ ## Docs inventory in this repo
129
+
130
+ The current Prisma PHP docs shipped here include:
131
+
132
+ - `authentication.md`
133
+ - `caching.md`
134
+ - `components.md`
135
+ - `email.md`
136
+ - `error-handling.md`
137
+ - `fetching-data.md`
138
+ - `file-manager.md`
139
+ - `index.md`
140
+ - `installation.md`
141
+ - `layouts-and-pages.md`
142
+ - `mcp.md`
143
+ - `metadata-and-og-images.md`
144
+ - `prisma-php-orm.md`
145
+ - `project-structure.md`
146
+ - `pulsepoint.md`
147
+ - `route-handlers.md`
148
+ - `upgrading.md`
149
+ - `validator.md`
150
+ - `websocket.md`
133
151
 
134
- ## Default interactive UI and fetching rule
152
+ When adding or reviewing AI guidance, do not stop at older docs only. Make sure the guidance also covers `email.md`, `mcp.md`, and `websocket.md`, plus newer behavior documented in `fetching-data.md` and `metadata-and-og-images.md`.
135
153
 
136
- For normal full-stack Prisma PHP work, assume the user wants the **PulsePoint-first** approach unless they explicitly ask otherwise.
154
+ ## Framework-generated files
155
+
156
+ Prisma PHP automatically generates and maintains certain framework files in consumer apps.
157
+
158
+ ### `files-list.json`
159
+
160
+ Do **not** create, edit, reorder, or manually maintain `files-list.json`.
161
+
162
+ Treat `files-list.json` as a framework-generated file for route discovery and internal bookkeeping. When creating, renaming, or removing routes in a Prisma PHP app, make the change in the actual route folders and route files under `src/app` and let Prisma PHP regenerate `files-list.json` automatically.
163
+
164
+ If a route task appears to require editing `files-list.json`, that is almost certainly the wrong approach.
165
+
166
+ ## Default interactive UI and data-flow rule
167
+
168
+ For normal full-stack Prisma PHP work, assume the user wants the PulsePoint-first approach unless they explicitly ask otherwise.
137
169
 
138
170
  Default interaction stack:
139
171
 
140
172
  1. render route UI with `index.php`
141
- 2. keep browser-side interactivity in **PulsePoint**
142
- 3. call backend PHP from the frontend with **`pp.fetchFunction(...)`**
143
- 4. mark callable PHP functions or methods with **`#[Exposed]`**
144
- 5. validate and normalize input on the PHP side with **`PP\Validator`**
173
+ 2. keep browser-side interactivity in PulsePoint
174
+ 3. call backend PHP from the frontend with `pp.fetchFunction(...)`
175
+ 4. mark callable PHP functions or methods with `#[Exposed]`
176
+ 5. validate and normalize input on the PHP side with `PP\Validator`
145
177
 
146
178
  Treat this as the default for:
147
179
 
@@ -154,6 +186,8 @@ Treat this as the default for:
154
186
  - inline validation
155
187
  - route-local CRUD actions
156
188
  - dashboard interactions
189
+ - streaming assistants
190
+ - progress logs
157
191
  - similar reactive page behavior
158
192
 
159
193
  Do **not** default to:
@@ -161,10 +195,11 @@ Do **not** default to:
161
195
  - a PHP-only interaction style
162
196
  - ad hoc `fetch('/api/...')` patterns
163
197
  - extra `route.php` files for page-local interactions that already fit `pp.fetchFunction(...)`
198
+ - a separate Node realtime or tool server when the documented Prisma PHP runtime already fits the task
164
199
 
165
- Choose a more PHP-only pattern only when:
200
+ Choose a more PHP-only or handler-only pattern only when:
166
201
 
167
- - the user explicitly asks for PHP-only behavior
202
+ - the user explicitly asks for it
168
203
  - the task is clearly non-reactive
169
204
  - the task is a standalone API, webhook, integration endpoint, or public JSON handler
170
205
 
@@ -176,20 +211,30 @@ There are two related structure rules, and AI must not mix their responsibilitie
176
211
 
177
212
  Use this pattern:
178
213
 
179
- 1. PHP
214
+ 1. PHP first
180
215
  2. one parent HTML element for the route content
181
- 3. when PulsePoint is present, keep one `<script>` block as the last child inside that same root element
216
+ 3. when PulsePoint is present, put `pp-component` on that route root
217
+ 4. keep one `<script>` block as the last child inside that same root element
218
+
219
+ Also follow these route-file rules:
220
+
221
+ - `index.php` and nested `layout.php` must render a single parent HTML element
222
+ - only the root `layout.php` should define `<html>`, `<head>`, and `<body>`
223
+ - when PulsePoint is present in a root `layout.php`, keep `MainLayout::$children` and any `<script>` inside one clear wrapper
182
224
 
183
225
  Example:
184
226
 
185
227
  ```php
186
228
  <?php
187
229
 
188
- // PHP Code
230
+ use PP\MainLayout;
231
+
232
+ MainLayout::$title = 'Todos';
233
+ MainLayout::$description = 'Track tasks and view the current item count.';
189
234
  ?>
190
235
 
191
- <section pp-component="dashboard-page">
192
- <h1>Dashboard</h1>
236
+ <section pp-component="todos-page">
237
+ <h1>Todos</h1>
193
238
  <p>Count: {count}</p>
194
239
  <script>
195
240
  const [count, setCount] = pp.state(0);
@@ -201,15 +246,18 @@ Example:
201
246
 
202
247
  Use this pattern:
203
248
 
204
- 1. PHP
249
+ 1. PHP first
205
250
  2. exactly one parent root element
206
- 3. keep any component-local `<script>` inside that root element, and let Prisma PHP inject `pp-component` for that boundary
251
+ 3. keep any component-local `<script>` inside that root element
252
+ 4. let Prisma PHP inject `pp-component` for that boundary automatically
207
253
 
208
254
  Example:
209
255
 
210
256
  ```php
211
257
  <?php
212
- // PHP Code
258
+
259
+ // PHP code
260
+
213
261
  ?>
214
262
 
215
263
  <div>
@@ -227,40 +275,91 @@ Do not:
227
275
  - manually add `pp-component` inside imported partial source
228
276
  - assume `ImportComponent` injects `pp-component` for normal route files
229
277
 
230
- ## Default workflow for AI agents
278
+ ## Metadata rules
279
+
280
+ For document metadata, prefer `MainLayout::$title` and `MainLayout::$description`.
281
+
282
+ Important metadata rules:
231
283
 
232
- Use this workflow unless the user asks for something narrower:
284
+ - a local `$title` variable only affects rendered page content unless you also assign metadata through `MainLayout`
285
+ - use `MainLayout::addCustomMetaData(...)` for additional `<meta>` values when needed
286
+ - keep visible headings separate from document metadata when the UI text and SEO title must differ
287
+ - read `metadata-and-og-images.md` or `layouts-and-pages.md` before inventing Next.js-style metadata exports or Open Graph image workflows
233
288
 
234
- 1. Read `./prisma-php.json`
235
- 2. Read the relevant installed doc from `node_modules/prisma-php/dist/docs`
236
- 3. Inspect nearby project files that match the route, feature, or component being changed
237
- 4. If the task is component-related, read `components.md` before generating PHPX component code
238
- 5. If the task is upload- or file-manager-related, read `file-manager.md` before generating upload, rename, delete, or file-listing code
239
- 6. Generate code using Prisma PHP conventions
240
- 7. Inspect `vendor/tsnc/prisma-php/src` only if framework internals are required
289
+ ## Streaming and SSE rules
241
290
 
242
- Do not jump directly into framework internals if the installed docs already answer the task.
291
+ Prisma PHP supports streaming through `pp.fetchFunction(...)` when an exposed function yields values.
292
+
293
+ Default streaming rules:
294
+
295
+ - prefer an exposed generator that simply yields strings or arrays
296
+ - let Prisma PHP handle the SSE response automatically for normal `pp.fetchFunction(...)` streaming
297
+ - on the client, put stream UI updates in `onStream`, `onStreamError`, and `onStreamComplete`
298
+ - do not wait for a final JSON payload when the response is streamed
299
+
300
+ Current parsing rules AI should know:
301
+
302
+ - Prisma PHP sends streamed payloads as SSE `data:` lines
303
+ - the built-in `pp.fetchFunction(...)` stream parser currently forwards only `data:` lines to `onStream`
304
+ - `event:`, `id:`, and `retry:` may be emitted by low-level SSE helpers, but the built-in stream callback currently ignores them
305
+ - prefer JSON values or single-line strings for streamed chunks instead of multi-line text blobs
306
+
307
+ Low-level helpers exist when manual SSE control is required:
308
+
309
+ - `PP\Streaming\SSE`
310
+ - `PP\Streaming\ServerSentEvent`
311
+
312
+ Core locations documented for those helpers are:
313
+
314
+ ```txt
315
+ vendor/tsnc/prisma-php/src/SSE.php
316
+ vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
317
+ ```
243
318
 
244
319
  ## Route file decision rules
245
320
 
246
321
  When the task is about creating or editing a route, do not guess.
247
322
 
248
- Important: creating a route means creating or updating the correct folder and route file under `src/app`. It does **not** mean editing generated route metadata. In particular, never update `files-list.json` by hand.
323
+ Important: creating a route means creating or updating the correct folder and route file under `src/app`. It does **not** mean editing generated route metadata.
249
324
 
250
- - Use `index.php` for rendered UI and normal page routes, and default to PulsePoint plus `pp.fetchFunction(...)` for interactive behavior inside those routes unless the user explicitly asks for PHP-only behavior
251
- - Use `layout.php` for shared UI that wraps route subtrees
252
- - Use `route.php` for direct handlers such as JSON endpoints, API-style routes, AJAX handlers, form-processing endpoints, webhooks, or other no-view server logic; do not default to `route.php` for normal route-local interactions that fit PulsePoint plus `pp.fetchFunction(...)`
253
- - Use `not-found.php` for route-specific not-found UI
254
- - Use `error.php` for route or app-level error UI
325
+ - use `index.php` for rendered UI and normal page routes
326
+ - use `layout.php` for shared UI that wraps route subtrees
327
+ - use `route.php` for direct handlers such as JSON endpoints, API-style routes, AJAX handlers, form-processing endpoints, and webhooks
328
+ - use `not-found.php` for route-specific not-found UI
329
+ - use `error.php` for route or app-level error UI
330
+ - use `loading.php` when the task is specifically about a loading UI state for a route subtree
255
331
 
256
- Also verify `backendOnly` in `prisma-php.json`:
332
+ For normal route-local interactivity, prefer `index.php` plus PulsePoint and `pp.fetchFunction(...)` over inventing extra handlers.
333
+
334
+ In a consumer app, also verify `backendOnly` in `prisma-php.json`:
257
335
 
258
336
  - if `backendOnly` is `false`, normal routes should usually be implemented with `index.php`
259
337
  - if `backendOnly` is `true`, route behavior will usually center on `route.php`
260
338
 
339
+ ## Default workflow for AI agents
340
+
341
+ Use this workflow unless the user asks for something narrower.
342
+
343
+ ### For this repository
344
+
345
+ 1. read `dist/docs/index.md`
346
+ 2. read the relevant document in `dist/docs`
347
+ 3. inspect nearby docs, examples, and guidance files in this repo
348
+ 4. keep `AGENTS.md` and `.github/copilot-instructions.md` aligned with the documented behavior
349
+ 5. inspect framework internals only when the docs still leave a real gap
350
+
351
+ ### For consumer app examples or generated-app tasks
352
+
353
+ 1. read `./prisma-php.json`
354
+ 2. read the relevant installed doc from `node_modules/prisma-php/dist/docs`
355
+ 3. inspect nearby project files that match the route, feature, or component being changed
356
+ 4. inspect `vendor/tsnc/prisma-php/src` only if the docs do not answer the task
357
+
358
+ Do not jump directly into framework internals if the current docs already answer the task.
359
+
261
360
  ## Authentication rules
262
361
 
263
- When the task involves auth, do not guess from Laravel, NextAuth, generic JWT packages, or ad hoc middleware habits.
362
+ When the task involves auth, do not guess from Laravel, generic JWT packages, or ad hoc middleware habits.
264
363
 
265
364
  Use this auth decision flow:
266
365
 
@@ -269,7 +368,7 @@ Use this auth decision flow:
269
368
  3. inspect `src/Lib/Auth/AuthConfig.php` when present
270
369
  4. inspect the current auth-related routes under `src/app`
271
370
  5. inspect Prisma models that support auth before generating registration, login, or provider code
272
- 6. keep route protection, function protection, and session lifecycle aligned with Prisma PHPs documented auth model
371
+ 6. keep route protection, function protection, and session lifecycle aligned with Prisma PHP's documented auth model
273
372
 
274
373
  Important auth rules:
275
374
 
@@ -304,7 +403,82 @@ Important file-manager rules:
304
403
  - do **not** place uploaded files inside `src/app`
305
404
  - do **not** assume HTML size hints replace `php.ini` upload limits
306
405
  - do **not** invent undocumented storage abstractions when `UploadFile` already fits the task
307
- - for upload, rename, replace, delete, and file-listing tasks, read `file-manager.md` first
406
+
407
+ ## Email rules
408
+
409
+ When the task involves email, read `email.md` first.
410
+
411
+ Prisma PHP email follows the documented `PP\PHPMailer\Mailer` model backed by PHPMailer. Do not replace it with raw `mail()`, undocumented wrappers, or habits copied from another mail framework.
412
+
413
+ Use this email workflow:
414
+
415
+ 1. read `email.md`
416
+ 2. inspect `.env` for SMTP and sender values in the target app
417
+ 3. inspect the route, exposed function, or handler that sends the email
418
+ 4. inspect the HTML body or attachment source when present
419
+ 5. inspect framework internals only when the docs and current app code still leave a gap
420
+
421
+ The documented core mailer file is:
422
+
423
+ ```txt
424
+ vendor/tsnc/prisma-php/src/PHPMailer/Mailer.php
425
+ ```
426
+
427
+ Important email rules:
428
+
429
+ - keep SMTP credentials and sender defaults in `.env`, not in route files
430
+ - the documented env vars are `SMTP_HOST`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_ENCRYPTION`, `SMTP_PORT`, `MAIL_FROM`, and `MAIL_FROM_NAME`
431
+ - validate user-provided email fields before calling the mailer
432
+ - prefer the documented fluent API such as `to(...)`, `subject(...)`, `html(...)`, `text(...)`, `attach(...)`, and `send()`
433
+ - use `raw()` only when low-level PHPMailer access is genuinely needed
434
+
435
+ ## WebSocket rules
436
+
437
+ When the task involves realtime messaging, presence, live dashboards, `Ratchet`, or browser `WebSocket`, read `websocket.md` first.
438
+
439
+ Prisma PHP websocket support follows a Ratchet-based PHP server plus a `ConnectionManager` under `src/Lib/Websocket`. Do not replace that default with Socket.IO, a separate Node server, or an unrelated hosted realtime service unless the user explicitly asks for a different architecture.
440
+
441
+ Use this websocket workflow:
442
+
443
+ 1. read `websocket.md`
444
+ 2. inspect whether websocket support is enabled in `prisma-php.json` in the target app
445
+ 3. inspect `src/Lib/Websocket`
446
+ 4. inspect the route or client script that opens the browser `WebSocket`
447
+ 5. inspect `settings/restart-websocket.ts` when local restart behavior matters
448
+ 6. inspect framework internals only when the docs do not answer the task
449
+
450
+ Important websocket rules:
451
+
452
+ - use `src/Lib/Websocket/websocket-server.php` as the source of truth for startup behavior
453
+ - use `src/Lib/Websocket/ConnectionManager.php` as the lifecycle boundary for clients and broadcasts
454
+ - preserve documented env vars and defaults: `WS_NAME`, `WS_VERSION`, `WS_HOST`, `WS_PORT`, `WS_VERBOSE`, `APP_TIMEZONE`
455
+ - preserve CLI overrides through `--host=...`, `--port=...`, and `--verbose=...`
456
+ - preserve the documented casing `src/Lib/Websocket`
457
+ - for existing apps, enable `websocket` in `prisma-php.json` and run `npx pp update project -y` before inventing manual scaffolding
458
+
459
+ ## MCP rules
460
+
461
+ When the task involves Model Context Protocol support, read `mcp.md` first.
462
+
463
+ Prisma PHP MCP support follows the documented `PhpMcp\Server` model with attribute-based tool discovery. Do not replace it with custom REST endpoints pretending to be MCP, hand-rolled JSON-RPC parsing, or unrelated agent abstractions when the documented Prisma PHP stack already fits the task.
464
+
465
+ Use this MCP workflow:
466
+
467
+ 1. read `mcp.md`
468
+ 2. inspect whether MCP support is enabled in `prisma-php.json` in the target app
469
+ 3. inspect `src/Lib/MCP`
470
+ 4. inspect tool classes and the services they call
471
+ 5. inspect auth, ORM, and env configuration when tools read protected or database-backed data
472
+ 6. inspect framework internals only when the docs do not answer the task
473
+
474
+ Important MCP rules:
475
+
476
+ - use `src/Lib/MCP/mcp-server.php` as the source of truth for startup behavior
477
+ - preserve attribute-based discovery with `#[McpTool]` and `#[Schema]`
478
+ - preserve the documented discovery model built around scanning the source tree instead of manually wiring every tool class by default
479
+ - preserve the documented casing `src/Lib/MCP`
480
+ - preserve documented env vars and defaults: `MCP_NAME`, `MCP_VERSION`, `MCP_HOST`, `MCP_PORT`, `MCP_PATH_PREFIX`, `MCP_JSON_RESPONSE`, `APP_TIMEZONE`
481
+ - for existing apps, enable `mcp` in `prisma-php.json` and run `npx pp update project -y` before inventing manual scaffolding
308
482
 
309
483
  ## Prisma ORM workflow rules
310
484
 
@@ -321,29 +495,33 @@ Use this ORM decision flow:
321
495
  7. after schema synchronization, run `npx ppo generate`
322
496
  8. only then write or update PHP code that depends on the generated Prisma classes
323
497
 
324
- Important rules:
498
+ Important ORM rules:
325
499
 
326
500
  - do **not** use `npx pp update project -y` as the normal fix for Prisma ORM schema changes
327
501
  - use `npx prisma migrate dev` for the normal development migration workflow
328
502
  - use `npx prisma migrate deploy` for production or CI/CD migration application
329
503
  - use `npx prisma db push` only for explicit prototyping or no-migration database sync
330
504
  - do **not** treat `npx ppo generate` as a migration step
331
- - `npx ppo generate` should run the first time generated PHP ORM classes are needed and whenever `schema.prisma` changes
332
- - if the task mentions Prisma ORM, `schema.prisma`, migrations, generated classes, SQLite, MySQL, or PostgreSQL, read `prisma-php-orm.md` first
333
505
 
334
506
  ## Validation rules
335
507
 
336
- When a task involves user input, form handling, search params, JSON payloads, `pp.fetchFunction(...)`, or `route.php` bodies, do not trust raw values.
508
+ When a task involves user input, form handling, search params, JSON payloads, `pp.fetchFunction(...)`, `route.php` bodies, or tool parameters, do not trust raw values.
337
509
 
338
510
  Default Prisma PHP validation rules:
339
511
 
340
- - use **`PP\Validator`** as the backend validation and normalization layer
341
- - prefer the **`Rule` builder** for rule-based validation
512
+ - use `PP\Validator` as the backend validation and normalization layer
513
+ - prefer the `Rule` builder for rule-based validation
342
514
  - validate in PHP even when the frontend already performs local checks
343
515
  - return structured validation results for expected failures
344
516
  - do not treat routine invalid input as an uncaught exception
345
517
  - in reactive flows, use PulsePoint for local state and `Validator` for authoritative server validation
346
518
 
519
+ When internals matter, the documented Prisma PHP core validator location is:
520
+
521
+ ```txt
522
+ vendor/tsnc/prisma-php/src/Validator.php
523
+ ```
524
+
347
525
  ## PulsePoint rules
348
526
 
349
527
  When a task involves reactive frontend behavior, read `pulsepoint.md` first.
@@ -355,18 +533,6 @@ Also follow these rules:
355
533
  - keep backend concerns separate from PulsePoint runtime concerns
356
534
  - prefer simple documented runtime primitives over abstractions copied from other ecosystems
357
535
 
358
- ## Reactive frontend + server-call rule
359
-
360
- For frontend interactivity in Prisma PHP, prefer the documented Prisma PHP pattern:
361
-
362
- - use **PulsePoint** for reactive browser state and UI behavior
363
- - use **`pp.fetchFunction(...)`** for page-local or component-local server calls
364
- - expose callable PHP functions with **`#[Exposed]`**
365
-
366
- Do not default to handcrafted `fetch('/api/...')` calls, ad hoc AJAX endpoints, or extra `route.php` files when the task is a normal reactive UI interaction that fits `pp.fetchFunction(...)`.
367
-
368
- Use `route.php` when the user explicitly needs an API-style endpoint, webhook, JSON route, or handler that should exist independently of the current page.
369
-
370
536
  ## Component rules
371
537
 
372
538
  When the task involves Prisma PHPX components, reusable UI elements, props, children, fragments, icons, buttons, accordions, or component composition, read `components.md` first.
@@ -377,7 +543,6 @@ Also follow these rules:
377
543
  - keep component file names and class names aligned
378
544
  - preserve documented PHPX patterns for `$props`, `$children`, `$class`, and `getAttributes(...)`
379
545
  - follow documented component placement and grouping conventions before inspecting framework internals
380
- - use `vendor/tsnc/prisma-php/src` only when the installed docs and `components.md` do not answer the task
381
546
 
382
547
  ## Prisma PHP XML syntax rules
383
548
 
@@ -444,24 +609,30 @@ Do not output permissive HTML shorthand in Prisma PHP UI files.
444
609
 
445
610
  ## When to inspect framework internals
446
611
 
447
- Prisma PHP core Composer package files live in:
612
+ Inspect framework internals only when the docs and current files do not answer the task.
613
+
614
+ Useful app-mode core locations include:
448
615
 
449
616
  ```txt
450
617
  vendor/tsnc/prisma-php/src
618
+ vendor/tsnc/prisma-php/src/PHPMailer/Mailer.php
619
+ vendor/tsnc/prisma-php/src/FileManager/UploadFile.php
620
+ vendor/tsnc/prisma-php/src/Validator.php
621
+ vendor/tsnc/prisma-php/src/SSE.php
622
+ vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
451
623
  ```
452
624
 
453
- Inspect this directory only when the task depends on framework internals not already answered by the installed docs.
454
-
455
- Use it when the task involves:
625
+ Use framework internals when the task involves:
456
626
 
457
627
  - confirming namespaces, classes, or helper names
458
628
  - understanding how a core class behaves internally
459
- - verifying available attributes such as `#[Exposed]`
629
+ - verifying available attributes such as `#[Exposed]`, `#[McpTool]`, or `#[Schema]`
460
630
  - checking PHPX compiler or template compiler behavior
461
631
  - tracing PulsePoint integration points inside Prisma PHP
462
- - debugging framework-level issues that are not explained by the docs
632
+ - confirming mailer, SSE, websocket, or MCP runtime behavior not already clear from the docs
633
+ - debugging framework-level issues that are not explained by the current docs
463
634
 
464
- For ordinary app work, prefer the installed docs and local project files first.
635
+ For ordinary app or docs work, prefer the current docs and local project files first.
465
636
 
466
637
  ## Upgrade and feature-enable workflow
467
638
 
@@ -469,20 +640,16 @@ If the task involves enabling a feature, syncing framework-managed files, or upd
469
640
 
470
641
  Important rules:
471
642
 
472
- - update `prisma-php.json` before assuming a feature is active
643
+ - update `prisma-php.json` before assuming a feature is active in a consumer app
473
644
  - do not assume Tailwind, Prisma, Swagger, WebSocket, MCP, or TypeScript support is enabled unless `prisma-php.json` says so
474
645
  - after changing feature flags, follow the documented project update flow
475
- - for AI-driven or scripted updates, prefer:
476
-
477
- ```bash
478
- npx pp update project -y
479
- ```
646
+ - for AI-driven or scripted updates, prefer `npx pp update project -y`
480
647
 
481
- This command is for project updates and framework-managed file refreshes. It is not the default ORM migration command.
648
+ That command is for project updates and framework-managed file refreshes. It is not the default ORM migration command.
482
649
 
483
650
  ## Final operating rule
484
651
 
485
- When Prisma PHP behavior is documented locally, read the relevant installed doc first and follow it.
652
+ When Prisma PHP behavior is documented locally, read the relevant current doc first and follow it.
486
653
 
487
654
  Do not guess.
488
655