create-prisma-php-app 5.0.0-alpha.3 → 5.0.0-alpha.31

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,104 +2,116 @@
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 AGENTS.md belongs in the root of a 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 `./node_modules/prisma-php/dist/docs/index.md` as the entry point for Prisma PHP guidance, then read the matching document in `./node_modules/prisma-php/dist/docs` before generating, editing, reviewing, or documenting framework-specific behavior.
8
8
 
9
- ## Source of truth priority
9
+ Treat the installed docs as framework knowledge. They explain what Prisma PHP can do and how to do it. Do not treat the presence of a page in `./node_modules/prisma-php/dist/docs` as proof that the current app has that feature enabled.
10
10
 
11
- Use this order of truth when working in a Prisma PHP project:
11
+ Do not guess framework behavior from Laravel, Next.js, React, Vue, Livewire, Alpine, Symfony, Socket.IO, or generic PHP habits. Prisma PHP's installed docs in `./node_modules/prisma-php/dist/docs` and the current project files are the source of truth.
12
12
 
13
- 1. The user’s explicit request
13
+ ## Documentation source of truth
14
+
15
+ For Prisma PHP projects, use this order first:
16
+
17
+ 1. the user's explicit request
14
18
  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
+ 3. the relevant installed document in `./node_modules/prisma-php/dist/docs`
20
+ 4. `./AGENTS.md`
21
+ 5. project-local conventions and existing app files
22
+ 6. Prisma PHP core internals in `vendor/tsnc/prisma-php/src` only when the docs still leave a gap
23
+ 7. general framework knowledge as the last fallback
19
24
 
20
- If a documented Prisma PHP rule conflicts with a habit from another framework, follow Prisma PHP.
25
+ Important rules:
26
+
27
+ - use `./prisma-php.json` as the single source of truth for current-project feature flags and framework-managed scaffolds
28
+ - treat `./node_modules/prisma-php/dist/docs` as the single documentation source of truth for the installed Prisma PHP version
29
+ - treat the docs inventory as a framework reference set for AI routing, not as a statement that every optional Prisma PHP feature is enabled in the current app
30
+ - expect `./AGENTS.md` at the project root
31
+ - when the installed docs and a habit from another framework conflict, follow Prisma PHP
32
+ - when updating Prisma PHP package/docs sources, keep `AGENTS.md` and `dist/docs` aligned for consumer apps; if the Prisma PHP package source repo also maintains `.github/copilot-instructions.md`, keep that source-repo file aligned there too
21
33
 
22
34
  ## Installed docs location
23
35
 
24
- The installed Prisma PHP documentation for the active project lives in:
36
+ In Prisma PHP applications, the installed docs live in:
25
37
 
26
38
  ```txt
27
39
  node_modules/prisma-php/dist/docs
28
40
  ```
29
41
 
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.
31
-
32
- Before writing framework-specific code, inspect the relevant documentation files in this directory.
42
+ The current docs entry point for the installed version is:
33
43
 
34
- ## Read `prisma-php.json` first
44
+ ```txt
45
+ node_modules/prisma-php/dist/docs/index.md
46
+ ```
35
47
 
36
- Before generating code or making framework decisions, read:
48
+ The project root should also include:
37
49
 
38
50
  ```txt
39
- ./prisma-php.json
51
+ AGENTS.md
40
52
  ```
41
53
 
42
- Treat it as the capability manifest for the current app.
54
+ ## Required doc-routing map
43
55
 
44
- Use it to verify whether the project has features such as:
56
+ Before generating code, examples, instructions, or reviews, choose the documentation file based on the task.
45
57
 
46
- - `tailwindcss`
47
- - `backendOnly`
48
- - `swaggerDocs`
49
- - `websocket`
50
- - `mcp`
51
- - `prisma`
52
- - `typescript`
58
+ Use the docs router to learn how Prisma PHP implements a task. Use `./prisma-php.json` to decide whether the current app enables the relevant optional feature.
53
59
 
54
- Also use it to confirm environment-specific project details such as:
60
+ ### Read these docs first for these tasks
55
61
 
56
- - project root path
57
- - PHP executable path
58
- - BrowserSync target and path rewrite rules
59
- - component scan directories
60
- - excluded files
62
+ - **Framework orientation, repo-wide guidance, or the high-level AI quick start**
63
+ Read `index.md`
61
64
 
62
- Do not assume a feature is enabled unless it is present and enabled in `prisma-php.json`.
65
+ - **Project setup, folder placement, route file choice, feature placement, or overall file conventions**
66
+ Read `project-structure.md`
63
67
 
64
- ## Framework-managed generated files
68
+ - **CLI project creation, starter kits, feature flags, or `npx pp update project` usage**
69
+ Read `commands.md`
65
70
 
66
- Prisma PHP automatically generates and maintains certain framework files.
71
+ - **Backend-only Prisma PHP usage, API-first projects, `backendOnly`, separate frontend consumers, or CORS setup for API routes**
72
+ Read `backend-only.md`
67
73
 
68
- ### `files-list.json`
74
+ - **Creating a page, layout, nested route, dynamic route, or normal UI route**
75
+ Read `layouts-and-pages.md`
69
76
 
