caspian-utils 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/docs/auth.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Authentication
3
- description: Manage session-backed authentication in Caspian with `casp.auth`, `AuthSettings`, the global `auth` object, centralized `auth_config.py`, page decorators, RPC protection, role-based routes, and optional Google or GitHub OAuth providers.
3
+ description: Use this page when the task mentions `auth_config.py`, sign-in, signout, protected routes, `require_auth`, RBAC, auth decorators, or Google or GitHub OAuth in Caspian.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Use the fetch-data guide when sign-in or signout happens through RPC, then use the state guide for transient auth-adjacent request state, validation to guard credentials, and routing or project structure to place auth files correctly.
@@ -113,7 +113,7 @@ Important behavior from the current implementation:
113
113
  - `default_token_validity` is parsed by the installed auth runtime with the format `^\d+(s|m|h|d)$`. Use values such as `30m`, `1h`, or `7d`.
114
114
  - `token_auto_refresh` only changes behavior when the request lifecycle calls `auth.refresh_session()`. In the installed `auth.py`, the flag alone does not refresh expiry by itself.
115
115
  - The framework `AuthSettings` dataclass defaults `is_all_routes_private=True`, but the project example above explicitly changes that to `False`.
116
- - In generated app-owned config like this workspace, `src/lib/auth/auth_config.py` starts with `is_all_routes_private=False`, so routes are public by default until the app chooses stricter route protection.
116
+ - In generated app-owned starter config, `src/lib/auth/auth_config.py` starts with `is_all_routes_private=False`, so routes are public by default until the app chooses stricter route protection.
117
117
  - `public_routes`, `auth_routes`, `private_routes`, and `role_based_routes` are exact path matches in the installed `Auth` methods.
118
118
  - `private_routes` matters only when `is_all_routes_private=False`.
119
119
  - `role_based_routes` currently expects `PATH -> [ROLES]`, not role names keyed to paths the other way around.
@@ -124,7 +124,7 @@ Important behavior from the current implementation:
124
124
 
125
125
  Make this decision at app setup time in `src/lib/auth/auth_config.py`.
126
126
 
127
- - In the default app-owned starter pattern used in this workspace, routes start public because `is_all_routes_private=False` in `src/lib/auth/auth_config.py`.
127
+ - In the default app-owned starter pattern, routes start public because `is_all_routes_private=False` in `src/lib/auth/auth_config.py`.
128
128
  - If the application has only a few public pages and most routes require auth, set `is_all_routes_private=True` and list the exceptions in `public_routes`.
129
129
  - If the application has many public pages and only a few protected areas, keep `is_all_routes_private=False` and list only the protected routes in `private_routes`.
130
130
  - In the current runtime, `auth_routes=["/signin", "/signup"]` stays public by default, and most apps do not need to change it unless the user explicitly asks for different auth routes.
@@ -756,14 +756,14 @@ Common placement patterns are:
756
756
 
757
757
  For browser-triggered auth forms, pair this page with `fetch-data.md`. For credential and form validation, pair it with `validation.md`.
758
758
 
759
- ## AI Routing Notes
759
+ ## AI Retrieval Notes
760
760
 
761
761
  If an AI agent is deciding how to handle auth in Caspian, apply these rules first.
762
762
 
763
763
  - Treat `casp.auth` as the default authentication layer.
764
764
  - Centralize route visibility, redirects, and RBAC policy in `src/lib/auth/auth_config.py`.
765
765
  - Decide route mode early in `src/lib/auth/auth_config.py`: use `is_all_routes_private=True` when most routes should require auth, otherwise keep `is_all_routes_private=False` and list protected routes in `private_routes`.
766
- - In app-owned starter config like this workspace, treat `is_all_routes_private=False` as the default starting point, which means routes begin public until the app opts into stricter protection.
766
+ - In app-owned starter config, treat `is_all_routes_private=False` as the default starting point, which means routes begin public until the app opts into stricter protection.
767
767
  - Treat `public_routes` as the public exception list for all-private apps. In the current defaults, `/` stays public and `auth_routes=["/signin", "/signup"]` stays public too.
768
768
  - Apply settings at startup in `main.py` with `configure_auth(build_auth_settings())`.
769
769
  - Register provider instances in `main.py` with `Auth.set_providers(...)` when Google or GitHub OAuth is enabled.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Cache
3
- description: Cache rendered Caspian route HTML with `casp.cache_handler`, `Cache`, and `CacheHandler`, using route-level TTLs, file-system storage, and explicit invalidation for public read-heavy pages.
3
+ description: Use this page when the task mentions `Cache`, `CacheHandler`, page caching, route HTML reuse, TTLs, or invalidation in Caspian.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Use the routing guide to place route-level cache declarations correctly, then pair cache with fetch-data when deciding what can be safely served from reused HTML.
@@ -242,7 +242,7 @@ Poor candidates are:
242
242
  - forms whose server-rendered HTML includes request-specific or sensitive state
243
243
  - pages that need sub-second freshness unless you have reliable invalidation hooks
244
244
 
245
- ## AI Routing Notes
245
+ ## AI Retrieval Notes
246
246
 
247
247
  If an AI agent is deciding whether or how to cache a Caspian route, apply these rules first.
248
248
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Commands
3
- description: Use the current Caspian CLI reference to choose the right scaffold, starter-kit, update, and Prisma regeneration workflow for the current workspace.
3
+ description: Use this Caspian command reference for scaffolding, project updates, feature enablement, builds, and ORM regeneration. Use when the task mentions `create-caspian-app`, `casp update project`, `npm run dev`, `npm run build`, `prisma migrate`, or `ppy generate`.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Start with installation for new apps, then use database, MCP, and structure docs when commands affect schema, server tooling, generated ORM files, or project layout.
@@ -8,18 +8,19 @@ related:
8
8
  - /docs/installation
9
9
  - /docs/database
10
10
  - /docs/mcp
11
+ - /docs/file-uploads
11
12
  - /docs/routing
12
13
  - /docs/project-structure
13
14
  - /docs/index
14
15
  ---
15
16
 
16
- This page documents the current Caspian command families used with this workspace and the surrounding docs toolchain.
17
+ This page documents the main Caspian command families and the checks an AI agent should make before running them in a project.
17
18
 
18
19
  ## Overview
19
20
 
20
- The current workspace includes a local `prisma` binary, but it does not include local `create-caspian-app`, `casp`, or `ppy` binaries under `node_modules/.bin`. Treat project creation, project update, and Python ORM generation as external `npx` workflows rather than project-local executables.
21
+ Project creation, project updates, and Python ORM generation are commonly driven through `npx` workflows plus any project-local `package.json` scripts that a given project defines.
21
22
 
22
- The current workspace `package.json` defines `projectName`, `tailwind`, `tailwind:build`, `browserSync`, `browserSync:build`, `dev`, and `build`. It does not currently define `npm run mcp` because `caspian.config.json` has `mcp: false`.
23
+ Do not assume a local binary, script, or generated file exists just because a doc mentions it. Confirm the actual `package.json`, repository tree, and `caspian.config.json` values in the project you are working on.
23
24
 
24
25
  Examples below use `npx create-caspian-app` for readability. If you want to force the latest published scaffold package explicitly, you can use `npx create-caspian-app@latest` instead.
25
26
 
@@ -32,7 +33,7 @@ This updated reference includes the newer updater behavior and the current scaff
32
33
  - Windows-safe execution that resolves `npx.cmd` on Win32
33
34
  - scaffold behavior that reuses an existing `.venv` instead of recreating it every time
34
35
 
35
- Before running update commands, read `caspian.config.json` because it controls feature flags and `excludeFiles` overwrite protection. In the current workspace that config shows `backendOnly: false`, `tailwindcss: true`, `mcp: false`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
36
+ Before running update commands, read `caspian.config.json` because it controls feature flags and any `excludeFiles` overwrite protection.
36
37
 
37
38
  Treat `caspian.config.json` as the single source of truth for optional feature enablement. Use feature-specific docs, files, or commands only after the matching flag is confirmed as enabled.
38
39
 
@@ -81,7 +82,9 @@ npm run dev
81
82
 
82
83
  Use when the user explicitly wants the local BrowserSync plus PostCSS development stack.
83
84
 
84
- In this workspace, `npm run dev` is a long-running command that can regenerate framework-owned outputs such as `public/css/styles.css`, `settings/component-map.json`, `settings/files-list.json`, `__pycache__/`, and `.pyc` files.
85
+ Only use this when the current project's `package.json` actually defines `npm run dev`.
86
+
87
+ Long-running local stack commands can regenerate framework-owned outputs such as built CSS, generated component maps, route maps, `__pycache__/`, and `.pyc` files. Treat project-specific generated outputs as artifacts when those workflows intentionally run.
85
88
 
86
89
  ### Build generated assets for deployment
87
90
 
@@ -91,6 +94,8 @@ npm run build
91
94
 
92
95
  Use when preparing deployment or when the user explicitly asks for a build.
93
96
 
97
+ Only use this when the current project's `package.json` actually defines `npm run build`.
98
+
94
99
  Do not use `npm run build` as the default validation step for routine route, feature, or documentation edits.
95
100
 
96
101
  ### Regenerate ORM after schema changes
@@ -117,6 +122,7 @@ Use when `prisma/schema.prisma` changes and you need migrations, seed flow, and
117
122
  - Use `npm run build` only for deployment prep or an explicit build request.
118
123
  - Treat `public/css/styles.css`, `settings/component-map.json`, `settings/files-list.json`, `__pycache__/`, and `.pyc` files as generated outputs when a script intentionally runs.
119
124
  - Analyze `settings/component-map.json` and `settings/files-list.json` when needed, but do not hand-edit them. `settings/component-map.ts` and `settings/files-list.ts` regenerate them during the intentional dev and build flows.
