caspian-utils 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/file-conventions.md +259 -0
- package/dist/docs/index.md +46 -44
- package/dist/docs/routing.md +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: File Conventions
|
|
3
|
+
description: Use this page when deciding what belongs in `index.html`, `index.py`, `layout.html`, `layout.py`, `loading.html`, `not-found.html`, or `error.html` in a Caspian app.
|
|
4
|
+
related:
|
|
5
|
+
title: Related docs
|
|
6
|
+
description: Use the routing guide for URL and subtree behavior, the structure guide for placement, the metadata guide for SEO fields, the cache guide for route-level caching, and the runtime maps when the task crosses into framework internals.
|
|
7
|
+
links:
|
|
8
|
+
- /docs/routing
|
|
9
|
+
- /docs/project-structure
|
|
10
|
+
- /docs/metadata
|
|
11
|
+
- /docs/cache
|
|
12
|
+
- /docs/pulsepoint
|
|
13
|
+
- /docs/core-runtime-map
|
|
14
|
+
- /docs/pulsepoint-runtime-map
|
|
15
|
+
- /docs/index
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
This page is the quick decision guide for the special file conventions under `src/app`.
|
|
19
|
+
|
|
20
|
+
Use it when a task names `index.html`, `index.py`, `layout.html`, `layout.py`, `loading.html`, `not-found.html`, or `error.html`, or when the question is where a page shell, route logic, loading UI, 404 page, or 500 page should live.
|
|
21
|
+
|
|
22
|
+
Treat `caspian.config.json` and the actual project tree as the source of truth for which features exist in the current workspace. For runtime ownership, verify these rules against:
|
|
23
|
+
|
|
24
|
+
- `main.py` for global `not-found.html` and `error.html` handling
|
|
25
|
+
- `.venv/Lib/site-packages/casp/layout.py` for `render_page(...)`, `render_layout(...)`, and nested layout behavior
|
|
26
|
+
- `.venv/Lib/site-packages/casp/loading.py` plus `public/js/pp-reactive-v2.js` for `loading.html` collection and SPA loading behavior
|
|
27
|
+
- `.venv/Lib/site-packages/casp/caspian_config.py` for how `index.*`, `layout.html`, and `loading.html` are indexed under `src/app`
|
|
28
|
+
|
|
29
|
+
## Quick Map
|
|
30
|
+
|
|
31
|
+
| File | Purpose | Add it when | Verify against |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `index.html` | Authored visible page template for a route | The route renders UI | `src/app/**`, `routing.md`, `pulsepoint.md` |
|
|
34
|
+
| `index.py` | Backend companion for route logic and metadata | The route needs `page()`, metadata, auth checks, redirects, caching, or route-owned `@rpc()` actions | `main.py`, `.venv/Lib/site-packages/casp/layout.py` |
|
|
35
|
+
| `layout.html` | Shared shell for a route subtree | Multiple child routes share wrapper markup | `.venv/Lib/site-packages/casp/layout.py`, `routing.md` |
|
|
36
|
+
| `layout.py` | Shared synchronous props and metadata defaults for a subtree | The shared shell needs Python-provided values or metadata | `.venv/Lib/site-packages/casp/layout.py`, `metadata.md` |
|
|
37
|
+
| `loading.html` | Route-scope loading UI used during SPA navigation | A section or page needs an immediate loading state before the next route finishes rendering | `.venv/Lib/site-packages/casp/loading.py`, `public/js/pp-reactive-v2.js` |
|
|
38
|
+
| `not-found.html` | Global 404 page | The app needs a branded fallback for unmatched URLs | `main.py` |
|
|
39
|
+
| `error.html` | Global 500 page | The app needs a safe fallback for unhandled exceptions | `main.py` |
|
|
40
|
+
|
|
41
|
+
## Authored HTML Rule
|
|
42
|
+
|
|
43
|
+
For authored route, layout, loading, not-found, and error HTML files, keep exactly one top-level parent HTML element or one imported `x-*` component root.
|
|
44
|
+
|
|
45
|
+
- Keep any `<!-- @import ... -->` directives above that root.
|
|
46
|
+
- Keep any owned plain `<script>` inside that root, not after it.
|
|
47
|
+
- Do not handwrite `pp-component` or `type="text/pp"`.
|
|
48
|
+
|
|
49
|
+
This is a runtime requirement, not a style preference.
|
|
50
|
+
|
|
51
|
+
## `index.html`
|
|
52
|
+
|
|
53
|
+
`index.html` is the authored page template for a route.
|
|
54
|
+
|
|
55
|
+
Use it for:
|
|
56
|
+
|
|
57
|
+
- visible page markup
|
|
58
|
+
- HTML-first `x-*` component usage
|
|
59
|
+
- PulsePoint state, refs, effects, and directives that belong to that route
|
|
60
|
+
- route-local plain `<script>` blocks that stay inside the same root
|
|
61
|
+
|
|
62
|
+
For any route that renders UI, keep the visible markup here even when the route also has an `index.py` companion.
|
|
63
|
+
|
|
64
|
+
Example:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<!-- @import Button from "../../components/Button.py" -->
|
|
68
|
+
|
|
69
|
+
<section class="space-y-4 p-6">
|
|
70
|
+
<h1 class="text-2xl font-semibold">Dashboard</h1>
|
|
71
|
+
|
|
72
|
+
<x-button onclick="setFilter('open')">
|
|
73
|
+
Show Open
|
|
74
|
+
</x-button>
|
|
75
|
+
|
|
76
|
+
<script>
|
|
77
|
+
const [filter, setFilter] = pp.state("all");
|
|
78
|
+
</script>
|
|
79
|
+
</section>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Use `index.html` by itself when the route is UI-only.
|
|
83
|
+
|
|
84
|
+
## `index.py`
|
|
85
|
+
|
|
86
|
+
`index.py` is the backend companion for a route.
|
|
87
|
+
|
|
88
|
+
Add it when the route needs:
|
|
89
|
+
|
|
90
|
+
- `page()`
|
|
91
|
+
- metadata
|
|
92
|
+
- auth checks or redirects
|
|
93
|
+
- route-level `Cache(...)`
|
|
94
|
+
- route-owned `@rpc()` actions
|
|
95
|
+
- server-side context before rendering the sibling template
|
|
96
|
+
|
|
97
|
+
For UI routes, `index.py` does not replace `index.html`. It prepares data and calls `render_page(__file__, ...)` so Caspian renders the sibling template.
|
|
98
|
+
|
|
99
|
+
Example:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from casp.layout import Metadata, render_page
|
|
103
|
+
|
|
104
|
+
metadata = Metadata(
|
|
105
|
+
title="Dashboard | Caspian",
|
|
106
|
+
description="Overview page for the dashboard.",
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
async def page(params: dict, request=None):
|
|
111
|
+
return render_page(__file__, {
|
|
112
|
+
"slug": params.get("slug"),
|
|
113
|
+
"has_request": request is not None,
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Current route-parameter behavior:
|
|
118
|
+
|
|
119
|
+
- path params arrive as a single `params` dict
|
|
120
|
+
- query params can be injected by name
|
|
121
|
+
- `request` is injected by keyword when declared
|
|
122
|
+
|
|
123
|
+
When one page needs to influence a wrapping layout, `page()` can return `(page_html, layout_props_dict)`.
|
|
124
|
+
|
|
125
|
+
## `layout.html`
|
|
126
|
+
|
|
127
|
+
`layout.html` is the shared wrapper for a route subtree.
|
|
128
|
+
|
|
129
|
+
Use it for:
|
|
130
|
+
|
|
131
|
+
- shared shell markup such as sidebars, headers, docs rails, or dashboard frames
|
|
132
|
+
- the `[[children|safe]]` insertion point for child routes
|
|
133
|
+
- shared layout props consumed as `[[ layout.* ]]`
|
|
134
|
+
- shared metadata fields consumed as `[[ metadata.* ]]`
|
|
135
|
+
|
|
136
|
+
Example:
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<div class="docs-shell">
|
|
140
|
+
<aside class="docs-nav">Docs navigation</aside>
|
|
141
|
+
|
|
142
|
+
<main class="docs-content" pp-reset-scroll="true">
|
|
143
|
+
[[children|safe]]
|
|
144
|
+
</main>
|
|
145
|
+
</div>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use nested `layout.html` files for sections like `dashboard/`, `docs/`, `account/`, or route groups such as `(marketing)/`.
|
|
149
|
+
|
|
150
|
+
In grouped shells with separate shell and content scrolling, put `pp-reset-scroll="true"` on the content pane that should reset on child-route navigation. Leave persistent shell scrollers such as sidebars unmarked when they should keep their own scroll position.
|
|
151
|
+
|
|
152
|
+
## `layout.py`
|
|
153
|
+
|
|
154
|
+
`layout.py` is the Python companion for `layout.html`.
|
|
155
|
+
|
|
156
|
+
Use it for:
|
|
157
|
+
|
|
158
|
+
- shared synchronous props
|
|
159
|
+
- metadata defaults for everything below that folder
|
|
160
|
+
- small shared layout decisions that belong to the subtree rather than one page
|
|
161
|
+
|
|
162
|
+
Return `render_layout(__file__), props` so the sibling `layout.html` stays the authored wrapper.
|
|
163
|
+
|
|
164
|
+
Example:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from casp.layout import Metadata, render_layout
|
|
168
|
+
|
|
169
|
+
metadata = Metadata(
|
|
170
|
+
title="Docs Section | Caspian",
|
|
171
|
+
description="Shared metadata for the docs subtree.",
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def layout():
|
|
176
|
+
return render_layout(__file__), {
|
|
177
|
+
"shell_class": "docs-shell",
|
|
178
|
+
"content_class": "docs-shell__content",
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Important runtime detail: `layout()` is synchronous in the installed runtime. Put async I/O in route `page()` functions or route-owned `@rpc()` actions instead of awaiting inside `layout.py`.
|
|
183
|
+
|
|
184
|
+
## `loading.html`
|
|
185
|
+
|
|
186
|
+
`loading.html` provides route-scope loading UI for SPA navigation.
|
|
187
|
+
|
|
188
|
+
The runtime indexes `src/app/**/loading.html` separately from routes and layouts. During navigation, the browser runtime looks for the closest matching loading file by URL scope and falls back up the path toward `/`.
|
|
189
|
+
|
|
190
|
+
Examples:
|
|
191
|
+
|
|
192
|
+
- `src/app/loading.html` can act as the root fallback loader
|
|
193
|
+
- `src/app/dashboard/loading.html` applies to `/dashboard` and its descendants unless a closer loading file exists
|
|
194
|
+
- `src/app/(marketing)/loading.html` applies to the grouped subtree even though `(marketing)` does not appear in the URL
|
|
195
|
+
|
|
196
|
+
To preserve the surrounding shell during navigation, put `pp-loading-content="true"` on the live container that should be swapped during loading, usually the main content pane in a layout.
|
|
197
|
+
|
|
198
|
+
Example layout shell:
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<main class="docs-content" pp-loading-content="true" pp-reset-scroll="true">
|
|
202
|
+
[[children|safe]]
|
|
203
|
+
</main>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Example loader:
|
|
207
|
+
|
|
208
|
+
```html
|
|
209
|
+
<div class="space-y-4 p-6">
|
|
210
|
+
<div class="h-4 rounded bg-muted animate-pulse"></div>
|
|
211
|
+
<div class="h-24 rounded bg-muted/70 animate-pulse"></div>
|
|
212
|
+
</div>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
If no `pp-loading-content="true"` container exists, the browser runtime falls back to `document.body`.
|
|
216
|
+
|
|
217
|
+
## `not-found.html`
|
|
218
|
+
|
|
219
|
+
`src/app/not-found.html` is the global 404 page.
|
|
220
|
+
|
|
221
|
+
When `main.py` catches a `404`, it looks for this exact root-level file, renders it through the nested layout pipeline, and returns it with a 404 status.
|
|
222
|
+
|
|
223
|
+
Important scope rule:
|
|
224
|
+
|
|
225
|
+
- this is a global root-level file, not a per-folder `not-found.html` convention in the current runtime
|
|
226
|
+
|
|
227
|
+
The runtime passes `request` into the template context and sets default page metadata for the response.
|
|
228
|
+
|
|
229
|
+
Use this file for branded invalid-URL fallbacks instead of leaving the app on the generic FastAPI or Starlette message.
|
|
230
|
+
|
|
231
|
+
## `error.html`
|
|
232
|
+
|
|
233
|
+
`src/app/error.html` is the global 500 page for unhandled exceptions.
|
|
234
|
+
|
|
235
|
+
When `main.py` catches a general exception, it looks for this exact root-level file, renders it through the nested layout pipeline, and returns it with a 500 status.
|
|
236
|
+
|
|
237
|
+
The runtime provides these template values:
|
|
238
|
+
|
|
239
|
+
- `request`
|
|
240
|
+
- `error_message`
|
|
241
|
+
- `error_trace`
|
|
242
|
+
|
|
243
|
+
In production, `error_trace` is suppressed. Keep this page safe for users and avoid exposing sensitive internals outside development environments.
|
|
244
|
+
|
|
245
|
+
If rendering `error.html` fails, the runtime falls back to a minimal plain HTML 500 response.
|
|
246
|
+
|
|
247
|
+
## Decision Rule
|
|
248
|
+
|
|
249
|
+
Use this order when deciding where a concern belongs:
|
|
250
|
+
|
|
251
|
+
1. Put visible route markup in `index.html`.
|
|
252
|
+
2. Add `index.py` only when the same route needs backend work.
|
|
253
|
+
3. Put shared subtree wrapper markup in `layout.html`.
|
|
254
|
+
4. Add `layout.py` only when that shared shell needs synchronous Python props or metadata.
|
|
255
|
+
5. Add `loading.html` when SPA navigation needs an immediate scoped loading state.
|
|
256
|
+
6. Use root `not-found.html` for unmatched URLs.
|
|
257
|
+
7. Use root `error.html` for unhandled exceptions.
|
|
258
|
+
|
|
259
|
+
Use [routing.md](./routing.md) for the broader file-based routing model, [metadata.md](./metadata.md) for page and layout metadata, [cache.md](./cache.md) for route caching in `index.py`, and [pulsepoint.md](./pulsepoint.md) for the authored template contract and browser runtime behavior.
|
package/dist/docs/index.md
CHANGED
|
@@ -8,10 +8,11 @@ related:
|
|
|
8
8
|
- /docs/ai-validation-checklist
|
|
9
9
|
- /docs/installation
|
|
10
10
|
- /docs/commands
|
|
11
|
-
- /docs/core-runtime-map
|
|
12
|
-
- /docs/pulsepoint-runtime-map
|
|
13
|
-
- /docs/mcp
|
|
11
|
+
- /docs/core-runtime-map
|
|
12
|
+
- /docs/pulsepoint-runtime-map
|
|
13
|
+
- /docs/mcp
|
|
14
14
|
- /docs/file-uploads
|
|
15
|
+
- /docs/file-conventions
|
|
15
16
|
- /docs/project-structure
|
|
16
17
|
- /docs/components
|
|
17
18
|
---
|
|
@@ -24,41 +25,41 @@ The docs can mention optional features even when those features are disabled in
|
|
|
24
25
|
|
|
25
26
|
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.
|
|
26
27
|
|
|
27
|
-
## Default Stack
|
|
28
|
-
|
|
29
|
-
When generating or editing a Caspian app, treat these as the default choices unless the task explicitly requires something else:
|
|
28
|
+
## Default Stack
|
|
29
|
+
|
|
30
|
+
When generating or editing a Caspian app, treat these as the default choices unless the task explicitly requires something else:
|
|
30
31
|
|
|
31
32
|
- Use PulsePoint for reactive frontend behavior.
|
|
32
33
|
- Treat every authored route, layout, and component HTML file like a React component return value: exactly one top-level parent HTML element or one imported `x-*` root, with any owned plain `<script>` kept inside that same root.
|
|
33
34
|
- When `caspian.config.json` has `tailwindcss: true`, use Python `merge_classes(...)` plus browser `twMerge(...)` as the only supported Tailwind class-merging path.
|
|
34
|
-
- Use `@rpc()` plus `pp.rpc()` for browser-triggered reads, writes, streaming, and uploads.
|
|
35
|
-
- Use `Validate` and `Rule` from `casp.validate` for server-side input validation and sanitization.
|
|
36
|
-
|
|
37
|
-
## AI Doc Shape
|
|
38
|
-
|
|
39
|
-
Each packaged feature doc should help AI answer the same five questions quickly:
|
|
40
|
-
|
|
41
|
-
- When does this doc apply?
|
|
42
|
-
- Which `caspian.config.json` flag, if any, gates the feature?
|
|
43
|
-
- Which app-owned files usually change?
|
|
44
|
-
- Which `main.py` or installed `casp` runtime files own the behavior?
|
|
45
|
-
- Which behavior should be verified before editing or explaining the feature?
|
|
46
|
-
|
|
47
|
-
Keep project-specific facts, temporary file inventory, and current app feature flags out of packaged docs. Put those in `AGENTS.md`, `.github/copilot-instructions.md`, or the project code instead.
|
|
48
|
-
|
|
49
|
-
Use [core-runtime-map.md](./core-runtime-map.md) for Python-side Caspian runtime ownership and [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) for browser-side PulsePoint runtime ownership.
|
|
50
|
-
|
|
51
|
-
## Redundancy Rule
|
|
52
|
-
|
|
53
|
-
Prefer one canonical explanation plus links from related docs.
|
|
54
|
-
|
|
55
|
-
- Put the full authored-template and PulsePoint runtime contract in [pulsepoint.md](./pulsepoint.md).
|
|
56
|
-
- Put the full route and layout placement contract in [routing.md](./routing.md).
|
|
57
|
-
- Put the full reusable component contract in [components.md](./components.md).
|
|
58
|
-
- Put the full Python runtime ownership map in [core-runtime-map.md](./core-runtime-map.md).
|
|
59
|
-
- Put the full PulsePoint feature lookup map in [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md).
|
|
60
|
-
|
|
61
|
-
Other docs should summarize these rules only when the reminder prevents a common mistake, then link to the canonical page instead of restating the whole rule block.
|
|
35
|
+
- Use `@rpc()` plus `pp.rpc()` for browser-triggered reads, writes, streaming, and uploads.
|
|
36
|
+
- Use `Validate` and `Rule` from `casp.validate` for server-side input validation and sanitization.
|
|
37
|
+
|
|
38
|
+
## AI Doc Shape
|
|
39
|
+
|
|
40
|
+
Each packaged feature doc should help AI answer the same five questions quickly:
|
|
41
|
+
|
|
42
|
+
- When does this doc apply?
|
|
43
|
+
- Which `caspian.config.json` flag, if any, gates the feature?
|
|
44
|
+
- Which app-owned files usually change?
|
|
45
|
+
- Which `main.py` or installed `casp` runtime files own the behavior?
|
|
46
|
+
- Which behavior should be verified before editing or explaining the feature?
|
|
47
|
+
|
|
48
|
+
Keep project-specific facts, temporary file inventory, and current app feature flags out of packaged docs. Put those in `AGENTS.md`, `.github/copilot-instructions.md`, or the project code instead.
|
|
49
|
+
|
|
50
|
+
Use [core-runtime-map.md](./core-runtime-map.md) for Python-side Caspian runtime ownership and [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) for browser-side PulsePoint runtime ownership.
|
|
51
|
+
|
|
52
|
+
## Redundancy Rule
|
|
53
|
+
|
|
54
|
+
Prefer one canonical explanation plus links from related docs.
|
|
55
|
+
|
|
56
|
+
- Put the full authored-template and PulsePoint runtime contract in [pulsepoint.md](./pulsepoint.md).
|
|
57
|
+
- Put the full route and layout placement contract in [routing.md](./routing.md).
|
|
58
|
+
- Put the full reusable component contract in [components.md](./components.md).
|
|
59
|
+
- Put the full Python runtime ownership map in [core-runtime-map.md](./core-runtime-map.md).
|
|
60
|
+
- Put the full PulsePoint feature lookup map in [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md).
|
|
61
|
+
|
|
62
|
+
Other docs should summarize these rules only when the reminder prevents a common mistake, then link to the canonical page instead of restating the whole rule block.
|
|
62
63
|
|
|
63
64
|
## Docs Location
|
|
64
65
|
|
|
@@ -72,11 +73,12 @@ The packaged Caspian docs referenced by this index live here:
|
|
|
72
73
|
- `ai-validation-checklist.md` - workflow and representative prompts for checking whether AI can find the correct Caspian docs, core files, and verification checkpoints
|
|
73
74
|
- `installation.md` - First-time setup flow for creating a new Caspian application
|
|
74
75
|
- `commands.md` - Main Caspian CLI workflows for project creation, generation, updates, and config-aware maintenance
|
|
75
|
-
- `core-runtime-map.md` - map of `main.py` plus installed `casp` modules to the packaged docs that explain them and the behaviors AI should trace there
|
|
76
|
-
- `pulsepoint-runtime-map.md` - fast feature-to-runtime lookup for PulsePoint state, effects, refs, context, portals, lists, events, RPC, uploads, streaming, SPA navigation, scroll restoration, and Tailwind merge behavior
|
|
77
|
-
- `mcp.md` - MCP-specific layout, launch flow, and AI routing rules for projects where `caspian.config.json` enables MCP
|
|
76
|
+
- `core-runtime-map.md` - map of `main.py` plus installed `casp` modules to the packaged docs that explain them and the behaviors AI should trace there
|
|
77
|
+
- `pulsepoint-runtime-map.md` - fast feature-to-runtime lookup for PulsePoint state, effects, refs, context, portals, lists, events, RPC, uploads, streaming, SPA navigation, scroll restoration, and Tailwind merge behavior
|
|
78
|
+
- `mcp.md` - MCP-specific layout, launch flow, and AI routing rules for projects where `caspian.config.json` enables MCP
|
|
78
79
|
- `database.md` - Prisma schema, migration, seed, and client-generation workflow for projects where `caspian.config.json` enables Prisma, plus Python-side helper caveats
|
|
79
80
|
- `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
|
|
81
|
+
- `file-conventions.md` - quick decision guide for `index.html`, `index.py`, `layout.html`, `layout.py`, `loading.html`, `not-found.html`, and `error.html`, plus the owning runtime files to verify
|
|
80
82
|
- `components.md` - Create reusable Python components, template-backed UI, HTML-first `x-*` component tags, the single-parent authored-root rule for component HTML files, and the Python-side `merge_classes(...)` contract when Tailwind CSS is enabled
|
|
81
83
|
- `pulsepoint.md` - Default reactive frontend runtime contract for component scripts, state, effects, directives, SPA navigation scroll restoration, `pp-reset-scroll`, and direct browser `twMerge(...)` usage when Tailwind CSS is enabled
|
|
82
84
|
- `fetch-data.md` - Initial server-side data loading and browser-triggered RPC flows with `pp.rpc()`, streaming, uploads, and auth-aware actions
|
|
@@ -98,13 +100,13 @@ Preferred lookup order:
|
|
|
98
100
|
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.
|
|
99
101
|
3. Before authoring or editing any `src/app/**` or component HTML template, apply the single-root invariant: one authored root only, any owned `<script>` inside that root, and no handwritten `pp-component` or `type="text/pp"`.
|
|
100
102
|
4. 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`.
|
|
101
|
-
5. If the task touches `main.py` or `.venv/Lib/site-packages/casp/**`, read `core-runtime-map.md` to jump to the controlling runtime file and the matching feature doc.
|
|
102
|
-
6. If the task names a PulsePoint feature or directive, read `pulsepoint-runtime-map.md` for the fastest feature-to-runtime lookup, then read `pulsepoint.md` for authoring rules.
|
|
103
|
-
7. 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.
|
|
104
|
-
8. 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.
|
|
105
|
-
9. Prefer packaged Caspian docs before upstream documentation when generating code, commands, or migration guidance.
|
|
106
|
-
10. Use `ai-validation-checklist.md` when you want to verify that the docs lead AI to the correct files and behavior checkpoints.
|
|
107
|
-
11. Keep `index.md` and cross-links aligned so AI can quickly discover the right doc.
|
|
103
|
+
5. If the task touches `main.py` or `.venv/Lib/site-packages/casp/**`, read `core-runtime-map.md` to jump to the controlling runtime file and the matching feature doc.
|
|
104
|
+
6. If the task names a PulsePoint feature or directive, read `pulsepoint-runtime-map.md` for the fastest feature-to-runtime lookup, then read `pulsepoint.md` for authoring rules.
|
|
105
|
+
7. 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.
|
|
106
|
+
8. Use `file-conventions.md` for quick decisions about `index.html`, `index.py`, `layout.html`, `layout.py`, `loading.html`, `not-found.html`, and `error.html`; 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.
|
|
107
|
+
9. Prefer packaged Caspian docs before upstream documentation when generating code, commands, or migration guidance.
|
|
108
|
+
10. Use `ai-validation-checklist.md` when you want to verify that the docs lead AI to the correct files and behavior checkpoints.
|
|
109
|
+
11. Keep `index.md` and cross-links aligned so AI can quickly discover the right doc.
|
|
108
110
|
|
|
109
111
|
## Maintenance
|
|
110
112
|
|
package/dist/docs/routing.md
CHANGED
|
@@ -33,7 +33,7 @@ Start with these rules:
|
|
|
33
33
|
- Use a standalone `index.py` only for non-visual routes such as redirects or action-only handlers.
|
|
34
34
|
- When a folder owns child routes, use `layout.html` to wrap them. This is the default pattern for dashboards, admin sections, account areas, settings trees, and route groups.
|
|
35
35
|
- In grouped shells with separate shell and content scrolling, put `pp-reset-scroll="true"` on the content pane in `layout.html` when that pane should reset on child-route navigation while the shell sidebar or rail keeps its own scroll.
|
|
36
|
-
- Use `layout.py` when a layout needs shared
|
|
36
|
+
- Use `layout.py` when a layout needs shared props or metadata before rendering. The `layout()` function may be synchronous or async.
|
|
37
37
|
- Keep visible route and layout markup in `index.html` and `layout.html`. Treat `index.py` and `layout.py` as backend companions, not as places to author visible HTML.
|
|
38
38
|
- Treat every authored route and layout template like a React component body: it must have exactly one top-level parent HTML element or one imported `x-*` root, and any owned plain `<script>` must live inside that same root.
|
|
39
39
|
|
|
@@ -86,7 +86,7 @@ When a user asks for a dashboard, admin area, account section, docs section, or
|
|
|
86
86
|
|
|
87
87
|
- Create a parent folder for the section.
|
|
88
88
|
- Add `layout.html` in that folder for the shared shell.
|
|
89
|
-
- Add `layout.py` only when that shared shell needs
|
|
89
|
+
- Add `layout.py` only when that shared shell needs shared props or metadata.
|
|
90
90
|
- Put each child page in its own route folder with `index.html` and an optional `index.py` companion.
|
|
91
91
|
- Use a normal folder name such as `dashboard/` when the section name should appear in the URL.
|
|
92
92
|
- Use a route-group folder such as `(marketing)/` when the folder should organize code and own a layout without adding a URL segment.
|