caspian-utils 0.0.12 → 0.0.14

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.
@@ -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
- ```
77
-
78
- Use when you want the workspace's app-owned FastMCP server only.
74
+ This is also the workflow to use after the user chooses to enable or disable an optional feature in `caspian.config.json`.
79
75
 
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.
82
+ Use when the user explicitly wants the local BrowserSync plus PostCSS development stack.
87
83
 
88
- ### Inspect the local MCP config directly
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.
89
85
 
90
- ```powershell
91
- .venv\Scripts\fastmcp.exe inspect src/lib/mcp/fastmcp.json
92
- ```
86
+ ### Build generated assets for deployment
93
87
 
94
- Use when you are debugging the nested FastMCP config or checking which tools the current MCP server exposes.
95
-
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
111
+
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.
119
121
 
120
- ## 2. Supported Flags And Options
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
 
@@ -649,7 +651,7 @@ Auth example:
649
651
 
650
652
  If you exclude a file, the updater preserves it, but you are responsible for merging future framework changes into that file manually.
651
653
 
652
- ## 10. Operational Notes
654
+ ## 11. Operational Notes
653
655
 
654
656
  1. On Windows, the updater resolves `npx.cmd` instead of plain `npx`, which makes execution more reliable on Win32.
655
657
  2. The updater still requires `caspian.config.json` in the current directory before running an update.
@@ -18,12 +18,14 @@ Import them into a template with an `@import` comment, then render them with JSX
18
18
 
19
19
  For the current workspace, component tooling scans Python files under the paths listed in `caspian.config.json`. Right now that means `src/`, so `src/components/` is the clean default location for reusable UI, even though any scanned path under `src/` can work.
20
20
 
21
+ As the app grows, treat `src/components/` as the default home for reusable application UI. Keep route-owned markup in `src/app/`, and keep non-UI helpers or services in `src/lib/`.
22
+
21
23
  ## Mental Model
22
24
 
23
25
  - Use a Python component when you want a reusable server-rendered UI building block.
24
26
  - Return an HTML string directly for small presentational components.
25
27
  - Use `render_html(...)` with a same-name `.html` file when the component has more markup, PulsePoint behavior, or clearer separation between Python logic and UI.
26
- - Keep page-level workflows in `src/app/`, and move reusable UI into components.
28
+ - Keep page-level workflows in `src/app/`, move reusable UI into `src/components/`, and keep helpers, services, validators, and adapters in `src/lib/`.
27
29
 
28
30
  ## Basic Component
29
31
 
@@ -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,8 +40,8 @@ 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
+ - `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
43
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
@@ -49,7 +51,7 @@ The packaged Caspian docs distributed by the current toolchain also live here:
49
51
  - `validation.md` - Input validation and sanitization with `Validate`, `Rule`, direct field checks, and multi-rule workflows for routes and RPC actions
50
52
  - `metadata.md` - Static and dynamic metadata, SEO inheritance, and Open Graph or Twitter card tags
51
53
  - `routing.md` - Next.js App Router-style file-based routing with `src/app`, dynamic segments, route groups, nested layouts, and single-root route templates
52
- - `project-structure.md` - Default Caspian layout and where routes, templates, shared code, and database files belong
54
+ - `project-structure.md` - Default Caspian layout and where route files, reusable UI in `src/components/`, reusable non-UI code in `src/lib/`, and database files belong
53
55
 
54
56
  ## AI Awareness Notes
55
57
 
@@ -59,11 +61,16 @@ 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. As the app grows, standardize on `src/app/` for route-owned files, `src/components/` for reusable rendered UI, and `src/lib/` for reusable non-UI support code such as services, validators, adapters, and shared helpers.
70
+ 9. For authored component, route, and layout HTML files, generate exactly one top-level lowercase HTML element. Think React-style single parent wrapper: keep any owned PulsePoint logic in a plain `<script>` inside that root, do not handwrite `pp-component="..."` or `type="text/pp"` because Caspian injects those runtime attributes automatically, and treat `<!-- @import ... -->` comments as file-level directives that belong above the authored root element instead of inside `<div>`, `<section>`, or `<html>`. When several component tags come from one Python file, import them from that exact file path, for example `<!-- @import { Breadcrumb, BreadcrumbItem, BreadcrumbList } from "../components/Breadcrumb.py" -->`.
71
+ 10. Prefer local docs before generating code, commands, or migration guidance.
72
+ 11. Check `node_modules/caspian-utils/dist/docs/` for packaged Caspian docs when local docs need more detail.
73
+ 12. Only fall back to upstream documentation when local and packaged markdown do not cover the topic.
67
74
 
