proteum 2.1.0 → 2.1.2

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.
Files changed (95) hide show
  1. package/AGENTS.md +44 -98
  2. package/README.md +143 -10
  3. package/agents/framework/AGENTS.md +146 -886
  4. package/agents/project/AGENTS.md +73 -127
  5. package/agents/project/client/AGENTS.md +22 -93
  6. package/agents/project/client/pages/AGENTS.md +24 -26
  7. package/agents/project/server/routes/AGENTS.md +10 -8
  8. package/agents/project/server/services/AGENTS.md +22 -159
  9. package/agents/project/tests/AGENTS.md +11 -8
  10. package/cli/app/config.ts +7 -20
  11. package/cli/bin.js +8 -0
  12. package/cli/commands/command.ts +243 -0
  13. package/cli/commands/commandLocalRunner.js +198 -0
  14. package/cli/commands/create.ts +5 -0
  15. package/cli/commands/deploy/web.ts +1 -2
  16. package/cli/commands/dev.ts +98 -2
  17. package/cli/commands/doctor.ts +8 -74
  18. package/cli/commands/explain.ts +8 -186
  19. package/cli/commands/init.ts +2 -94
  20. package/cli/commands/trace.ts +228 -0
  21. package/cli/compiler/artifacts/commands.ts +217 -0
  22. package/cli/compiler/artifacts/manifest.ts +35 -21
  23. package/cli/compiler/artifacts/services.ts +300 -1
  24. package/cli/compiler/client/index.ts +43 -8
  25. package/cli/compiler/common/commands.ts +175 -0
  26. package/cli/compiler/common/index.ts +1 -1
  27. package/cli/compiler/common/proteumManifest.ts +15 -114
  28. package/cli/compiler/index.ts +25 -2
  29. package/cli/compiler/server/index.ts +31 -6
  30. package/cli/index.ts +1 -4
  31. package/cli/paths.ts +16 -1
  32. package/cli/presentation/commands.ts +104 -14
  33. package/cli/presentation/devSession.ts +22 -3
  34. package/cli/presentation/proteum_logo_400x400_square_icon.txt +400 -0
  35. package/cli/runtime/commands.ts +121 -4
  36. package/cli/scaffold/index.ts +720 -0
  37. package/cli/scaffold/templates.ts +344 -0
  38. package/cli/scaffold/types.ts +26 -0
  39. package/cli/tsconfig.json +4 -1
  40. package/cli/utils/check.ts +1 -1
  41. package/client/app/component.tsx +13 -9
  42. package/client/dev/profiler/index.tsx +2511 -0
  43. package/client/dev/profiler/noop.tsx +5 -0
  44. package/client/dev/profiler/runtime.noop.ts +116 -0
  45. package/client/dev/profiler/runtime.ts +840 -0
  46. package/client/services/router/components/router.tsx +30 -2
  47. package/client/services/router/index.tsx +27 -3
  48. package/client/services/router/request/api.ts +133 -17
  49. package/commands/proteum/diagnostics.ts +11 -0
  50. package/common/dev/commands.ts +50 -0
  51. package/common/dev/diagnostics.ts +298 -0
  52. package/common/dev/profiler.ts +92 -0
  53. package/common/dev/proteumManifest.ts +135 -0
  54. package/common/dev/requestTrace.ts +115 -0
  55. package/common/env/proteumEnv.ts +284 -0
  56. package/common/router/index.ts +4 -22
  57. package/docs/dev-commands.md +93 -0
  58. package/docs/diagnostics.md +88 -0
  59. package/docs/request-tracing.md +132 -0
  60. package/eslint.js +11 -6
  61. package/package.json +3 -3
  62. package/server/app/commands.ts +35 -370
  63. package/server/app/commandsManager.ts +393 -0
  64. package/server/app/container/config.ts +11 -49
  65. package/server/app/container/console/index.ts +2 -3
  66. package/server/app/container/index.ts +5 -2
  67. package/server/app/container/trace/index.ts +364 -0
  68. package/server/app/devCommands.ts +192 -0
  69. package/server/app/devDiagnostics.ts +53 -0
  70. package/server/app/index.ts +29 -6
  71. package/server/index.ts +0 -1
  72. package/server/services/auth/index.ts +525 -61
  73. package/server/services/auth/router/index.ts +106 -7
  74. package/server/services/cron/CronTask.ts +73 -5
  75. package/server/services/cron/index.ts +34 -11
  76. package/server/services/fetch/index.ts +3 -10
  77. package/server/services/prisma/index.ts +66 -4
  78. package/server/services/router/http/index.ts +173 -6
  79. package/server/services/router/index.ts +200 -12
  80. package/server/services/router/request/api.ts +30 -1
  81. package/server/services/router/response/index.ts +83 -10
  82. package/server/services/router/response/page/document.tsx +16 -0
  83. package/server/services/router/response/page/index.tsx +27 -1
  84. package/skills/clean-project-code/SKILL.md +7 -2
  85. package/test-results/.last-run.json +4 -0
  86. package/types/aliases.d.ts +6 -0
  87. package/types/global/utils.d.ts +7 -14
  88. package/Rte.zip +0 -0
  89. package/agents/project/agents.md.zip +0 -0
  90. package/doc/TODO.md +0 -71
  91. package/doc/front/router.md +0 -27
  92. package/doc/workspace/workspace.png +0 -0
  93. package/doc/workspace/workspace2.png +0 -0
  94. package/doc/workspace/workspace_26.01.22.png +0 -0
  95. package/server/services/router/http/session.ts.old +0 -40
package/AGENTS.md CHANGED
@@ -1,113 +1,59 @@
1
- # Proteum Framework
1
+ # Proteum Core
2
2
 
3
- ## Vision
3
+ This file governs work in the Proteum framework repository itself. For downstream app rules, use `agents/framework/AGENTS.md`.
4
4
 
5
- Proteum aims to become the first SSR / SEO / TypeScript framework built primarily for non-human developers and AI agents.
5
+ ## Priorities
6
6
 
7
- The framework should maximize LLM efficiency, correctness, determinism, and performance when building Proteum-based projects.
8
-
9
- When tradeoffs exist, prioritize framework decisions in this order:
7
+ When tradeoffs exist, optimize in this order:
10
8
 
11
9
  1. Reduce shipped client bundle size and unnecessary runtime code.
12
- 2. Increase build-time, server-time, and browser-time performance.
13
- 3. Improve SEO output and LLM-friendly, crawlable, semantic HTML.
10
+ 2. Improve build-time, server-time, and browser-time performance.
11
+ 3. Improve SEO output and crawlable, semantic HTML.
14
12
  4. Preserve explicit, typed, machine-readable contracts for agents.
15
13
 
16
- When working on Proteum itself, optimize for agent ergonomics first:
14
+ ## Core Rules
17
15
 
18
- - Prefer explicit, typed, machine-readable contracts over implicit runtime magic, hidden conventions, ambient globals, or tribal knowledge.
19
- - Enforce strong, consistent TypeScript typings across the whole project. Do not introduce `any` or `unknown`.
20
- - Make routes, data loading, server actions / controllers, services, SEO metadata, sitemap generation, static generation, and environment contracts easy to discover, inspect, and explain.
21
- - Treat SSR and SEO as first-class framework primitives, not app-level patchwork.
22
- - Prefer server-first designs that avoid shipping client JavaScript unless it is required for user-facing behavior.
23
- - Favor small, single-purpose files and modules that reduce context load and make edits easier for agents to scope safely.
24
- - Generated code should improve traceability and type safety, not obscure behavior. It should be deterministic, auditable, and easy for agents to map back to source files.
25
- - Prefer inference from the explicit application class in `server/index.ts` whenever possible. Treat `server/index.ts` as the canonical type root for application services, router services, router context, and models instead of duplicating manual type declarations.
26
- - Prefer exact end-to-end contracts for inputs, outputs, errors, side effects, and caching behavior.
27
- - Prefer framework features that make impact analysis, verification, and debugging easier for agents.
28
- - Prefer output that is fast to render, easy to crawl, semantically rich, and easy for LLMs to parse reliably.
29
- - Avoid introducing abstractions that require broad codebase memory to use correctly.
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.
30
23
 
31
- When proposing or implementing a core change, evaluate it against this question:
24
+ ## Workflow
32
25
 
33
- - Does this make Proteum easier for an AI agent to understand, modify, verify, and operate with high confidence?
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.
34
28
 
35
- # Workflow
29
+ ## Core Changes
36
30
 
37
- - Everytime I input error messages without any instructions, don't implement fixes.
38
- Instead, ivestigate the potential causes of the errors, and for each:
39
- 1. Evaluate / quantify the probabiliies
40
- 2. Give why and
41
- 3. Suggest how to fix it
42
- - When you have finished your work, summarize in one top-level short sentence ALL the changes you made since the beginning of the WHOLE conversation. Output as "Commit message". Max 90 characters.
31
+ - Validate framework changes against both reference apps:
32
+ - `/Users/gaetan/Desktop/Projets/crosspath/platform`
33
+ - `/Users/gaetan/Desktop/Projets/unique.domains/website`
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.
43
39
 