125
+ - Keep any runtime upload directory that the project uses in the BrowserSync ignore list so uploads do not trigger reloads on every new blob.
120
126
  - Do not edit `__pycache__/` directories or `.pyc` files, and do not leave them in the final diff.
121
127
 
122
128
  ## 3. Supported Flags And Options
@@ -579,7 +585,7 @@ Result: parsing error because more than one version source was provided.
579
585
 
580
586
  ## 8. Prisma And Python ORM Regeneration
581
587
 
582
- The create and update commands above are not the whole maintenance story for this workspace. When `prisma/schema.prisma` changes, follow the ORM flow below so the TypeScript Prisma client, database state, and Python ORM layer stay aligned.
588
+ The create and update commands above are not the whole maintenance story for a Prisma-enabled Caspian project. When `prisma/schema.prisma` changes, follow the ORM flow below so the TypeScript Prisma client, database state, and Python ORM layer stay aligned.
583
589
 
584
590
  ### Required order after schema changes
585
591
 
@@ -659,7 +665,7 @@ If you exclude a file, the updater preserves it, but you are responsible for mer
659
665
  4. Starter kits still support later overrides via explicit CLI flags.
660
666
  5. Frontend-oriented flags are only fully meaningful when `backendOnly` is false.
661
667
 
662
- ## AI Routing Notes
668
+ ## AI Retrieval Notes
663
669
 
664
670
  If an AI agent is deciding which command flow to use, apply these rules first.
665
671
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Components
3
- description: Create reusable Caspian components as `@component` Python functions, import them into templates as `<MyComponent />`, and split interactive UI into same-name HTML templates when PulsePoint logic is involved.
3
+ description: Use this page when the task mentions `@component`, reusable UI, component imports, same-name `.html` templates, or where shared components belong in a Caspian project.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Use the structure guide for file placement, the routing guide for route templates, the PulsePoint guide for browser-side scripts, and the data guide for component-owned RPC flows.
@@ -16,7 +16,7 @@ Components in Caspian are Python functions decorated with `@component`.
16
16
 
17
17
  Import them into a template with an `@import` comment, then render them with JSX-style tags such as `<MyComponent />` or `<MyComponent>...</MyComponent>`.
18
18
 
19
- For the current workspace, component tooling scans Python files under the paths listed in `caspian.config.json`. Right now that means `src/`, so `src/components/` is the clean default location for reusable UI, even though any scanned path under `src/` can work.
19
+ Component tooling scans Python files under the paths listed in `caspian.config.json`. When `componentScanDirs` includes `src/`, `src/components/` is the clean default location for reusable UI, even though any scanned path can work.
20
20
 
21
21
  As the app grows, treat `src/components/` as the default home for reusable application UI. Keep route-owned markup in `src/app/`, and keep non-UI helpers or services in `src/lib/`.
22
22
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Database
3
- description: Use Prisma in this workspace through `prisma/schema.prisma`, `prisma.config.ts`, migrations, seeding, and the generated client defined by the local schema.
3
+ description: Use this page when the task mentions Prisma, `schema.prisma`, `prisma.config.ts`, migrations, `seed.ts`, Prisma Client, or `ppy generate` in a Caspian project.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Use the project structure guide to place database files correctly, then use the fetch-data guide when Prisma calls need to power route rendering or RPC actions.
@@ -12,9 +12,9 @@ related:
12
12
  - /docs/index
13
13
  ---
14
14
 
15
- This page documents the Prisma workflow present in this workspace.
15
+ This page documents the Prisma workflow for Caspian projects where `caspian.config.json` enables Prisma.
16
16
 
17
- This repo currently uses Prisma for schema management, migrations, and seed tooling on the Node side. The local `prisma/schema.prisma` uses `generator client { provider = "prisma-client-js" }`, `prisma.config.ts` seeds through `tsx prisma/seed.ts`, and this workspace already includes an app-owned Python database layer under `src/lib/prisma/`. If Python routes or RPC actions need database access, reuse that package instead of creating another helper.
17
+ When a project enables Prisma, use `prisma/schema.prisma` for schema management, `prisma.config.ts` for Prisma config and seed wiring, and reuse an app-owned `src/lib/prisma/` package when the project includes one.
18
18
 
19
19
  Treat `caspian.config.json` as the single source of truth for whether Prisma is enabled in a workspace. If `prisma` is false and the user wants Prisma, ask first, then update `caspian.config.json` and run `npx casp update project` before assuming Prisma-managed files exist.
20
20
 
@@ -102,7 +102,7 @@ model Post {
102
102
  }
103
103
  ```
104
104
 
105
- After changing the schema, use this order in the current workspace:
105
+ After changing the schema, use this order:
106
106
 
107
107
  1. Run `npx prisma migrate dev`.
108
108
  2. If seed data or the seed script needs the new schema, run `npx prisma generate` and then `npx prisma db seed`.
@@ -129,21 +129,21 @@ Default rule:
129
129
  - Use migrations for tracked application changes.
130
130
  - Use `db push` only when you intentionally want a faster, migration-free prototype loop.
131
131
 
132
- ## Prisma Files In This Workspace
132
+ ## Prisma Files To Inspect
133
133
 
134
- The current repo ships Prisma files in these locations:
134
+ In a Prisma-enabled Caspian project, inspect these locations:
135
135
 
136
136
  ### `prisma/schema.prisma`
137
137
 
138
- This file is the schema source of truth. It currently defines a `prisma-client-js` generator.
138
+ This file is the schema source of truth. Confirm the actual datasource and generator configuration in the current project.
139
139
 
140
140
  ### `prisma.config.ts`
141
141
 
142
- This file configures the schema path, migrations path, and the seed entry point. In this workspace it runs seeds through `tsx prisma/seed.ts`.
142
+ This file configures the schema path, migrations path, and the seed entry point. Confirm the actual seed command and import path in the current project.
143
143
 
144
144
  ### `prisma/seed.ts`
145
145
 
146
- This file is the current example of code that imports and uses the generated Prisma client.
146
+ This file is the project-local example of code that imports and uses the generated Prisma client.
147
147
 
148
148
  ### `node_modules/@prisma/client/`
149
149
 
@@ -151,13 +151,13 @@ After `npx prisma generate`, Prisma writes the generated JavaScript client into
151
151
 
152
152
  ### `src/lib/prisma/`
153
153
 
154
- This workspace already includes an app-owned async Python database package that exports `prisma`, `PrismaClient`, generated models, and helper types.
154
+ If the project includes an app-owned async Python database package here, it typically exports `prisma`, `PrismaClient`, generated models, and helper types.
155
155
 
156
156
  If Python route or RPC code needs database access, import from `src.lib.prisma` and keep that import path explicit in application code. Refresh generated classes with `npx ppy generate` instead of editing them manually.
157
157
 
158
158
  ## Python Route Usage
159
159
 
160
- This workspace already ships an app-owned Python Prisma-style layer under `src/lib/prisma/`. Treat it as async-first and reuse it from route and RPC code.
160
+ If the project ships an app-owned Python Prisma-style layer under `src/lib/prisma/`, treat it as async-first and reuse it from route and RPC code.
161
161
 
162
162
  Example:
163
163
 
@@ -273,6 +273,18 @@ async def create_user(email: str, name: str | None = None):
273
273
 
274
274
  Use validation before writes, especially for form payloads and public RPC actions. See `validation.md` for the recommended boundary checks.
275
275
 
276
+ ## Upload Metadata Pattern
277
+
278
+ When a Caspian file manager needs durable metadata, keep the blob and the metadata in separate layers.
279
+
280
+ - Write the uploaded blob to disk or object storage.
281
+ - Persist the durable metadata in Prisma.
282
+ - Store fields such as owner relation, original name, stored name, asset path, MIME type, collection, kind, size, and uploaded timestamp in the Prisma model.
283
+ - Remove both the stored blob and the Prisma row during delete flows.
284
+ - Do not use JSON manifests as the primary metadata store when Prisma is enabled.
285
+
286
+ See [file-uploads.md](./file-uploads.md) for the route-local RPC plus public asset storage pattern.
287
+
276
288
  ## Advanced Features
277
289
 
278
290
  ### Aggregations
@@ -326,7 +338,7 @@ Use raw SQL sparingly. Prefer the generated Prisma API when the query can be exp
326
338
  - Validate incoming mutation data before calling `create`, `update`, or `delete` operations.
327
339
  - Prefer Prisma queries over raw SQL, and prefer raw SQL over undocumented custom query helpers.
328
340
 
329
- ## AI Routing Notes
341
+ ## AI Retrieval Notes
330
342
 
331
343
  If an AI agent is working on a Caspian app with Prisma enabled, apply these rules first.
332
344
 
@@ -336,8 +348,9 @@ If an AI agent is working on a Caspian app with Prisma enabled, apply these rule
336
348
  - If the schema change requires seed data, run `npx prisma generate` and then `npx prisma db seed`.
337
349
  - Run `npx ppy generate` after schema changes to refresh the Python ORM classes.
338
350
  - Never hand-edit generated Prisma or Python ORM classes.
339
- - Read `prisma.config.ts` and `prisma/seed.ts` when you need the current workspace's Prisma tooling examples.
351
+ - Read `prisma.config.ts` and `prisma/seed.ts` when you need the current project's Prisma tooling examples.
340
352
  - Reuse the existing `src/lib/prisma/` package when the Python app needs database access.
353
+ - For file managers and uploads, persist metadata in Prisma and keep blob storage separate. See [file-uploads.md](./file-uploads.md).
341
354
  - Put reusable database helpers in `src/lib/`; keep route and RPC orchestration in `src/app/`.
342
355
  - Use `async def page()` for first-render reads. Keep `layout()` synchronous in the current runtime, and use `@rpc()` plus `pp.rpc()` for browser-triggered reads and writes.
343
356
  - Check `fetch-data.md` for route versus RPC guidance and `validation.md` before writing public mutations.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Fetch Data
3
- description: Fetch first-render and interactive data in Caspian with async route functions, `@rpc()` actions, `pp.rpc()`, streaming, and uploads, with RPC as the default browser-to-server data path.
3
+ description: Use this page when the task mentions `page()`, `layout()`, `@rpc()`, `pp.rpc()`, streaming, interactive fetches, uploads, or browser-triggered data loads in Caspian.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Use the routing guide to place route logic correctly, then use the auth guide for protected actions, the MCP guide for AI-facing tools, the state guide for transient request-scoped mutation state, the cache guide for reusable first-render HTML, and the PulsePoint runtime guide for client-side `pp.rpc()` details.
@@ -9,6 +9,7 @@ related:
9
9
  - /docs/mcp
10
10
  - /docs/state
11
11
  - /docs/database
12
+ - /docs/file-uploads
12
13
  - /docs/cache
13
14
  - /docs/routing
14
15
  - /docs/pulsepoint
@@ -20,7 +21,7 @@ This page explains how data fetching works in Caspian. Use route functions for i
20
21
 
21
22
  Treat RPC as the default way for browser code to talk to Python in Caspian. Do not reach for ad hoc fetch calls to custom JSON endpoints, alternate transport layers, or older helper names unless the task explicitly requires that shape.
22
23
 
23
- MCP is a separate integration surface. Do not place app-owned FastMCP tools in route `index.py` files or treat `@rpc()` actions as a replacement for MCP tools. Use `mcp.md` and `src/lib/mcp/` only when `caspian.config.json` has `mcp: true`. In this workspace, `mcp: false`, so do not assume those files exist.
24
+ MCP is a separate integration surface. Do not place app-owned FastMCP tools in route `index.py` files or treat `@rpc()` actions as a replacement for MCP tools. Use `mcp.md` and `src/lib/mcp/` only when `caspian.config.json` has `mcp: true`. If `mcp` is false, do not assume those files exist.
24
25
 
25
26
  ## Overview
26
27
 
@@ -73,7 +74,7 @@ Notes:
73
74
  - Put shared section-level props in `layout.py` when multiple child routes need the same synchronous payload. The current layout engine does not await `layout()`.
74
75
  - Keep reusable database or API clients under `src/lib/`; keep route-specific orchestration in `src/app/`.
75
76
 
76
- If the data source is Prisma, confirm `caspian.config.json` has `prisma: true`, then see `database.md` for the current workspace's schema, migration, and generation workflow. In this workspace, Prisma is enabled and the app-owned Python database layer lives under `src/lib/prisma/`.
77
+ If the data source is Prisma, confirm `caspian.config.json` has `prisma: true`, then see `database.md` for the project's schema, migration, and generation workflow. If the project includes an app-owned Python database layer under `src/lib/prisma/`, reuse it instead of creating another helper.
77
78
 
78
79
  ## Interactive Data With RPC
79
80
 
@@ -174,28 +175,68 @@ Use streaming when the user should see partial progress instead of waiting for a
174
175
 
175
176
  ## File Uploads
176
177
 
177
- RPC actions can accept FastAPI upload types.
178
+ RPC actions can accept FastAPI upload types, but the preferred Caspian pattern is route-local upload actions in `src/app/**/index.py`, shared persistence helpers in `src/lib/`, and reactive client updates through `pp.rpc()`.
178
179
 
179
- Example:
180
+ Example route-local upload action:
180
181
 
181
182
  ```python