70
- Do **not** create, edit, reorder, or manually maintain `files-list.json`.
77
+ - **Creating, editing, composing, or reviewing PHPX components, props, children, fragments, icons, buttons, accordions, or component file placement**
78
+ Read `components.md`
71
79
 
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.
80
+ - **TypeScript frontend tooling, the `typescript` feature flag, the root `ts/` directory, `ts/main.ts`, npm packages, or registered browser helpers used from template expressions and PulsePoint scripts**
81
+ Read `typescript.md`, then use `pulsepoint.md`, `layouts-and-pages.md`, or `components.md` for the affected component boundary
73
82
 
74
- If a route task appears to require editing `files-list.json`, that is almost certainly the wrong approach. The correct workflow is:
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`
75
85
 
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
86
+ - **AI integration, provider SDKs, chat UIs, streamed assistant output, or deciding between page-local assistant UI, websocket, and MCP tools**
87
+ Read `get-started-ia.md`, then use `fetching-data.md`, `validator.md`, `websocket.md`, or `mcp.md` as needed
79
88
 
80
- ## Required doc-routing map
89
+ - **PulsePoint runtime behavior such as `pp.state`, `pp.effect`, `pp-for`, `pp-spread`, or `pp-ref`**
90
+ Read `pulsepoint.md`
81
91
 
82
- Before generating code, choose the documentation file based on the task.
92
+ - **Validation, sanitization, `PP\Validator`, `PP\Rule`, field validation, form validation, live validation, or request validation rules**
93
+ Read `validator.md`, then apply the relevant local guidance from `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
83
94
 
84
- ### Read these docs first for these tasks
95
+ - **Environment variables, `.env`, `PP\Env`, `Env::get`, `Env::string`, `Env::bool`, `Env::int`, feature flags, host and port config, or runtime bootstrap settings**
96
+ Read `env.md`, then verify the official env docs at `env` and `env-file`
85
97
 
86
- - **Project setup, folder placement, route file choice, or overall file conventions**
87
- Read `project-structure.md`
98
+ - **Bootstrap flow, request initialization, `FUNCTION_CALL_SECRET`, `prisma_php_csrf`, `pp_local_store_key`, route resolution, or runtime init order**
99
+ Read `bootstrap-runtime.md`, then use `env.md`, `fetching-data.md`, or `error-handling.md` as needed
88
100
 
89
- - **Creating a page, layout, nested route, dynamic route, or normal UI route**
90
- Read `layouts-and-pages.md`
101
+ - **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**
102
+ 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`
91
103
 
92
- - **Creating, editing, composing, or reviewing PHPX components, props, children, fragments, icons, buttons, accordions, or component file placement**
93
- Read `components.md`
104
+ - **SMTP setup, `.env` mail variables, `PP\PHPMailer\Mailer`, HTML bodies, plain-text bodies, recipients, reply-to, CC, BCC, or attachments**
105
+ Read `email.md`, then verify the official email docs at `email-get-started`
94
106
 
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 `get-started-file`
107
+ - **Ratchet websocket setup, `IoServer`, `HttpServer`, `WsServer`, `ConnectionManager`, browser `WebSocket`, or realtime route behavior**
108
+ Read `websocket.md`, then verify the official websocket docs in this order: `websocket-get-started`, `websocket-chat-app`
97
109
 
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`
110
+ - **MCP support, `#[McpTool]`, `#[Schema]`, `PhpMcp\Server\Server`, `StreamableHttpServerTransport`, AI tool endpoints, or `src/Lib/MCP/mcp-server.php`**
111
+ Read `mcp.md`, then verify the official MCP docs in this order: `prisma-php-ai-mcp`, `ai-tools`
100
112
 
101
- - **Loading data, calling backend logic from the frontend, `pp.fetchFunction(...)`, `#[Exposed]`, or interactive backend validation**
102
- Read `fetching-data.md`
113
+ - **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**
114
+ Read `authentication.md`, then verify the matching official docs in this order: `auth-get-started`, `credentials`, `state-manager-auth`
103
115
 
104
116
  - **Cache behavior, route caching, invalidation, or `CacheHandler`**
105
117
  Read `caching.md`
@@ -110,17 +122,14 @@ Before generating code, choose the documentation file based on the task.
110
122
  - **Expected errors, uncaught exceptions, `error.php`, `not-found.php`, `ErrorHandler`, or validation failures as expected errors**
111
123
  Read `error-handling.md`
112
124
 
113
- - **Metadata, title, description, head scripts, favicon, icon, or `MainLayout` metadata behavior**
125
+ - **Metadata, title, description, custom head tags, favicon, icon, apple icon, or `MainLayout` metadata behavior**
114
126
  Read `metadata-and-og-images.md`
115
127
 
116
- - **API-style routes, JSON responses, handlers, form-processing endpoints, `route.php`, or request validation in handlers**
128
+ - **API-style routes, JSON responses, handlers, webhooks, form-processing endpoints, `route.php`, or request validation in handlers**
117
129
  Read `route-handlers.md`