44
- ## Framework Workflow
40
+ ## Proposals
45
41
 
46
- When changing Proteum itself, always ground the work in the real apps that use it.
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.
47
48
 
48
- - Treat these two projects as the reference surface for current Proteum usage and needs:
49
- - `/Users/gaetan/Desktop/Projets/crosspath/platform`
50
- - `/Users/gaetan/Desktop/Projets/unique.domains/website`
51
- - Before proposing a framework change, inspect how both apps currently use the feature, runtime, API, compiler behavior, or generated files involved.
52
- - Prefer removing framework magic when the same result can be expressed with explicit runtime contracts, generated code, or typed context.
53
- - If a webpack plugin, Babel plugin, alias, helper, runtime service, or npm package is not meaningfully used by both reference apps, challenge its existence and prefer deleting it.
54
-
55
- ## Current Proteum Direction
56
-
57
- Future changes should preserve and extend the current explicit model instead of reintroducing runtime magic.
58
-
59
- - Strong typings are mandatory across the whole project. Do not use `any` or `unknown`; keep types explicit, precise, and consistent.
60
- - Prefer deriving types from the explicit application class in `server/index.ts` instead of recreating them manually in feature code, helpers, or generated output.
61
- - Server route entrypoints live in `server/controllers/**/*.ts` files.
62
- - Controllers extend `Controller` and read request-scoped values from `this.request`.
63
- - Controllers validate request input via `this.input(schema)` inside the method body. Do not use decorators for validation metadata.
64
- - `server/config/*.ts` should export plain typed config constants with `Services.config(ServiceClass, { ... })`, for example `export const missionsConfig = Services.config(Missions, { ... })`.
65
- - `server/index.ts` should default-export the app `Application` subclass and instantiate root services as public fields via `new ServiceClass(this, config, this)`.
66
- - Normal services extend `Service` and should use `this.services`, `this.models`, and `this.app` instead of implicit globals or magic imports.
67
- - App services should be inferred from the explicit `server/index.ts` application graph and the config passed into each constructor, not hand-maintained parallel interfaces.
68
- - Router services and router/request context values such as `user`, `auth`, and similar request-scoped contracts should come from inferred request and app types, not ad hoc casts.
69
- - Models should be inferred from the app/model registry rooted at `server/index.ts` and exposed through generated app types, not from duplicated hand-written model maps.
70
- - Controllers should own auth, input parsing, and request concerns, then pass explicit typed values into services.
71
- - Do not reintroduce runtime server imports or globals such as `@request`, `@models`, or `@app`.
72
- - Client pages use `Router.page(path, render)` or `Router.page(path, setup, render)`.
73
- - SSR data loading belongs in the `setup` function returned object, not in `api.fetch(...)`.
74
- - Client-side controller access should come from the generated controller tree and client context, not from fake runtime imports.
75
- - When referencing an app service, a router service, or a model, expose it in the current block scope first by destructuring from `this.request`, `this.app`, or `this.app.Models.client`, then call methods on that local binding. The service, router value, or model should be the first element of the callee chain.
76
-
77
- ## Solution Proposals
78
-
79
- When presenting a framework solution, make it easy to judge against the real apps.
80
-
81
- - Start from the actual mismatch or risk seen in the apps, not from abstract framework theory.
82
- - Show the target API with concrete client and server usage examples that match current Proteum conventions.
83
- - Distinguish:
84
- - the ideal end-state API
85
- - any transitional migration rule or guardrail
86
- - Call out what becomes impossible or safer after the change.
87
- - If the change affects generated code, explain what source files drive generation and what artifacts are produced.
88
- - If the change removes older behavior, explicitly name what is being deleted and why it is obsolete.
89
-
90
- ## Implementation Rules
91
-
92
- - Keep framework changes aligned with the explicit controller/page architecture already adopted in the reference apps.
93
- - Prefer deleting client-side code, dependencies, and emitted assets when the same capability can stay on the server or be generated statically.
94
- - Prefer deleting obsolete branches, compatibility layers, plugins, and dependencies over keeping dead paths around.
95
- - Prefer compiler logic that is deterministic, auditable, and easy for another agent to trace from source to generated output.
96
- - Prefer local destructuring that exposes typed app services, router services, router context values, and models in the current block scope before use, instead of chaining through `this.request`, `this.app`, or `this.app.Models.client` at each call site.
97
- - Reject changes that increase bundle size, runtime cost, or crawlability risk unless the benefit is concrete and validated in both reference apps.
98
- - When removing old behavior, also remove the related packages, config flags, typings, docs, and dead helper files in the same pass when safe.
99
- - If a core change breaks one of the reference apps, keep iterating until the framework and the affected app usage are both corrected.
100
-
101
- ## Real-World Validation
102
-
103
- Do not stop at static analysis or isolated core compilation when the change affects runtime behavior.
104
-
105
- - Validate framework changes against the two reference apps whenever the change touches routing, controllers, generated code, SSR, client runtime, services, webpack, Babel, or emitted assets.
106
- - Preferred runtime validation:
107
- - run `npx proteum dev --no-cache -port 3xxx` in both apps on explicit ports
108
- - open the real pages with Playwright
109
- - inspect browser console errors and warnings
110
- - inspect server startup and runtime errors
111
- - Build-only checks are not sufficient for runtime/compiler changes. Use them as supplements, not as the final proof.
112
- - Keep fixing regressions exposed by the dev-server and browser pass until both apps boot and the browser console shows no new real errors.
113
- - Treat external/local-environment warnings separately from framework regressions, and say clearly when something is unrelated to the current change.
49
+ ## Runtime Validation
50
+
51
+ Do not stop at static analysis for routing, controllers, generated code, SSR, client runtime, services, webpack, Babel, or emitted assets.
52
+
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.
58
+
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
@@ -28,7 +28,7 @@ Proteum combines:
28
28
  - **Explicit request entrypoints.** Controllers are classes. Request access is explicit through `this.request`.
