proteum 2.1.0-5 → 2.1.1
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/AGENTS.md +37 -49
- package/README.md +52 -1
- package/agents/framework/AGENTS.md +104 -236
- package/agents/project/AGENTS.md +36 -70
- package/cli/commands/command.ts +243 -0
- package/cli/commands/commandLocalRunner.js +198 -0
- package/cli/commands/dev.ts +95 -1
- package/cli/commands/doctor.ts +8 -74
- package/cli/commands/explain.ts +8 -194
- package/cli/commands/trace.ts +8 -0
- package/cli/compiler/artifacts/commands.ts +217 -0
- package/cli/compiler/artifacts/manifest.ts +17 -2
- package/cli/compiler/artifacts/services.ts +291 -0
- package/cli/compiler/client/index.ts +13 -0
- package/cli/compiler/common/commands.ts +175 -0
- package/cli/compiler/common/proteumManifest.ts +15 -124
- package/cli/compiler/index.ts +25 -2
- package/cli/compiler/server/index.ts +3 -0
- package/cli/presentation/commands.ts +37 -5
- package/cli/runtime/commands.ts +29 -1
- package/cli/tsconfig.json +4 -1
- package/cli/utils/check.ts +1 -1
- package/client/app/component.tsx +11 -0
- package/client/dev/profiler/index.tsx +1511 -0
- package/client/dev/profiler/noop.tsx +5 -0
- package/client/dev/profiler/runtime.noop.ts +116 -0
- package/client/dev/profiler/runtime.ts +840 -0
- package/client/services/router/components/router.tsx +30 -2
- package/client/services/router/index.tsx +25 -0
- package/client/services/router/request/api.ts +133 -17
- package/commands/proteum/diagnostics.ts +11 -0
- package/common/dev/commands.ts +50 -0
- package/common/dev/diagnostics.ts +298 -0
- package/common/dev/profiler.ts +91 -0
- package/common/dev/proteumManifest.ts +135 -0
- package/common/dev/requestTrace.ts +28 -1
- package/docs/dev-commands.md +86 -0
- package/docs/request-tracing.md +2 -0
- package/package.json +1 -2
- package/server/app/commands.ts +35 -370
- package/server/app/commandsManager.ts +393 -0
- package/server/app/container/console/index.ts +0 -2
- package/server/app/container/trace/index.ts +88 -8
- package/server/app/devCommands.ts +192 -0
- package/server/app/devDiagnostics.ts +53 -0
- package/server/app/index.ts +27 -4
- package/server/services/cron/CronTask.ts +73 -5
- package/server/services/cron/index.ts +34 -11
- package/server/services/fetch/index.ts +3 -10
- package/server/services/prisma/index.ts +1 -1
- package/server/services/router/http/index.ts +132 -21
- package/server/services/router/index.ts +40 -4
- package/server/services/router/request/api.ts +30 -1
- package/skills/clean-project-code/SKILL.md +7 -2
- package/test-results/.last-run.json +4 -0
- package/types/aliases.d.ts +6 -0
package/AGENTS.md
CHANGED
|
@@ -1,71 +1,59 @@
|
|
|
1
1
|
# Proteum Core
|
|
2
2
|
|
|
3
|
-
This file governs work in the Proteum framework repository itself.
|
|
3
|
+
This file governs work in the Proteum framework repository itself. For downstream app rules, use `agents/framework/AGENTS.md`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Priorities
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Proteum aims to become the first SSR / SEO / TypeScript framework built primarily for non-human developers and AI agents.
|
|
10
|
-
|
|
11
|
-
When tradeoffs exist, prioritize framework decisions in this order:
|
|
7
|
+
When tradeoffs exist, optimize in this order:
|
|
12
8
|
|
|
13
9
|
1. Reduce shipped client bundle size and unnecessary runtime code.
|
|
14
|
-
2.
|
|
15
|
-
3. Improve SEO output and
|
|
10
|
+
2. Improve build-time, server-time, and browser-time performance.
|
|
11
|
+
3. Improve SEO output and crawlable, semantic HTML.
|
|
16
12
|
4. Preserve explicit, typed, machine-readable contracts for agents.
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
## Core Rules
|
|
19
15
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
16
|
+
- Prefer explicit typed contracts over runtime magic or hidden conventions.
|
|
17
|
+
- Keep `server/index.ts` as the canonical type root for services, router context, request context, and models.
|
|
18
|
+
- Keep generated code deterministic, auditable, and easy to map back to source.
|
|
19
|
+
- Prefer typed traces and manifest-backed diagnostics over ad hoc logging.
|
|
20
|
+
- Check existing repo dependencies and npm before inventing a new helper, runtime, plugin, or abstraction.
|
|
21
|
+
- Prefer established, flexible, well-typed packages; build custom only when packages fail on bundle size, performance, SSR behavior, typing, flexibility, or maintenance risk.
|
|
22
|
+
- Delete obsolete compatibility layers, helper indirection, and unused packages when safe.
|
|
25
23
|
|
|
26
24
|
## Workflow
|
|
27
25
|
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
2. explain why
|
|
31
|
-
3. suggest how to fix it
|
|
32
|
-
- When you have finished your work, summarize in one top-level short sentence all the changes you made since the beginning of the conversation. Output as `Commit message`. Max 90 characters.
|
|
33
|
-
|
|
34
|
-
## Framework Change Rules
|
|
26
|
+
- If the user pastes raw errors without asking for a fix, do not implement changes. List likely causes and, for each one, give probability, why, and how to fix it.
|
|
27
|
+
- End your work with `Commit message`: one short top-level sentence, max 90 characters.
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
## Core Changes
|
|
37
30
|
|
|
38
|
-
-
|
|
31
|
+
- Validate framework changes against both reference apps:
|
|
39
32
|
- `/Users/gaetan/Desktop/Projets/crosspath/platform`
|
|
40
33
|
- `/Users/gaetan/Desktop/Projets/unique.domains/website`
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
## Proposal Rules
|
|
48
|
-
|
|
49
|
-
When proposing a core change:
|
|
50
|
-
|
|
51
|
-
- start from the concrete mismatch or risk seen in the reference apps
|
|
52
|
-
- show the target API with real client and server usage examples that match current Proteum conventions
|
|
53
|
-
- distinguish the ideal end-state API from any transitional migration rule
|
|
54
|
-
- explain which source files drive generated artifacts when generation changes
|
|
55
|
-
- explicitly name removed behavior and why it is obsolete
|
|
34
|
+
- Inspect how both apps currently use the touched feature, runtime, API, compiler behavior, or generated output before proposing or implementing changes.
|
|
35
|
+
- Keep core changes aligned with the explicit controller/page architecture in `agents/framework/AGENTS.md`.
|
|
36
|
+
- Prefer removing framework magic when the same result can be expressed with explicit contracts, generated code, or typed context.
|
|
37
|
+
- Challenge any webpack plugin, Babel plugin, alias, helper, runtime service, or npm package that is not meaningfully used by both apps.
|
|
38
|
+
- Remove dead docs, flags, helper files, and compatibility branches in the same pass when safe.
|
|
56
39
|
|
|
57
|
-
##
|
|
40
|
+
## Proposals
|
|
58
41
|
|
|
59
|
-
|
|
42
|
+
- Start from the concrete mismatch or risk visible in the reference apps.
|
|
43
|
+
- Name the npm packages or package categories evaluated first when adding capability or infrastructure.
|
|
44
|
+
- Show the target API with real Proteum-style client and server usage.
|
|
45
|
+
- Separate the ideal end state from any migration rule.
|
|
46
|
+
- Name the source files that drive generated artifacts when generation changes.
|
|
47
|
+
- Explicitly name removed behavior and why it is obsolete.
|
|
60
48
|
|
|
61
|
-
|
|
49
|
+
## Runtime Validation
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
- use `proteum trace arm --capture deep`, reproduce the request once, then inspect `proteum trace latest` or `proteum trace show <requestId>` when the issue is request-time behavior
|
|
65
|
-
- open the real pages with Playwright
|
|
66
|
-
- inspect browser console errors and warnings
|
|
67
|
-
- inspect server startup and runtime errors
|
|
51
|
+
Do not stop at static analysis for routing, controllers, generated code, SSR, client runtime, services, webpack, Babel, or emitted assets.
|
|
68
52
|
|
|
69
|
-
|
|
53
|
+
- Run `npx proteum dev --no-cache --port 3xxx` in both reference apps on explicit ports.
|
|
54
|
+
- For request-time behavior, arm traces with `proteum trace arm --capture deep`, reproduce once, then inspect `proteum trace latest` or `proteum trace show <requestId>`.
|
|
55
|
+
- Open the real pages with Playwright.
|
|
56
|
+
- Inspect browser console errors and warnings.
|
|
57
|
+
- Inspect server startup and runtime errors.
|
|
70
58
|
|
|
71
|
-
|
|
59
|
+
Build-only checks are supplementary. Iterate until both apps boot and show no new framework regressions, and call unrelated environment warnings out separately.
|
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ my-app/
|
|
|
38
38
|
identity.yaml
|
|
39
39
|
.env # optional file for required local env vars
|
|
40
40
|
package.json
|
|
41
|
+
commands/
|
|
41
42
|
client/
|
|
42
43
|
pages/
|
|
43
44
|
_layout/
|
|
@@ -68,6 +69,7 @@ Important files:
|
|
|
68
69
|
- `server/index.ts`: default-exported `Application` subclass that instantiates root services and router plugins
|
|
69
70
|
- `client/pages/**`: SSR page entrypoints registered through `Router.page(...)`
|
|
70
71
|
- `server/controllers/**`: request handlers that extend `Controller`
|
|
72
|
+
- `commands/**`: dev-only internal commands that extend `Commands`
|
|
71
73
|
- `server/services/**`: business logic that extends `Service`
|
|
72
74
|
- `.proteum/**`: framework-owned generated contracts and manifests
|
|
73
75
|
|
|
@@ -200,6 +202,35 @@ Controller rules:
|
|
|
200
202
|
- call business logic through `this.services`, `this.models`, or `this.app`
|
|
201
203
|
- return explicit values instead of relying on ambient globals
|
|
202
204
|
|
|
205
|
+
## Example: Command
|
|
206
|
+
|
|
207
|
+
Proteum commands are explicit dev-only internal entrypoints.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
import { Commands } from '@server/app/commands';
|
|
211
|
+
|
|
212
|
+
export default class DiagnosticsCommands extends Commands {
|
|
213
|
+
public async ping() {
|
|
214
|
+
const { Stats } = this.services;
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
app: this.app.identity.identifier,
|
|
218
|
+
domains: await Stats.general(),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Command rules:
|
|
225
|
+
|
|
226
|
+
- files live under `commands/**/*.ts`
|
|
227
|
+
- each file default-exports a class extending `Commands` from `@server/app/commands`
|
|
228
|
+
- methods with bodies become generated dev commands
|
|
229
|
+
- command path comes from the file path plus the method name
|
|
230
|
+
- `export const commandPath = 'Custom/path'` can override the base path when needed
|
|
231
|
+
- `commands/tsconfig.json` and `.proteum/server/commands.d.ts` give `/commands` its own dev-only alias and app typing surface
|
|
232
|
+
- commands run only in dev contexts: `proteum command ...`, the dev profiler, or dev-only `__proteum/commands` endpoints
|
|
233
|
+
|
|
203
234
|
## Example: Service
|
|
204
235
|
|
|
205
236
|
Proteum services keep business logic out of request handlers.
|
|
@@ -234,6 +265,7 @@ Typical generated artifacts:
|
|
|
234
265
|
- `.proteum/client/controllers.ts`
|
|
235
266
|
- `.proteum/client/layouts.ts`
|
|
236
267
|
- `.proteum/common/controllers.ts`
|
|
268
|
+
- `.proteum/server/commands.ts`
|
|
237
269
|
- `.proteum/server/routes.ts`
|
|
238
270
|
- `.proteum/server/controllers.ts`
|
|
239
271
|
|
|
@@ -256,6 +288,7 @@ Proteum ships with a compact CLI focused on the real app lifecycle:
|
|
|
256
288
|
| `proteum doctor` | Inspect manifest diagnostics |
|
|
257
289
|
| `proteum explain` | Explain routes, controllers, services, layouts, conventions, and env |
|
|
258
290
|
| `proteum trace` | Inspect live dev-only request traces from the running SSR server |
|
|
291
|
+
| `proteum command` | Run a dev-only internal command locally or against a running dev server |
|
|
259
292
|
| `proteum init` | Experimental project scaffolding when scaffold assets are installed |
|
|
260
293
|
|
|
261
294
|
Recommended daily workflow:
|
|
@@ -273,13 +306,29 @@ Useful inspection commands:
|
|
|
273
306
|
proteum doctor
|
|
274
307
|
proteum doctor --json
|
|
275
308
|
proteum explain
|
|
276
|
-
proteum explain --routes --controllers
|
|
309
|
+
proteum explain --routes --controllers --commands
|
|
277
310
|
proteum explain --all --json
|
|
311
|
+
proteum command proteum/diagnostics/ping
|
|
312
|
+
proteum command proteum/diagnostics/ping --port 3101
|
|
278
313
|
proteum trace requests
|
|
279
314
|
proteum trace arm --capture deep
|
|
280
315
|
proteum trace latest
|
|
281
316
|
```
|
|
282
317
|
|
|
318
|
+
## Dev Commands
|
|
319
|
+
|
|
320
|
+
Proteum includes a dev-only command surface for internal testing, debugging, and one-off execution that should not become a normal controller or route.
|
|
321
|
+
|
|
322
|
+
- commands live under `./commands/**/*.ts`
|
|
323
|
+
- each file default-exports a class extending `Commands` from `@server/app/commands`
|
|
324
|
+
- each method is addressed by `file/path/methodName`
|
|
325
|
+
- Proteum creates `commands/tsconfig.json` when the folder exists so command files inherit the server alias/type project
|
|
326
|
+
- `proteum command foo/bar` refreshes generated artifacts, builds the dev output, starts a temporary local dev server, runs the command, prints the result, and exits
|
|
327
|
+
- `proteum command foo/bar --port 3101` runs the same command against an existing `proteum dev` instance
|
|
328
|
+
- the dev profiler exposes the same command list and run action through the `Commands` tab
|
|
329
|
+
|
|
330
|
+
Proteum itself also ships a small built-in diagnostic command at `proteum/diagnostics/ping`, so the command surface is never empty in dev.
|
|
331
|
+
|
|
283
332
|
## Request Tracing
|
|
284
333
|
|
|
285
334
|
Proteum includes a dev-only in-memory request trace buffer for routing, controller, context, SSR, and render debugging.
|
|
@@ -299,6 +348,7 @@ Default behavior:
|
|
|
299
348
|
- traces live in memory and are bounded by `TRACE_REQUESTS_LIMIT` and `TRACE_EVENTS_LIMIT`
|
|
300
349
|
- payloads are summarized, long strings are truncated, and sensitive fields such as cookies, passwords, and tokens are redacted
|
|
301
350
|
- `TRACE_PERSIST_ON_ERROR` can export crashing requests under `var/traces/`
|
|
351
|
+
- `proteum dev` removes auto-persisted crash traces from `var/traces/` when the dev session stops
|
|
302
352
|
|
|
303
353
|
Trace env example:
|
|
304
354
|
|
|
@@ -337,6 +387,7 @@ Proteum answers those questions with explicit artifacts:
|
|
|
337
387
|
- `.proteum/manifest.json` for machine-readable app structure
|
|
338
388
|
- `proteum explain --json` for structured framework introspection
|
|
339
389
|
- `proteum doctor --json` for structured diagnostics
|
|
390
|
+
- `proteum command ...` plus the profiler `Commands` tab for dev-only internal execution
|
|
340
391
|
|
|
341
392
|
If you are an LLM or automation agent, start here:
|
|
342
393
|
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
# Proteum App Contract
|
|
2
2
|
|
|
3
|
-
This is the canonical
|
|
3
|
+
This is the canonical contract for Proteum-based projects. Local project `AGENTS.md` files should add deltas only, not restate these rules.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## First Pass
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
When you enter a Proteum app, inspect it in this order:
|
|
7
|
+
Inspect apps in this order:
|
|
10
8
|
|
|
11
9
|
1. Run `npx proteum explain --json` or read `./.proteum/manifest.json`.
|
|
12
|
-
2. Inspect `./server/index.ts
|
|
13
|
-
3.
|
|
14
|
-
4.
|
|
15
|
-
5. If
|
|
16
|
-
6. If a server is already running on that port, use `npx proteum trace` to inspect past requests, errors, and their context before reproducing the issue or adding temporary logs.
|
|
10
|
+
2. Inspect `./server/index.ts`, `./server/config/*.ts`, and the touched files under `./commands`, `./server/controllers`, `./server/services`, `./server/routes`, and `./client/pages`.
|
|
11
|
+
3. Run `npx proteum doctor` if routing or generation looks suspicious.
|
|
12
|
+
4. For request-time issues in dev, read the default port from `PORT` or `./.proteum/manifest.json`; if a server is already running there, inspect `npx proteum trace` output before reproducing the issue or adding logs.
|
|
13
|
+
5. If existing traces are insufficient, run `npx proteum trace arm --capture deep`, reproduce once, then inspect the captured request.
|
|
17
14
|
|
|
18
15
|
## Non-Negotiable Rules
|
|
19
16
|
|
|
20
|
-
- Client pages live in `client/pages/**` and register routes with top-level `Router.page(...)` or `Router.error(...)
|
|
17
|
+
- Client pages live in `client/pages/**` and register routes with top-level `Router.page(...)` or `Router.error(...)`.
|
|
21
18
|
- Page URLs come from the explicit `Router.page('/path', ...)` call, not from the file path.
|
|
22
19
|
- Callable app APIs live only in `server/controllers/**/*.ts` files that extend `Controller`.
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- Request-scoped state
|
|
27
|
-
- SSR page data belongs in
|
|
20
|
+
- Dev-only internal execution lives only in `commands/**/*.ts` files that extend `Commands`.
|
|
21
|
+
- Manual HTTP endpoints live only in `server/routes/**`.
|
|
22
|
+
- Controllers call `this.input(schema)` inside the method body, at most once per method.
|
|
23
|
+
- Request-scoped state lives only on `this.request` and manual-route/router context objects.
|
|
24
|
+
- SSR page data belongs in page `setup`, not in `api.fetch(...)`.
|
|
28
25
|
- Normal service methods do not read request state directly.
|
|
29
26
|
- Do not import runtime values from `@models`.
|
|
30
27
|
- Do not use `@request` runtime globals.
|
|
@@ -34,233 +31,115 @@ When you enter a Proteum app, inspect it in this order:
|
|
|
34
31
|
|
|
35
32
|
## Source Of Truth
|
|
36
33
|
|
|
37
|
-
Proteum reads
|
|
34
|
+
Proteum reads:
|
|
38
35
|
|
|
39
36
|
- `package.json`
|
|
40
37
|
- `identity.yaml`
|
|
41
|
-
- `process.env` via
|
|
38
|
+
- `process.env` via `PORT`, `ENV_*`, `URL`, and `TRACE_*`
|
|
42
39
|
- `server/config/*.ts`
|
|
43
40
|
- `server/index.ts`
|
|
44
41
|
- `server/services/**/service.json`
|
|
42
|
+
- `commands/**/*.ts`
|
|
45
43
|
- `server/controllers/**/*.ts`
|
|
46
44
|
- `server/routes/**/*.ts`
|
|
47
45
|
- `client/pages/**/*.ts(x)`
|
|
48
46
|
- `client/pages/**/_layout/index.tsx`
|
|
49
47
|
- `public/**`
|
|
50
48
|
|
|
51
|
-
Proteum
|
|
49
|
+
Proteum owns:
|
|
52
50
|
|
|
53
51
|
- `.proteum/manifest.json`
|
|
54
52
|
- `.proteum/client/*`
|
|
55
53
|
- `.proteum/common/*`
|
|
56
54
|
- `.proteum/server/*`
|
|
57
55
|
|
|
58
|
-
Project code should
|
|
56
|
+
Project code should consume:
|
|
59
57
|
|
|
60
58
|
- `@generated/client/*`
|
|
61
59
|
- `@generated/common/*`
|
|
62
60
|
- `@generated/server/*`
|
|
63
|
-
- `@/client/context`
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- `npx proteum explain --json
|
|
68
|
-
- `npx proteum doctor --json
|
|
69
|
-
- `npx proteum trace
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
- root
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
- `export const
|
|
99
|
-
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
|
|
146
|
-
Error pages:
|
|
147
|
-
|
|
148
|
-
- use `Router.error(code, options, render)` in `client/pages/_messages/**`
|
|
149
|
-
|
|
150
|
-
## Client Context And Controller Calls
|
|
151
|
-
|
|
152
|
-
Use the generated client context entrypoint:
|
|
153
|
-
|
|
154
|
-
```ts
|
|
155
|
-
import useContext from '@/client/context';
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Then call generated controllers directly:
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
const { Founder } = useContext();
|
|
162
|
-
await Founder.projects.updateProject(payload);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Use direct controller calls for interactions. Do not recreate fake runtime imports or client-side `@app` access.
|
|
166
|
-
|
|
167
|
-
## Manual Server Routes
|
|
168
|
-
|
|
169
|
-
Use `server/routes/**` only for explicit HTTP behavior that should not be a generated controller action.
|
|
170
|
-
|
|
171
|
-
Good fits:
|
|
172
|
-
|
|
173
|
-
- redirects
|
|
174
|
-
- sitemap or RSS
|
|
175
|
-
- OAuth callbacks
|
|
176
|
-
- webhooks
|
|
177
|
-
- public resources with custom semantics
|
|
178
|
-
|
|
179
|
-
Rules:
|
|
180
|
-
|
|
181
|
-
- import server-side app services from `@app`
|
|
182
|
-
- use route handler context for `request`, `response`, router plugins, and custom router context
|
|
183
|
-
- if the route is just a normal app API, prefer a controller instead
|
|
184
|
-
|
|
185
|
-
## Models And Aliases
|
|
186
|
-
|
|
187
|
-
Use Prisma typings from:
|
|
188
|
-
|
|
189
|
-
```ts
|
|
190
|
-
import type * as Models from '@models/types';
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Use runtime models through:
|
|
194
|
-
|
|
195
|
-
- `this.models`
|
|
196
|
-
- `this.app.Models.client`
|
|
197
|
-
|
|
198
|
-
Rules:
|
|
199
|
-
|
|
200
|
-
- do not import runtime values from `@models`
|
|
201
|
-
- keep Prisma runtime access inside services when possible
|
|
202
|
-
- prefer explicit `select` or narrow `include`
|
|
203
|
-
- do not edit generated Prisma client files
|
|
204
|
-
|
|
205
|
-
Relevant aliases:
|
|
206
|
-
|
|
207
|
-
- `@/client/...`, `@/server/...`, `@/common/...`: app code
|
|
208
|
-
- `@client/...`, `@server/...`, `@common/...`: Proteum core modules
|
|
209
|
-
- `@app`: server-side application services for manual routes only
|
|
210
|
-
- `@generated/*`: generated app surfaces
|
|
211
|
-
|
|
212
|
-
## Task Playbooks
|
|
213
|
-
|
|
214
|
-
### Add A New App API
|
|
215
|
-
|
|
216
|
-
1. Add or extend a root service under `server/services/<Feature>/index.ts`.
|
|
217
|
-
2. Add or update `server/services/<Feature>/service.json`.
|
|
218
|
-
3. Add a controller under `server/controllers/**`.
|
|
219
|
-
4. Validate once with `this.input(schema)`.
|
|
220
|
-
5. Resolve auth and request-derived values in the controller.
|
|
221
|
-
6. Call the service from the client through the generated controller tree.
|
|
222
|
-
|
|
223
|
-
### Add A New SSR Page
|
|
224
|
-
|
|
225
|
-
1. Create or update `client/pages/.../index.tsx`.
|
|
226
|
-
2. Register `Router.page('/real-url', setup, render)`.
|
|
227
|
-
3. Return `_auth`, `_layout`, and SSR data from `setup`.
|
|
228
|
-
4. Read resolved data in `render`.
|
|
229
|
-
5. Use `@/client/context` or render args only for interactive follow-up actions.
|
|
230
|
-
|
|
231
|
-
### Add A New Manual Route
|
|
232
|
-
|
|
233
|
-
1. Create `server/routes/...`.
|
|
234
|
-
2. Import `Router` and needed app services from `@app`.
|
|
235
|
-
3. Register `Router.get/post/put/patch/delete(...)`.
|
|
236
|
-
4. Return response helpers or raw serializable data.
|
|
237
|
-
|
|
238
|
-
### Diagnose A Runtime Issue
|
|
239
|
-
|
|
240
|
-
1. Run `npx proteum explain --json`.
|
|
241
|
-
2. Run `npx proteum doctor`.
|
|
242
|
-
3. Read the default port from `PORT` or `./.proteum/manifest.json` and check whether a server is already running there.
|
|
243
|
-
4. If a server is already running on that default port, inspect existing traces first:
|
|
244
|
-
- `npx proteum trace requests --port <envPort>`
|
|
245
|
-
- `npx proteum trace latest --port <envPort>`
|
|
246
|
-
- `npx proteum trace show <requestId> --port <envPort>` when you need the full context for a past error
|
|
247
|
-
5. If the issue is request-time behavior in dev and the existing traces are not enough, run:
|
|
248
|
-
- `npx proteum trace arm --capture deep --port <envPort>`
|
|
249
|
-
- reproduce the failing request once
|
|
250
|
-
- `npx proteum trace latest --port <envPort>` or `npx proteum trace show <requestId> --port <envPort>`
|
|
251
|
-
6. Inspect the touched controller, service, route, or page source.
|
|
252
|
-
7. Only add temporary logging if the trace is insufficient.
|
|
253
|
-
|
|
254
|
-
For the full trace reference, see `node_modules/proteum/docs/request-tracing.md` in installed apps or `docs/request-tracing.md` in the framework repository.
|
|
255
|
-
|
|
256
|
-
## Preferred Patterns
|
|
257
|
-
|
|
258
|
-
- explicit `server/index.ts` bootstrap over hidden registration
|
|
259
|
-
- `Router.page(path, setup, render)` over page-local fetch hacks
|
|
260
|
-
- controller-backed app APIs over ad hoc manual `/api/...` route files
|
|
261
|
-
- service classes over random server helpers with hidden dependencies
|
|
262
|
-
- one canonical source of truth for catalogs, registries, and shared types
|
|
263
|
-
- project-local Shadcn-based UI primitives when the app already provides them
|
|
61
|
+
- `@/client/context` as the generated client context entrypoint
|
|
62
|
+
|
|
63
|
+
Prefer structured CLI surfaces over re-deriving framework facts from source:
|
|
64
|
+
|
|
65
|
+
- `npx proteum explain --json`
|
|
66
|
+
- `npx proteum doctor --json`
|
|
67
|
+
- `npx proteum trace ...`
|
|
68
|
+
- `npx proteum command ...`
|
|
69
|
+
|
|
70
|
+
## File Contracts
|
|
71
|
+
|
|
72
|
+
### App Bootstrap And Services
|
|
73
|
+
|
|
74
|
+
- `server/index.ts` default-exports the app `Application` subclass and is the canonical type root.
|
|
75
|
+
- Root services are public class fields instantiated with `new ServiceClass(this, config, this)`.
|
|
76
|
+
- Typed root-service config lives in `server/config/*.ts` via `Services.config(ServiceClass, { ... })`.
|
|
77
|
+
- Router plugins are instantiated explicitly inside the `Router` config `plugins` object.
|
|
78
|
+
- `server/services/**/service.json` plus `server/index.ts` drive generated service typings and manifest entries.
|
|
79
|
+
- Business logic lives in classes that extend `Service` and use `this.services`, `this.models`, and `this.app`.
|
|
80
|
+
- Keep auth, input parsing, locale, cookies, and request-derived values in controllers, then pass explicit typed arguments into services.
|
|
81
|
+
- Split growing features into explicit subservices.
|
|
82
|
+
|
|
83
|
+
### Controllers
|
|
84
|
+
|
|
85
|
+
- Files live under `server/controllers/**/*.ts` and default-export a class extending `Controller`.
|
|
86
|
+
- Methods with bodies become generated client-callable endpoints.
|
|
87
|
+
- Route path comes from the controller file path plus the method name.
|
|
88
|
+
- `export const controllerPath = 'Custom/path'` can override the base path.
|
|
89
|
+
- Generated client calls use `POST`.
|
|
90
|
+
|
|
91
|
+
### Commands
|
|
92
|
+
|
|
93
|
+
- Files live under `commands/**/*.ts` and default-export a class extending `Commands` from `@server/app/commands`.
|
|
94
|
+
- Methods with bodies become generated dev commands.
|
|
95
|
+
- Command path comes from the file path plus the method name.
|
|
96
|
+
- `export const commandPath = 'Custom/path'` can override the base path.
|
|
97
|
+
- Commands are for dev-only internal execution through `proteum command ...` or the profiler `Commands` tab.
|
|
98
|
+
- Keep command logic internal; do not turn it into a normal controller unless it is a real app API.
|
|
99
|
+
|
|
100
|
+
### Client Pages
|
|
101
|
+
|
|
102
|
+
- Proteum scans page files for top-level `Router.page(...)` and `Router.error(...)` calls.
|
|
103
|
+
- File path controls chunk identity and layout discovery; route path comes from the explicit `Router.page(...)` string.
|
|
104
|
+
- Supported page signatures are `Router.page(path, render)`, `Router.page(path, setup, render)`, `Router.page(path, options, render)`, and `Router.page(path, options, setup, render)`.
|
|
105
|
+
- For new work, prefer `Router.page(path, setup, render)` or `Router.page(path, options, setup, render)`.
|
|
106
|
+
- `setup` returns one flat object. Reserved keys like `_auth`, `_layout`, `_static`, and `_redirectLogged` are route options; all other keys are SSR data.
|
|
107
|
+
- Controller fetchers and promises returned from `setup` resolve before render.
|
|
108
|
+
- `render` consumes resolved setup data and uses generated controller methods from render args or `@/client/context`.
|
|
109
|
+
- Use `api.reload(...)` or `api.set(...)` only when intentionally mutating active page setup state.
|
|
110
|
+
- Error pages use `Router.error(code, options, render)` in `client/pages/_messages/**`.
|
|
111
|
+
|
|
112
|
+
### Manual Routes
|
|
113
|
+
|
|
114
|
+
- Use `server/routes/**` only for explicit HTTP behavior that should not be a generated controller action.
|
|
115
|
+
- Good fits include redirects, sitemap or RSS output, OAuth callbacks, webhooks, and public resources with custom semantics.
|
|
116
|
+
- Import server-side app services from `@app` and use route handler context for `request`, `response`, router plugins, and custom router context.
|
|
117
|
+
- If the route is a normal app API, prefer a controller.
|
|
118
|
+
|
|
119
|
+
### Models And Aliases
|
|
120
|
+
|
|
121
|
+
- Use Prisma typings from `@models/types`.
|
|
122
|
+
- Use runtime models through `this.models` or `this.app.Models.client`.
|
|
123
|
+
- Keep Prisma runtime access inside services when possible and prefer explicit `select` or narrow `include`.
|
|
124
|
+
- Do not import runtime values from `@models` or edit generated Prisma client files.
|
|
125
|
+
- Aliases:
|
|
126
|
+
- `@/client/...`, `@/server/...`, `@/common/...`: app code
|
|
127
|
+
- `@client/...`, `@server/...`, `@common/...`: Proteum core modules
|
|
128
|
+
- `@app`: server-side application services for manual routes only
|
|
129
|
+
- `@generated/*`: generated app surfaces
|
|
130
|
+
|
|
131
|
+
## Design Rules
|
|
132
|
+
|
|
133
|
+
- Prefer explicit `server/index.ts` bootstrap over hidden registration.
|
|
134
|
+
- Prefer controller-backed app APIs over ad hoc manual `/api/...` routes.
|
|
135
|
+
- Prefer service classes over server helpers with hidden dependencies.
|
|
136
|
+
- Keep one canonical source of truth for catalogs, registries, and shared types.
|
|
137
|
+
- Reuse project-local Shadcn-based UI primitives when the app already provides them.
|
|
138
|
+
- Before inventing a helper, primitive, parser, formatter, SDK wrapper, or build-time tool, first check whether the repo already depends on a suitable package.
|
|
139
|
+
- If it does not, search npm before writing a custom implementation.
|
|
140
|
+
- Prefer widely adopted, actively maintained, flexible, well-typed packages.
|
|
141
|
+
- Only build custom infrastructure when packages would clearly hurt bundle size, SSR behavior, performance, explicit contracts, or long-term maintainability.
|
|
142
|
+
- If you choose custom over a package, state briefly why.
|
|
264
143
|
|
|
265
144
|
## Discouraged Patterns
|
|
266
145
|
|
|
@@ -276,21 +155,10 @@ For the full trace reference, see `node_modules/proteum/docs/request-tracing.md`
|
|
|
276
155
|
Verify at the correct layer:
|
|
277
156
|
|
|
278
157
|
- route additions: boot the app and hit the real URL
|
|
279
|
-
- controller changes: exercise the generated client call or
|
|
158
|
+
- controller changes: exercise the generated client call or generated `/api/...` endpoint
|
|
280
159
|
- SSR changes: load the real page and inspect rendered HTML plus browser console
|
|
281
|
-
- router
|
|
282
|
-
|
|
283
|
-
When you need to diagnose or test against an app that may already be running:
|
|
284
|
-
|
|
285
|
-
- read the default port from `PORT` or `./.proteum/manifest.json`
|
|
286
|
-
- check whether a server is already running on that port
|
|
287
|
-
- if it is, inspect `proteum trace requests`, `proteum trace latest`, and `proteum trace show <requestId>` before reproducing the issue
|
|
160
|
+
- router or plugin changes: verify request context, auth, redirects, metrics, and validation on a running app
|
|
288
161
|
|
|
289
|
-
|
|
162
|
+
When an app may already be running, check the default port from `PORT` or `./.proteum/manifest.json` and inspect `proteum trace requests`, `proteum trace latest`, and `proteum trace show <requestId>` before reproducing the issue. If those traces are not enough, arm `npx proteum trace arm --capture deep`, reproduce once, then inspect the new request.
|
|
290
163
|
|
|
291
|
-
|
|
292
|
-
- `npx proteum refresh`
|
|
293
|
-
- `npx proteum typecheck`
|
|
294
|
-
- `npx proteum lint`
|
|
295
|
-
- `npx proteum check`
|
|
296
|
-
- `npx proteum build prod`
|
|
164
|
+
Useful commands: `proteum dev`, `npx proteum refresh`, `npx proteum typecheck`, `npx proteum lint`, `npx proteum check`, `npx proteum build prod`, `npx proteum command <path>`.
|