118
130
 
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 the official Validator docs at `https://prismaphp.tsnc.tech/docs/php-validator`, then apply the relevant local guidance from `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
131
+ - **Swagger or OpenAPI generation, `swaggerDocs`, `pphp-swagger.json`, `create-swagger-docs`, or `settings/prisma-schema-config.json`**
132
+ Read `swagger-docs.md`
124
133
 
125
134
  - **Upgrading Prisma PHP, enabling features, syncing framework-managed project files, or running project updates**
126
135
  Read `upgrading.md`
@@ -128,20 +137,102 @@ Before generating code, choose the documentation file based on the task.
128
137
  - **First-time project installation or app creation flow**
129
138
  Read `installation.md`
130
139
 
131
- - **General doc entry point and framework orientation**
132
- Read `index.md`
140
+ ## Framework docs inventory in this repo
141
+
142
+ The current Prisma PHP docs shipped here include:
143
+
144
+ - `authentication.md`
145
+ - `backend-only.md`
146
+ - `bootstrap-runtime.md`
147
+ - `caching.md`
148
+ - `commands.md`
149
+ - `components.md`
150
+ - `email.md`
151
+ - `env.md`
152
+ - `error-handling.md`
153
+ - `fetching-data.md`
154
+ - `file-manager.md`
155
+ - `get-started-ia.md`
156
+ - `index.md`
157
+ - `installation.md`
158
+ - `layouts-and-pages.md`
159
+ - `mcp.md`
160
+ - `metadata-and-og-images.md`
161
+ - `prisma-php-orm.md`
162
+ - `project-structure.md`
163
+ - `pulsepoint.md`
164
+ - `route-handlers.md`
165
+ - `swagger-docs.md`
166
+ - `typescript.md`
167
+ - `upgrading.md`
168
+ - `validator.md`
169
+ - `websocket.md`
170
+
171
+ This inventory exists to help AI find the right Prisma PHP guidance quickly. It is not a feature inventory for the current app.
172
+
173
+ When a task depends on optional capabilities such as `backendOnly`, `swaggerDocs`, `typescript`, `websocket`, or `mcp`, inspect `./prisma-php.json` before assuming the generated scaffold exists.
174
+
175
+ When adding or reviewing AI guidance, do not stop at older docs only. Make sure the guidance also covers `backend-only.md`, `email.md`, `env.md`, `get-started-ia.md`, `mcp.md`, `swagger-docs.md`, `typescript.md`, and `websocket.md`, plus newer behavior documented in `fetching-data.md` and `metadata-and-og-images.md`.
176
+
177
+ ## Framework-generated files
178
+
179
+ Prisma PHP automatically generates and maintains certain framework files in consumer apps.
180
+
181
+ ### `files-list.json`
133
182
 
134
- ## Default interactive UI and fetching rule
183
+ Do **not** create, edit, reorder, or manually maintain `files-list.json`.
135
184
 
136
- For normal full-stack Prisma PHP work, assume the user wants the **PulsePoint-first** approach unless they explicitly ask otherwise.
185
+ 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.
186
+
187
+ If a route task appears to require editing `files-list.json`, that is almost certainly the wrong approach.
188
+
189
+ ## Reusable project organization
190
+
191
+ When organizing a growing Prisma PHP app, keep route code and reusable code separated.
192
+
193
+ - keep `src/app` focused on the route tree, route-local layouts, pages, handlers, and route-scoped partials
194
+ - prefer `src/Components` for reusable application UI components shared across multiple routes or layouts
195
+ - keep reusable non-UI code such as services, auth, middleware, Prisma classes, and helper libraries in `src/Lib`
196
+ - if a partial starts in `src/app` but becomes shared across the app, promote it into `src/Components`
197
+ - do **not** default to placing app-wide reusable components under `src/app` unless the user explicitly wants route-local colocation
198
+
199
+ ## Framework-managed package scripts
200
+
201
+ Prisma PHP can generate `package.json` scripts for BrowserSync, Tailwind, TypeScript, WebSocket, MCP, Swagger docs, and related project helpers.
202
+
203
+ AI agents should follow this default rule:
204
+
205
+ - prefer `npm run dev` for ordinary local development
206
+ - prefer `npm run build` for ordinary production-style asset builds
207
+ - do **not** default to telling users to run `npm run tailwind`, `npm run tailwind:build`, `npm run ts:watch`, or `npm run ts:build` after routine file changes, because those are usually framework-managed through the generated top-level scripts
208
+ - use `npm run websocket` or `npm run mcp` only when isolating local runtime startup, debugging, or when the project's scripts show those services are not already covered by the normal development flow
209
+ - use `npm run create-swagger-docs` only when Swagger or OpenAPI output must be intentionally generated or refreshed
210
+
211
+ When a task involves package scripts, read `commands.md` first and inspect the current `package.json` before assuming which feature scripts exist.
212
+
213
+ ## CLI command alignment
214
+
215
+ When a task involves Prisma PHP CLI usage, keep the command guidance aligned with `commands.md`.
216
+
217
+ - for new apps, prefer `npx create-prisma-php-app <project-name>` as the default recommended create command
218
+ - for existing apps, prefer `npx pp update project` after saving feature changes in `prisma-php.json`
219
+ - when an existing app needs a specific release channel or pinned update version, prefer `npx pp update project --tag <value>` or `npx pp update project --tag=<value>`
220
+ - use `--tag <value>` or `--tag=<value>` for release-channel or pinned-version updates
221
+ - do **not** use `npx pp update project` as a substitute for Prisma ORM migration commands
222
+
223
+ ## Default interactive UI and data-flow rule
224
+
225
+ For normal full-stack Prisma PHP work, assume the user wants the PulsePoint-first approach unless they explicitly ask otherwise.
226
+
227
+ PulsePoint is the primary JavaScript authoring model for frontend work in Prisma PHP. For normal page behavior, keep the client logic inside a plain inline `<script>` within the route or imported-partial root, let Prisma PHP scope and execute it, and prefer `pp.fetchFunction(...)` over ad hoc endpoints.
137
228
 
138
229
  Default interaction stack:
139
230
 
140
231
  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`**
232
+ 2. keep browser-side interactivity in PulsePoint
233
+ 3. call backend PHP from the frontend with `pp.fetchFunction(...)`
234
+ 4. mark callable PHP functions or methods with `#[Exposed]`
235
+ 5. validate and normalize input on the PHP side with `PP\Validator`
145
236
 
146
237
  Treat this as the default for:
147
238
 
@@ -154,54 +245,175 @@ Treat this as the default for:
154
245
  - inline validation
155
246
  - route-local CRUD actions
156
247
  - dashboard interactions
248
+ - streaming assistants
249
+ - progress logs
157
250
  - similar reactive page behavior
158
251
 
159
252
  Do **not** default to:
160
253
 
161
254
  - a PHP-only interaction style
255
+ - plain browser-DOM wiring when PulsePoint state, bindings, and native `on*` handlers already fit the task
162
256
  - ad hoc `fetch('/api/...')` patterns
163
257
  - extra `route.php` files for page-local interactions that already fit `pp.fetchFunction(...)`
258
+ - a separate Node realtime or tool server when the documented Prisma PHP runtime already fits the task
164
259
 
165
- Choose a more PHP-only pattern only when:
260
+ Choose a more PHP-only or handler-only pattern only when:
166
261
 
167
- - the user explicitly asks for PHP-only behavior
262
+ - the user explicitly asks for it
168
263
  - the task is clearly non-reactive
169
264
  - the task is a standalone API, webhook, integration endpoint, or public JSON handler
170
265
 
171
- ## Default workflow for AI agents
266
+ ## Route structure rule AI must not get wrong
267
+
268
+ There are two related structure rules, and AI must not mix their responsibilities.
269
+
270
+ ### Normal route files such as `index.php` and nested `layout.php`
271
+
272
+ Use this pattern:
273
+
274
+ 1. PHP first
275
+ 2. one parent HTML element for the route content
276
+ 3. when PulsePoint is present, let Prisma PHP inject the route or layout `pp-component` scope on that root automatically
277
+ 4. keep one `<script>` block as the last child inside that same root element
278
+
279
+ Also follow these route-file rules:
280
+
281
+ - `index.php` and nested `layout.php` must render a single parent HTML element
282
+ - for normal pages and nested layouts, do **not** manually author `pp-component` on that root; Prisma PHP adds it automatically
283
+ - author a plain `<script>` tag inside that root when PulsePoint logic is needed and do **not** add `type="text/pp"` manually
284
+ - write PulsePoint state, derived values, and functions directly at the top level of that script; do **not** wrap them in `DOMContentLoaded`, an IIFE, manual `pp.mount()` calls, or custom scoping helpers
285
+ - only the root `layout.php` should define `<html>`, `<head>`, and `<body>`
286
+ - when PulsePoint is present in a root `layout.php`, keep `MainLayout::$children` and any `<script>` inside one clear wrapper
287
+
288
+ Example:
289
+
290
+ ```php
291
+ <?php
292
+
293
+ use PP\MainLayout;
294
+
295
+ MainLayout::$title = 'Todos';
296
+ MainLayout::$description = 'Track tasks and view the current item count.';
297
+ ?>
298
+
299
+ <section>
300
+ <h1>Todos</h1>
301
+ <p>Count: {count}</p>
302
+ <script>
303
+ const [count, setCount] = pp.state(0);
304
+ </script>
305
+ </section>
306
+ ```
307
+
308
+ ### Imported partials rendered with `ImportComponent::render(...)`
309
+
310
+ Use this pattern:
311
+
312
+ 1. PHP first
313
+ 2. exactly one parent root element
314
+ 3. keep any component-local `<script>` inside that root element
315
+
316
+ Example:
317
+
318
+ ```php
319
+ <?php
320
+
321
+ // PHP code
172
322
 
173
- Use this workflow unless the user asks for something narrower:
323
+ ?>
174
324
 
175
- 1. Read `./prisma-php.json`
176
- 2. Read the relevant installed doc from `node_modules/prisma-php/dist/docs`
177
- 3. Inspect nearby project files that match the route, feature, or component being changed
178
- 4. If the task is component-related, read `components.md` before generating PHPX component code
179
- 5. If the task is upload- or file-manager-related, read `file-manager.md` before generating upload, rename, delete, or file-listing code
180
- 6. Generate code using Prisma PHP conventions
181
- 7. Inspect `vendor/tsnc/prisma-php/src` only if framework internals are required
325
+ <div>
326
+ <h2>Search</h2>
327
+ <input value="{query}" />
328
+ <script>
329
+ console.log('Search component ready');
330
+ </script>
331
+ </div>
332
+ ```
333
+
334
+ Do not:
335
+
336
+ - put a sibling `<script>` next to a route root or imported partial root
337
+ - manually add `pp-component` inside imported partial source
338
+ - manually add `type="text/pp"` to route or imported-partial scripts
339
+ - wrap imported-partial PulsePoint code in `DOMContentLoaded`, an IIFE, manual `pp.mount()` calls, or custom auto-execute helpers
340
+
341
+ ## Metadata rules
342
+
343
+ For document metadata, prefer `MainLayout::$title` and `MainLayout::$description`.
344
+
345
+ Important metadata rules:
346
+
347
+ - a local `$title` variable only affects rendered page content unless you also assign metadata through `MainLayout`
348
+ - use `MainLayout::addCustomMetadata(...)` for additional `<meta>` values when needed
349
+ - keep visible headings separate from document metadata when the UI text and SEO title must differ
350
+ - read `metadata-and-og-images.md` or `layouts-and-pages.md` before inventing Next.js-style metadata exports or Open Graph image workflows
351
+
352
+ ## Streaming and SSE rules
353
+
354
+ Prisma PHP supports streaming through `pp.fetchFunction(...)` when an exposed function yields values.
182
355
 
183
- Do not jump directly into framework internals if the installed docs already answer the task.
356
+ Default streaming rules:
357
+
358
+ - prefer an exposed generator that simply yields strings or arrays
359
+ - let Prisma PHP handle the SSE response automatically for normal `pp.fetchFunction(...)` streaming
360
+ - on the client, put stream UI updates in `onStream`, `onStreamError`, and `onStreamComplete`
361
+ - do not wait for a final JSON payload when the response is streamed
362
+
363
+ Current parsing rules AI should know:
364
+
365
+ - Prisma PHP sends streamed payloads as SSE `data:` lines
366
+ - the built-in `pp.fetchFunction(...)` stream parser currently forwards only `data:` lines to `onStream`
367
+ - `event:`, `id:`, and `retry:` may be emitted by low-level SSE helpers, but the built-in stream callback currently ignores them
368
+ - prefer JSON values or single-line strings for streamed chunks instead of multi-line text blobs
369
+
370
+ Low-level helpers exist when manual SSE control is required:
371
+
372
+ - `PP\Streaming\SSE`
373
+ - `PP\Streaming\ServerSentEvent`
374
+
375
+ Core locations documented for those helpers are:
376
+
377
+ ```txt
378
+ vendor/tsnc/prisma-php/src/Streaming/SSE.php
379
+ vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
380
+ ```
184
381
 
185
382
  ## Route file decision rules
186
383
 
187
384
  When the task is about creating or editing a route, do not guess.
188
385
 
189
- 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.
386
+ 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.
190
387
 
191
- - 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
192
- - Use `layout.php` for shared UI that wraps route subtrees
193
- - 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(...)`
194
- - Use `not-found.php` for route-specific not-found UI
195
- - Use `error.php` for route or app-level error UI
388
+ - use `index.php` for rendered UI and normal page routes
389
+ - use `layout.php` for shared UI that wraps route subtrees
390
+ - use `route.php` for direct handlers such as JSON endpoints, API-style routes, AJAX handlers, form-processing endpoints, and webhooks
391
+ - use `not-found.php` for route-specific not-found UI
392
+ - use `error.php` for route or app-level error UI
393
+ - use `loading.php` when the task is specifically about a loading UI state for a route subtree
196
394
 
197
- Also verify `backendOnly` in `prisma-php.json`:
395
+ For normal route-local interactivity, prefer `index.php` plus PulsePoint and `pp.fetchFunction(...)` over inventing extra handlers.
396
+
397
+ In a consumer app, also verify `backendOnly` in `prisma-php.json`:
198
398
 
199
399
  - if `backendOnly` is `false`, normal routes should usually be implemented with `index.php`
200
400
  - if `backendOnly` is `true`, route behavior will usually center on `route.php`
201
401
 
402
+ ## Default workflow for AI agents
403
+
404
+ Use this workflow unless the user asks for something narrower.
405
+
406
+ 1. read `./prisma-php.json`
407
+ 2. read the relevant installed doc from `./node_modules/prisma-php/dist/docs`
408
+ 3. inspect `./AGENTS.md` for project-level Prisma PHP guidance
409
+ 4. inspect nearby project files that match the route, feature, or component being changed
410
+ 5. inspect `vendor/tsnc/prisma-php/src` only if the docs do not answer the task
411
+
412
+ Do not jump directly into framework internals if the current docs already answer the task.
413
+
202
414
  ## Authentication rules
203
415
 
204
- When the task involves auth, do not guess from Laravel, NextAuth, generic JWT packages, or ad hoc middleware habits.
416
+ When the task involves auth, do not guess from Laravel, generic JWT packages, or ad hoc middleware habits.
205
417
 
206
418
  Use this auth decision flow:
207
419
 
@@ -210,15 +422,23 @@ Use this auth decision flow:
210
422
  3. inspect `src/Lib/Auth/AuthConfig.php` when present
211
423
  4. inspect the current auth-related routes under `src/app`
212
424
  5. inspect Prisma models that support auth before generating registration, login, or provider code
213
- 6. keep route protection, function protection, and session lifecycle aligned with Prisma PHPs documented auth model
425
+ 6. keep route protection, function protection, and session lifecycle aligned with Prisma PHP's documented auth model
214
426
 
215
427
  Important auth rules:
216
428
 
217
429
  - route privacy strategy is configured from `AuthConfig.php`
218
430
  - Prisma PHP supports both public-default and private-default route protection strategies
219
- - sign users in with `Auth::signIn(...)`
220
- - sign users out with `Auth::signOut(...)`
221
- - use `refreshUserSession(...)` when current-session auth payloads must be updated after role or profile changes
431
+ - Prisma PHP defaults to public routes, so keep the public-default strategy when the app will expose many public pages
432
+ - choose the route privacy strategy early, ideally before creating most routes in a new app or route subtree
433
+ - if the app will have only a few public entry points and most routes should require login, switch to the private-default strategy
434
+ - when choosing private-default routing, enable both `AuthConfig::IS_ALL_ROUTES_PRIVATE` and `AuthConfig::IS_TOKEN_AUTO_REFRESH`
435
+ - when `IS_ALL_ROUTES_PRIVATE` is `true`, keep public exceptions in `AuthConfig::$publicRoutes`; home remains public by default because it starts as `['/']`
436
+ - keep `AuthConfig::$authRoutes` public by default unless the user explicitly wants a different auth route allowlist
437
+ - there is no need to modify other Prisma PHP core files to enable private-default routing
438
+ - if `src/Lib/Auth/AuthConfig.php` was customized, protect it from future project updates by adding `./src/Lib/Auth/AuthConfig.php` to `excludeFiles` in `prisma-php.json`
439
+ - sign users in with `Auth::getInstance()->signIn(...)`
440
+ - sign users out with `Auth::getInstance()->signOut(...)`
441
+ - use `Auth::getInstance()->refreshUserSession(...)` when current-session auth payloads must be updated after role or profile changes
222
442
  - use role-based route protection in auth config for page access control
223
443
  - use `#[Exposed(allowedRoles: [...])]` for function-level access control when frontend code calls PHP directly
224
444
  - for credentials auth, model the schema first, then generate ORM classes before writing auth flows
@@ -245,7 +465,102 @@ Important file-manager rules:
245
465
  - do **not** place uploaded files inside `src/app`
246
466
  - do **not** assume HTML size hints replace `php.ini` upload limits
247
467
  - do **not** invent undocumented storage abstractions when `UploadFile` already fits the task
248
- - for upload, rename, replace, delete, and file-listing tasks, read `file-manager.md` first
468
+
469
+ ## Email rules
470
+
471
+ When the task involves email, read `email.md` first.
472
+
473
+ 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.
474
+
475
+ Use this email workflow:
476
+
477
+ 1. read `email.md`
478
+ 2. inspect `.env` for SMTP and sender values in the target app
479
+ 3. inspect the route, exposed function, or handler that sends the email
480
+ 4. inspect the HTML body or attachment source when present
481
+ 5. inspect framework internals only when the docs and current app code still leave a gap
482
+
483
+ The documented core mailer file is:
484
+
485
+ ```txt
486
+ vendor/tsnc/prisma-php/src/PHPMailer/Mailer.php
487
+ ```
488
+
489
+ Important email rules:
490
+
491
+ - keep SMTP credentials and sender defaults in `.env`, not in route files
492
+ - the documented env vars are `SMTP_HOST`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_ENCRYPTION`, `SMTP_PORT`, `MAIL_FROM`, and `MAIL_FROM_NAME`
493
+ - validate user-provided email fields before calling the mailer
494
+ - prefer the documented fluent API such as `to(...)`, `subject(...)`, `html(...)`, `text(...)`, `attach(...)`, and `send()`
495
+ - use `raw()` only when low-level PHPMailer access is genuinely needed
496
+
497
+ ## Env rules
498
+
499
+ When the task involves `.env`, `PP\Env`, feature flags, ports, host names, timezones, API keys, numeric limits, or other runtime configuration values, read `env.md` first.
500
+
501
+ Use this env workflow:
502
+
503
+ 1. read `env.md`
504
+ 2. inspect `.env` or the deployment environment when the task depends on actual values
505
+ 3. inspect the bootstrap or server entry file that loads or consumes the environment
506
+ 4. inspect the feature-specific doc such as `email.md`, `mcp.md`, `websocket.md`, `get-started-ia.md`, or `prisma-php-orm.md` when the env values belong to that feature
507
+ 5. inspect `vendor/tsnc/prisma-php/src/Env.php` only if the docs do not answer the task
508
+
509
+ Important env rules:
510
+
511
+ - prefer `PP\Env` over repeated ad hoc `getenv()` parsing in documented Prisma PHP code paths
512
+ - use `Env::string(...)`, `Env::bool(...)`, and `Env::int(...)` for typed access with defaults
513
+ - use `Env::get(...)` when raw nullable string access is actually needed
514
+ - remember that `PP\Env` reads values from `getenv()`, `$_ENV`, and `$_SERVER`; it does not parse `.env` by itself
515
+ - keep secrets and deployment-specific settings in `.env` or the real runtime environment, not hardcoded in route files or components
516
+
517
+ ## WebSocket rules
518
+
519
+ When the task involves realtime messaging, presence, live dashboards, `Ratchet`, or browser `WebSocket`, read `websocket.md` first.
520
+
521
+ 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.
522
+
523
+ Use this websocket workflow:
524
+
525
+ 1. read `websocket.md`
526
+ 2. inspect whether websocket support is enabled in `prisma-php.json` in the target app
527
+ 3. inspect `src/Lib/Websocket`
528
+ 4. inspect the route or client script that opens the browser `WebSocket`
529
+ 5. inspect `settings/restart-websocket.ts` when local restart behavior matters
530
+ 6. inspect framework internals only when the docs do not answer the task
531
+
532
+ Important websocket rules:
533
+
534
+ - use `src/Lib/Websocket/websocket-server.php` as the source of truth for startup behavior
535
+ - use `src/Lib/Websocket/ConnectionManager.php` as the lifecycle boundary for clients and broadcasts
536
+ - preserve documented env vars and defaults: `WS_NAME`, `WS_VERSION`, `WS_HOST`, `WS_PORT`, `WS_VERBOSE`, `APP_TIMEZONE`
537
+ - preserve CLI overrides through `--host=...`, `--port=...`, and `--verbose=...`
538
+ - preserve the documented casing `src/Lib/Websocket`
539
+ - for existing apps, enable `websocket` in `prisma-php.json` and run `npx pp update project -y` before inventing manual scaffolding
540
+
541
+ ## MCP rules
542
+
543
+ When the task involves Model Context Protocol support, read `mcp.md` first.
544
+
545
+ 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.
546
+
547
+ Use this MCP workflow:
548
+
549
+ 1. read `mcp.md`
550
+ 2. inspect whether MCP support is enabled in `prisma-php.json` in the target app
551
+ 3. inspect `src/Lib/MCP`
552
+ 4. inspect tool classes and the services they call
553
+ 5. inspect auth, ORM, and env configuration when tools read protected or database-backed data
554
+ 6. inspect framework internals only when the docs do not answer the task
555
+
556
+ Important MCP rules:
557
+
558
+ - use `src/Lib/MCP/mcp-server.php` as the source of truth for startup behavior
559
+ - preserve attribute-based discovery with `#[McpTool]` and `#[Schema]`
560
+ - preserve the documented discovery model built around scanning the source tree instead of manually wiring every tool class by default
561
+ - preserve the documented casing `src/Lib/MCP`
562
+ - preserve documented env vars and defaults: `MCP_NAME`, `MCP_VERSION`, `MCP_HOST`, `MCP_PORT`, `MCP_PATH_PREFIX`, `MCP_JSON_RESPONSE`, `APP_TIMEZONE`
563
+ - for existing apps, enable `mcp` in `prisma-php.json` and run `npx pp update project -y` before inventing manual scaffolding
249
564
 