182
183
  from fastapi import File, UploadFile
183
184
  from casp.rpc import rpc
184
- import shutil
185
185
 
186
- @rpc()
187
- def upload_file(file: UploadFile = File(...)):
188
- with open(f"uploads/{file.filename}", "wb") as buffer:
189
- shutil.copyfileobj(file.file, buffer)
186
+ from src.lib.dashboard.file_manager import (
187
+ build_file_manager_payload,
188
+ save_file_manager_upload,
189
+ )
190
+
191
+ @rpc(require_auth=True)
192
+ async def upload_file(file: UploadFile = File(...), collection: str = "auto"):
193
+ user_id = current_user_id()
194
+ content = await file.read()
195
+
196
+ uploaded = await save_file_manager_upload(
197
+ user_id,
198
+ file_name=file.filename or "file",
199
+ content=content,
200
+ mime_type=file.content_type,
201
+ desired_group=collection,
202
+ )
190
203
 
191
204
  return {
192
- "status": "success",
193
- "filename": file.filename,
194
- "size": file.size,
205
+ "success": True,
206
+ "uploaded": uploaded,
207
+ "data": await build_file_manager_payload(user_id),
208
+ }
209
+ ```
210
+
211
+ Client example:
212
+
213
+ ```html
214
+ <script>
215
+ async function uploadSelectedFiles(fileList, collection = "auto") {
216
+ for (const file of Array.from(fileList ?? [])) {
217
+ const response = await pp.rpc("upload_file", { file, collection }, {
218
+ onUploadProgress: (progress) => {
219
+ console.log(progress.percentage ?? 0);
220
+ },
221
+ });
222
+
223
+ if (response?.data) {
224
+ setFileManagerData(response.data);
225
+ }
195
226
  }
227
+ }
228
+ </script>
196
229
  ```
197
230
 
198
- On the client, call `pp.rpc()` and pass `onUploadProgress` when the UI needs progress updates.
231
+ Use this pattern for real file managers:
232
+
233
+ - Keep upload and delete actions in the owning route `index.py`, not in `main.py`.
234
+ - Use `page()` to render the initial manager payload.
235
+ - Store durable metadata in Prisma and store the browser-accessible blob separately under `public/assets/file-manager/`.
236
+ - Use `pp.state(...)` plus `pp-for` for the list UI instead of manual `innerHTML` writes.
237
+ - Add `public/assets/file-manager` to `PUBLIC_IGNORE_DIRS` in `settings/bs-config.ts` so runtime uploads do not trigger BrowserSync reloads during `npm run dev`.
238
+
239
+ Read [file-uploads.md](./file-uploads.md) for the complete file-manager pattern.
199
240
 
200
241
  ## Auth, Roles, And Limits
201
242
 
@@ -244,7 +285,7 @@ A common pattern is:
244
285
 
245
286
  If the first-render HTML is expensive to produce and safe to share between visitors, add route-level caching with [cache.md](./cache.md) and invalidate affected URIs after successful mutations.
246
287
 
247
- ## AI Routing Notes
288
+ ## AI Retrieval Notes
248
289
 
249
290
  If an AI agent is choosing how to load data in Caspian, apply these rules first.
250
291
 
@@ -255,6 +296,7 @@ If an AI agent is choosing how to load data in Caspian, apply these rules first.
255
296
  - Use `@rpc()` for backend functions that should be callable from the browser.
256
297
  - Use `pp.rpc()` for client-side calls; do not prefer older `pp.fetchFunction()` wording.
257
298
  - Prefer route-render data plus RPC over inventing parallel REST endpoints for normal Caspian page interactions.
299
+ - Read [file-uploads.md](./file-uploads.md) when the task involves file pickers, upload progress, media libraries, or file-manager UI.
258
300
  - Use [cache.md](./cache.md) when a route's initial HTML should be reused across requests and invalidated after writes.
259
301
  - Use [state.md](./state.md) when an RPC mutation needs transient request-scoped success or error state outside the direct response payload.
260
302
  - Use `onStream` for streamed responses and `onUploadProgress` for upload-aware client calls.
@@ -0,0 +1,171 @@
1
+ ---
2
+ title: File Uploads And File Managers
3
+ description: Use this page when the task mentions file uploads, file managers, file pickers, upload progress, public storage paths, or BrowserSync-safe upload directories in Caspian.
4
+ related:
5
+ title: Related docs
6
+ description: Use fetch-data for the route versus RPC split, PulsePoint for client runtime behavior, database for Prisma persistence, project structure for file placement, validation for upload guards, and commands for local watcher behavior.
7
+ links:
8
+ - /docs/fetch-data
9
+ - /docs/pulsepoint
10
+ - /docs/database
11
+ - /docs/project-structure
12
+ - /docs/validation
13
+ - /docs/commands
14
+ - /docs/index
15
+ ---
16
+
17
+ This page documents the recommended file upload and file manager pattern for Caspian projects.
18
+
19
+ Treat uploads as normal route behavior. Keep the owning browser UI in the route template, keep upload and delete `@rpc()` actions in the owning route `index.py`, and move reusable storage or persistence helpers into `src/lib/`.
20
+
21
+ ## Default Pattern
22
+
23
+ - Keep first-render file manager data in `page()` so the initial HTML already contains the current asset list and storage summary.
24
+ - Keep upload and delete actions in the route's `index.py`; do not move ordinary upload flows into `main.py`.
25
+ - Keep reusable file-manager helpers in `src/lib/`.
26
+ - Store uploaded blobs under a project-owned public directory such as `public/storage/...` when the files should be browser-accessible.
27
+ - Store durable metadata in Prisma, not in JSON manifests or ad hoc metadata files.
28
+ - Use `pp.state(...)` plus `pp-for` to render and update the file list from returned server payloads.
29
+ - Use `onUploadProgress` only for progress UI; let the RPC return refreshed manager data for the authoritative post-upload state.
30
+
31
+ ## Recommended Placement
32
+
33
+ | Concern | Preferred location | Notes |
34
+ | --- | --- | --- |
35
+ | File picker UI, tabs, filters, progress state | `src/app/**/index.html` | Use PulsePoint state and template rendering. |
36
+ | Upload and delete `@rpc()` actions | `src/app/**/index.py` | Keep these route-local so they stay close to the owning page. |
37
+ | Shared storage, normalization, and persistence helpers | `src/lib/**` | Reuse helpers across routes without pushing route behavior into app bootstrap. |
38
+ | Upload metadata model | `prisma/schema.prisma` | Persist owner, file name, MIME type, path, size, collection, and timestamps in Prisma. |
39
+ | Browser-accessible uploaded blobs | `public/storage/**` or another app-owned public directory | Keep the public path predictable and derived from stored metadata. |
40
+ | BrowserSync upload ignore | `settings/bs-config.ts` | Keep the active public upload directory in `PUBLIC_IGNORE_DIRS`. |
41
+
42
+ ## Route Flow
43
+
44
+ The normal Caspian file-manager flow is:
45
+
46
+ 1. `page()` calls a shared helper such as `build_file_manager_payload(...)` and renders the first payload into the route template.
47
+ 2. The route template hydrates that payload into `pp.state(...)`.
48
+ 3. The file input calls `pp.rpc(...)` with a `File` object and optional `onUploadProgress` callback.
49
+ 4. The route-local `@rpc()` action validates auth, file presence, size, and routing-specific inputs.
50
+ 5. A shared helper writes the blob, creates or updates the Prisma row, and returns a serialized asset payload.
51
+ 6. The RPC action returns refreshed manager data.
52
+ 7. PulsePoint replaces the route state and `pp-for` rerenders the list.
53
+
54
+ ## Example Route-Local RPC
55
+
56
+ ```python
57
+ from fastapi import File, UploadFile
58
+ from casp.rpc import rpc
59
+
60
+ from src.lib.dashboard.file_manager import (
61
+ build_file_manager_payload,
62
+ save_file_manager_upload,
63
+ )
64
+
65
+ @rpc(require_auth=True)
66
+ async def upload_asset(file: UploadFile = File(...), collection: str = "auto"):
67
+ user_id = current_user_id()
68
+ content = await file.read()
69
+
70
+ uploaded = await save_file_manager_upload(
71
+ user_id,
72
+ file_name=file.filename or "file",
73
+ content=content,
74
+ mime_type=file.content_type,
75
+ desired_group=collection,
76
+ )
77
+
78
+ return {
79
+ "success": True,
80
+ "uploaded": uploaded,
81
+ "data": await build_file_manager_payload(user_id),
82
+ }
83
+ ```
84
+
85
+ Keep route-specific auth checks, input validation, and final response shape here. Keep file naming, directory choice, and Prisma persistence in the shared helper.
86
+
87
+ ## Client Pattern
88
+
89
+ ```html
90
+ <section class="files-page">
91
+ <input type="file" multiple onchange="{uploadSelectedFiles(event.target.files)}" />
92
+
93
+ <template pp-for="asset in assets">
94
+ <article key="{asset.id}">
95
+ <a href="{asset.url}">{asset.name}</a>
96
+ </article>
97
+ </template>
98
+
99
+ <script>
100
+ const [fileManagerData, setFileManagerData] = pp.state(initialFileManagerData);
101
+ const assets = fileManagerData.assets ?? [];
102
+
103
+ async function uploadSelectedFiles(fileList) {
104
+ for (const file of Array.from(fileList ?? [])) {
105
+ const response = await pp.rpc("upload_asset", { file }, {
106
+ onUploadProgress: (progress) => {
107
+ console.log(progress.percentage ?? 0);
108
+ },
109
+ });
110
+
111
+ if (response?.data) {
112
+ setFileManagerData(response.data);
113
+ }
114
+ }
115
+ }
116
+ </script>
117
+ </section>
118
+ ```
119
+
120
+ Prefer this state-driven shape over manual `innerHTML` list painting. In Caspian pages, manual DOM writes are easy to lose when PulsePoint rerenders the owner template.
121
+
122
+ ## Persistence Rules
123
+
124
+ When Prisma is enabled, the durable record of an uploaded file should live in the database.
125
+
126
+ - Write the blob to disk or object storage.
127
+ - Write the metadata to Prisma.
128
+ - Derive public URLs from the stored path.
129
+ - On delete, remove both the stored file and its Prisma row.
130
+ - Treat old JSON manifests only as migration input, not as the primary store.
131
+
132
+ Typical metadata fields include:
133
+
134
+ - owner or user relation
135
+ - original file name
136
+ - stored file name
137
+ - asset path
138
+ - MIME type
139
+ - collection or grouping key
140
+ - kind or preview type
141
+ - size in bytes
142
+ - uploaded timestamp
143
+
144
+ ## BrowserSync And Uploaded Public Files
145
+
146
+ If runtime uploads write into `public/assets/file-manager/`, BrowserSync should ignore that directory during local development. Otherwise every upload can trigger a full browser reload.
147
+
148
+ Use a workspace-relative ignore entry in `settings/bs-config.ts`:
149
+
150
+ ```ts
151
+ const PUBLIC_IGNORE_DIRS = ["public/assets/file-manager"];
152
+ ```
153
+
154
+ Match those entries against workspace-relative paths so nested uploads such as `public/assets/file-manager/user-1/media/example.png` are ignored too.
155
+
156
+ ## What To Avoid
157
+
158
+ - Do not add ordinary upload routes or file-manager glue to `main.py`.
159
+ - Do not use JSON files under `storage/` as the active metadata store when Prisma is enabled.
160
+ - Do not treat `onUploadProgress` callbacks as the source of truth for the final asset list.
161
+ - Do not manually repaint the file list with `innerHTML` when PulsePoint state can own the list.
162
+ - Do not leave uploaded public directories out of BrowserSync ignore rules.
163
+
164
+ ## AI Retrieval Notes
165
+
166
+ - Read this page first when the task mentions uploads, file pickers, file managers, media libraries, or upload progress UI.
167
+ - Use `fetch-data.md` for the route-render versus RPC split.
168
+ - Use `database.md` when Prisma models or relations must change for upload metadata.
169
+ - Use `validation.md` for MIME, extension, and other boundary checks, then keep explicit size and auth checks in the owning RPC action.
170
+ - Use `project-structure.md` for placement rules, especially `src/app/` versus `src/lib/` and `public/assets/file-manager/`.
171
+ - Use `commands.md` and `settings/bs-config.ts` when uploads should not trigger BrowserSync reloads during `npm run dev`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Caspian Docs
3
- description: Caspian documentation with AI-aware routing to the right local docs before framework-specific code generation or project setup changes, with components, PulsePoint, RPC, and Validate as the default app stack.
3
+ description: Packaged Caspian documentation manifest for AI task routing, feature discovery, and file placement. Use this page when deciding which Caspian doc to read first or which feature guide applies.
4
4
  related:
5
5
  title: Next Steps
6
6
  description: Start with installation, review the CLI commands, then use the structure and component guides to place Caspian files correctly.
@@ -8,15 +8,18 @@ related:
8
8
  - /docs/installation
9
9
  - /docs/commands
10
10
  - /docs/mcp
11
+ - /docs/file-uploads
11
12
  - /docs/project-structure
12
13
  - /docs/components
13
14
  ---
14
15
 
15
- This directory contains the local Caspian documentation set for quick reference and AI-aware routing.
16
+ This directory contains the packaged Caspian documentation set for AI-aware feature discovery, task routing, and file-placement guidance.
16
17
 
17
- Before making feature, tooling, or file-placement decisions in a Caspian workspace, read `./caspian.config.json` almost immediately. That file is the project feature gate and tells you which capabilities are enabled, such as Prisma, MCP, TypeScript, Tailwind, backend-only mode, and component scan directories.
18
+ Treat these docs as reusable Caspian feature guidance. Treat `./caspian.config.json` as the single source of truth for which optional features are enabled in the project being analyzed.
18
19
 
19
- Treat `caspian.config.json` as the single source of truth for optional feature enablement. Use feature-specific docs only after the matching flag is confirmed as enabled. If a feature is disabled and the user wants it, ask whether they want to enable it first, then follow the update workflow in `commands.md`.
20
+ The docs can mention optional features even when those features are disabled in a project. Their job is to explain how a feature works, when a doc applies, and which files to inspect next once the feature is confirmed as relevant.
21
+
22
+ Before making feature, tooling, or file-placement decisions in a Caspian project, read `./caspian.config.json` almost immediately. That file tells you which optional capabilities are enabled, such as Prisma, MCP, TypeScript, Tailwind, backend-only mode, and component scan directories.
20
23
 
21
24
  ## Default Stack
22
25
 
@@ -28,11 +31,7 @@ When generating or editing a Caspian app, treat these as the default choices unl
28
31
 
29
32
  ## Docs Location
30
33
 
31
- The local AI-aware docs for this workspace live here:
32
-
33
- - `node_modules/caspian-utils/dist/docs/`
34
-
35
- The packaged Caspian docs distributed by the current toolchain also live here:
34
+ The packaged Caspian docs referenced by this index live here:
36
35
 
37
36
  - `node_modules/caspian-utils/dist/docs/`
38
37
 
@@ -40,12 +39,13 @@ The packaged Caspian docs distributed by the current toolchain also live here:
40
39
 
41
40
  - `installation.md` - First-time setup flow for creating a new Caspian application
42
41
  - `commands.md` - Main Caspian CLI workflows for project creation, generation, updates, and config-aware maintenance
43
- - `mcp.md` - MCP-specific layout, launch flow, and AI routing rules for workspaces where `caspian.config.json` enables MCP
44
- - `database.md` - Prisma schema, migration, seed, and client-generation workflow for workspaces where `caspian.config.json` enables Prisma, plus Python-side helper caveats
42
+ - `mcp.md` - MCP-specific layout, launch flow, and AI routing rules for projects where `caspian.config.json` enables MCP
43
+ - `database.md` - Prisma schema, migration, seed, and client-generation workflow for projects where `caspian.config.json` enables Prisma, plus Python-side helper caveats
45
44
  - `auth.md` - Session-backed authentication with `casp.auth`, centralized `auth_config.py`, public-vs-private route mode guidance, RPC-first signout guidance, RBAC, and OAuth provider helpers
46
45
  - `components.md` - Create reusable Python components, template-backed UI, JSX-style imports, and the single-parent root rule for component HTML files
47
46
  - `pulsepoint.md` - Default reactive frontend runtime contract for component scripts, state, effects, directives, and client-side behaviors
48
47
  - `fetch-data.md` - Initial server-side data loading and browser-triggered RPC flows with `pp.rpc()`, streaming, uploads, and auth-aware actions
48
+ - `file-uploads.md` - Route-local file uploads and file-manager flows with `@rpc()`, `pp.rpc()`, Prisma metadata, public asset storage, and BrowserSync ignore rules
49
49
  - `state.md` - Request-scoped server state with `StateManager`, session-backed JSON persistence, and listener callbacks for transient flows
50
50
  - `cache.md` - Route-level HTML caching with `Cache`, `CacheHandler`, TTL behavior, file-system storage, and invalidation patterns
51
51
  - `validation.md` - Input validation and sanitization with `Validate`, `Rule`, direct field checks, and multi-rule workflows for routes and RPC actions
@@ -53,24 +53,19 @@ The packaged Caspian docs distributed by the current toolchain also live here:
53
53
  - `routing.md` - Next.js App Router-style file-based routing with `src/app`, dynamic segments, route groups, nested layouts, and single-root route templates
54
54
  - `project-structure.md` - Default Caspian layout and where route files, reusable UI in `src/components/`, reusable non-UI code in `src/lib/`, and database files belong
55
55
 
56
- ## AI Awareness Notes
56
+ ## AI Retrieval Notes
57
57
 
58
- If an AI tool needs Caspian project documentation, start with this directory and use this file as the manifest.
58
+ If an AI tool needs Caspian documentation, start with this directory and use this file as the manifest.
59
59
 
60
60
  Preferred lookup order:
61
61
 
62
62
  1. Read `node_modules/caspian-utils/dist/docs/index.md` to discover available local docs.
63
- 2. Read `./caspian.config.json` before making any feature assumption. Use it to confirm which project capabilities are enabled and which directories or tooling rules apply.
63
+ 2. Read `./caspian.config.json` before making any feature assumption. A doc existing in the package does not mean that feature is enabled in the current project.
64
64
  3. Treat `caspian.config.json` as the single source of truth for optional features. Use feature-specific docs only when the matching flag is enabled. If a feature is disabled and the user wants it, ask first, then update `caspian.config.json` and follow the update workflow in `commands.md`.
65
- 4. Read `commands.md` before running any `package.json` script. In this workspace, npm scripts are opt-in operational commands, not default validation steps. Do not run them unless the user explicitly asks, the task genuinely requires that exact script, or deployment preparation needs `npm run build`.
66
- 5. Treat generated outputs such as `public/css/styles.css`, `settings/component-map.json`, `settings/files-list.json`, `__pycache__/`, and `.pyc` files as framework-managed artifacts when the local stack is intentionally running. They are not authored source files and should not be kept in the final diff unless the task explicitly requires them.
67
- 6. Analyze `settings/component-map.json` and `settings/files-list.json` when you need the current generated view of components or routes, but do not hand-edit them. The framework regenerates them through `settings/component-map.ts` and `settings/files-list.ts` when the dev or build pipeline intentionally runs.
68
- 7. Read `database.md` only when `caspian.config.json` enables Prisma, read `mcp.md` only when `caspian.config.json` enables MCP, and use `auth.md`, `components.md`, `pulsepoint.md`, `fetch-data.md`, `state.md`, `cache.md`, and `validation.md` as the next routing docs for those non-flagged concerns.
69
- 8. As the app grows, standardize on `src/app/` for route-owned files, `src/components/` for reusable rendered UI, and `src/lib/` for reusable non-UI support code such as services, validators, adapters, and shared helpers.
70
- 9. For authored component, route, and layout HTML files, generate exactly one top-level lowercase HTML element. Think React-style single parent wrapper: keep any owned PulsePoint logic in a plain `<script>` inside that root, do not handwrite `pp-component="..."` or `type="text/pp"` because Caspian injects those runtime attributes automatically, and treat `<!-- @import ... -->` comments as file-level directives that belong above the authored root element instead of inside `<div>`, `<section>`, or `<html>`. When several component tags come from one Python file, import them from that exact file path, for example `<!-- @import { Breadcrumb, BreadcrumbItem, BreadcrumbList } from "../components/Breadcrumb.py" -->`.
71
- 10. Prefer local docs before generating code, commands, or migration guidance.
72
- 11. Check `node_modules/caspian-utils/dist/docs/` for packaged Caspian docs when local docs need more detail.
73
- 12. Only fall back to upstream documentation when local and packaged markdown do not cover the topic.
65
+ 4. After the feature is confirmed, inspect the actual project files that decide behavior, such as `package.json`, `main.py`, `src/app/**`, `src/lib/**`, `settings/**`, `prisma/**`, and the installed `casp` runtime.
66
+ 5. Use `commands.md` for scaffold and update workflows, `project-structure.md` for placement decisions, and the feature docs such as `mcp.md`, `database.md`, `auth.md`, `fetch-data.md`, and `file-uploads.md` for task-specific guidance.
67
+ 6. Prefer packaged Caspian docs before upstream documentation when generating code, commands, or migration guidance.
68
+ 7. Keep `index.md` and cross-links aligned so AI can quickly discover the right doc.
74
69
 
75
70
  ## Maintenance
76
71
 
@@ -1,12 +1,13 @@
1
1
  ---
2
2
  title: Installation
3
- description: Learn how to create a new Caspian application so AI agents use the first-time setup flow instead of assuming an existing project is already in place.
3
+ description: Use this page when creating a new Caspian application, scaffolding a project, running first-time setup, or choosing optional features during install.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Continue with the routing, structure, and MCP guides after scaffold so the new app follows Caspian conventions and keeps optional FastMCP files in the right place.
7
7
  links:
8
8
  - /docs/commands
9
9
  - /docs/mcp
10
+ - /docs/file-uploads
10
11
  - /docs/routing
11
12
  - /docs/project-structure
12
13
  - /docs/index
@@ -18,7 +19,7 @@ This page documents the first-time Caspian setup flow for new applications.
18
19
 
19
20
  Caspian provides a scaffold flow for new apps with a FastAPI backend and a PulsePoint-based reactive frontend workflow.
20
21
 
21
- In this workspace, the local `caspian-utils` package ships documentation only, so scaffold commands are resolved through external `npx` packages rather than project-local binaries.
22
+ These packaged docs can exist inside an already-created Caspian project, but scaffold commands themselves are typically resolved through external `npx` packages rather than from this docs directory.
22
23
 
23
24
  ## Default App Stack
24
25
 
@@ -60,7 +61,7 @@ After scaffold, read `caspian.config.json` and treat it as the single source of
60
61
 
61
62
  If a feature is disabled and the user wants it later, ask whether they want to enable it first, then update `caspian.config.json` and run `npx casp update project` so framework-managed files align with the new feature set.
62
63
 
63
- If the project enables MCP, use `mcp.md` after scaffold to place the app-owned FastMCP server and config files correctly for the current workspace conventions.
64
+ If the project enables MCP, use `mcp.md` after scaffold to place the app-owned FastMCP server and config files correctly for that project's conventions.
64
65
 
65
66
  ## Recommended VS Code Setup
66
67
 
@@ -84,7 +85,7 @@ cd my-app
84
85
  npm run dev
85
86
  ```
86
87
 
87
- In this workspace, `npm run dev` is backed by BrowserSync plus PostCSS watchers, not a Vite dev server.
88
+ Confirm what `npm run dev` does in the generated project's `package.json`. Many Caspian projects use BrowserSync plus PostCSS watchers rather than a Vite dev server, but the actual script wins.
88
89
 
89
90
  For AI agents and other automated helpers, this is an opt-in local-stack command, not a default validation step. Do not run `package.json` scripts just because a route, feature, or doc changed.
90
91
 
@@ -92,6 +93,8 @@ If `npm run dev` is intentionally running, let that stack own generated outputs
92
93
 
93
94
  Inspect `settings/component-map.json` and `settings/files-list.json` when you need the generated component or route inventory, but do not hand-edit them. The framework refreshes them from `settings/component-map.ts` and `settings/files-list.ts`.
94
95
 
96
+ If runtime uploads write into a public upload directory, keep that directory in `settings/bs-config.ts` `PUBLIC_IGNORE_DIRS` so BrowserSync does not reload on every uploaded file.
97
+
95
98
  ## After Setup
96
99
 
97
100
  Once the project is scaffolded:
@@ -101,11 +104,12 @@ Once the project is scaffolded:
101
104
  - Read `auth.md` before choosing public-vs-private route mode, wiring session config, sign-in or signout flows, route guards, or OAuth providers.
102
105
  - Read `pulsepoint.md` before generating interactive frontend behavior.
103
106
  - Read `fetch-data.md` before adding browser-triggered reads, writes, uploads, or streams.
107
+ - Read `file-uploads.md` before building file pickers, media libraries, or Prisma-backed file-manager flows.
104
108
  - Read `validation.md` before handling forms, auth input, or RPC payloads.
105
109
  - Read `routing.md` to learn how `src/app` folders map to URLs.
106
110
  - Read `project-structure.md` to place route code, shared libraries, config, and database files in the correct directories.
107
111
 
108
- ## AI Routing Notes
112
+ ## AI Retrieval Notes
109
113
 
110
114
  If an AI agent is reading this page, treat it as the source for new-project installation steps.
111
115
 
package/dist/docs/mcp.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: MCP
3
- description: Check `caspian.config.json` first. When it enables MCP, this page becomes the relevant guide for reviewing, fixing, launching, and extending the workspace MCP feature.
3
+ description: Check `caspian.config.json` first. Use this page when the task mentions MCP, FastMCP, `mcp_server.py`, `fastmcp.json`, tool servers, or enabling MCP in a Caspian project.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Start with project structure for file placement, then use commands for feature enablement and local run flows, and index for documentation routing.
@@ -11,9 +11,9 @@ related:
11
11
  - /docs/index
12
12
  ---
13
13
 
14
- This page documents the Model Context Protocol workflow for Caspian workspaces.
14
+ This page documents the Model Context Protocol workflow for Caspian projects.
15
15
 
16
- Treat `caspian.config.json` as the single source of truth for whether MCP is enabled. If `caspian.config.json` confirms `"mcp": true`, this page is relevant, the MCP-specific files in the workspace are the correct files to analyze, and the feature can be reviewed, fixed, launched, or extended here.
16
+ Treat `caspian.config.json` as the single source of truth for whether MCP is enabled. If `caspian.config.json` confirms `"mcp": true`, this page is relevant, the MCP-specific files in the project are the correct files to analyze, and the feature can be reviewed, fixed, launched, or extended here.
17
17
 
18
18
  If `caspian.config.json` has `"mcp": false`, treat this page as reference material only. Do not assume `src/lib/mcp/**`, `settings/restart-mcp.ts`, or MCP-related npm scripts exist until the user chooses to enable MCP and the update workflow has run.
19
19
 
@@ -22,35 +22,35 @@ If `caspian.config.json` has `"mcp": false`, treat this page as reference materi
22
22
  1. Read `caspian.config.json` and confirm `mcp: true` before assuming MCP files or scripts should exist.
23
23
  2. If `mcp` is false and the user wants MCP, ask for confirmation first.
24
24
  3. After the user confirms, update `caspian.config.json` and run `npx casp update project` so framework-managed MCP files align with the new feature set.
25
- 4. After the update, inspect the actual `package.json`, `src/lib/mcp/`, and any launcher files that the workspace now contains.
25
+ 4. After the update, inspect the actual `package.json`, `src/lib/mcp/`, and any launcher files that the project now contains.
26
26
 
27
- ## MCP-Enabled Workspace Layout
27
+ ## MCP-Enabled Project Layout
28
28
 
29
29
  When `caspian.config.json` has `mcp: true`, these are the main MCP surfaces to inspect:
30
30
 
31
31
  - `src/lib/mcp/mcp_server.py` for the app-owned FastMCP server, tool definitions, instructions, and MCP-specific helper logic.
32
32
  - `src/lib/mcp/fastmcp.json` for the default FastMCP config, transport, host, port, path, and server entrypoint.
33
- - `settings/restart-mcp.ts` for workspace-specific launcher logic, discovery order, environment overrides, or log filtering when that file is present.
34
- - `package.json` for the actual MCP-related scripts that the current workspace defines.
33
+ - `settings/restart-mcp.ts` for project-specific launcher logic, discovery order, environment overrides, or log filtering when that file is present.
34
+ - `package.json` for the actual MCP-related scripts that the current project defines.
35
35
 
36
- If these files exist in the workspace, they are the right files to analyze when reviewing or fixing MCP behavior.
36
+ If these files exist in the project, they are the right files to analyze when reviewing or fixing MCP behavior.
37
37
 
38
38
  ## What To Review
39
39
 
40
40
  When `mcp: true` and an MCP issue needs investigation, inspect the files in this order:
41
41
 
42
42
  1. `caspian.config.json` to confirm the feature is enabled.
43
- 2. `package.json` to see which MCP scripts the workspace actually exposes.
43
+ 2. `package.json` to see which MCP scripts the project actually exposes.
44
44
  3. `src/lib/mcp/mcp_server.py` for tool implementation and server behavior.
45
45
  4. `src/lib/mcp/fastmcp.json` for config and entrypoint details.
46
- 5. `settings/restart-mcp.ts` when the workspace includes it and launcher behavior is part of the issue.
46
+ 5. `settings/restart-mcp.ts` when the project includes it and launcher behavior is part of the issue.
47
47
 
48
48
  ## Running MCP
49
49
 
50
- Only when `caspian.config.json` has `mcp: true` and the relevant files or scripts exist:
50
+ Only when `caspian.config.json` has `mcp: true` and the relevant files or scripts exist in the project:
51
51
 
52
- - Use the workspace-defined `npm run mcp` command when `package.json` provides it.
53
- - Use `npm run dev` only if the workspace wires MCP into the full local stack and the user explicitly wants that full stack running.
52
+ - Use the project-defined `npm run mcp` command when `package.json` provides it.
53
+ - Use `npm run dev` only if the project wires MCP into the full local stack and the user explicitly wants that full stack running.
54
54
  - Use direct FastMCP commands against `src/lib/mcp/fastmcp.json` when that config file exists, for example:
55
55
 
56
56
  ```powershell
@@ -58,18 +58,12 @@ Only when `caspian.config.json` has `mcp: true` and the relevant files or script
58
58
  .venv\Scripts\fastmcp.exe run src/lib/mcp/fastmcp.json --no-banner
59
59
  ```
60
60
 
61
- Because script names and launcher wiring can vary by workspace version, always confirm the actual scripts in `package.json` instead of assuming them from docs alone.
61
+ Because script names and launcher wiring can vary by project, always confirm the actual scripts in `package.json` instead of assuming them from docs alone.
62
62
 
63
- ## Current Workspace Status
64
-
65
- - `caspian.config.json` currently has `mcp: false`.
66
- - `package.json` does not currently define `npm run mcp`.
67
- - The current repo tree should not be treated as if `src/lib/mcp/**` is guaranteed to exist.
68
-
69
- ## AI Routing Notes
63
+ ## AI Retrieval Notes
70
64
 
71
65
  1. Read `caspian.config.json` first.
72
66
  2. If `mcp` is false, do not infer MCP files, scripts, or launch flow from generic Caspian examples.
73
67
  3. If the user wants MCP while it is disabled, ask first, then update `caspian.config.json` and use `npx casp update project` before continuing.
74
- 4. If `mcp` is true, this page becomes the relevant MCP guide and the MCP-specific files in the workspace become the correct analysis surface.
75
- 5. Inspect the actual generated files and scripts in the workspace before editing or starting anything.
68
+ 4. If `mcp` is true, this page becomes the relevant MCP guide and the MCP-specific files in the project become the correct analysis surface.
69
+ 5. Inspect the actual generated files and scripts in the project before editing or starting anything.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Metadata & SEO
3
- description: Define static and dynamic metadata in Caspian so titles, descriptions, and social cards inherit correctly from layouts to pages.
3
+ description: Use this page when the task mentions metadata, SEO, page titles, descriptions, Open Graph, Twitter cards, or layout-to-page metadata inheritance in Caspian.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Use the routing guide to place layout.py and index.py files correctly, then use the structure guide when deciding where metadata defaults belong.
@@ -185,7 +185,7 @@ Keep visual layout data and SEO metadata separate.
185
185
  - Put page-specific static metadata in `index.py`.
186
186
  - Put dynamic metadata inside `page()` after you have route params or fetched data.
187
187
 
188
- ## AI Routing Notes
188
+ ## AI Retrieval Notes
189
189
 
190
190
  If an AI agent is deciding where to put SEO fields, apply these rules first.
191
191
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Project Structure
3
- description: Understand the default Caspian project layout so AI agents place routes, reusable components, PulsePoint templates, RPC actions, validation helpers, auth code, MCP files, configuration, and database changes in the correct directories.
3
+ description: Understand the default Caspian project layout so AI agents place routes, reusable components, `src/lib` helpers, auth code, MCP files, public assets, and database changes in the correct directories. Use when deciding where project files belong.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Start with installation for new apps, then use the component guide for reusable UI, the auth guide for bootstrap and session wiring, the MCP guide for server layout, the routing guide to map URLs correctly, and the cache guide when route HTML should be reused safely.
@@ -12,11 +12,14 @@ related:
12
12
  - /docs/routing
13
13
  - /docs/cache
14
14
  - /docs/database
15
+ - /docs/file-uploads
15
16
  - /docs/index
16
17
  ---
17
18
 
18
19
  This page explains the default layout of a Caspian application, where Caspian core files live, and which paths AI agents should treat as project code versus framework internals.
19
20
 
21
+ Treat it as a framework guide for Caspian projects. Use `caspian.config.json` and the actual repository tree to confirm which optional directories and files exist in the current project.
22
+
20
23
  ## Overview
21
24
 
22
25
  Caspian uses a lean project layout that keeps application code in `src`, database files in `prisma`, static assets in `public`, configuration in `caspian.config.json`, and framework internals in the installed package.
@@ -40,6 +43,7 @@ Treat `caspian.config.json` as the single source of truth for optional feature e
40
43
  - `src/lib/mcp/` contains the app-owned FastMCP server and nested FastMCP config when MCP is enabled.
41
44
  - `prisma/` contains the Prisma schema and seed scripts.
42
45
  - `public/` contains static assets served directly.
46
+ - `settings/` contains BrowserSync, build, restart, and generated-project helper files.
43
47
  - `main.py` is the application entry point.
44
48
  - `caspian.config.json` is the core feature configuration file.
45
49
  - `.venv/Lib/site-packages/casp/` contains the installed Caspian framework core.
@@ -54,6 +58,9 @@ my-app/
54
58
  prisma/
55
59
  schema.prisma
56
60
  seed.ts
61
+ settings/
62
+ bs-config.ts
63
+ build.ts
57
64
  public/
58
65
  src/
59
66
  app/
@@ -118,7 +125,7 @@ For component HTML files, follow the same one-parent rule as route HTML files: o
118
125
 
119
126
  Do not handwrite `pp-component="..."` or `type="text/pp"` in component source templates either. Write plain `<script>` inside the single root and let the render pipeline inject the runtime shape.
120
127
 
121
- This workspace's component tooling scans `src/` based on `caspian.config.json`, so `src/components/` is a conventionally clean location, not a hard-coded runtime requirement.
128
+ The directories listed in `componentScanDirs` determine where component tooling scans. When that list includes `src/`, `src/components/` is a conventionally clean location, not a hard-coded runtime requirement.
122
129
 
123
130
  ### `src/lib/`
124
131
 
@@ -126,15 +133,17 @@ Use this folder for shared helpers, reusable validators, RPC-facing service wrap
126
133
 
127
134
  If the code is primarily rendered UI that will be imported as a component tag, prefer `src/components/`. If the code is a helper, service, adapter, validator, or other non-visual support module, prefer `src/lib/`.
128
135
 
129
- This workspace already includes an app-owned Python database layer under `src/lib/prisma/`. Reuse that package for Python-side data access and keep any additional shared database helpers in `src/lib/`.
136
+ For file upload and manager flows, keep route-owned `@rpc()` actions in `src/app/**/index.py` and keep shared storage, naming, filesystem, and Prisma-backed persistence helpers in `src/lib/`.
137
+
138
+ When a project includes an app-owned Python database layer under `src/lib/prisma/`, reuse that package for Python-side data access and keep any additional shared database helpers in `src/lib/`.
130
139
 
131
- When MCP is enabled in the current workspace, this folder also contains the app-owned FastMCP server under `src/lib/mcp/`.
140
+ When MCP is enabled for the project, this folder also contains the app-owned FastMCP server under `src/lib/mcp/`.
132
141
 
133
142
  ### Shared Database Helpers
134
143
 
135
144
  If your Python routes or RPC actions need reusable database access code, keep that helper layer under `src/lib/` and extend the existing `src/lib/prisma/` package.
136
145
 
137
- In this workspace, Prisma schema and seed files live under `prisma/`, while the Python-side adapter is application-owned code under `src/lib/prisma/`.
146
+ In a Prisma-enabled Caspian project, schema and seed files typically live under `prisma/`, while the Python-side adapter lives in application-owned code under `src/lib/prisma/` when that layer exists.
138
147
 
139
148
  ### `src/lib/auth/`
140
149
 
@@ -151,7 +160,7 @@ When `caspian.config.json` has `mcp: true`:
151
160
 
152
161
  Keep MCP tool definitions here instead of placing them in route files, `main.py`, or framework internals.
153
162
 
154
- In the current workspace, `mcp: false`, so do not assume this folder exists until the feature is enabled and the update workflow has run.
163
+ If `caspian.config.json` has `mcp: false`, do not assume this folder exists until the feature is enabled and the update workflow has run.
155
164
 
156
165
  ### `prisma/`
157
166
 
@@ -161,6 +170,10 @@ This folder contains your database model definitions in `schema.prisma` and any
161
170
 
162
171
  Store static assets here, including images, fonts, and generated frontend assets that should be served directly.
163
172
 
173
+ Runtime-uploaded public blobs can also live here. Confirm the actual upload path in the project code and keep that directory aligned with any BrowserSync ignore rules.
174
+
175
+ If the local BrowserSync stack is running, keep that upload directory in `settings/bs-config.ts` `PUBLIC_IGNORE_DIRS` so new uploads do not force a full browser reload.
176
+
164
177
  ## Key Files
165
178
 
166
179
  ### `main.py`
@@ -184,7 +197,13 @@ The core feature configuration file for the application.
184
197
 
185
198
  AI agents should read this file before making almost any feature-level decision. Use it to confirm which capabilities are enabled, which code generation paths make sense, and which directories should be scanned for components or other project assets.
186
199
 
187
- In the current workspace, `caspian.config.json` shows `backendOnly: false`, `tailwindcss: true`, `mcp: false`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
200
+ Read the actual values in `caspian.config.json` instead of inferring feature state from this doc.
201
+
202
+ ### `settings/bs-config.ts`
203
+
204
+ The BrowserSync watcher configuration for the local stack lives here.
205
+
206
+ When runtime uploads write into `public/assets/file-manager/`, keep `public/assets/file-manager` in `PUBLIC_IGNORE_DIRS` and match it against workspace-relative paths so nested uploaded files do not trigger reloads.
188
207
 
189
208
  ### `src/lib/auth/auth_config.py`
190
209
 
@@ -210,6 +229,8 @@ If this layout imports reusable components, place each `<!-- @import ... -->` co
210
229
 
211
230
  The backend logic for the route. This is where route behavior can load first-render data, expose `@rpc()` actions, and import framework features such as auth helpers, `casp.validate`, and route-level `Cache(...)` declarations.
212
231
 
232
+ When a route owns a file manager or upload UI, keep the owning upload and delete `@rpc()` actions in that route's `index.py` and move reusable filesystem or Prisma helpers into `src/lib/`. Do not move ordinary upload behavior into `main.py`.
233
+
213
234
  ### `src/app/index.html`
214
235
 
215
236
  The route template. It supports standard HTML, `<!-- @import ... -->` component imports, and PulsePoint directives, and it should be the default place for reactive frontend behavior in Caspian.
@@ -237,11 +258,11 @@ Notable internal files include:
237
258
 
238
259
  The packaged Caspian documentation location distributed with the current toolchain.
239
260
 
240
- ## AI Routing Notes
261
+ ## AI Retrieval Notes
241
262
 
242
263
  If an AI agent is deciding where to make changes, use these rules first.
243
264
 
244
- - Read `caspian.config.json` almost immediately before making feature, tooling, or file-placement decisions. It tells you which Caspian features are enabled in the current workspace.
265
+ - Read `caspian.config.json` almost immediately before making feature, tooling, or file-placement decisions. It tells you which Caspian features are enabled in the current project.
245
266
  - Treat `caspian.config.json` as the single source of truth for optional feature enablement. Use feature-specific docs and file paths only when the matching flag is enabled.
246
267
  - If an optional feature is disabled and the user wants it, ask first, then update `caspian.config.json` and use `npx casp update project` before assuming feature-managed files exist.
247
268
  - Treat `package.json` scripts as opt-in operations. Do not run `npm run dev` or `npm run build` unless the user explicitly asks, the task genuinely requires that exact script, or deployment prep needs `npm run build`.
@@ -249,6 +270,7 @@ If an AI agent is deciding where to make changes, use these rules first.
249
270
  - Inspect `settings/component-map.json` and `settings/files-list.json` when you need the generated component or route inventory, but do not hand-edit them. The workspace regenerates them from `settings/component-map.ts` and `settings/files-list.ts`.
250
271
  - Put route templates and route-specific backend logic in `src/app/`.
251
272
  - As the app grows, keep route-owned code in `src/app/`, reusable rendered UI in `src/components/`, and reusable non-UI support code in `src/lib/`.
273
+ - Read [file-uploads.md](./file-uploads.md) when the task involves upload widgets, media libraries, or file-manager flows.
252
274
  - Check [routing.md](./routing.md) when you need URL segment rules, layout nesting behavior, or dynamic route conventions.
253
275
  - Put reusable component files in `src/components/` and check [components.md](./components.md) for `@component`, `render_html(__file__)`, import comments, and single-root template rules.
254
276
  - When deciding between `src/components/` and `src/lib/`, use `src/components/` for anything rendered as reusable UI and `src/lib/` for helpers, services, validators, adapters, and shared business logic.
@@ -256,12 +278,13 @@ If an AI agent is deciding where to make changes, use these rules first.
256
278
  - Keep `<!-- @import ... -->` comments above the single authored root element in route, layout, and component HTML files.
257
279
  - For route and component HTML files, always emit one top-level lowercase HTML element. Good: one wrapper containing the content and a plain `<script>` when needed. Bad: a wrapper element followed by a sibling top-level `<script>`, or handwritten `pp-component="..."` and `type="text/pp"` attributes in source.
258
280
  - Put shared helpers and reusable libraries in `src/lib/`.
281
+ - Use `settings/bs-config.ts` when uploaded public assets should not trigger BrowserSync reloads during the local stack.
259
282
  - Put app-owned FastMCP code in `src/lib/mcp/` only when `caspian.config.json` enables MCP.
260
283
  - Use PulsePoint conventions in route templates for reactive frontend behavior.
261
284
  - Use `@rpc()` in route/backend code and `pp.rpc()` in client code for browser-triggered data flows.
262
285
  - Use `casp.cache_handler` when a route's first-render HTML should be reused safely across requests.
263
286
  - Use `casp.validate` at route and RPC boundaries, and move reusable validators into `src/lib/` when multiple routes share them.
264
- - Use `database.md` when the task involves Prisma schema changes, migrations, seed logic, or workspace-specific database helper conventions.
287
+ - Use `database.md` when the task involves Prisma schema changes, migrations, seed logic, or project-specific database helper conventions.
265
288
  - Put authentication configuration in `src/lib/auth/auth_config.py`.
266
289
  - Put auth bootstrap, session middleware, and provider registration changes in `main.py`.
267
290
  - Put database models and seed logic in `prisma/`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: PulsePoint Runtime Guide
3
- description: Learn how AI agents should author PulsePoint against the shipped browser runtime in `public/js/pp-reactive-v2.js` and the Caspian render pipeline that injects runtime attributes automatically.
3
+ description: Use this page when the task mentions PulsePoint, `pp.state`, `pp.effect`, `pp-ref`, `pp-for`, portals, SPA navigation, or `public/js/pp-reactive-v2.js`.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Read the components, routing, data-fetching, and project-structure docs alongside the PulsePoint runtime contract.
@@ -14,19 +14,19 @@ related:
14
14
 
15
15
  ## Purpose
16
16
 
17
- This file documents the current PulsePoint contract for this workspace. Treat it as the AI-facing source of truth when generating or reviewing interactive Caspian UI.
17
+ This file documents the PulsePoint contract for the shipped Caspian browser runtime. Treat it as the AI-facing source of truth when generating or reviewing interactive Caspian UI.
18
18
 
19
19
  If a task involves `pp.state`, `pp.effect`, `pp.layoutEffect`, `pp-ref`, `pp-spread`, `pp-for`, context, portals, SPA navigation, or component boundary behavior, read this page first and keep generated code aligned with the runtime implemented in this repo.
20
20
 
21
- Use `components.md` for authoring Python `@component` files and same-name HTML templates. Use this page for the browser-side PulsePoint contract, the authoring rules that feed it, and the React-style mental model used by the current runtime.
21
+ Use `components.md` for authoring Python `@component` files and same-name HTML templates. Use this page for the browser-side PulsePoint contract, the authoring rules that feed it, and the React-style mental model used by the shipped runtime.
22
22
 
23
- PulsePoint is the default reactive frontend layer for Caspian. In this workspace it follows a React-like component pattern, but it is HTML-first rather than JSX-first.
23
+ PulsePoint is the default reactive frontend layer for Caspian. In the current runtime it follows a React-like component pattern, but it is HTML-first rather than JSX-first.
24
24
 
25
25
  Do not assume React, Vue, Svelte, JSX, Alpine, HTMX, or older PulsePoint docs unless the task explicitly asks for a different frontend contract.
26
26
 
27
27
  ## Source Of Truth
28
28
 
29
- For the current workspace, follow this order when documenting or generating PulsePoint code:
29
+ When documenting or generating PulsePoint code, follow this order:
30
30
 
31
31
  - `public/js/pp-reactive-v2.js` is the shipped browser runtime contract AI should follow.
32
32
  - `main.py` is the render-pipeline source of truth for how Caspian injects runtime attributes and rewrites scripts before the browser sees the HTML.
@@ -376,6 +376,7 @@ RPC notes:
376
376
  - Passing `true` as the third argument means `abortPrevious: true`.
377
377
  - The options object supports `abortPrevious`, `onStream`, `onStreamError`, `onStreamComplete`, `onUploadProgress`, and `onUploadComplete`.
378
378
  - File uploads switch to the XHR path when upload progress callbacks are needed.
379
+ - For file managers, use upload callbacks for progress UI but replace the asset list from returned RPC state with `pp.state(...)` and `pp-for` instead of manual DOM repainting. See [file-uploads.md](./file-uploads.md).
379
380
  - Streamed `text/event-stream` responses are supported when a stream handler is provided.
380
381
  - Redirect headers are honored through `pp.redirect()`.
381
382
 
@@ -419,6 +420,7 @@ Use these rules when generating or editing PulsePoint runtime code:
419
420
  - Use native `on*` attributes, not framework-specific event syntax.
420
421
  - Use refs and portals only through the implemented `pp` APIs.
421
422
  - Use `pp.rpc()` for the bundled runtime API instead of older `pp.fetchFunction()` wording.
423
+ - For upload managers, keep the authoritative asset list in `pp.state(...)` and route uploads through `pp.rpc()` with `onUploadProgress` as needed.
422
424
  - Avoid generating internal runtime attributes.
423
425
  - Avoid scriptless nested components when the child template contains its own bindings.
424
426
  - Prefer authored-template examples over runtime-inspected HTML examples unless the doc is specifically explaining runtime internals.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Routing
3
- description: Understand Caspian's Next.js App Router-style file-based routing, including src/app conventions, index files, dynamic segments, route groups, nested layouts, and component-friendly route templates.
3
+ description: Use this page when the task mentions `src/app`, `index.py`, `index.html`, `layout.py`, dynamic routes, route groups, nested layouts, or file-based routing in Caspian.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Read the structure guide first, then use the components guide for reusable UI, the metadata guide for SEO fields, the cache guide for route-level HTML reuse, and the PulsePoint runtime guide for interactive route templates.
@@ -8,6 +8,7 @@ related:
8
8
  - /docs/project-structure
9
9
  - /docs/components
10
10
  - /docs/cache
11
+ - /docs/file-uploads
11
12
  - /docs/metadata
12
13
  - /docs/pulsepoint
13
14
  - /docs/index
@@ -169,6 +170,8 @@ async def page():
169
170
 
170
171
  Use this pattern when the route needs to fetch data, compute metadata, or do other non-blocking server work before rendering.
171
172
 
173
+ When a route owns a file manager or upload UI, keep the owning upload and delete `@rpc()` actions in that same `index.py` and move reusable filesystem or Prisma helpers into `src/lib/`. Do not move ordinary upload behavior into `main.py`. See [file-uploads.md](./file-uploads.md).
174
+
172
175
  For static and dynamic metadata rules, inheritance order, and social card fields, see [metadata.md](./metadata.md).
173
176
 
174
177
  If the rendered HTML for that route is public and safe to reuse, declare route-level caching in the same file with `Cache(...)`. See [cache.md](./cache.md).
@@ -304,7 +307,7 @@ src/
304
307
  index.py
305
308
  ```
