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

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