68
75
  ## Maintenance
69
76
 
@@ -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,6 +86,12 @@ 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:
@@ -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.
@@ -21,16 +21,21 @@ This page explains the default layout of a Caspian application, where Caspian co
21
21
 
22
22
  Caspian uses a lean project layout that keeps application code in `src`, database files in `prisma`, static assets in `public`, configuration in `caspian.config.json`, and framework internals in the installed package.
23
23
 
24
+ As an app grows, keep reusable rendered UI in `src/components/`, keep reusable non-UI support code in `src/lib/`, and keep route-owned files in `src/app/`. That split keeps page composition separate from shared component and service code.
25
+
24
26
  In that layout, the default stack is Python components for reusable UI, PulsePoint in templates for reactive browser behavior, RPC for browser-triggered server calls, and `casp.validate` for input validation at route and action boundaries.
25
27
 
26
28
  For public pages that can safely reuse rendered HTML, Caspian also supports route-level page caching through `casp.cache_handler`.
27
29
 
28
30
  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
31
 
32
+ 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`.
33
+
30
34
  ## Top-Level Areas
31
35
 
32
- - `src/` contains routes, page templates, styles, and shared libraries.
33
- - `src/components/` contains reusable Python components and optional same-name HTML templates.
36
+ - `src/` contains routes, page templates, styles, reusable components, and shared libraries.
37
+ - `src/components/` contains reusable application UI components and optional same-name HTML templates.
38
+ - `src/lib/` contains reusable non-UI code such as helpers, services, validators, adapters, and shared support modules.
34
39
  - `src/lib/auth/auth_config.py` contains auth-specific configuration for the app.
35
40
  - `src/lib/mcp/` contains the app-owned FastMCP server and nested FastMCP config when MCP is enabled.
36
41
  - `prisma/` contains the Prisma schema and seed scripts.
@@ -81,6 +86,8 @@ my-app/
81
86
  docs/
82
87
  ```
83
88
 
89
+ Optional directories such as `src/lib/mcp/` appear only when the relevant feature flag is enabled in `caspian.config.json`.
90
+
84
91
  ## Directory Breakdown
85
92
 
86
93
  ### `src/`
@@ -101,6 +108,8 @@ See `routing.md` for the full App Router-style rules for dynamic segments, route
101
108
 
102
109
  Use this folder for reusable UI components that should be imported into route templates or other component templates.
103
110
 
111
+ As the app grows, default to `src/components/` for application-level UI that will be shared across routes or features. Keep page-only markup close to the route in `src/app/`, but move shared cards, forms, shells, navigation, and other reusable visual building blocks into `src/components/`.
112
+
104
113
  The common Caspian pattern is a Python file such as `Button.py` with `@component`, optionally paired with a same-name HTML file such as `Button.html` when the component has richer markup or PulsePoint behavior.
105
114
 
106
115
  One Python file can also export multiple related `@component` functions. When that happens, import those tags from that exact file path in HTML, for example `<!-- @import { Breadcrumb, BreadcrumbItem, BreadcrumbList } from "../components/Breadcrumb.py" -->`, instead of assuming each tag has its own sibling `.py` file.
@@ -113,7 +122,9 @@ This workspace's component tooling scans `src/` based on `caspian.config.json`,
113
122
 
114
123
  ### `src/lib/`
115
124
 
116
- Use this folder for shared helpers, reusable validators, RPC-facing service wrappers, reusable UI utilities, and app-level support code.
125
+ Use this folder for shared helpers, reusable validators, RPC-facing service wrappers, data-access helpers, formatting utilities, and other app-level support code that is not itself a reusable rendered component.
126
+
127
+ If the code is primarily rendered UI that will be imported as a component tag, prefer `src/components/`. If the code is a helper, service, adapter, validator, or other non-visual support module, prefer `src/lib/`.
117
128
 