306
309
 
307
- ## AI Routing Notes
310
+ ## AI Retrieval Notes
308
311
 
309
312
  If an AI agent is choosing where to add or update route code, apply these rules first.
310
313
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: State Management
3
- description: Manage transient Caspian server state with `casp.state_manager` and `StateManager`, using request-scoped ContextVar storage, shallow AttributeDict reads, listener callbacks, and session-backed JSON persistence.
3
+ description: Use this page when the task mentions `StateManager`, `request.state.session`, request-scoped state, listeners, or session-backed JSON state in Caspian.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Pair server request state with auth and RPC flows, then read the PulsePoint guide when the state really belongs in the browser instead of the request lifecycle.
@@ -64,7 +64,7 @@ Important implementation detail:
64
64
 
65
65
  In other words, cross-request persistence depends on the surrounding Caspian middleware keeping `request.state.session` available and in sync with session storage.
66
66
 
67
- In this workspace's current `main.py`, `SessionMiddleware` exposes `request.session`, but the middleware stack does not mirror that into `request.state.session`. Treat persistence as opt-in until you add that bridge explicitly.
67
+ Inspect the current project's `main.py`: if `SessionMiddleware` exposes `request.session` but the middleware stack does not mirror that into `request.state.session`, treat persistence as opt-in until you add that bridge explicitly.
68
68
 