250
565
  ## Prisma ORM workflow rules
251
566
 
@@ -262,52 +577,48 @@ Use this ORM decision flow:
262
577
  7. after schema synchronization, run `npx ppo generate`
263
578
  8. only then write or update PHP code that depends on the generated Prisma classes
264
579
 
265
- Important rules:
580
+ Important ORM rules:
266
581
 
267
582
  - do **not** use `npx pp update project -y` as the normal fix for Prisma ORM schema changes
268
583
  - use `npx prisma migrate dev` for the normal development migration workflow
269
584
  - use `npx prisma migrate deploy` for production or CI/CD migration application
270
585
  - use `npx prisma db push` only for explicit prototyping or no-migration database sync
271
586
  - do **not** treat `npx ppo generate` as a migration step
272
- - `npx ppo generate` should run the first time generated PHP ORM classes are needed and whenever `schema.prisma` changes
273
- - if the task mentions Prisma ORM, `schema.prisma`, migrations, generated classes, SQLite, MySQL, or PostgreSQL, read `prisma-php-orm.md` first
274
587
 
275
588
  ## Validation rules
276
589
 
277
- When a task involves user input, form handling, search params, JSON payloads, `pp.fetchFunction(...)`, or `route.php` bodies, do not trust raw values.
590
+ 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.
278
591
 
279
592
  Default Prisma PHP validation rules:
280
593
 
281
- - use **`PP\Validator`** as the backend validation and normalization layer
282
- - prefer the **`Rule` builder** for rule-based validation
594
+ - use `PP\Validator` as the backend validation and normalization layer
595
+ - prefer the `Rule` builder for rule-based validation
283
596
  - validate in PHP even when the frontend already performs local checks
284
597
  - return structured validation results for expected failures
285
598
  - do not treat routine invalid input as an uncaught exception
286
599
  - in reactive flows, use PulsePoint for local state and `Validator` for authoritative server validation
287
600
 
601
+ When internals matter, the documented Prisma PHP core validator location is:
602
+
603
+ ```txt
604
+ vendor/tsnc/prisma-php/src/Validator.php
605
+ ```
606
+
288
607
  ## PulsePoint rules
289
608
 
290
609
  When a task involves reactive frontend behavior, read `pulsepoint.md` first.
291
610
 
292
611
  Also follow these rules:
