proteum 2.1.9 → 2.2.0
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/.codex/environments/environment.toml +11 -0
- package/AGENTS.md +25 -11
- package/README.md +19 -9
- package/agents/project/AGENTS.md +165 -120
- package/agents/project/CODING_STYLE.md +1 -1
- package/agents/project/app-root/AGENTS.md +16 -0
- package/agents/project/client/AGENTS.md +5 -5
- package/agents/project/client/pages/AGENTS.md +13 -13
- package/agents/project/diagnostics.md +19 -10
- package/agents/project/optimizations.md +5 -6
- package/agents/project/root/AGENTS.md +295 -0
- package/agents/project/server/routes/AGENTS.md +2 -2
- package/agents/project/server/services/AGENTS.md +4 -2
- package/agents/project/tests/AGENTS.md +2 -2
- package/cli/app/index.ts +31 -7
- package/cli/commands/configure.ts +226 -0
- package/cli/commands/dev.ts +0 -2
- package/cli/commands/diagnose.ts +33 -1
- package/cli/commands/explain.ts +1 -1
- package/cli/commands/migrate.ts +51 -0
- package/cli/commands/orient.ts +169 -0
- package/cli/commands/perf.ts +8 -1
- package/cli/commands/verify.ts +1003 -49
- package/cli/compiler/artifacts/manifest.ts +4 -4
- package/cli/compiler/artifacts/routing.ts +2 -2
- package/cli/compiler/artifacts/services.ts +12 -3
- package/cli/compiler/client/index.ts +65 -19
- package/cli/compiler/common/files/style.ts +47 -2
- package/cli/compiler/common/generatedRouteModules.ts +31 -38
- package/cli/compiler/common/index.ts +10 -0
- package/cli/compiler/common/proteumManifest.ts +1 -0
- package/cli/compiler/server/index.ts +34 -9
- package/cli/context.ts +6 -1
- package/cli/index.ts +7 -8
- package/cli/migrate/pageContract.ts +516 -0
- package/cli/paths.ts +47 -6
- package/cli/presentation/commands.ts +100 -10
- package/cli/presentation/devSession.ts +4 -6
- package/cli/presentation/help.ts +2 -2
- package/cli/presentation/ink.ts +10 -5
- package/cli/presentation/welcome.ts +2 -4
- package/cli/runtime/commands.ts +94 -1
- package/cli/scaffold/index.ts +2 -2
- package/cli/scaffold/templates.ts +4 -2
- package/cli/utils/agents.ts +273 -58
- package/client/dev/profiler/index.tsx +3 -2
- package/client/router.ts +10 -2
- package/client/services/router/index.tsx +6 -22
- package/common/dev/connect.ts +20 -4
- package/common/dev/console.ts +7 -0
- package/common/dev/contractsDoctor.ts +354 -0
- package/common/dev/diagnostics.ts +10 -7
- package/common/dev/inspection.ts +830 -38
- package/common/dev/performance.ts +19 -5
- package/common/dev/profiler.ts +1 -0
- package/common/dev/proteumManifest.ts +5 -4
- package/common/dev/requestTrace.ts +12 -1
- package/common/router/contracts.ts +8 -11
- package/common/router/index.ts +2 -2
- package/common/router/pageData.ts +72 -0
- package/common/router/register.ts +10 -46
- package/common/router/response/page.ts +28 -16
- package/docs/dev-sessions.md +8 -4
- package/docs/diagnostics.md +77 -11
- package/docs/migrate-from-2.1.3.md +388 -0
- package/docs/request-tracing.md +25 -6
- package/package.json +6 -1
- package/scripts/update-codex-agents.ts +2 -2
- package/server/app/container/console/index.ts +11 -1
- package/server/app/container/trace/index.ts +117 -0
- package/server/app/devDiagnostics.ts +1 -1
- package/server/app/index.ts +5 -1
- package/server/services/auth/index.ts +9 -0
- package/server/services/router/index.ts +64 -14
- package/server/services/router/request/api.ts +7 -1
- package/server/services/router/response/index.ts +8 -28
- package/types/global/vendors.d.ts +12 -0
- package/types/vendors.d.ts +12 -0
- package/common/router/pageSetup.ts +0 -51
package/docs/diagnostics.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# Diagnostics and Explainability
|
|
2
2
|
|
|
3
|
-
Proteum exposes
|
|
3
|
+
Proteum exposes three manifest-backed orientation and diagnostics surfaces plus one composite request-diagnosis surface:
|
|
4
4
|
|
|
5
|
+
- `proteum orient`: resolve the likely owner, guidance files, connected boundaries, and next steps before opening code
|
|
5
6
|
- `proteum explain`: inspect the generated app structure
|
|
6
7
|
- `proteum doctor`: inspect manifest diagnostics
|
|
7
8
|
- `proteum diagnose`: combine owner lookup, diagnostics, matching request traces, and buffered server logs for one concrete query or path
|
|
8
9
|
|
|
9
|
-
These are not separate models for different tools. `explain
|
|
10
|
+
These are not separate models for different tools. `orient`, `explain`, and `doctor` share the same generated manifest snapshot, while `diagnose` layers live dev-only request data on top of that same framework view.
|
|
10
11
|
|
|
11
12
|
Performance inspection is a sibling surface, not a separate instrumentation stack: `proteum perf` and the profiler `Perf` tab aggregate the same dev-only request traces that back `proteum trace`.
|
|
12
13
|
|
|
@@ -14,8 +15,9 @@ Performance inspection is a sibling surface, not a separate instrumentation stac
|
|
|
14
15
|
|
|
15
16
|
The canonical snapshot lives in `./.proteum/manifest.json`.
|
|
16
17
|
|
|
17
|
-
Proteum uses that same manifest in
|
|
18
|
+
Proteum uses that same manifest in seven places:
|
|
18
19
|
|
|
20
|
+
- `proteum orient` for owner lookup, guidance resolution, connected-boundary summary, and next-step suggestions
|
|
19
21
|
- `proteum explain` for human-readable and `--json` output
|
|
20
22
|
- `proteum doctor` for human-readable and `--json` output
|
|
21
23
|
- `proteum explain owner <query>` for ownership lookup over the manifest index
|
|
@@ -32,6 +34,8 @@ If a command such as `proteum explain`, `proteum doctor`, `proteum diagnose`, or
|
|
|
32
34
|
Common usage:
|
|
33
35
|
|
|
34
36
|
```bash
|
|
37
|
+
proteum orient /api/Auth/CurrentUser
|
|
38
|
+
|
|
35
39
|
proteum explain
|
|
36
40
|
proteum explain owner /api/Auth/CurrentUser
|
|
37
41
|
proteum explain --routes --controllers --commands
|
|
@@ -46,14 +50,34 @@ proteum diagnose /
|
|
|
46
50
|
proteum diagnose /dashboard --port 3101
|
|
47
51
|
proteum diagnose /api/Auth/CurrentUser --url http://127.0.0.1:3101
|
|
48
52
|
|
|
53
|
+
proteum verify owner /api/Auth/CurrentUser
|
|
54
|
+
proteum verify request /dashboard --port 3101
|
|
55
|
+
proteum verify browser /dashboard --port 3101 --session-email admin@example.com --session-role ADMIN
|
|
56
|
+
|
|
49
57
|
proteum perf top --since today
|
|
50
58
|
proteum perf request /dashboard --port 3101
|
|
51
59
|
proteum perf compare --baseline yesterday --target today --group-by route
|
|
52
60
|
proteum perf memory --since 1h --group-by controller
|
|
53
61
|
```
|
|
54
62
|
|
|
63
|
+
`proteum orient --json` emits:
|
|
64
|
+
|
|
65
|
+
- `query`
|
|
66
|
+
- `normalizedQuery`
|
|
67
|
+
- `app`
|
|
68
|
+
- `guidance`
|
|
69
|
+
- `owner`
|
|
70
|
+
- `connected`
|
|
71
|
+
- `nextSteps`
|
|
72
|
+
- `warnings`
|
|
73
|
+
|
|
55
74
|
`proteum explain --json` emits the selected manifest sections as machine-readable JSON.
|
|
56
75
|
|
|
76
|
+
`proteum explain owner <query> --json` keeps the existing owner ranking shape and adds:
|
|
77
|
+
|
|
78
|
+
- `scopeLabel`
|
|
79
|
+
- `originHint`
|
|
80
|
+
|
|
57
81
|
`proteum doctor --json` emits:
|
|
58
82
|
|
|
59
83
|
- `summary.errors`
|
|
@@ -64,6 +88,8 @@ proteum perf memory --since 1h --group-by controller
|
|
|
64
88
|
`proteum diagnose` emits a composite response with:
|
|
65
89
|
|
|
66
90
|
- `owner`
|
|
91
|
+
- `orientation`
|
|
92
|
+
- `chain`
|
|
67
93
|
- `doctor`
|
|
68
94
|
- `contracts`
|
|
69
95
|
- `request`
|
|
@@ -71,13 +97,31 @@ proteum perf memory --since 1h --group-by controller
|
|
|
71
97
|
- `suspects`
|
|
72
98
|
- `serverLogs`
|
|
73
99
|
|
|
100
|
+
`proteum verify owner|request|browser --json` emits:
|
|
101
|
+
|
|
102
|
+
- `action`
|
|
103
|
+
- `target`
|
|
104
|
+
- `orientation`
|
|
105
|
+
- `introducedFindings`
|
|
106
|
+
- `preExistingFindings`
|
|
107
|
+
- `verificationSteps`
|
|
108
|
+
- `result`
|
|
109
|
+
|
|
74
110
|
`proteum perf` emits trace-derived performance views:
|
|
75
111
|
|
|
76
112
|
- `top`: grouped hot paths with avg, p95, CPU, SQL, render, and heap deltas
|
|
77
|
-
- `request`: one traced request waterfall with stage timings, CPU, SQL, render, self time, and
|
|
113
|
+
- `request`: one traced request waterfall with stage timings, CPU, SQL, render, self time, payload sizes, chain attribution, and SQL fingerprints
|
|
78
114
|
- `compare`: grouped baseline vs target deltas
|
|
79
115
|
- `memory`: grouped heap and RSS drift summaries
|
|
80
116
|
|
|
117
|
+
Focused verification defaults to the smallest trustworthy surface first:
|
|
118
|
+
|
|
119
|
+
- `verify owner`: orient the target, then choose request, command, or local owner-scoped diagnostics
|
|
120
|
+
- `verify request`: hit one real request, collect `diagnose`, and classify introduced vs pre-existing findings
|
|
121
|
+
- `verify browser`: only when browser-visible behavior matters, using an app-local isolated Playwright workspace
|
|
122
|
+
|
|
123
|
+
Focused verification fails on introduced blocking findings by default and does not fail on unrelated pre-existing blockers unless `--strict-global` is passed.
|
|
124
|
+
|
|
81
125
|
## Dev HTTP Endpoints
|
|
82
126
|
|
|
83
127
|
In `profile: dev`, the running app exposes:
|
|
@@ -138,14 +182,36 @@ During `proteum dev`, the bottom profiler is the human-facing UI over the same d
|
|
|
138
182
|
|
|
139
183
|
Use the profiler when a human needs to browse the same data that an agent or CLI command can already inspect directly.
|
|
140
184
|
|
|
185
|
+
## Runtime Contract Diagnostics
|
|
186
|
+
|
|
187
|
+
`proteum doctor --contracts` now emits additive runtime-focused diagnostics for framework-owned failures that are often misdiagnosed as leaf-component bugs:
|
|
188
|
+
|
|
189
|
+
- `runtime/provider-hook-outside-provider`
|
|
190
|
+
- `runtime/client-only-hook-in-ssr`
|
|
191
|
+
- `runtime/router-context-outside-router`
|
|
192
|
+
- `runtime/connected-boundary-mismatch`
|
|
193
|
+
|
|
194
|
+
Each diagnostic includes:
|
|
195
|
+
|
|
196
|
+
- `code`
|
|
197
|
+
- `message`
|
|
198
|
+
- `filepath`
|
|
199
|
+
- `sourceLocation`
|
|
200
|
+
- `fixHint`
|
|
201
|
+
- `relatedFilepaths`
|
|
202
|
+
|
|
203
|
+
Treat these as framework contract failures first. The fix usually belongs at the provider, router, connected-boundary, or SSR/client split where the contract was broken, not only in the component that happened to throw.
|
|
204
|
+
|
|
141
205
|
## Agent Workflow
|
|
142
206
|
|
|
143
207
|
For AI coding agents or automation:
|
|
144
208
|
|
|
145
|
-
1.
|
|
146
|
-
2.
|
|
147
|
-
3. Run `proteum
|
|
148
|
-
4.
|
|
149
|
-
5.
|
|
150
|
-
6.
|
|
151
|
-
7.
|
|
209
|
+
1. Start with `proteum orient <query>` when the target might be generated, connected, framework-owned, or multi-repo.
|
|
210
|
+
2. Read `./.proteum/manifest.json` or run `proteum explain --json` only after you know which surface matters.
|
|
211
|
+
3. Run `proteum doctor --json` and `proteum doctor --contracts --json` to inspect framework and generated-artifact diagnostics.
|
|
212
|
+
4. Use `proteum verify owner <query>` or `proteum diagnose <path> --port <port>` for the smallest trustworthy runtime surface before broad checks.
|
|
213
|
+
5. Use `proteum verify browser` for browser-visible verification, and only drop to direct Playwright when request-level verification cannot reproduce the issue. Keep auth sourced from `proteum session`, and reserve browser flows for the final verifier agent unless they are the only trustworthy surface.
|
|
214
|
+
6. For performance, CPU, SQL, render, cache, or connected-boundary questions, use `proteum perf request <requestId|path>` against the same running dev server.
|
|
215
|
+
7. Use `proteum trace ...` when you need lower-level event detail than `diagnose` or `perf` provides.
|
|
216
|
+
8. Run global checks second, not first. Unrelated diagnostics should remain visible but non-blocking during focused verification unless strict global mode is required.
|
|
217
|
+
9. Open the profiler only when a human-readable view helps; it should agree with the CLI after refresh.
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
# Migrating from Proteum 2.1.3
|
|
2
|
+
|
|
3
|
+
This guide covers the breaking changes between `proteum@2.1.3` and the current framework code in this repository.
|
|
4
|
+
|
|
5
|
+
The important conclusion is that the breaking surface is mostly at the app root and tooling contract level, not in day-to-day page, controller, or service authoring. In the repo diff from `2.1.3` to the current `2.1.9` line, I did not find a mandatory rewrite of `Router.page(...)`, controller methods, or normal service method bodies. The required migration is mainly about config files, env, service metadata discovery, and connected-app setup.
|
|
6
|
+
|
|
7
|
+
## Breaking Changes Summary
|
|
8
|
+
|
|
9
|
+
### 1. `identity.yaml` is no longer supported
|
|
10
|
+
|
|
11
|
+
`2.1.3` expected a YAML file at the app root:
|
|
12
|
+
|
|
13
|
+
- `identity.yaml`
|
|
14
|
+
|
|
15
|
+
Current Proteum requires a typed TypeScript config:
|
|
16
|
+
|
|
17
|
+
- `identity.config.ts`
|
|
18
|
+
|
|
19
|
+
The file must default-export `Application.identity(...)` from `proteum/config`.
|
|
20
|
+
|
|
21
|
+
### 2. `proteum.config.ts` is now required
|
|
22
|
+
|
|
23
|
+
`2.1.3` had no app-level setup file for compiler or connected-project config.
|
|
24
|
+
|
|
25
|
+
Current Proteum requires:
|
|
26
|
+
|
|
27
|
+
- `proteum.config.ts`
|
|
28
|
+
|
|
29
|
+
The file must default-export `Application.setup(...)` from `proteum/config`.
|
|
30
|
+
|
|
31
|
+
This is where app-level framework config now lives, especially:
|
|
32
|
+
|
|
33
|
+
- `transpile`
|
|
34
|
+
- `connect`
|
|
35
|
+
|
|
36
|
+
### 3. `URL_INTERNAL` is now a required env var
|
|
37
|
+
|
|
38
|
+
`2.1.3` required:
|
|
39
|
+
|
|
40
|
+
- `ENV_NAME`
|
|
41
|
+
- `ENV_PROFILE`
|
|
42
|
+
- `PORT`
|
|
43
|
+
- `URL`
|
|
44
|
+
|
|
45
|
+
Current Proteum also requires:
|
|
46
|
+
|
|
47
|
+
- `URL_INTERNAL`
|
|
48
|
+
|
|
49
|
+
The router and SSR runtime now treat the internal base URL as a first-class contract instead of reusing `URL` implicitly.
|
|
50
|
+
|
|
51
|
+
### 4. `server/services/**/service.json` is no longer part of the contract
|
|
52
|
+
|
|
53
|
+
In `2.1.3`, Proteum still read service metadata from `server/services/**/service.json`.
|
|
54
|
+
|
|
55
|
+
Current Proteum reads the service graph from:
|
|
56
|
+
|
|
57
|
+
- `server/index.ts`
|
|
58
|
+
- typed config exports under `server/config/*.ts`
|
|
59
|
+
|
|
60
|
+
If you still have `service.json` files from a `2.1.3` app, they are obsolete and should be removed.
|
|
61
|
+
|
|
62
|
+
If you used `priority` there, move that value into the typed service config export with `Services.config(...)`.
|
|
63
|
+
|
|
64
|
+
### 5. Connected apps must be declared explicitly
|
|
65
|
+
|
|
66
|
+
Current Proteum adds an explicit connected-project contract in `proteum.config.ts`.
|
|
67
|
+
|
|
68
|
+
If your app consumes controllers from another Proteum app, you now need:
|
|
69
|
+
|
|
70
|
+
- `connect.<Namespace>.source`
|
|
71
|
+
- `connect.<Namespace>.urlInternal`
|
|
72
|
+
|
|
73
|
+
There is no namespace-based inference. The producer app must also already be on the new contract because Proteum now expects the producer app root to contain:
|
|
74
|
+
|
|
75
|
+
- `identity.config.ts`
|
|
76
|
+
- `proteum.config.ts`
|
|
77
|
+
- generated connected contract files
|
|
78
|
+
|
|
79
|
+
### 6. `proteum dev` is stricter when connected apps are configured
|
|
80
|
+
|
|
81
|
+
If `connect` is configured, current `proteum dev` verifies the producer app health endpoint before it declares the server ready.
|
|
82
|
+
|
|
83
|
+
That means broken or stale connected-app config is now a startup failure, not just a latent runtime problem.
|
|
84
|
+
|
|
85
|
+
### 7. Human-facing CLI output changed
|
|
86
|
+
|
|
87
|
+
Current Proteum prints a welcome banner only for the bare `proteum build` and bare `proteum dev` commands, and `proteum dev` now has tracked session files plus `list` and `stop` subcommands.
|
|
88
|
+
|
|
89
|
+
This is not an app-code migration, but it can break scripts that parse mixed stdout/stderr loosely. Prefer `--json` for automation.
|
|
90
|
+
|
|
91
|
+
## Migration Checklist
|
|
92
|
+
|
|
93
|
+
### 1. Upgrade the package
|
|
94
|
+
|
|
95
|
+
Update the app dependency to the current Proteum version, then reinstall.
|
|
96
|
+
|
|
97
|
+
### 2. Replace `identity.yaml` with `identity.config.ts`
|
|
98
|
+
|
|
99
|
+
Create a new root file:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { Application } from 'proteum/config';
|
|
103
|
+
|
|
104
|
+
export default Application.identity({
|
|
105
|
+
name: 'My App',
|
|
106
|
+
identifier: 'MyApp',
|
|
107
|
+
description: 'My Proteum app',
|
|
108
|
+
author: {
|
|
109
|
+
name: 'My Team',
|
|
110
|
+
url: 'https://example.com',
|
|
111
|
+
email: 'team@example.com',
|
|
112
|
+
},
|
|
113
|
+
social: {},
|
|
114
|
+
language: 'en',
|
|
115
|
+
locale: 'en-US',
|
|
116
|
+
maincolor: 'white',
|
|
117
|
+
iconsPack: 'light',
|
|
118
|
+
web: {
|
|
119
|
+
title: 'My App',
|
|
120
|
+
titleSuffix: 'My App',
|
|
121
|
+
fullTitle: 'My App',
|
|
122
|
+
description: 'My Proteum app',
|
|
123
|
+
version: '0.0.1',
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Mapping from the old YAML shape is mostly direct:
|
|
129
|
+
|
|
130
|
+
- `name` stays `name`
|
|
131
|
+
- `identifier` stays `identifier`
|
|
132
|
+
- `description` stays `description`
|
|
133
|
+
- `author.*` stays `author.*`
|
|
134
|
+
- `language`, `locale`, `maincolor`, `iconsPack` keep the same meaning
|
|
135
|
+
- `web.*` keeps the same meaning
|
|
136
|
+
|
|
137
|
+
Then remove the old file:
|
|
138
|
+
|
|
139
|
+
- `identity.yaml`
|
|
140
|
+
|
|
141
|
+
### 3. Add `proteum.config.ts`
|
|
142
|
+
|
|
143
|
+
Create a new root file:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { Application } from 'proteum/config';
|
|
147
|
+
|
|
148
|
+
export default Application.setup({
|
|
149
|
+
transpile: [],
|
|
150
|
+
connect: {},
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
If your app does not consume another Proteum app and does not need package transpilation, this empty config is enough.
|
|
155
|
+
|
|
156
|
+
If your app compiles workspace or source-distributed packages through Proteum, put them in `transpile`.
|
|
157
|
+
|
|
158
|
+
Example:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { Application } from 'proteum/config';
|
|
162
|
+
|
|
163
|
+
export default Application.setup({
|
|
164
|
+
transpile: ['@acme/components'],
|
|
165
|
+
connect: {},
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### 4. Add `URL_INTERNAL` to `.env`
|
|
170
|
+
|
|
171
|
+
At minimum, a migrated app now needs:
|
|
172
|
+
|
|
173
|
+
```dotenv
|
|
174
|
+
ENV_NAME=local
|
|
175
|
+
ENV_PROFILE=dev
|
|
176
|
+
PORT=3010
|
|
177
|
+
URL=http://localhost:3010
|
|
178
|
+
URL_INTERNAL=http://localhost:3010
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
For many local apps, `URL_INTERNAL` can initially match `URL`.
|
|
182
|
+
|
|
183
|
+
Use a different internal URL only when the app is reached differently from server-side code than from a browser.
|
|
184
|
+
|
|
185
|
+
### 5. Remove `service.json` and move metadata into typed config
|
|
186
|
+
|
|
187
|
+
Delete any legacy files such as:
|
|
188
|
+
|
|
189
|
+
- `server/services/Foo/service.json`
|
|
190
|
+
|
|
191
|
+
Current Proteum derives the root service graph from `server/index.ts`, so the real source of truth is now the code that instantiates root services there.
|
|
192
|
+
|
|
193
|
+
If the old `service.json` carried priority metadata, move it into the typed config export.
|
|
194
|
+
|
|
195
|
+
Old pattern:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"priority": 5
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
New pattern:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { Services } from '@server/app';
|
|
207
|
+
import MetricsRouter from '@/server/services/utils/Metrics/router';
|
|
208
|
+
|
|
209
|
+
export const routerMetricsConfig = Services.config(MetricsRouter, {
|
|
210
|
+
priority: 5,
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Then make sure `server/index.ts` instantiates the service explicitly:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
public Router = new Router(this, {
|
|
218
|
+
...userConfig.routerBaseConfig,
|
|
219
|
+
plugins: {
|
|
220
|
+
metrics: new MetricsRouter(userConfig.routerMetricsConfig, this),
|
|
221
|
+
},
|
|
222
|
+
}, this);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 6. Keep `server/index.ts` explicit
|
|
226
|
+
|
|
227
|
+
Current Proteum expects the installed root services and router plugins to be visible directly in `server/index.ts`.
|
|
228
|
+
|
|
229
|
+
The migration target is:
|
|
230
|
+
|
|
231
|
+
- root services are instantiated as class properties on the `Application` subclass
|
|
232
|
+
- router plugins are instantiated inside the `Router` config
|
|
233
|
+
- typed config values come from `server/config/*.ts`
|
|
234
|
+
|
|
235
|
+
If your `2.1.3` app relied on legacy discovery metadata, replace that with explicit code.
|
|
236
|
+
|
|
237
|
+
## Connected-App Migration
|
|
238
|
+
|
|
239
|
+
This section applies only if one Proteum app consumes controllers from another Proteum app.
|
|
240
|
+
|
|
241
|
+
### 1. Upgrade the producer app too
|
|
242
|
+
|
|
243
|
+
A current consumer app expects a producer app root that already has:
|
|
244
|
+
|
|
245
|
+
- `identity.config.ts`
|
|
246
|
+
- `proteum.config.ts`
|
|
247
|
+
|
|
248
|
+
So a `file:` connected source pointing at an untouched `2.1.3` producer will fail.
|
|
249
|
+
|
|
250
|
+
### 2. Declare `connect` explicitly in `proteum.config.ts`
|
|
251
|
+
|
|
252
|
+
Example:
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
import { Application } from 'proteum/config';
|
|
256
|
+
|
|
257
|
+
export default Application.setup({
|
|
258
|
+
connect: {
|
|
259
|
+
Product: {
|
|
260
|
+
source: process.env.PRODUCT_CONNECTED_SOURCE,
|
|
261
|
+
urlInternal: process.env.PRODUCT_URL_INTERNAL,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 3. Add the new env vars used by that config
|
|
268
|
+
|
|
269
|
+
Example:
|
|
270
|
+
|
|
271
|
+
```dotenv
|
|
272
|
+
PRODUCT_CONNECTED_SOURCE=file:../product
|
|
273
|
+
PRODUCT_URL_INTERNAL=http://localhost:3020
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Supported source styles in the current contract are:
|
|
277
|
+
|
|
278
|
+
- `file:../relative-producer-app`
|
|
279
|
+
- `github:owner/repo?ref=<ref>&path=proteum.connected.json`
|
|
280
|
+
|
|
281
|
+
### 4. Expect stricter startup behavior
|
|
282
|
+
|
|
283
|
+
When `connect` is configured, `proteum dev` now checks the producer health endpoint before it reports ready.
|
|
284
|
+
|
|
285
|
+
If startup fails, validate in this order:
|
|
286
|
+
|
|
287
|
+
1. The producer app has already been migrated.
|
|
288
|
+
2. `connect.<Namespace>.source` points at the right producer app root.
|
|
289
|
+
3. `connect.<Namespace>.urlInternal` points at the producer dev server.
|
|
290
|
+
4. The producer app is running.
|
|
291
|
+
5. `npx proteum connect --strict` passes in the consumer app.
|
|
292
|
+
|
|
293
|
+
## Monorepo and Workspace Notes
|
|
294
|
+
|
|
295
|
+
Current Proteum is better at resolving hoisted and workspace installs than `2.1.3`, but old app tsconfig files often still hardcode shallow `node_modules` paths.
|
|
296
|
+
|
|
297
|
+
If your app lives inside a monorepo and TypeScript path resolution starts failing after the upgrade, align `client/tsconfig.json` and `server/tsconfig.json` with the current scaffold shape:
|
|
298
|
+
|
|
299
|
+
- include `../identity.config.ts` and `../proteum.config.ts` in the server tsconfig
|
|
300
|
+
- make sure the `extends` path points to the real visible `proteum/tsconfig.common.json`
|
|
301
|
+
- make sure the `@client/*`, `@common/*`, and `@server/*` aliases point to the real visible Proteum install
|
|
302
|
+
- make sure Preact compat aliases include `react-dom/client` when your app imports it
|
|
303
|
+
|
|
304
|
+
This is usually only needed for workspace or hoisted installs. Standalone apps with a local `node_modules/proteum` often keep working after the config-file migration alone.
|
|
305
|
+
|
|
306
|
+
## CLI and Workflow Changes
|
|
307
|
+
|
|
308
|
+
These are worth updating even though they are not core app-code migrations.
|
|
309
|
+
|
|
310
|
+
### Use `--json` for automation
|
|
311
|
+
|
|
312
|
+
Only bare `proteum build` and bare `proteum dev` runs print a banner. For scripts, CI helpers, or editor tooling, prefer:
|
|
313
|
+
|
|
314
|
+
- `npx proteum explain --json`
|
|
315
|
+
- `npx proteum doctor --json`
|
|
316
|
+
- `npx proteum connect --json`
|
|
317
|
+
|
|
318
|
+
### Use tracked dev sessions
|
|
319
|
+
|
|
320
|
+
Current `proteum dev` supports tracked session management:
|
|
321
|
+
|
|
322
|
+
- `npx proteum dev --session-file var/run/proteum/dev/app.json --replace-existing`
|
|
323
|
+
- `npx proteum dev list --json`
|
|
324
|
+
- `npx proteum dev stop --session-file var/run/proteum/dev/app.json`
|
|
325
|
+
|
|
326
|
+
If your local workflow starts multiple dev servers, this is the current supported model.
|
|
327
|
+
|
|
328
|
+
### New diagnostics are available
|
|
329
|
+
|
|
330
|
+
These are new capabilities, not migration requirements, but they are the fastest way to validate the upgrade:
|
|
331
|
+
|
|
332
|
+
- `npx proteum connect --strict`
|
|
333
|
+
- `npx proteum explain --connected --controllers`
|
|
334
|
+
- `npx proteum diagnose / --port <port>`
|
|
335
|
+
- `npx proteum perf top --port <port>`
|
|
336
|
+
- `npx proteum trace latest --port <port>`
|
|
337
|
+
|
|
338
|
+
## Recommended Migration Order
|
|
339
|
+
|
|
340
|
+
1. Upgrade the package.
|
|
341
|
+
2. Convert `identity.yaml` to `identity.config.ts`.
|
|
342
|
+
3. Add `proteum.config.ts`.
|
|
343
|
+
4. Add `URL_INTERNAL`.
|
|
344
|
+
5. Delete all legacy `service.json` files.
|
|
345
|
+
6. Move any legacy service metadata, especially `priority`, into `Services.config(...)`.
|
|
346
|
+
7. Confirm `server/index.ts` explicitly instantiates every root service and router plugin.
|
|
347
|
+
8. If the app is connected to another app, migrate the producer app and then add explicit `connect` config.
|
|
348
|
+
9. If the app is inside a workspace, align tsconfig paths with the actual Proteum install location.
|
|
349
|
+
10. Run `npx proteum refresh`, then validate with the commands below.
|
|
350
|
+
|
|
351
|
+
## Validation After Migration
|
|
352
|
+
|
|
353
|
+
Run these from the migrated app:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
npx proteum refresh
|
|
357
|
+
npx proteum explain --env
|
|
358
|
+
npx proteum doctor --contracts --strict
|
|
359
|
+
npx proteum check
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
If the app uses connected projects, also run:
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
npx proteum connect --strict
|
|
366
|
+
npx proteum explain --connected --controllers
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Then boot the app and verify the live runtime:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
npx proteum dev --port 3010
|
|
373
|
+
npx proteum diagnose / --port 3010
|
|
374
|
+
npx proteum trace latest --port 3010
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Short Version
|
|
378
|
+
|
|
379
|
+
If you want the shortest possible migration plan:
|
|
380
|
+
|
|
381
|
+
1. Replace `identity.yaml` with `identity.config.ts`.
|
|
382
|
+
2. Add `proteum.config.ts`.
|
|
383
|
+
3. Add `URL_INTERNAL`.
|
|
384
|
+
4. Delete `server/services/**/service.json`.
|
|
385
|
+
5. Move any service `priority` into `Services.config(...)`.
|
|
386
|
+
6. If you connect apps together, declare `connect.<Namespace>.source` and `connect.<Namespace>.urlInternal` explicitly.
|
|
387
|
+
|
|
388
|
+
That is the minimum needed to move a real `2.1.3` app onto the current Proteum contract.
|
package/docs/request-tracing.md
CHANGED
|
@@ -34,9 +34,9 @@ Before reproducing a bug or starting a new test pass:
|
|
|
34
34
|
Typical debugging flow:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
proteum
|
|
38
|
-
|
|
39
|
-
proteum
|
|
37
|
+
proteum orient /dashboard
|
|
38
|
+
proteum diagnose /dashboard --hit /dashboard --port 3103
|
|
39
|
+
proteum perf request /dashboard --port 3103
|
|
40
40
|
proteum trace show <requestId> --port 3103
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -44,14 +44,16 @@ Use `--url http://host:port` when the dev server is reachable on a non-standard
|
|
|
44
44
|
|
|
45
45
|
If the request under test is protected and login UX is not the feature under test, mint an auth cookie with `proteum session <email> --role <role>` before reproducing the request. This keeps the trace focused on the protected behavior instead of the login flow.
|
|
46
46
|
|
|
47
|
-
If you already know the failing path and want a one-shot suspect list before reading raw events, start with `proteum diagnose <path> --port <port>` and drop into `proteum trace show <requestId>` only when the lower-level event stream is still needed.
|
|
47
|
+
If you already know the failing path and want a one-shot suspect list before reading raw events, start with `proteum diagnose <path> --port <port>` and `proteum perf request <path> --port <port>` first, then drop into `proteum trace show <requestId>` only when the lower-level event stream is still needed.
|
|
48
|
+
|
|
49
|
+
Use ad hoc database queries or one-off scripts only after `orient`, `diagnose`, `perf request`, and `trace show` still leave the request chain unclear.
|
|
48
50
|
|
|
49
|
-
Trace summaries include `sql=<count>`. Detailed trace output includes both a `Calls` section for API
|
|
51
|
+
Trace summaries include `sql=<count>`. Detailed trace output includes both a `Calls` section for API, cache, or fetcher activity and a `SQL` section for captured Prisma queries.
|
|
50
52
|
|
|
51
53
|
`proteum perf` is a grouped view over the same trace store:
|
|
52
54
|
|
|
53
55
|
- `top` ranks routes, concrete paths, or controllers by avg, p95, CPU, SQL, render, self time, and heap delta
|
|
54
|
-
- `request` shows one traced request waterfall with stage timings plus the hottest calls and SQL
|
|
56
|
+
- `request` shows one traced request waterfall with stage timings plus the hottest calls, SQL, chain attribution, connected boundary, and SQL fingerprints
|
|
55
57
|
- `compare` shows baseline-vs-target regressions between trace windows such as `yesterday` and `today`
|
|
56
58
|
- `memory` shows grouped heap and RSS drift trends
|
|
57
59
|
|
|
@@ -65,6 +67,7 @@ Depending on capture mode, traces can include:
|
|
|
65
67
|
- route resolution start, match, and deep-mode skip reasons
|
|
66
68
|
- controller start and result shape
|
|
67
69
|
- synchronous SSR fetcher calls, API batch fetchers, and async request traces
|
|
70
|
+
- cache hits and cache writes observed during request handling
|
|
68
71
|
- Prisma SQL queries with caller method/path, optional fetcher attribution, SQL text, params, kind, operation, and timing
|
|
69
72
|
- created router/context keys
|
|
70
73
|
- setup output keys and page data summaries
|
|
@@ -72,6 +75,7 @@ Depending on capture mode, traces can include:
|
|
|
72
75
|
- render start/end timings and document output sizes
|
|
73
76
|
- per-request CPU usage deltas plus heap and RSS snapshots before and after the request
|
|
74
77
|
- normalized request errors
|
|
78
|
+
- additive owner, service, cache, and connected-boundary metadata propagated from route/controller resolution into downstream calls and SQL
|
|
75
79
|
|
|
76
80
|
## SQL Tracing
|
|
77
81
|
|
|
@@ -87,6 +91,21 @@ Prisma query tracing covers both ORM operations and raw queries.
|
|
|
87
91
|
|
|
88
92
|
This currently covers SQL issued through Proteum's Prisma service, including raw helpers that flow through the same Prisma client.
|
|
89
93
|
|
|
94
|
+
Each traced SQL entry can now include:
|
|
95
|
+
|
|
96
|
+
- `fingerprint`: stable normalized SQL shape for repeated-query comparison
|
|
97
|
+
- `ownerLabel` and `ownerFilepath`: route/controller ownership propagated from the request
|
|
98
|
+
- `serviceLabel`: the inferred service boundary when available
|
|
99
|
+
- `connectedNamespace`: the connected producer namespace when the request crossed an app boundary
|
|
100
|
+
|
|
101
|
+
`proteum diagnose` and `proteum perf request` collapse those lower-level records into a compact request chain:
|
|
102
|
+
|
|
103
|
+
- route or controller
|
|
104
|
+
- service
|
|
105
|
+
- cache branch when used
|
|
106
|
+
- connected app boundary when used
|
|
107
|
+
- SQL fingerprints
|
|
108
|
+
|
|
90
109
|
## Capture Modes
|
|
91
110
|
|
|
92
111
|
- `summary`: smallest capture, focused on request lifecycle and high-signal events
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proteum",
|
|
3
3
|
"description": "LLM-first Opinionated Typescript Framework for web applications.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/proteum.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"proteum": "cli/bin.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@babel/generator": "^7.29.0",
|
|
20
|
+
"@babel/parser": "^7.29.0",
|
|
21
|
+
"@babel/traverse": "^7.29.0",
|
|
22
|
+
"@babel/types": "^7.29.0",
|
|
19
23
|
"@inkjs/ui": "^2.0.0",
|
|
20
24
|
"@prisma/adapter-mariadb": "7.2.0",
|
|
21
25
|
"@prisma/client": "7.2.0",
|
|
@@ -69,6 +73,7 @@
|
|
|
69
73
|
"preact": "^10.27.1",
|
|
70
74
|
"preact-render-to-string": "^6.6.1",
|
|
71
75
|
"prompts": "^2.4.2",
|
|
76
|
+
"react": "^19.2.0",
|
|
72
77
|
"react-apexcharts": "^2.1.0",
|
|
73
78
|
"replace-once": "^1.0.0",
|
|
74
79
|
"responsive-loader": "^3.1.2",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { configureProjectAgentSymlinks } from '../cli/utils/agents';
|
|
10
10
|
|
|
11
11
|
/*----------------------------------
|
|
12
12
|
- TYPES
|
|
@@ -31,5 +31,5 @@ for (const projectRoot of projectRoots) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
console.log(`[update-codex-agents] Syncing project Codex assets in ${projectRoot}`);
|
|
34
|
-
|
|
34
|
+
configureProjectAgentSymlinks({ appRoot: projectRoot, coreRoot: proteumRoot });
|
|
35
35
|
}
|
|
@@ -237,6 +237,12 @@ export default class Console {
|
|
|
237
237
|
...(typeof channel.method === 'string' ? { method: channel.method } : {}),
|
|
238
238
|
...(typeof channel.path === 'string' ? { path: channel.path } : {}),
|
|
239
239
|
...(typeof channel.user === 'string' ? { user: channel.user } : {}),
|
|
240
|
+
...(typeof channel.connectedNamespace === 'string' ? { connectedNamespace: channel.connectedNamespace } : {}),
|
|
241
|
+
...(typeof channel.ownerLabel === 'string' ? { ownerLabel: channel.ownerLabel } : {}),
|
|
242
|
+
...(typeof channel.ownerFilepath === 'string' ? { ownerFilepath: channel.ownerFilepath } : {}),
|
|
243
|
+
...(typeof channel.serviceLabel === 'string' ? { serviceLabel: channel.serviceLabel } : {}),
|
|
244
|
+
...(typeof channel.cacheKey === 'string' ? { cacheKey: channel.cacheKey } : {}),
|
|
245
|
+
...(typeof channel.cachePhase === 'string' ? { cachePhase: channel.cachePhase } : {}),
|
|
240
246
|
...(typeof channel.traceCallId === 'string' ? { traceCallId: channel.traceCallId } : {}),
|
|
241
247
|
...(typeof channel.traceCallOrigin === 'string' ? { traceCallOrigin: channel.traceCallOrigin } : {}),
|
|
242
248
|
...(typeof channel.traceCallLabel === 'string' ? { traceCallLabel: channel.traceCallLabel } : {}),
|
|
@@ -288,7 +294,11 @@ export default class Console {
|
|
|
288
294
|
public async createBugReport(error: TCatchedError, request?: ServerRequest) {
|
|
289
295
|
const application = this.container.application;
|
|
290
296
|
if (application === undefined)
|
|
291
|
-
return console.error(
|
|
297
|
+
return console.error(
|
|
298
|
+
LogPrefix,
|
|
299
|
+
"Can't send bug report because the application is not instanciated",
|
|
300
|
+
error,
|
|
301
|
+
);
|
|
292
302
|
|
|
293
303
|
// Get context
|
|
294
304
|
const now = new Date();
|