69
69
  ## Request Lifecycle
70
70
 
@@ -251,7 +251,7 @@ Poor candidates are:
251
251
 
252
252
  For browser-triggered writes and route actions, pair this page with [fetch-data.md](./fetch-data.md). For middleware and session-aware auth flows, pair it with [auth.md](./auth.md).
253
253
 
254
- ## AI Routing Notes
254
+ ## AI Retrieval Notes
255
255
 
256
256
  If an AI agent is deciding how to use transient state in a Caspian app, apply these rules first.
257
257
 
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  title: Validation
3
- description: Validate and sanitize Caspian inputs with `casp.validate`, `Validate`, `Rule`, direct validators, rule-based checks, and file or date or ID validation before route or RPC logic persists data, with Validate as the default server-side validation layer.
3
+ description: Use this page when the task mentions `Validate`, `Rule`, sanitization, form validation, credential checks, or guarding route and RPC inputs in Caspian.
4
4
  related:
5
- title: Related docs
5
+ title: Related docs
6
6
  description: Use the auth guide for session and credential flows, the fetch-data guide when validation runs inside RPC actions, then use the structure guide to place reusable validators in the right layer.
7
- links:
7
+ links:
8
8
  - /docs/auth
9
- - /docs/fetch-data
10
- - /docs/routing
11
- - /docs/project-structure
12
- - /docs/index
9
+ - /docs/fetch-data
10
+ - /docs/routing
11
+ - /docs/project-structure
12
+ - /docs/index
13
13
  ---
14
14
 
15
15
  This page explains the current installed Caspian validation API for direct field checks, rule-based validation, sanitization, and reusable input guards.
@@ -203,6 +203,8 @@ The installed file includes upload-oriented helpers and rules.
203
203
 
204
204
  Use these rules for RPC uploads and form submissions that accept files.
205
205
 
206
+ Combine them with explicit auth, size, and storage-boundary checks in the owning RPC action before writing files to disk or Prisma. See [file-uploads.md](./file-uploads.md) for the recommended file-manager pattern.
207
+
206
208
  ## Sanitization
207
209
 
208
210
  Validation in Caspian is more than rule checking. The installed implementation also sanitizes or normalizes several values.
@@ -276,7 +278,7 @@ def create_account(data: dict):
276
278
  return {"success": True}
277
279
  ```
278
280
 
279
- ## AI Routing Notes
281
+ ## AI Retrieval Notes
280
282
 
281
283
  If an AI agent is deciding how to validate input in Caspian, apply these rules first.
282
284
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caspian-utils",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Caspian tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {