caspian-utils 0.0.11 → 0.0.13

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
@@ -3,7 +3,7 @@ title: Authentication
3
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.
4
4
  related:
5
5
  title: Related docs
6
- description: Use the fetch-data guide when sign-in 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.
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.
7
7
  links:
8
8
  - /docs/fetch-data
9
9
  - /docs/state
@@ -50,6 +50,7 @@ from casp.auth import (
50
50
 
51
51
  - Define app-wide auth behavior in `build_auth_settings()` and apply it once at startup with `configure_auth(...)`.
52
52
  - Use `auth.sign_in(...)` and `auth.sign_out(...)` instead of setting or clearing session keys directly.
53
+ - Prefer `pp.rpc(...)` plus `@rpc(require_auth=True)` for signout buttons or menus rendered in pages or components. Use a dedicated signout route only when you need a plain HTML form POST or a no-JavaScript fallback.
53
54
  - Use `@require_auth`, `@require_role`, and `@guest_only` for page access rules.
54
55
  - Use `@rpc(require_auth=True, allowed_roles=[...])` for browser-triggered actions that need protection.
55
56
  - Use `StateManager` only for transient auth-adjacent request state; keep the authenticated session itself owned by `casp.auth`.
@@ -112,12 +113,52 @@ Important behavior from the current implementation:
112
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`.
113
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.
114
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.
115
117
  - `public_routes`, `auth_routes`, `private_routes`, and `role_based_routes` are exact path matches in the installed `Auth` methods.
116
118
  - `private_routes` matters only when `is_all_routes_private=False`.
117
119
  - `role_based_routes` currently expects `PATH -> [ROLES]`, not role names keyed to paths the other way around.
118
120
  - `role_identifier` defaults to `role`, and the current `auth.sign_in(...)` flow also normalizes `userRole` into `role` when possible.
119
121
  - `api_auth_prefix` defaults to `/api/auth` and should stay centralized here rather than being hard-coded across routes.
120
122
 
123
+ ## Choosing Public vs Private Route Mode
124
+
125
+ Make this decision at app setup time in `src/lib/auth/auth_config.py`.
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`.
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
+ - 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
+ - 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.
131
+ - In all-private mode, the default `public_routes=["/"]` keeps the home page public unless you change that list.
132
+ - `token_auto_refresh=True` does not make routes private. It only enables sliding-session refresh when the request lifecycle calls `auth.refresh_session()`.
133
+ - You do not need to modify Caspian core files for this decision. Keep the policy in `src/lib/auth/auth_config.py`.
134
+ - If you customize `src/lib/auth/auth_config.py`, add it to `excludeFiles` in `caspian.config.json` so update commands do not overwrite your local auth policy.
135
+
136
+ Example all-private setup with a few public exceptions:
137
+
138
+ ```python
139
+ return AuthSettings(
140
+ default_token_validity="1h",
141
+ token_auto_refresh=False,
142
+ is_all_routes_private=True,
143
+ public_routes=["/", "/pricing", "/about"],
144
+ auth_routes=["/signin", "/signup"],
145
+ private_routes=[],
146
+ )
147
+ ```
148
+
149
+ Example mixed app with many public routes and only a few protected areas:
150
+
151
+ ```python
152
+ return AuthSettings(
153
+ default_token_validity="1h",
154
+ token_auto_refresh=False,
155
+ is_all_routes_private=False,
156
+ public_routes=["/"],
157
+ auth_routes=["/signin", "/signup"],
158
+ private_routes=["/dashboard", "/settings", "/billing"],
159
+ )
160
+ ```
161
+
121
162
  ## Environment Variables
122
163
 
123
164
  The installed auth code reads several values from `.env` when explicit values are not passed.
@@ -414,16 +455,58 @@ src/
414
455
  signup/
415
456
  index.py
416
457
  index.html
417
- signout/
418
- index.py
458
+ signout/
459
+ index.py
419
460
  dashboard/
420
461
  index.py
421
462
  index.html
422
463
  ```
423
464
 
424
- Use `guest_only()` on signin and signup routes, use `auth.sign_in(...)` inside the owning RPC action after validation and credential checks, and protect private destinations with `require_auth()` or central route policy.
465
+ Use `guest_only()` on signin and signup routes, use `auth.sign_in(...)` inside the owning RPC action after validation and credential checks, prefer RPC for signout UI actions, and protect private destinations with `require_auth()` or central route policy.
466
+
467
+ Preferred signout pattern: auth-protected RPC from a page or component.
468
+
469
+ Use this when the logout trigger lives in a page, layout, header, dropdown, or reusable component. The HTML can live at page level or component level.
470
+
471
+ ```html
472
+ <div>
473
+ <button onclick="signout()">
474
+ Sign out
475
+ </button>
476
+
477
+ <script>
478
+ async function signout() {
479
+ await pp.rpc("signout");
480
+ }
481
+ </script>
482
+ </div>
483
+ ```
484
+
485
+ ```python
486
+ from casp.auth import auth
487
+ from casp.rpc import rpc
488
+
489
+
490
+ @rpc(require_auth=True)
491
+ def signout():
492
+ return auth.sign_out()
493
+ ```
494
+
495
+ Fallback signout pattern: dedicated route.
496
+
497
+ Use this when you need a plain HTML form POST, a no-JavaScript fallback, or a full-route signout endpoint.
498
+
499
+ HTML:
500
+
501
+ ```html
502
+ <form action="/signout" method="post">
503
+ <button type="submit">
504
+ <span>Log Out</span>
505
+ </button>
506
+ </form>
507
+ ```
425
508
 
426
- Simple signout route example:
509
+ Route: `src/app/(auth)/signout/index.py`
427
510
 
428
511
  ```python
429
512
  from casp.auth import auth, require_auth
@@ -659,11 +742,17 @@ Validate and authenticate close to the input boundary.
659
742
  Common placement patterns are:
660
743
 
661
744
  - put centralized policy in `src/lib/auth/auth_config.py`
745
+ - decide public-vs-private route mode at app start in `src/lib/auth/auth_config.py` instead of scattering route privacy logic across route files
746
+ - use `is_all_routes_private=True` only when most routes should require auth; otherwise keep `is_all_routes_private=False` and maintain `private_routes`
747
+ - keep public exceptions in `public_routes`, and leave `auth_routes=["/signin", "/signup"]` alone unless the app explicitly needs different auth endpoints
662
748
  - call `configure_auth(build_auth_settings())` during startup
663
- - keep sign-in, signup, signout, and reset-password handlers in the owning route backend under `src/app/**/index.py`
749
+ - keep sign-in, signup, and reset-password handlers in the owning route backend under `src/app/**/index.py`
750
+ - prefer signout through `pp.rpc("signout")` with `@rpc(require_auth=True)` when the trigger lives in page or component UI
751
+ - use a dedicated signout route only for no-JavaScript, form-post, or full-navigation edge cases
664
752
  - use `@rpc()` for browser-triggered auth actions and page decorators for full-route protection
665
753
  - use `Validate` and `Rule` from `casp.validate` before password checks, user lookup, persistence, or external provider flows
666
754
  - keep reusable auth helpers in `src/lib/auth/`
755
+ - protect customized auth policy files from updater overwrite with `excludeFiles` in `caspian.config.json`
667
756
 
668
757
  For browser-triggered auth forms, pair this page with `fetch-data.md`. For credential and form validation, pair it with `validation.md`.
669
758
 
@@ -673,15 +762,22 @@ If an AI agent is deciding how to handle auth in Caspian, apply these rules firs
673
762
 
674
763
  - Treat `casp.auth` as the default authentication layer.
675
764
  - Centralize route visibility, redirects, and RBAC policy in `src/lib/auth/auth_config.py`.
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.
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.
676
768
  - Apply settings at startup in `main.py` with `configure_auth(build_auth_settings())`.
677
769
  - Register provider instances in `main.py` with `Auth.set_providers(...)` when Google or GitHub OAuth is enabled.
678
770
  - Use `auth.sign_in(...)` and `auth.sign_out(...)` for session lifecycle changes.
771
+ - Prefer `pp.rpc("signout")` plus `@rpc(require_auth=True)` for logout buttons or menus in pages and components.
772
+ - Use a dedicated `/signout` route only for plain HTML form POST, no-JavaScript fallback, or other full-navigation edge cases.
773
+ - Do not treat `token_auto_refresh` as a route-privacy switch. In the current app it only affects sliding-session refresh if `auth.refresh_session()` is called.
679
774
  - Use `@require_auth`, `@require_role`, and `@guest_only` for page-level access rules.
680
775
  - Use `@rpc(require_auth=True, allowed_roles=[...])` for protected browser-triggered actions.
681
776
  - Keep `SessionMiddleware` outermost so auth, CSRF, and RPC handlers can read `request.session`.
682
777
  - Use [state.md](./state.md) only for transient auth-adjacent request state, not as the auth session store.
683
778
  - Align `SESSION_LIFETIME_HOURS` with `default_token_validity` unless you intentionally want different cookie and auth-payload expiry windows.
684
779
  - Prefer exact route strings in `public_routes`, `auth_routes`, `private_routes`, and `role_based_routes`.
780
+ - Protect customized `src/lib/auth/auth_config.py` from updater overwrite by adding it to `excludeFiles` in `caspian.config.json`.
685
781
  - Keep auth secrets and OAuth provider credentials in `.env`.
686
782
  - Set `AUTH_COOKIE_NAME` explicitly so the session middleware cookie name and auth settings stay aligned.
687
783
  - Use `.venv/Lib/site-packages/casp/auth.py` only when the task is about framework auth internals or debugging installed behavior.
@@ -19,7 +19,7 @@ This page documents the current Caspian command families used with this workspac
19
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
21
 
22
- The current workspace also includes a local MCP run path through `npm run mcp`, which starts the app-owned FastMCP server via `settings/restart-mcp.ts`.
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
23
 
24
24
  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
25
 
@@ -32,7 +32,9 @@ This updated reference includes the newer updater behavior and the current scaff
32
32
  - Windows-safe execution that resolves `npx.cmd` on Win32
33
33
  - scaffold behavior that reuses an existing `.venv` instead of recreating it every time
34
34
 
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: true`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
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
+
37
+ 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.
36
38
 
37
39
  ## 1. Main Command Families
38
40
 
@@ -69,37 +71,27 @@ npx casp update project
69
71
 
70
72
  Use when you are inside an existing Caspian project and want to refresh framework-managed files using the project's `caspian.config.json`.
71
73
 
72
- ### Run the local MCP server
73
-
74
- ```bash
75
- npm run mcp
76
- ```
74
+ This is also the workflow to use after the user chooses to enable or disable an optional feature in `caspian.config.json`.
77
75
 
78
- Use when you want the workspace's app-owned FastMCP server only.
79
-
80
- ### Run the full local stack including MCP
76
+ ### Run the full local stack
81
77
 
82
78
  ```bash
83
79
  npm run dev
84
80
  ```
85
81
 
86
- Use when you want BrowserSync, Tailwind, the Python app server, and MCP together.
87
-
88
- ### Inspect the local MCP config directly
82
+ Use when the user explicitly wants the local BrowserSync plus PostCSS development stack.
89
83
 
90
- ```powershell
91
- .venv\Scripts\fastmcp.exe inspect src/lib/mcp/fastmcp.json
92
- ```
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.
93
85
 
94
- Use when you are debugging the nested FastMCP config or checking which tools the current MCP server exposes.
86
+ ### Build generated assets for deployment
95
87
 
96
- ### Run FastMCP directly with the nested config
97
-
98
- ```powershell
99
- .venv\Scripts\fastmcp.exe run src/lib/mcp/fastmcp.json --no-banner
88
+ ```bash
89
+ npm run build
100
90
  ```
101
91
 
102
- Use when you want the raw FastMCP path without the npm wrapper.
92
+ Use when preparing deployment or when the user explicitly asks for a build.
93
+
94
+ Do not use `npm run build` as the default validation step for routine route, feature, or documentation edits.
103
95
 
104
96
  ### Regenerate ORM after schema changes
105
97
 
@@ -115,9 +107,19 @@ npx ppy generate
115
107
 
116
108
  Use when `prisma/schema.prisma` changes and you need migrations, seed flow, and the generated Python ORM layer to stay aligned.
117
109
 
118
- Because this workspace keeps `fastmcp.json` under `src/lib/mcp/`, plain `fastmcp run` from the project root does not auto-detect the config. Use `npm run mcp` or pass the explicit config path.
110
+ ## 2. Script Guardrails
119
111
 
120
- ## 2. Supported Flags And Options
112
+ - Before using an optional feature, confirm its flag in `caspian.config.json`.
113
+ - If the flag is false and the user wants that feature, ask first, then update `caspian.config.json` and run `npx casp update project` before assuming feature-managed files or scripts exist.
114
+ - Do not run `package.json` scripts by default just because source files changed.
115
+ - Treat `npm run dev` and `npm run build` as opt-in workflows.
116
+ - Use `npm run dev` only when the user explicitly asks to start the local stack or the task truly needs that running workflow.
117
+ - Use `npm run build` only for deployment prep or an explicit build request.
118
+ - 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
+ - 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.
120
+ - Do not edit `__pycache__/` directories or `.pyc` files, and do not leave them in the final diff.
121
+
122
+ ## 3. Supported Flags And Options
121
123
 
122
124
  ### For `create-caspian-app`
123
125
 
@@ -147,9 +149,9 @@ Because this workspace keeps `fastmcp.json` under `src/lib/mcp/`, plain `fastmcp
147
149
 
148
150
  The updater throws an error if conflicting version sources are provided.
149
151
 
150
- ## 3. Create Command Combinations
152
+ ## 4. Create Command Combinations
151
153
 
152
- ### 3.1 Base create command
154
+ ### 4.1 Base create command
153
155
 
154
156
  #### Interactive create
155
157
 
@@ -175,7 +177,7 @@ In skip-prompt mode, the default feature values are:
175
177
  - `mcp: false`
176
178
  - `prisma: false`
177
179
 
178
- ### 3.2 Backend-only combinations
180
+ ### 4.2 Backend-only combinations
179
181
 
180
182
  In backend-only mode, the main meaningful toggles are `--mcp` and `--prisma`. Frontend-oriented flags may still appear in raw CLI args, but they are not part of the normal backend-only feature flow.
181
183
 
@@ -225,7 +227,7 @@ npx create-caspian-app my-app --backend-only --tailwindcss --typescript
225
227
 
226
228
  These flags can be present in raw CLI args, but backend-only mode removes frontend assets and disables the normal TypeScript and frontend path, so they are not practical combinations.
227
229
 
228
- ### 3.3 Full-stack combinations
230
+ ### 4.3 Full-stack combinations
229
231
 
230
232
  These apply when `--backend-only` is not used.
231
233
 
@@ -373,7 +375,7 @@ npx create-caspian-app my-app --tailwindcss --typescript --mcp --prisma -y
373
375
 
374
376
  Use when you want the most complete default full-stack configuration.
375
377
 
376
- ## 4. Starter Kit Command Combinations
378
+ ## 5. Starter Kit Command Combinations
377
379
 
378
380
  ### Built-in starter kits
379
381
 
@@ -471,7 +473,7 @@ npx create-caspian-app my-app --starter-kit=custom --starter-kit-source=https://
471
473
 
472
474
  Use when the scaffold should come from an external Git repository. The CLI clones the repository, removes `.git`, and updates project config for the new project.
473
475
 
474
- ## 5. Update Command Combinations
476
+ ## 6. Update Command Combinations
475
477
 
476
478
  The updater recognizes only the `update project` command family. Anything outside that family is rejected by the wrapper.
477
479
 
@@ -545,7 +547,7 @@ npx casp update project --version=1.2.3 -y
545
547
 
546
548
  Use for automated pinned upgrades.
547
549
 
548
- ## 6. Invalid Or Conflicting Update Cases
550
+ ## 7. Invalid Or Conflicting Update Cases
549
551
 
550
552
  These cases matter because the newer updater parsing is stricter.
551
553
 
@@ -575,7 +577,7 @@ npx casp update project 1.2.3 --version 2.0.0
575
577
 
576
578
  Result: parsing error because more than one version source was provided.
577
579
 
578
- ## 7. Prisma And Python ORM Regeneration
580
+ ## 8. Prisma And Python ORM Regeneration
579
581
 
580
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.
581
583
 
@@ -608,7 +610,7 @@ Do not manually create or edit these generated files:
608
610
 
609
611
  See [database.md](./database.md) for the full schema, migration, seed, and async usage guide.
610
612
 
611
- ## 8. Practical Recommendation Matrix
613
+ ## 9. Practical Recommendation Matrix
612
614
 
613
615
  | Goal | Recommended command |
614
616
  | --- | --- |
@@ -623,7 +625,7 @@ See [database.md](./database.md) for the full schema, migration, seed, and async
623
625
  | Update current project to an exact version | `npx casp update project --version 1.2.3 -y` |
624
626
  | Regenerate Python ORM after schema changes | `npx prisma migrate dev` then optional seed commands, then `npx ppy generate` |
625
627
 
626
- ## 9. Configuration Notes
628
+ ## 10. Configuration Notes
627
629
 
628
630
  The CLI reads `caspian.config.json` to decide how it should interact with the project.
629
631
 
@@ -643,9 +645,13 @@ This is useful for protecting:
643
645
  - entry-point files
644
646
  - other locally modified framework-managed files
645
647
 
648
+ Auth example:
649
+
650
+ - add `./src/lib/auth/auth_config.py` to `excludeFiles` when you customize route privacy policy, public-route exceptions, redirects, or other app-specific auth settings there
651
+
646
652
  If you exclude a file, the updater preserves it, but you are responsible for merging future framework changes into that file manually.
647
653
 
648
- ## 10. Operational Notes
654
+ ## 11. Operational Notes
649
655
 
650
656
  1. On Windows, the updater resolves `npx.cmd` instead of plain `npx`, which makes execution more reliable on Win32.
651
657
  2. The updater still requires `caspian.config.json` in the current directory before running an update.
@@ -16,6 +16,8 @@ This page documents the Prisma workflow present in this workspace.
16
16
 
17
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.
18
18
 
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
+
19
21
  ## Overview
20
22
 
21
23
  The standard Prisma flow in Caspian is:
@@ -20,7 +20,7 @@ This page explains how data fetching works in Caspian. Use route functions for i
20
20
 
21
21
  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
22
 
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. In this workspace, MCP tool definitions live under `src/lib/mcp/` and are documented in `mcp.md`.
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
24
 
25
25
  ## Overview
26
26
 
@@ -73,7 +73,7 @@ Notes:
73
73
  - 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
74
  - Keep reusable database or API clients under `src/lib/`; keep route-specific orchestration in `src/app/`.
75
75
 
76
- If the data source is Prisma, see `database.md` for the current workspace's schema, migration, and generation workflow. This scaffold does not generate Python-side Prisma helpers under `src/lib/` by default.
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
77
 
78
78
  ## Interactive Data With RPC
79
79
 
@@ -16,6 +16,8 @@ This directory contains the local Caspian documentation set for quick reference
16
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
18
 
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
+
19
21
  ## Default Stack
20
22
 
21
23
  When generating or editing a Caspian app, treat these as the default choices unless the task explicitly requires something else:
@@ -38,9 +40,9 @@ The packaged Caspian docs distributed by the current toolchain also live here:
38
40
 
39
41
  - `installation.md` - First-time setup flow for creating a new Caspian application
40
42
  - `commands.md` - Main Caspian CLI workflows for project creation, generation, updates, and config-aware maintenance
41
- - `mcp.md` - Workspace FastMCP server layout, nested config path, local launch flow, and MCP-specific AI routing rules
42
- - `database.md` - Prisma schema, migration, seed, and client-generation workflow for the current workspace, plus Python-side helper caveats
43
- - `auth.md` - Session-backed authentication with `casp.auth`, centralized `auth_config.py`, decorators, RBAC, and OAuth provider helpers
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
45
+ - `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
44
46
  - `components.md` - Create reusable Python components, template-backed UI, JSX-style imports, and the single-parent root rule for component HTML files
45
47
  - `pulsepoint.md` - Default reactive frontend runtime contract for component scripts, state, effects, directives, and client-side behaviors
46
48
  - `fetch-data.md` - Initial server-side data loading and browser-triggered RPC flows with `pp.rpc()`, streaming, uploads, and auth-aware actions
@@ -59,11 +61,15 @@ Preferred lookup order:
59
61
 
60
62
  1. Read `node_modules/caspian-utils/dist/docs/index.md` to discover available local docs.
61
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.
62
- 3. Read `database.md` for Prisma setup and ORM usage, `mcp.md` for the current FastMCP server layout and local run flow, `auth.md` for session auth and route protection, `components.md` for reusable UI authoring, `pulsepoint.md` for browser-side reactive runtime behavior, `fetch-data.md` for data flows, `state.md` for transient request-scoped state, `cache.md` for page caching, and `validation.md` for input boundaries.
63
- 4. 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" -->`.
64
- 5. Prefer local docs before generating code, commands, or migration guidance.
65
- 6. Check `node_modules/caspian-utils/dist/docs/` for packaged Caspian docs when local docs need more detail.
66
- 7. Only fall back to upstream documentation when local and packaged markdown do not cover the topic.
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. 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" -->`.
70
+ 9. Prefer local docs before generating code, commands, or migration guidance.
71
+ 10. Check `node_modules/caspian-utils/dist/docs/` for packaged Caspian docs when local docs need more detail.
72
+ 11. Only fall back to upstream documentation when local and packaged markdown do not cover the topic.
67
73
 
68
74
  ## Maintenance
69
75
 
@@ -56,6 +56,10 @@ The interactive wizard walks through the main project options, including:
56
56
  - Feature toggles such as backend-only mode, Tailwind CSS, Prisma, MCP, and TypeScript
57
57
  - Other scaffold options exposed by the current CLI version
58
58
 
59
+ After scaffold, read `caspian.config.json` and treat it as the single source of truth for which optional features are enabled in that project. Use feature-specific docs only after the matching flag is confirmed as enabled.
60
+
61
+ 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
+
59
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.
60
64
 
61
65
  ## Recommended VS Code Setup
@@ -82,13 +86,19 @@ npm run dev
82
86
 
83
87
  In this workspace, `npm run dev` is backed by BrowserSync plus PostCSS watchers, not a Vite dev server.
84
88
 
89
+ 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
+ If `npm run dev` is intentionally running, let that stack own generated outputs such as `public/css/styles.css`, `settings/component-map.json`, `settings/files-list.json`, `__pycache__/`, and `.pyc` files. Use `npm run build` only for deployment prep or when the user explicitly asks for a build.
92
+
93
+ 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
+
85
95
  ## After Setup
86
96
 
87
97
  Once the project is scaffolded:
88
98
 
89
99
  - Read `database.md` when the app includes Prisma ORM support or needs database changes.
90
100
  - Read `mcp.md` when the app includes MCP support or needs FastMCP server, config, or launch-flow changes.
91
- - Read `auth.md` before wiring session config, sign-in or signout routes, route guards, or OAuth providers.
101
+ - Read `auth.md` before choosing public-vs-private route mode, wiring session config, sign-in or signout flows, route guards, or OAuth providers.
92
102
  - Read `pulsepoint.md` before generating interactive frontend behavior.
93
103
  - Read `fetch-data.md` before adding browser-triggered reads, writes, uploads, or streams.
94
104
  - Read `validation.md` before handling forms, auth input, or RPC payloads.
@@ -102,6 +112,9 @@ If an AI agent is reading this page, treat it as the source for new-project inst
102
112
  - Use this workflow when the user is creating a Caspian app from scratch.
103
113
  - Do not use existing-project migration or update commands unless the project already exists.
104
114
  - After scaffold, default to PulsePoint for interactive UI, RPC for browser-to-server data flow, and `casp.validate` for validation.
115
+ - Treat `package.json` scripts as opt-in commands after scaffold. Do not auto-run `npm run dev` or `npm run build` for ordinary source edits.
116
+ - Read `caspian.config.json` after scaffold and treat it as the single source of truth for optional features before using feature-specific docs.
117
+ - 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 the framework-managed files exist.
105
118
  - If MCP is enabled, read [mcp.md](./mcp.md) before editing FastMCP files or assuming where the server config should live.
106
119
  - Once the app exists, check [routing.md](./routing.md) before creating or changing routes under `src/app/`.
107
120
  - Check [index.md](./index.md) first when deciding which local doc to follow.
package/dist/docs/mcp.md CHANGED
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  title: MCP
3
- description: Use the workspace FastMCP setup through src/lib/mcp/mcp_server.py, src/lib/mcp/fastmcp.json, and settings/restart-mcp.ts, with npm-driven startup and explicit manual paths when running FastMCP directly.
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.
4
4
  related:
5
5
  title: Related docs
6
- description: Start with project structure for file placement, then use commands for local run flows and index for documentation routing.
6
+ description: Start with project structure for file placement, then use commands for feature enablement and local run flows, and index for documentation routing.
7
7
  links:
8
8
  - /docs/project-structure
9
9
  - /docs/commands
@@ -11,92 +11,65 @@ related:
11
11
  - /docs/index
12
12
  ---
13
13
 
14
- This page documents the Model Context Protocol workflow present in this workspace.
14
+ This page documents the Model Context Protocol workflow for Caspian workspaces.
15
15
 
16
- The current repo enables MCP in `caspian.config.json`, keeps the app-owned FastMCP server at `src/lib/mcp/mcp_server.py`, keeps the FastMCP config at `src/lib/mcp/fastmcp.json`, and starts it through `npm run mcp`, which runs `settings/restart-mcp.ts`.
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.
17
17
 
18
- ## Overview
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
 
20
- Use these rules as the default MCP workflow in this workspace:
20
+ ## Enablement Workflow
21
21
 
22
- 1. Read `caspian.config.json` and confirm `mcp: true` before assuming MCP files should exist or be started.
23
- 2. Edit `src/lib/mcp/mcp_server.py` when changing FastMCP tools, server instructions, or server-owned helper logic.
24
- 3. Edit `src/lib/mcp/fastmcp.json` when changing the transport, host, port, path, or server entrypoint.
25
- 4. Edit `settings/restart-mcp.ts` when changing discovery order, environment overrides, or MCP log filtering.
26
- 5. Use `npm run mcp` as the normal local launch flow.
22
+ 1. Read `caspian.config.json` and confirm `mcp: true` before assuming MCP files or scripts should exist.
23
+ 2. If `mcp` is false and the user wants MCP, ask for confirmation first.
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.
27
26
 
28
- ## Current Workspace Layout
27
+ ## MCP-Enabled Workspace Layout
29
28
 
30
- - `src/lib/mcp/mcp_server.py` defines `mcp = FastMCP(...)` and the current workspace tools.
31
- - `src/lib/mcp/fastmcp.json` points to `src/lib/mcp/mcp_server.py` and configures `streamable-http` on `127.0.0.1:5101/mcp`.
32
- - `settings/restart-mcp.ts` is the npm-facing launcher. It resolves MCP config paths, starts FastMCP, and trims noisy banner or warning output down to essential lines.
33
- - `package.json` defines `npm run mcp` as `tsx settings/restart-mcp.ts` and includes `mcp` in `npm run dev`.
34
- - `caspian.config.json` is the feature gate. If `mcp` is false, the MCP runner exits cleanly without starting a server.
29
+ When `caspian.config.json` has `mcp: true`, these are the main MCP surfaces to inspect:
35
30
 
36
- ## Current Tools
31
+ - `src/lib/mcp/mcp_server.py` for the app-owned FastMCP server, tool definitions, instructions, and MCP-specific helper logic.
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.
37
35
 
38
- The app-owned MCP server currently exposes these read-only tools:
36
+ If these files exist in the workspace, they are the right files to analyze when reviewing or fixing MCP behavior.
39
37
 
40
- - `project_info` returns the project name, root path, version metadata, browser sync target, feature flags, and component scan directories.
41
- - `workspace_files` returns the generated workspace file list, optionally filtered to `all`, `app`, or `public`.
42
- - `component_inventory` returns the latest generated component map from `settings/component-map.json`.
38
+ ## What To Review
43
39
 
44
- Add or change tools in `src/lib/mcp/mcp_server.py`.
40
+ When `mcp: true` and an MCP issue needs investigation, inspect the files in this order:
45
41
 
46
- ## Running The Server
42
+ 1. `caspian.config.json` to confirm the feature is enabled.
43
+ 2. `package.json` to see which MCP scripts the workspace actually exposes.
44
+ 3. `src/lib/mcp/mcp_server.py` for tool implementation and server behavior.
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.
47
47
 
48
- ### Preferred local commands
48
+ ## Running MCP
49
49
 
50
- ```bash
51
- npm run mcp
52
- npm run dev
53
- ```
54
-
55
- Use `npm run mcp` when you want the MCP server only. Use `npm run dev` when you want BrowserSync, Tailwind, the Python app server, and MCP together.
56
-
57
- ### Direct FastMCP commands
50
+ Only when `caspian.config.json` has `mcp: true` and the relevant files or scripts exist:
58
51
 
59
- On this Windows workspace, the direct FastMCP commands are:
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.
54
+ - Use direct FastMCP commands against `src/lib/mcp/fastmcp.json` when that config file exists, for example:
60
55
 
61
56
  ```powershell
62
57
  .venv\Scripts\fastmcp.exe inspect src/lib/mcp/fastmcp.json
63
58
  .venv\Scripts\fastmcp.exe run src/lib/mcp/fastmcp.json --no-banner
64
59
  ```
65
60
 
66
- Because the config file lives under `src/lib/mcp/`, plain `fastmcp run` from the project root does not auto-detect it. Use `npm run mcp` or pass the explicit config path.
67
-
68
- ## Config And Discovery Rules
69
-
70
- `settings/restart-mcp.ts` currently resolves MCP server specs in this order:
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.
71
62
 
72
- 1. `MCP_SERVER_SPEC`
73
- 2. `src/lib/mcp/fastmcp.json`
74
- 3. `fastmcp.json`
75
- 4. `mcp.json`
63
+ ## Current Workspace Status
76
64
 
77
- The runner also forwards these optional overrides to FastMCP:
78
-
79
- - `MCP_TRANSPORT`
80
- - `MCP_HOST`
81
- - `MCP_PORT`
82
- - `MCP_PATH`
83
- - `MCP_LOG_LEVEL`
84
-
85
- Keep the `source.path` value in `src/lib/mcp/fastmcp.json` root-relative as `src/lib/mcp/mcp_server.py`. Do not shorten it to `mcp_server.py` unless the launch working directory changes too, because FastMCP resolves that path from the current working directory.
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.
86
68
 
87
69
  ## AI Routing Notes
88
70
 
89
- If an AI tool is working on MCP in this workspace, use this order:
90
-
91
- 1. Read `caspian.config.json` to confirm `mcp: true`.
92
- 2. Read `node_modules/caspian-utils/dist/docs/mcp.md` for the current workspace MCP rules.
93
- 3. Read `src/lib/mcp/mcp_server.py` for tool definitions and server instructions.
94
- 4. Read `src/lib/mcp/fastmcp.json` for transport and entrypoint configuration.
95
- 5. Read `settings/restart-mcp.ts` and `package.json` for local start behavior.
96
-
97
- Default placement rules:
98
-
99
- - Put app-owned FastMCP tools in `src/lib/mcp/mcp_server.py`.
100
- - Keep the default FastMCP config in `src/lib/mcp/fastmcp.json`.
101
- - Keep npm-facing launch behavior in `settings/restart-mcp.ts`.
102
- - If the MCP file layout changes, update this page, `AGENTS.md`, `.github/copilot-instructions.md`, and any workspace runner logic together.
71
+ 1. Read `caspian.config.json` first.
72
+ 2. If `mcp` is false, do not infer MCP files, scripts, or launch flow from generic Caspian examples.
73
+ 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.
@@ -27,6 +27,8 @@ For public pages that can safely reuse rendered HTML, Caspian also supports rout
27
27
 
28
28
  Before an AI agent decides which Caspian features are available in a workspace, it should read `./caspian.config.json` almost immediately. That file is the feature gate for project capabilities such as `backendOnly`, `tailwindcss`, `mcp`, `prisma`, `typescript`, and `componentScanDirs`.
29
29
 
30
+ Treat `caspian.config.json` as the single source of truth for optional feature enablement. Use feature-specific files and docs only after the matching flag is confirmed as 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`.
31
+
30
32
  ## Top-Level Areas
31
33
 
32
34
  - `src/` contains routes, page templates, styles, and shared libraries.
@@ -81,6 +83,8 @@ my-app/
81
83
  docs/
82
84
  ```
83
85
 
86
+ Optional directories such as `src/lib/mcp/` appear only when the relevant feature flag is enabled in `caspian.config.json`.
87
+
84
88
  ## Directory Breakdown
85
89
 
86
90
  ### `src/`
@@ -133,13 +137,15 @@ Use this folder for authentication-specific project code. The main auth configur
133
137
 
134
138
  Use this folder for app-owned Model Context Protocol server files.
135
139
 
136
- In the current workspace:
140
+ When `caspian.config.json` has `mcp: true`:
137
141
 
138
142
  - `src/lib/mcp/mcp_server.py` defines `mcp = FastMCP(...)` and the current tool set.
139
- - `src/lib/mcp/fastmcp.json` is the default FastMCP config used by `npm run mcp`.
143
+ - `src/lib/mcp/fastmcp.json` is the default FastMCP config file for any workspace-defined MCP launcher, such as `npm run mcp` when that script exists.
140
144
 
141
145
  Keep MCP tool definitions here instead of placing them in route files, `main.py`, or framework internals.
142
146
 
147
+ In the current workspace, `mcp: false`, so do not assume this folder exists until the feature is enabled and the update workflow has run.
148
+
143
149
  ### `prisma/`
144
150
 
145
151
  This folder contains your database model definitions in `schema.prisma` and any seed logic such as `seed.ts`.
@@ -171,7 +177,7 @@ The core feature configuration file for the application.
171
177
 
172
178
  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.
173
179
 
174
- In the current workspace, `caspian.config.json` shows `backendOnly: false`, `tailwindcss: true`, `mcp: true`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
180
+ In the current workspace, `caspian.config.json` shows `backendOnly: false`, `tailwindcss: true`, `mcp: false`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
175
181
 
176
182
  ### `src/lib/auth/auth_config.py`
177
183
 
@@ -179,11 +185,11 @@ The project auth configuration file. Use this path when changing authentication
179
185
 
180
186
  ### `src/lib/mcp/mcp_server.py`
181
187
 
182
- The app-owned FastMCP server module for this workspace. It exports the `mcp` server instance and should be the default place for workspace MCP tools.
188
+ When `caspian.config.json` has `mcp: true`, this is the app-owned FastMCP server module. It exports the `mcp` server instance and should be the default place for workspace MCP tools.
183
189
 
184
190
  ### `src/lib/mcp/fastmcp.json`
185
191
 
186
- The default FastMCP config file for this workspace.
192
+ When `caspian.config.json` has `mcp: true`, this is the default FastMCP config file for the workspace.
187
193
 
188
194
  Because this file is nested under `src/lib/mcp/`, direct FastMCP commands should pass the explicit path, for example `fastmcp run src/lib/mcp/fastmcp.json`, unless the launch working directory changes.
189
195
 
@@ -229,14 +235,19 @@ The packaged Caspian documentation location distributed with the current toolcha
229
235
  If an AI agent is deciding where to make changes, use these rules first.
230
236
 
231
237
  - 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.
238
+ - 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.
239
+ - 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.
240
+ - 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`.
241
+ - Treat `__pycache__/` directories, `.pyc` files, `public/css/styles.css`, `settings/component-map.json`, and `settings/files-list.json` as generated artifacts when the local stack is intentionally running. They are not authored source files.
242
+ - 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`.
232
243
  - Put route templates and route-specific backend logic in `src/app/`.
233
244
  - Check [routing.md](./routing.md) when you need URL segment rules, layout nesting behavior, or dynamic route conventions.
234
245
  - 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.
235
- - Use [mcp.md](./mcp.md) when the task involves FastMCP tool definitions, nested config discovery, or local MCP commands.
246
+ - Use [mcp.md](./mcp.md) only when `caspian.config.json` enables MCP and the task involves FastMCP tool definitions, nested config discovery, or local MCP commands.
236
247
  - Keep `<!-- @import ... -->` comments above the single authored root element in route, layout, and component HTML files.
237
248
  - 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.
238
249
  - Put shared helpers and reusable libraries in `src/lib/`.
239
- - Put app-owned FastMCP code in `src/lib/mcp/`.
250
+ - Put app-owned FastMCP code in `src/lib/mcp/` only when `caspian.config.json` enables MCP.
240
251
  - Use PulsePoint conventions in route templates for reactive frontend behavior.
241
252
  - Use `@rpc()` in route/backend code and `pp.rpc()` in client code for browser-triggered data flows.
242
253
  - Use `casp.cache_handler` when a route's first-render HTML should be reused safely across requests.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caspian-utils",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Caspian tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {