create-caspian-app 0.2.0-beta.38 → 0.2.0-beta.39
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.
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
- In all-private mode, keep public exceptions in `public_routes`; the runtime defaults keep `/` public and keep `auth_routes=["/signin", "/signup"]` public.
|
|
29
29
|
- Do not treat `token_auto_refresh` as the switch that makes routes private. In the current app it only affects sliding-session refresh if `auth.refresh_session()` is called.
|
|
30
30
|
- Use PulsePoint and `pp.rpc(...)` as the default frontend and client-to-server contract unless the user requests another stack.
|
|
31
|
+
- For file uploads and file-manager flows, keep browser interaction in route templates, keep upload and delete `@rpc()` actions in the owning `src/app/**/index.py`, keep shared storage and persistence helpers in `src/lib/**`, store metadata in Prisma, and store browser-accessible blobs under `public/storage/**`.
|
|
32
|
+
- When runtime uploads write into `public/storage/**`, keep `public/storage` in `settings/bs-config.ts` `PUBLIC_IGNORE_DIRS` so `npm run dev` does not reload on each upload.
|
|
31
33
|
- For logout flows, prefer `pp.rpc("signout")` backed by `@rpc(require_auth=True)` from page-level or component-level UI. Use a dedicated signout route only for plain form POST, no-JavaScript fallback, or other full-navigation edge cases.
|
|
32
34
|
- Protect customized `src/lib/auth/auth_config.py` from updater overwrite by adding `./src/lib/auth/auth_config.py` to `excludeFiles` in `caspian.config.json`.
|
|
33
35
|
- Treat `pp-component` on routes, layouts, and components, and `type="text/pp"` on owned PulsePoint scripts, as compiler-injected by the Python side; do not add them manually in authored templates unless the task is explicitly about runtime internals.
|
|
@@ -42,6 +44,7 @@
|
|
|
42
44
|
|
|
43
45
|
- Treat `main.py` as the repo source of truth for FastAPI setup, static asset routes, auth bootstrap, middleware order, route registration, cache defaults, and error handlers.
|
|
44
46
|
- Preserve the effective middleware execution order unless the task explicitly changes request semantics: `SessionMiddleware -> CSRFMiddleware -> AuthMiddleware -> RPCMiddleware`.
|
|
47
|
+
- Do not move normal file upload or file-manager behavior into `main.py`; keep those actions in the owning route `index.py` and shared helpers in `src/lib/**`.
|
|
45
48
|
- Document route param behavior exactly as implemented here.
|
|
46
49
|
- Do not use `main.py` alone to infer whether optional features are enabled; confirm that in `caspian.config.json` first.
|
|
47
50
|
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
- Keep `src/lib/` for app-owned shared non-UI code, service wrappers, validators, adapters, and reusable helpers.
|
|
51
54
|
- Prefer `src/components/` for reusable rendered UI instead of placing component modules in `src/lib/`.
|
|
52
55
|
- Reuse the generated `src/lib/prisma/` package for Python database access, but do not hand-edit files under `src/lib/prisma/`; regenerate them with `npx ppy generate` after schema changes.
|
|
56
|
+
- For file managers, keep shared storage, normalization, and Prisma-backed persistence helpers here while route-owned upload and delete `@rpc()` actions stay in `src/app/**/index.py`.
|
|
53
57
|
- When `caspian.config.json` has `mcp: true`, keep app-owned MCP tools in `src/lib/mcp/mcp_server.py` and keep the default FastMCP config in `src/lib/mcp/fastmcp.json`. If those locations change, update `settings/restart-mcp.ts` and the MCP docs together.
|
|
54
58
|
- Keep auth policy in `src/lib/auth/auth_config.py`. Keep auth bootstrap and middleware order changes in `main.py`.
|
|
55
59
|
|
|
@@ -78,6 +82,7 @@
|
|
|
78
82
|
- Do not author `pp-component="..."` manually in route or layout templates; the Python render pipeline injects it onto the single root element.
|
|
79
83
|
- Do not author `type="text/pp"` manually in route or layout templates either. Use plain `<script>` in source and let the render path rewrite it.
|
|
80
84
|
- Keep authored route and layout templates to one top-level lowercase HTML root element, the same constraint used for component templates. If a script is needed, keep it inside that root instead of as a sibling top-level node.
|
|
85
|
+
- For upload managers and similar interactive lists, prefer `pp.state(...)` plus `pp-for` over manual DOM painting so rerenders keep the list stable.
|
|
81
86
|
- Do not assume React, Vue, JSX, HTMX, or another frontend runtime unless the user explicitly requests one.
|
|
82
87
|
|
|
83
88
|
### `prisma/**`
|
|
@@ -112,6 +117,8 @@
|
|
|
112
117
|
- if a feature flag is false and the user wants that feature, ask before enabling it, then update `caspian.config.json` and use `npx casp update project` to refresh framework-managed files
|
|
113
118
|
- do not run `package.json` scripts by default for ordinary source edits; only use them when the user explicitly asks, the task requires them, or deployment prep needs `npm run build`
|
|
114
119
|
- `npm run dev` is a long-running local stack command that can regenerate `public/css/styles.css`, `settings/component-map.json`, `settings/files-list.json`, `__pycache__/`, and `.pyc` artifacts; those are generated outputs, not authored source files
|
|
120
|
+
- `node_modules/caspian-utils/dist/docs/file-uploads.md` is the source doc for route-local upload and file-manager guidance in this workspace
|
|
121
|
+
- uploaded public blobs live under `public/storage/**`, and `settings/bs-config.ts` should keep `public/storage` in `PUBLIC_IGNORE_DIRS`
|
|
115
122
|
- `settings/component-map.ts` and `settings/files-list.ts` own `settings/component-map.json` and `settings/files-list.json`; inspect the JSON when needed, but let the framework regenerate it instead of editing it by hand
|
|
116
123
|
- auth policy lives in `src/lib/auth/auth_config.py`
|
|
117
124
|
- the app-owned starter config in this workspace begins public-first with `is_all_routes_private=False`, so treat routes as public by default unless the app explicitly switches to all-private mode
|
package/dist/AGENTS.md
CHANGED
|
@@ -59,15 +59,17 @@ Treat `caspian.config.json` as the single source of truth for whether an optiona
|
|
|
59
59
|
- `pp-component` is injected by the Python render pipeline onto page, layout, and component roots; authored route and component templates should not add it manually.
|
|
60
60
|
- `main.py` runs `transform_scripts(...)`, so authored body `<script>` tags are rewritten to `<script type="text/pp">` in rendered HTML; route, layout, and component templates should write plain `<script>` in source.
|
|
61
61
|
- Route and component HTML templates must keep exactly one top-level lowercase HTML element so Caspian can inject `pp-component`. Think React-style single parent wrapper: good `<div>...</div>` with any owned script inside that same root, bad sibling top-level tags such as `<div>...</div><script ...></script>`.
|
|
62
|
+
- File-manager flows in this repo should keep upload and delete `@rpc()` actions in the owning `src/app/**/index.py`, keep shared filesystem and Prisma helpers in `src/lib/**`, persist metadata in Prisma, and store browser-accessible blobs under `public/storage/**`.
|
|
62
63
|
- When `npm run dev` is intentionally running, let that long-running stack own generated outputs such as `public/css/styles.css`, `settings/component-map.json`, `settings/files-list.json`, `__pycache__/`, and `.pyc` files. Treat those as generated artifacts, not authored source.
|
|
63
64
|
- `settings/component-map.json` and `settings/files-list.json` are generated by `settings/component-map.ts` and `settings/files-list.ts` through the dev and build pipelines. Analyze them when needed, but do not hand-edit them.
|
|
65
|
+
- `settings/bs-config.ts` should keep `public/storage` in `PUBLIC_IGNORE_DIRS` so runtime uploads do not trigger BrowserSync reloads during the local stack.
|
|
64
66
|
- In the current router inside `main.py`, path params are passed to `page()` as the first positional `dict` argument.
|
|
65
67
|
- Matching query params can still be injected by name, and `request` is injected by keyword when declared.
|
|
66
68
|
- The installed `casp.layout` runtime calls `layout()` synchronously. Keep async I/O in `page()` or `@rpc()`.
|
|
67
69
|
- `StateManager` reads and writes `request.state.session`, but the current middleware stack in `main.py` does not mirror `request.session` into `request.state.session`.
|
|
68
70
|
- Do not assume `StateManager` persistence survives across requests until that bridge exists.
|
|
69
71
|
- Route HTML caching uses `caches/` and `caches/cache_manifest.json` through `casp.cache_handler`.
|
|
70
|
-
- The current app tree has root templates in `src/app/` and
|
|
72
|
+
- The current app tree has root templates in `src/app/` and already includes route-specific `index.py` files where routes need server-side logic, including upload and file-manager flows.
|
|
71
73
|
|
|
72
74
|
## Task Routing
|
|
73
75
|
|
|
@@ -81,6 +83,7 @@ Use this map before making changes.
|
|
|
81
83
|
| Routing, layouts, metadata | `node_modules/caspian-utils/dist/docs/routing.md` | `main.py`, `.venv/Lib/site-packages/casp/layout.py` |
|
|
82
84
|
| Auth, sessions, RBAC, providers | `node_modules/caspian-utils/dist/docs/auth.md` | `src/lib/auth/auth_config.py`, `main.py`, `.venv/Lib/site-packages/casp/auth.py` |
|
|
83
85
|
| RPC, data loading, streaming, uploads | `node_modules/caspian-utils/dist/docs/fetch-data.md`, `node_modules/caspian-utils/dist/docs/pulsepoint.md` | `.venv/Lib/site-packages/casp/rpc.py`, `public/js/pp-reactive-v2.js`, `main.py` |
|
|
86
|
+
| File uploads and managers | `node_modules/caspian-utils/dist/docs/file-uploads.md`, `node_modules/caspian-utils/dist/docs/fetch-data.md` | `src/app/**`, `src/lib/**`, `prisma/**`, `settings/bs-config.ts` |
|
|
84
87
|
| Server state | `node_modules/caspian-utils/dist/docs/state.md` | `.venv/Lib/site-packages/casp/state_manager.py`, `main.py` |
|
|
85
88
|
| Page caching | `node_modules/caspian-utils/dist/docs/cache.md` | `.venv/Lib/site-packages/casp/cache_handler.py`, `main.py` |
|
|
86
89
|
| Validation | `node_modules/caspian-utils/dist/docs/validation.md` | `.venv/Lib/site-packages/casp/validate.py` |
|
|
@@ -91,6 +94,7 @@ Use this map before making changes.
|
|
|
91
94
|
- Keep app-owned shared code in `src/lib/**`.
|
|
92
95
|
- Keep reusable application UI components in `src/components/**`.
|
|
93
96
|
- Keep route-specific logic in `src/app/**`.
|
|
97
|
+
- For file-manager work, keep route-owned upload and delete `@rpc()` actions in `src/app/**/index.py`, keep shared storage and Prisma helper logic in `src/lib/**`, and keep uploaded public blobs under `public/storage/**`.
|
|
94
98
|
- When deciding between `src/components/**` and `src/lib/**`, put reusable rendered UI in `src/components/**` and put services, validators, adapters, database helpers, and other non-UI support code in `src/lib/**`.
|
|
95
99
|
- Read `caspian.config.json` before deciding whether a Caspian feature should be used, documented, scaffolded, or avoided in the current workspace.
|
|
96
100
|
- Treat `caspian.config.json` as the single source of truth for optional features. Do not use feature-specific files, commands, or docs until the corresponding flag is enabled.
|
|
@@ -125,6 +129,7 @@ The packaged docs in this workspace are already mostly aligned with the installe
|
|
|
125
129
|
|
|
126
130
|
- `database.md` is the source doc for the Prisma and Python ORM workflow in this repo: schema changes go through `npx prisma migrate dev`, optional `npx prisma generate` plus `npx prisma db seed`, then `npx ppy generate`, and generated ORM files under `src/lib/prisma/` plus `settings/prisma-schema.json` are not hand-edited.
|
|
127
131
|
- `mcp.md` is the source doc for MCP-enabled workspaces, but in this workspace `caspian.config.json` currently has `mcp: false`, so do not assume `src/lib/mcp/**` or `npm run mcp` exist until MCP is explicitly enabled.
|
|
132
|
+
- `file-uploads.md` is the source doc for route-local uploads and file-manager flows in this repo: keep upload and delete RPCs in the owning route `index.py`, keep shared storage plus Prisma helpers in `src/lib/**`, store browser-accessible blobs under `public/storage/**`, and keep that directory in `settings/bs-config.ts` `PUBLIC_IGNORE_DIRS`.
|
|
128
133
|
- Feature-specific docs are conditional on `caspian.config.json`: use `database.md` only when `prisma: true`, use `mcp.md` only when `mcp: true`, and treat disabled-feature docs as reference material until the user chooses to enable that feature.
|
|
129
134
|
- `auth.md` is the source doc for auth routing guidance: choose all-private mode only when public routes are the minority, keep auth policy in `src/lib/auth/auth_config.py`, protect that file with `excludeFiles` if customized, prefer auth-protected RPC logout from page or component UI, and keep dedicated signout routes for form-post or no-JavaScript fallbacks.
|
|
130
135
|
- `state.md` is correct to warn that cross-request persistence depends on `request.state.session`, which is not bridged in the current `main.py`.
|
|
@@ -18,6 +18,7 @@ import caspianConfig from "../caspian.config.json";
|
|
|
18
18
|
const { __dirname } = getFileMeta();
|
|
19
19
|
const bs: BrowserSyncInstance = browserSync.create();
|
|
20
20
|
|
|
21
|
+
const WORKSPACE_ROOT = join(__dirname, "..");
|
|
21
22
|
const PUBLIC_IGNORE_DIRS = [""];
|
|
22
23
|
let previousRouteFiles: string[] = [];
|
|
23
24
|
let lastChangedFile: string | null = null;
|
|
@@ -32,7 +33,14 @@ function getReservedPorts(): Set<number> {
|
|
|
32
33
|
return reservedPorts;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const mcpSpecPath = join(
|
|
36
|
+
const mcpSpecPath = join(
|
|
37
|
+
__dirname,
|
|
38
|
+
"..",
|
|
39
|
+
"src",
|
|
40
|
+
"lib",
|
|
41
|
+
"mcp",
|
|
42
|
+
"fastmcp.json",
|
|
43
|
+
);
|
|
36
44
|
if (!existsSync(mcpSpecPath)) {
|
|
37
45
|
return reservedPorts;
|
|
38
46
|
}
|
|
@@ -159,6 +167,14 @@ function updateRouteFilesCache() {
|
|
|
159
167
|
}
|
|
160
168
|
}
|
|
161
169
|
|
|
170
|
+
function isIgnoredPublicPath(absPath: string): boolean {
|
|
171
|
+
const normalizedPath = relative(WORKSPACE_ROOT, absPath).replace(/\\/g, "/");
|
|
172
|
+
|
|
173
|
+
return PUBLIC_IGNORE_DIRS.some(
|
|
174
|
+
(dir) => normalizedPath === dir || normalizedPath.startsWith(`${dir}/`),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
162
178
|
const publicPipeline = new DebouncedWorker(
|
|
163
179
|
async () => {
|
|
164
180
|
console.log(chalk.cyan("→ Public directory changed, reloading browser..."));
|
|
@@ -191,8 +207,7 @@ const publicPipeline = new DebouncedWorker(
|
|
|
191
207
|
createSrcWatcher(join(PUBLIC_DIR, "**", "*"), {
|
|
192
208
|
onEvent: (_ev, abs, _) => {
|
|
193
209
|
const relFromPublic = relative(PUBLIC_DIR, abs);
|
|
194
|
-
|
|
195
|
-
if (PUBLIC_IGNORE_DIRS.includes(normalized.split("/")[0])) return;
|
|
210
|
+
if (isIgnoredPublicPath(abs)) return;
|
|
196
211
|
publicPipeline.schedule(relFromPublic);
|
|
197
212
|
},
|
|
198
213
|
awaitWriteFinish: DEFAULT_AWF,
|