29
29
  - **Local validation.** Validate handler input inside the handler with `this.input(schema)`.
30
30
  - **Deterministic generation.** Proteum owns `.proteum/` and regenerates it from source.
31
- - **Explainability matters.** `proteum explain` and `proteum doctor` expose the framework view of your app.
31
+ - **Explainability matters.** `proteum explain`, `proteum doctor`, and `proteum trace` expose the framework view of your app and its live requests, and the profiler renders the same diagnostics surfaces for humans in dev.
32
32
  - **SEO is not an afterthought.** Identity, routes, layouts, and SSR data are part of the app contract.
33
33
 
34
34
  ## What a Proteum App Looks Like
@@ -36,8 +36,9 @@ Proteum combines:
36
36
  ```text
37
37
  my-app/
38
38
  identity.yaml
39
- env.yaml
39
+ .env # optional file for required local env vars
40
40
  package.json
41
+ commands/
41
42
  client/
42
43
  pages/
43
44
  _layout/
@@ -63,14 +64,34 @@ my-app/
63
64
  Important files:
64
65
 
65
66
  - `identity.yaml`: app identity, naming, locale, and SEO-facing metadata defaults
66
- - `env.yaml`: environment contract loaded by the app
67
+ - `process.env` / optional `.env`: `PORT`, `ENV_*`, `URL`, and `TRACE_*` environment variables loaded by the app
67
68
  - `server/config/*.ts`: plain typed config exports consumed by the explicit app bootstrap
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
 
76
+ Required Proteum env vars:
77
+
78
+ - `ENV_NAME`: `local` or `server`
79
+ - `ENV_PROFILE`: `dev`, `testing`, or `prod`
80
+ - `PORT`: default router port
81
+ - `URL`: canonical absolute base URL for `Router.url(..., true)`
82
+
83
+ Proteum does not provide defaults for required env vars. They must be defined explicitly in `process.env` or `.env`.
84
+
85
+ Use `proteum explain env` to see the required env vars, their allowed values, and whether each one is currently provided.
86
+
87
+ Optional trace env vars:
88
+
89
+ - `TRACE_ENABLE`
90
+ - `TRACE_REQUESTS_LIMIT`
91
+ - `TRACE_EVENTS_LIMIT`
92
+ - `TRACE_CAPTURE`
93
+ - `TRACE_PERSIST_ON_ERROR`
94
+
74
95
  ## Example: Server Bootstrap
75
96
 
76
97
  Proteum app services are declared explicitly through typed config exports plus a concrete `Application` subclass.
@@ -87,7 +108,7 @@ type RouterBaseConfig = Omit<ServiceConfig<typeof Router>, 'plugins'>;
87
108
  export const usersConfig = Services.config(Users, {});
88
109
 
89
110
  export const routerBaseConfig = {
90
- domains: AppContainer.Environment.router.domains,
111
+ currentDomain: AppContainer.Environment.router.currentDomain,
91
112
  http: {
92
113
  domain: 'example.com',
93
114
  port: AppContainer.Environment.router.port,
@@ -181,6 +202,35 @@ Controller rules:
181
202
  - call business logic through `this.services`, `this.models`, or `this.app`
182
203
  - return explicit values instead of relying on ambient globals
183
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
+
184
234
  ## Example: Service
185
235
 
186
236
  Proteum services keep business logic out of request handlers.
@@ -215,6 +265,7 @@ Typical generated artifacts:
215
265
  - `.proteum/client/controllers.ts`
216
266
  - `.proteum/client/layouts.ts`
217
267
  - `.proteum/common/controllers.ts`
268
+ - `.proteum/server/commands.ts`
218
269
  - `.proteum/server/routes.ts`
219
270
  - `.proteum/server/controllers.ts`
220
271
 
@@ -236,7 +287,10 @@ Proteum ships with a compact CLI focused on the real app lifecycle:
236
287
  | `proteum build --prod` | Produce the production server and client bundles into `bin/` |
237
288
  | `proteum doctor` | Inspect manifest diagnostics |
238
289
  | `proteum explain` | Explain routes, controllers, services, layouts, conventions, and env |
239
- | `proteum init` | Experimental project scaffolding when scaffold assets are installed |
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 |
292
+ | `proteum init` | Scaffold a new Proteum app with built-in deterministic templates |
293
+ | `proteum create` | Scaffold a page, controller, command, route, or root service inside an app |
240
294
 
241
295
  Recommended daily workflow:
242
296
 
@@ -253,10 +307,83 @@ Useful inspection commands:
253
307
  proteum doctor
254
308
  proteum doctor --json
255
309
  proteum explain
256
- proteum explain --routes --controllers
310
+ proteum explain --routes --controllers --commands
257
311
  proteum explain --all --json
312
+ proteum command proteum/diagnostics/ping
313
+ proteum command proteum/diagnostics/ping --port 3101
314
+ proteum trace requests
315
+ proteum trace arm --capture deep
316
+ proteum trace latest
258
317
  ```
259
318
 
319
+ Useful scaffolding commands:
320
+
321
+ ```bash
322
+ proteum init my-app --name "My App"
323
+ proteum init my-app --name "My App" --dry-run --json
324
+ proteum create page marketing/faq --route /faq
325
+ proteum create controller Founder/projects --method list
326
+ proteum create service Conversion/Plans
327
+ ```
328
+
329
+ `proteum explain` and `proteum doctor` share the same manifest-backed diagnostics contract as the profiler `Explain` and `Doctor` tabs. For the full dev diagnostics model, see [docs/diagnostics.md](docs/diagnostics.md).
330
+
331
+ ## Dev Commands
332
+
333
+ Proteum includes a dev-only command surface for internal testing, debugging, and one-off execution that should not become a normal controller or route.
334
+
335
+ - commands live under `./commands/**/*.ts`
336
+ - each file default-exports a class extending `Commands` from `@server/app/commands`
337
+ - each method is addressed by `file/path/methodName`
338
+ - Proteum creates `commands/tsconfig.json` when the folder exists so command files inherit the server alias/type project
339
+ - `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
340
+ - `proteum command foo/bar --port 3101` runs the same command against an existing `proteum dev` instance
341
+ - the dev profiler exposes the same command list and run action through the `Commands` tab
342
+ - the same profiler also exposes `Explain` and `Doctor` tabs backed by the same manifest diagnostics contract as the CLI
343
+
344
+ Proteum itself also ships a small built-in diagnostic command at `proteum/diagnostics/ping`, so the command surface is never empty in dev.
345
+
346
+ ## Request Tracing
347
+
348
+ Proteum includes a dev-only in-memory request trace buffer for auth, routing, controller, context, SSR, and render debugging.
349
+
350
+ This is separate from `proteum explain` and `proteum doctor`: tracing is live request-time data, while explain/doctor are manifest-backed structure and diagnostics.
351
+
352
+ When diagnosing or testing against an app, first read the default port from `PORT` or `./.proteum/manifest.json` and check whether a server is already running there. If it is, inspect the existing traces before reproducing the issue so you can collect past errors and their context.
353
+
354
+ - `proteum trace requests`: list the most recent request summaries
355
+ - `proteum trace latest`: show the latest captured request
356
+ - `proteum trace show <requestId>`: inspect one trace in detail
357
+ - `proteum trace arm --capture deep`: force the next request into deep capture mode
358
+ - `proteum trace export <requestId>`: write one trace to disk
359
+ - `proteum trace latest --url http://127.0.0.1:3010`: target a non-standard dev base URL directly
360
+
361
+ Default behavior:
362
+
363
+ - tracing is enabled only in `profile: dev`
364
+ - traces live in memory and are bounded by `TRACE_REQUESTS_LIMIT` and `TRACE_EVENTS_LIMIT`
365
+ - payloads are summarized, long strings are truncated, and sensitive fields such as cookies, passwords, and tokens are redacted
366
+ - `TRACE_PERSIST_ON_ERROR` can export crashing requests under `var/traces/`
367
+ - `proteum dev` removes auto-persisted crash traces from `var/traces/` when the dev session stops
368
+
369
+ Trace env example:
370
+
371
+ ```bash
372
+ export TRACE_ENABLE=true
373
+ export TRACE_REQUESTS_LIMIT=200
374
+ export TRACE_EVENTS_LIMIT=800
375
+ export TRACE_CAPTURE=resolve
376
+ export TRACE_PERSIST_ON_ERROR=true
377
+ ```
378
+
379
+ Capture modes:
380
+
381
+ - `summary`: request lifecycle plus high-signal events
382
+ - `resolve`: adds auth, route resolution, and controller/context steps
383
+ - `deep`: adds route skip reasons and deeper payload summaries for one request investigation
384
+
385
+ The trace CLI talks to the running dev server over the dev-only `__proteum/trace` HTTP endpoints. Use `--port` for a different local port or `--url` when the host itself is non-standard. For the full guide, see [docs/request-tracing.md](docs/request-tracing.md).
386
+
260
387
  ## LLM-Friendly By Design
261
388
 
262
389
  Proteum is built so an agent can answer these questions quickly and reliably:
@@ -271,22 +398,26 @@ Proteum is built so an agent can answer these questions quickly and reliably:
271
398
  Proteum answers those questions with explicit artifacts:
272
399
 
273
400
  - `identity.yaml` for app identity
274
- - `env.yaml` for the environment surface
401
+ - `PORT`, `ENV_*`, `URL`, and `TRACE_*` env vars for the environment surface
275
402
  - `server/index.ts` for the explicit root service graph
276
403
  - `.proteum/manifest.json` for machine-readable app structure
277
404
  - `proteum explain --json` for structured framework introspection
278
405
  - `proteum doctor --json` for structured diagnostics
406
+ - the profiler `Explain` and `Doctor` tabs for a human-readable view over the same manifest-backed contract
407
+ - `proteum command ...` plus the profiler `Commands` tab for dev-only internal execution
279
408
 
280
409
  If you are an LLM or automation agent, start here:
281
410
 
282
411
  1. Read `identity.yaml`.
283
- 2. Read `env.yaml`.
412
+ 2. Read `PORT`, the relevant `ENV_*`, `URL`, and `TRACE_*` env vars, or run `proteum explain env`.
284
413
  3. Inspect `server/index.ts` and `server/config/*.ts` for the explicit app bootstrap.
285
414
  4. Read `.proteum/manifest.json` or run `proteum explain --json`.
286
415
  5. Inspect `server/controllers/**` for request entrypoints.
287
416
  6. Inspect `server/services/**` for business logic.
288
417
  7. Inspect `client/pages/**` for SSR routes and page setup contracts.
289
418
 
419
+ For implementation rules in a real Proteum app, treat the local `AGENTS.md` files plus `proteum explain`, `proteum doctor`, and `proteum trace` as the task contract. This README is the framework overview, not the project-local instruction layer.
420
+
290
421
  ## What Proteum Avoids
291
422
 
292
423
  Proteum intentionally avoids several patterns that make frameworks harder to inspect and harder to trust:
@@ -335,15 +466,17 @@ Install in an app:
335
466
  npm install proteum
336
467
  ```
337
468
 
338
- If the scaffold assets are available in your distribution, you can bootstrap a new app with:
469
+ You can bootstrap a new app with:
339
470
 
340
471
  ```bash
341
- npx proteum init
472
+ npx proteum init my-app --name "My App"
473
+ npx proteum init my-app --name "My App" --dry-run --json
342
474
  ```
343
475
 
344
476
  Then use the normal workflow:
345
477
 
346
478
  ```bash
479
+ npm install
347
480
  npx proteum dev
348
481
  npx proteum check
349
482
  npx proteum build --prod