293
612
 
613
+ - treat PulsePoint as the primary JavaScript authoring model for normal full-stack frontend work
614
+ - keep page and imported-partial client logic inside the boundary's plain `<script>` tag instead of building extra DOM-ready or self-executing wrappers
615
+ - prefer `pp.fetchFunction(...)` over ad hoc `fetch('/api/...')` calls for page-local PHP interactions
616
+ - reserve plain browser JavaScript outside PulsePoint for external libraries, low-level browser APIs, and reusable helpers in `ts/`
294
617
  - do not invent undocumented PulsePoint helpers or directives
295
618
  - do not write React, Vue, Alpine, or Livewire syntax and call it PulsePoint
296
619
  - keep backend concerns separate from PulsePoint runtime concerns
297
620
  - prefer simple documented runtime primitives over abstractions copied from other ecosystems
298
621
 
299
- ## Reactive frontend + server-call rule
300
-
301
- For frontend interactivity in Prisma PHP, prefer the documented Prisma PHP pattern:
302
-
303
- - use **PulsePoint** for reactive browser state and UI behavior
304
- - use **`pp.fetchFunction(...)`** for page-local or component-local server calls
305
- - expose callable PHP functions with **`#[Exposed]`**
306
-
307
- 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(...)`.
308
-
309
- 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.
310
-
311
622
  ## Component rules
312
623
 
313
624
  When the task involves Prisma PHPX components, reusable UI elements, props, children, fragments, icons, buttons, accordions, or component composition, read `components.md` first.
@@ -318,7 +629,6 @@ Also follow these rules:
318
629
  - keep component file names and class names aligned
319
630
  - preserve documented PHPX patterns for `$props`, `$children`, `$class`, and `getAttributes(...)`
320
631
  - follow documented component placement and grouping conventions before inspecting framework internals
321
- - use `vendor/tsnc/prisma-php/src` only when the installed docs and `components.md` do not answer the task
322
632
 
323
633
  ## Prisma PHP XML syntax rules
324
634
 
@@ -385,24 +695,30 @@ Do not output permissive HTML shorthand in Prisma PHP UI files.
385
695
 
386
696
  ## When to inspect framework internals
387
697
 
388
- Prisma PHP core Composer package files live in:
698
+ Inspect framework internals only when the docs and current files do not answer the task.
699
+
700
+ Useful app-mode core locations include:
389
701
 
390
702
  ```txt
391
703
  vendor/tsnc/prisma-php/src
704
+ vendor/tsnc/prisma-php/src/PHPMailer/Mailer.php
705
+ vendor/tsnc/prisma-php/src/FileManager/UploadFile.php
706
+ vendor/tsnc/prisma-php/src/Validator.php
707
+ vendor/tsnc/prisma-php/src/Streaming/SSE.php
708
+ vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
392
709
  ```
393
710
 
394
- Inspect this directory only when the task depends on framework internals not already answered by the installed docs.
395
-
396
- Use it when the task involves:
711
+ Use framework internals when the task involves:
397
712
 
398
713
  - confirming namespaces, classes, or helper names
399
714
  - understanding how a core class behaves internally
400
- - verifying available attributes such as `#[Exposed]`
715
+ - verifying available attributes such as `#[Exposed]`, `#[McpTool]`, or `#[Schema]`
401
716
  - checking PHPX compiler or template compiler behavior
402
717
  - tracing PulsePoint integration points inside Prisma PHP
403
- - debugging framework-level issues that are not explained by the docs
718
+ - confirming mailer, SSE, websocket, or MCP runtime behavior not already clear from the docs
719
+ - debugging framework-level issues that are not explained by the current docs
404
720
 
405
- For ordinary app work, prefer the installed docs and local project files first.
721
+ For ordinary app or docs work, prefer the current docs and local project files first.
406
722
 
407
723
  ## Upgrade and feature-enable workflow
408
724
 
@@ -410,20 +726,17 @@ If the task involves enabling a feature, syncing framework-managed files, or upd
410
726
 
411
727
  Important rules:
412
728
 
413
- - update `prisma-php.json` before assuming a feature is active
729
+ - update `prisma-php.json` before assuming a feature is active in a consumer app
414
730
  - do not assume Tailwind, Prisma, Swagger, WebSocket, MCP, or TypeScript support is enabled unless `prisma-php.json` says so
731
+ - keep customized framework-managed files such as `src/Lib/Auth/AuthConfig.php` in `excludeFiles` when you need project updates to preserve them
415
732
  - after changing feature flags, follow the documented project update flow
416
- - for AI-driven or scripted updates, prefer:
417
-
418
- ```bash
419
- npx pp update project -y
420
- ```
733
+ - for AI-driven or scripted updates, prefer `npx pp update project -y`
421
734
 
422
- This command is for project updates and framework-managed file refreshes. It is not the default ORM migration command.
735
+ That command is for project updates and framework-managed file refreshes. It is not the default ORM migration command.
423
736
 
424
737
  ## Final operating rule
425
738
 
426
- When Prisma PHP behavior is documented locally, read the relevant installed doc first and follow it.
739
+ When Prisma PHP behavior is documented locally, read the relevant current doc first and follow it.
427
740
 
428
741
  Do not guess.
429
742