118
129
  This workspace already includes an app-owned Python database layer under `src/lib/prisma/`. Reuse that package for Python-side data access and keep any additional shared database helpers in `src/lib/`.
119
130
 
@@ -133,13 +144,15 @@ Use this folder for authentication-specific project code. The main auth configur
133
144
 
134
145
  Use this folder for app-owned Model Context Protocol server files.
135
146
 
136
- In the current workspace:
147
+ When `caspian.config.json` has `mcp: true`:
137
148
 
138
149
  - `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`.
150
+ - `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
151
 
141
152
  Keep MCP tool definitions here instead of placing them in route files, `main.py`, or framework internals.
142
153
 
154
+ In the current workspace, `mcp: false`, so do not assume this folder exists until the feature is enabled and the update workflow has run.
155
+
143
156
  ### `prisma/`
144
157
 
145
158
  This folder contains your database model definitions in `schema.prisma` and any seed logic such as `seed.ts`.
@@ -171,7 +184,7 @@ The core feature configuration file for the application.
171
184
 
172
185
  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
186
 
174
- In the current workspace, `caspian.config.json` shows `backendOnly: false`, `tailwindcss: true`, `mcp: true`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
187
+ In the current workspace, `caspian.config.json` shows `backendOnly: false`, `tailwindcss: true`, `mcp: false`, `prisma: true`, `typescript: false`, and `componentScanDirs: ["src"]`.
175
188
 
176
189
  ### `src/lib/auth/auth_config.py`
177
190
 
@@ -179,11 +192,11 @@ The project auth configuration file. Use this path when changing authentication
179
192
 
180
193
  ### `src/lib/mcp/mcp_server.py`
181
194
 
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.
195
+ 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
196
 
184
197
  ### `src/lib/mcp/fastmcp.json`
185
198
 
186
- The default FastMCP config file for this workspace.
199
+ When `caspian.config.json` has `mcp: true`, this is the default FastMCP config file for the workspace.
187
200
 
188
201
  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
202
 
@@ -229,14 +242,21 @@ The packaged Caspian documentation location distributed with the current toolcha
229
242
  If an AI agent is deciding where to make changes, use these rules first.
230
243
 
231
244
  - Read `caspian.config.json` almost immediately before making feature, tooling, or file-placement decisions. It tells you which Caspian features are enabled in the current workspace.
245
+ - Treat `caspian.config.json` as the single source of truth for optional feature enablement. Use feature-specific docs and file paths only when the matching flag is enabled.
246
+ - If an optional feature is disabled and the user wants it, ask first, then update `caspian.config.json` and use `npx casp update project` before assuming feature-managed files exist.
247
+ - 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`.
248
+ - 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.
249
+ - 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
250
  - Put route templates and route-specific backend logic in `src/app/`.
251
+ - As the app grows, keep route-owned code in `src/app/`, reusable rendered UI in `src/components/`, and reusable non-UI support code in `src/lib/`.
233
252
  - Check [routing.md](./routing.md) when you need URL segment rules, layout nesting behavior, or dynamic route conventions.
234
253
  - 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.
254
+ - When deciding between `src/components/` and `src/lib/`, use `src/components/` for anything rendered as reusable UI and `src/lib/` for helpers, services, validators, adapters, and shared business logic.
255
+ - 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
256
  - Keep `<!-- @import ... -->` comments above the single authored root element in route, layout, and component HTML files.
237
257
  - 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
258
  - Put shared helpers and reusable libraries in `src/lib/`.
239
- - Put app-owned FastMCP code in `src/lib/mcp/`.
259
+ - Put app-owned FastMCP code in `src/lib/mcp/` only when `caspian.config.json` enables MCP.
240
260
  - Use PulsePoint conventions in route templates for reactive frontend behavior.
241
261
  - Use `@rpc()` in route/backend code and `pp.rpc()` in client code for browser-triggered data flows.
242
262
  - 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.12",
3
+ "version": "0.0.14",
4
4
  "description": "Caspian tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {