caspian-utils 0.0.23 → 0.0.24
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.
|
@@ -53,6 +53,7 @@ Use prompts like these to check whether AI lands on the correct docs and files.
|
|
|
53
53
|
| Prompt | First docs AI should read | Controlling files AI should reach | Verification focus |
|
|
54
54
|
| --- | --- | --- | --- |
|
|
55
55
|
| Create a protected dashboard section with child routes and a shared shell. | [index.md](./index.md), [routing.md](./routing.md), [auth.md](./auth.md), [project-structure.md](./project-structure.md) | `src/app/**`, `src/lib/auth/auth_config.py`, `main.py`, `.venv/Lib/site-packages/casp/layout.py` | section layout ownership, route privacy mode, and child-route wrapping |
|
|
56
|
+
| Create a new contact page with interactive form behavior. | [index.md](./index.md), [routing.md](./routing.md), [pulsepoint.md](./pulsepoint.md), [components.md](./components.md) | `src/app/**/index.html`, `main.py`, `.venv/Lib/site-packages/casp/components_compiler.py`, `.venv/Lib/site-packages/casp/scripts_type.py` | single-root template shape, script-inside-root authoring, and authored-vs-runtime boundaries |
|
|
56
57
|
| Add a file manager page with upload progress and persisted metadata. | [index.md](./index.md), [file-uploads.md](./file-uploads.md), [fetch-data.md](./fetch-data.md), [database.md](./database.md) | `src/app/**/index.html`, `src/app/**/index.py`, `src/lib/**`, `prisma/schema.prisma` when Prisma applies | route-owned upload actions, persisted metadata flow, and Prisma-backed storage boundaries |
|
|
57
58
|
| Explain why authored Caspian templates use a plain `<script>` instead of `type="text/pp"`. | [index.md](./index.md), [pulsepoint.md](./pulsepoint.md), [components.md](./components.md), [routing.md](./routing.md) | `main.py`, `.venv/Lib/site-packages/casp/scripts_type.py`, `.venv/Lib/site-packages/casp/components_compiler.py` | script rewriting, `pp-component` injection, and authored-vs-runtime boundaries |
|
|
58
59
|
| Debug why `StateManager` does not persist across a full redirect. | [index.md](./index.md), [state.md](./state.md), [auth.md](./auth.md), [core-runtime-map.md](./core-runtime-map.md) | `main.py`, `.venv/Lib/site-packages/casp/state_manager.py` | wire vs non-wire reset behavior and `request.state.session` dependency |
|
|
@@ -68,6 +69,7 @@ Treat the table as a prompt pack for spot checks, not as a full validation matri
|
|
|
68
69
|
- AI reads only the packaged feature doc and never checks `main.py` or the installed runtime.
|
|
69
70
|
- AI edits framework internals when the task only requires app-owned route or helper changes.
|
|
70
71
|
- AI treats runtime HTML examples as authored template examples.
|
|
72
|
+
- AI generates a route or component template with a valid-looking root element but leaves a sibling top-level `<script>` or second top-level element after it.
|
|
71
73
|
- AI decides behavior from memory without checking the owning implementation details.
|
|
72
74
|
|
|
73
75
|
## Decision Rule
|
package/dist/docs/components.md
CHANGED
|
@@ -241,10 +241,17 @@ Top-of-file `<!-- @import ... -->` directives are allowed before that root eleme
|
|
|
241
241
|
|
|
242
242
|
In source, that parent may be a native HTML element or a single imported `x-*` component tag. After component expansion, the template must still resolve to one final native HTML root so Caspian has exactly one place to inject `pp-component`.
|
|
243
243
|
|
|
244
|
-
This is not just style guidance. The installed compiler injects `pp-component` onto the final root element, and it raises an error when the template has no root, multiple sibling roots, or stray top-level text.
|
|
244
|
+
This is not just style guidance. The installed compiler injects `pp-component` onto the final root element, and it raises an error when the template has no root, multiple sibling roots, a sibling script after the root, or stray top-level text.
|
|
245
245
|
|
|
246
246
|
For AI-generated templates, treat this as a hard authoring rule: write the HTML the same way a React component returns one parent node. If the template needs a PulsePoint script, keep that script inside the same parent root.
|
|
247
247
|
|
|
248
|
+
Failure shape to avoid:
|
|
249
|
+
|
|
250
|
+
- one root element followed by a sibling `<script>`
|
|
251
|
+
- two top-level sibling elements
|
|
252
|
+
- top-level text outside the root
|
|
253
|
+
- an imported `x-*` root that expands to multiple native siblings
|
|
254
|
+
|
|
248
255
|
Good:
|
|
249
256
|
|
|
250
257
|
```html
|
|
@@ -276,6 +283,18 @@ Also bad:
|
|
|
276
283
|
<p>Body</p>
|
|
277
284
|
```
|
|
278
285
|
|
|
286
|
+
Also bad:
|
|
287
|
+
|
|
288
|
+
```html
|
|
289
|
+
<x-card>
|
|
290
|
+
<h2>Title</h2>
|
|
291
|
+
</x-card>
|
|
292
|
+
|
|
293
|
+
<script>
|
|
294
|
+
const [open, setOpen] = pp.state(false);
|
|
295
|
+
</script>
|
|
296
|
+
```
|
|
297
|
+
|
|
279
298
|
If you choose an imported `x-*` component as the authored root of the file, make sure it resolves to one native HTML root when compiled. Do not leave an unresolved component tag as the root, and do not emit multiple top-level component siblings.
|
|
280
299
|
|
|
281
300
|
## Props, Types, And Children
|
package/dist/docs/index.md
CHANGED
|
@@ -28,6 +28,7 @@ Before making feature, tooling, or file-placement decisions in a Caspian project
|
|
|
28
28
|
When generating or editing a Caspian app, treat these as the default choices unless the task explicitly requires something else:
|
|
29
29
|
|
|
30
30
|
- Use PulsePoint for reactive frontend behavior.
|
|
31
|
+
- 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.
|
|
31
32
|
- When `caspian.config.json` has `tailwindcss: true`, use Python `merge_classes(...)` plus browser `twMerge(...)` as the only supported Tailwind class-merging path.
|
|
32
33
|
- Use `@rpc()` plus `pp.rpc()` for browser-triggered reads, writes, streaming, and uploads.
|
|
33
34
|
- Use `Validate` and `Rule` from `casp.validate` for server-side input validation and sanitization.
|
|
@@ -67,13 +68,14 @@ Preferred lookup order:
|
|
|
67
68
|
|
|
68
69
|
1. Read `node_modules/caspian-utils/dist/docs/index.md` to discover available local docs.
|
|
69
70
|
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.
|
|
70
|
-
3.
|
|
71
|
-
4.
|
|
72
|
-
5.
|
|
73
|
-
6.
|
|
74
|
-
7.
|
|
75
|
-
8.
|
|
76
|
-
9.
|
|
71
|
+
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"`.
|
|
72
|
+
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`.
|
|
73
|
+
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.
|
|
74
|
+
6. 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.
|
|
75
|
+
7. 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.
|
|
76
|
+
8. Prefer packaged Caspian docs before upstream documentation when generating code, commands, or migration guidance.
|
|
77
|
+
9. Use `ai-validation-checklist.md` when you want to verify that the docs lead AI to the correct files and behavior checkpoints.
|
|
78
|
+
10. Keep `index.md` and cross-links aligned so AI can quickly discover the right doc.
|
|
77
79
|
|
|
78
80
|
## Maintenance
|
|
79
81
|
|
package/dist/docs/pulsepoint.md
CHANGED
|
@@ -73,6 +73,8 @@ For authored Caspian templates:
|
|
|
73
73
|
- Do not handwrite `pp-component="..."`.
|
|
74
74
|
- Do not handwrite `type="text/pp"`.
|
|
75
75
|
|
|
76
|
+
Treat that single-root rule as a hard invariant for AI-generated templates. A sibling `<script>` after the root or any second top-level element will break Caspian's `pp-component` injection and fail the render.
|
|
77
|
+
|
|
76
78
|
Keep visible route, layout, and component markup in the HTML templates. Treat `index.py` and `layout.py` as backend companions for data, metadata, props, RPC actions, auth, caching, redirects, and other server-side preparation, not as template bodies.
|
|
77
79
|
|
|
78
80
|
Caspian already handles those details for you during render.
|
|
@@ -102,6 +104,18 @@ Authored example:
|
|
|
102
104
|
|
|
103
105
|
When that template reaches the browser, Caspian will already have injected the component id and rewritten the owned script to `type="text/pp"`. Those runtime attributes are for the rendered output, not for authored source examples.
|
|
104
106
|
|
|
107
|
+
Invalid authored shape:
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<section>
|
|
111
|
+
<h2>{title}</h2>
|
|
112
|
+
</section>
|
|
113
|
+
|
|
114
|
+
<script>
|
|
115
|
+
const { title = "Counter" } = pp.props;
|
|
116
|
+
</script>
|
|
117
|
+
```
|
|
118
|
+
|
|
105
119
|
## Runtime shape
|
|
106
120
|
|
|
107
121
|
PulsePoint is a browser-side component runtime. It executes one component script per root, renders HTML from the component scope, morphs the DOM in place, binds native event handlers, restores focus, updates refs, applies portals, and then runs layout/effect hooks.
|
package/dist/docs/routing.md
CHANGED
|
@@ -33,6 +33,18 @@ Start with these rules:
|
|
|
33
33
|
- 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.
|
|
34
34
|
- Use `layout.py` when a layout needs shared synchronous props or metadata before rendering.
|
|
35
35
|
- 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.
|
|
36
|
+
- 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.
|
|
37
|
+
|
|
38
|
+
## Hard Template Invariant
|
|
39
|
+
|
|
40
|
+
For authored route and layout templates, the single-root rule is a hard runtime requirement.
|
|
41
|
+
|
|
42
|
+
- Use exactly one authored parent node.
|
|
43
|
+
- Keep any `<!-- @import ... -->` directives above that root.
|
|
44
|
+
- Keep any owned plain `<script>` inside that root, not after it.
|
|
45
|
+
- Do not leave sibling top-level HTML tags, sibling component tags, or stray top-level text.
|
|
46
|
+
|
|
47
|
+
If AI generates this incorrectly, Caspian fails render with errors like `must have exactly one top-level HTML element so Caspian can inject pp-component`.
|
|
36
48
|
|
|
37
49
|
Use [cache.md](./cache.md) when an `index.py` route also needs declarative page caching via `Cache(...)`.
|
|
38
50
|
|
|
@@ -167,7 +179,7 @@ Place those import comments at the top of the file, above the authored root elem
|
|
|
167
179
|
|
|
168
180
|
Route templates follow the same authored-vs-runtime contract documented in [pulsepoint.md](./pulsepoint.md) and the same single-root discipline documented in [components.md](./components.md): keep one authored parent node, keep any `<!-- @import ... -->` directives above that root, use a plain `<script>` inside that root when needed, and do not handwrite `pp-component` or `type="text/pp"`. That root may be a native HTML element or a single imported `x-*` component tag, but after expansion it must resolve to one final HTML root.
|
|
169
181
|
|
|
170
|
-
For AI-generated route templates, treat `src/app/**/index.html` the same way you would a React component body: return one parent node that contains the entire route markup.
|
|
182
|
+
For AI-generated route templates, treat `src/app/**/index.html` the same way you would a React component body: return one parent node that contains the entire route markup. This includes any owned script.
|
|
171
183
|
|
|
172
184
|
Good:
|
|
173
185
|
|
|
@@ -195,6 +207,16 @@ Bad:
|
|
|
195
207
|
|
|
196
208
|
Also bad:
|
|
197
209
|
|
|
210
|
+
```html
|
|
211
|
+
<section class="dashboard-shell">
|
|
212
|
+
<h1>Dashboard</h1>
|
|
213
|
+
</section>
|
|
214
|
+
|
|
215
|
+
<aside class="dashboard-help">Tips</aside>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Also bad:
|
|
219
|
+
|
|
198
220
|
```html
|
|
199
221
|
<section class="dashboard-shell">
|
|
200
222
|
<!-- @import StatsCard from "../components" -->
|