proteum 2.2.8 → 2.3.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/AGENTS.md +5 -3
- package/README.md +50 -12
- package/agents/project/AGENTS.md +47 -10
- package/agents/project/CODING_STYLE.md +5 -1
- package/agents/project/client/AGENTS.md +2 -0
- package/agents/project/diagnostics.md +8 -5
- package/agents/project/optimizations.md +1 -0
- package/agents/project/root/AGENTS.md +18 -10
- package/agents/project/tests/AGENTS.md +6 -1
- package/agents/project/tests/e2e/AGENTS.md +13 -0
- package/agents/project/tests/e2e/REAL_WORLD_JOURNEY_TESTS.md +192 -0
- package/cli/commands/check.ts +21 -3
- package/cli/commands/configure.ts +1 -0
- package/cli/commands/connect.ts +40 -4
- package/cli/commands/diagnose.ts +136 -5
- package/cli/commands/doctor.ts +24 -4
- package/cli/commands/explain.ts +105 -6
- package/cli/commands/mcp.ts +16 -0
- package/cli/commands/orient.ts +66 -3
- package/cli/commands/perf.ts +118 -13
- package/cli/commands/runtime.ts +151 -0
- package/cli/commands/trace.ts +116 -21
- package/cli/mcp/provider.ts +365 -0
- package/cli/mcp/stdio.ts +16 -0
- package/cli/presentation/commands.ts +79 -22
- package/cli/presentation/devSession.ts +2 -0
- package/cli/runtime/commands.ts +95 -12
- package/cli/utils/agentOutput.ts +46 -0
- package/cli/utils/agents.ts +225 -48
- package/common/dev/inspection.ts +30 -9
- package/common/dev/mcpPayloads.ts +736 -0
- package/common/dev/mcpServer.ts +254 -0
- package/docs/agent-routing.md +126 -0
- package/docs/dev-commands.md +2 -0
- package/docs/dev-sessions.md +2 -1
- package/docs/diagnostics.md +68 -23
- package/docs/mcp.md +149 -0
- package/docs/migrate-from-2.1.3.md +15 -5
- package/docs/request-tracing.md +12 -6
- package/eslint.js +220 -0
- package/package.json +2 -1
- package/server/app/devMcp.ts +159 -0
- package/server/services/router/http/cache.ts +116 -0
- package/server/services/router/http/index.ts +94 -35
- package/server/services/router/index.ts +8 -11
- package/tests/agents-utils.test.cjs +89 -11
- package/tests/dev-transpile-watch.test.cjs +117 -8
- package/tests/eslint-rules.test.cjs +110 -0
- package/tests/inspection.test.cjs +67 -0
- package/tests/mcp.test.cjs +127 -0
- package/tests/router-cache-config.test.cjs +74 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CallToolResult, ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
|
+
|
|
5
|
+
import { stringifyMcpPayload, type TProteumMcpPayload } from './mcpPayloads';
|
|
6
|
+
|
|
7
|
+
export type TProteumMcpDetail = 'compact' | 'full';
|
|
8
|
+
|
|
9
|
+
export type TProteumMcpProvider = {
|
|
10
|
+
diagnose: (input: {
|
|
11
|
+
logsLevel?: 'silly' | 'log' | 'info' | 'warn' | 'error';
|
|
12
|
+
logsLimit?: number;
|
|
13
|
+
path?: string;
|
|
14
|
+
query?: string;
|
|
15
|
+
requestId?: string;
|
|
16
|
+
}) => Promise<TProteumMcpPayload>;
|
|
17
|
+
doctor: (input: { contracts?: boolean }) => Promise<TProteumMcpPayload>;
|
|
18
|
+
explainSummary: (input: { query?: string }) => Promise<TProteumMcpPayload>;
|
|
19
|
+
instructionsResolve: (input: { query?: string }) => Promise<TProteumMcpPayload>;
|
|
20
|
+
logsTail: (input: { level?: 'silly' | 'log' | 'info' | 'warn' | 'error'; limit?: number }) => Promise<TProteumMcpPayload>;
|
|
21
|
+
orient: (input: { query: string }) => Promise<TProteumMcpPayload>;
|
|
22
|
+
perfRequest: (input: { query: string }) => Promise<TProteumMcpPayload>;
|
|
23
|
+
perfTop: (input: { groupBy?: 'path' | 'route' | 'controller'; limit?: number; since?: string }) => Promise<TProteumMcpPayload>;
|
|
24
|
+
readResource: (uri: string) => Promise<TProteumMcpPayload>;
|
|
25
|
+
runtimeStatus: (input: Record<string, never>) => Promise<TProteumMcpPayload>;
|
|
26
|
+
traceLatest: (input: { detail?: TProteumMcpDetail; limit?: number; offset?: number }) => Promise<TProteumMcpPayload>;
|
|
27
|
+
traceShow: (input: { detail?: TProteumMcpDetail; limit?: number; offset?: number; requestId: string }) => Promise<TProteumMcpPayload>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type TCreateProteumMcpServerArgs = {
|
|
31
|
+
provider: TProteumMcpProvider;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const jsonToolResult = (payload: object): CallToolResult => ({
|
|
36
|
+
content: [
|
|
37
|
+
{
|
|
38
|
+
type: 'text',
|
|
39
|
+
text: stringifyMcpPayload(payload),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const jsonResourceResult = (uri: string, payload: object): ReadResourceResult => ({
|
|
45
|
+
contents: [
|
|
46
|
+
{
|
|
47
|
+
mimeType: 'application/json',
|
|
48
|
+
text: stringifyMcpPayload(payload),
|
|
49
|
+
uri,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const readOnlyAnnotations = {
|
|
55
|
+
destructiveHint: false,
|
|
56
|
+
idempotentHint: true,
|
|
57
|
+
openWorldHint: false,
|
|
58
|
+
readOnlyHint: true,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const detailSchema = z.enum(['compact', 'full']).optional();
|
|
62
|
+
const logsLevelSchema = z.enum(['silly', 'log', 'info', 'warn', 'error']).optional();
|
|
63
|
+
const positiveLimitSchema = z.number().int().min(1).max(100).optional();
|
|
64
|
+
const offsetSchema = z.number().int().min(0).max(10_000).optional();
|
|
65
|
+
|
|
66
|
+
export const createProteumMcpServer = ({ provider, version }: TCreateProteumMcpServerArgs) => {
|
|
67
|
+
const server = new McpServer(
|
|
68
|
+
{
|
|
69
|
+
name: 'proteum',
|
|
70
|
+
version,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
capabilities: {
|
|
74
|
+
logging: {},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
server.registerTool(
|
|
80
|
+
'runtime_status',
|
|
81
|
+
{
|
|
82
|
+
annotations: readOnlyAnnotations,
|
|
83
|
+
description: 'Return the compact Proteum app manifest, selected dev runtime, tracked sessions, and health.',
|
|
84
|
+
inputSchema: {},
|
|
85
|
+
title: 'Proteum Runtime Status',
|
|
86
|
+
},
|
|
87
|
+
async () => jsonToolResult(await provider.runtimeStatus({})),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
server.registerTool(
|
|
91
|
+
'orient',
|
|
92
|
+
{
|
|
93
|
+
annotations: readOnlyAnnotations,
|
|
94
|
+
description: 'Resolve owners, instruction files, connected boundaries, and next diagnostic actions for a query.',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
query: z.string().min(1).describe('Route, controller, file path, connected namespace, or task query.'),
|
|
97
|
+
},
|
|
98
|
+
title: 'Proteum Orient',
|
|
99
|
+
},
|
|
100
|
+
async ({ query }) => jsonToolResult(await provider.orient({ query })),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
server.registerTool(
|
|
104
|
+
'instructions_resolve',
|
|
105
|
+
{
|
|
106
|
+
annotations: readOnlyAnnotations,
|
|
107
|
+
description: 'Return the routed Proteum instruction files an agent should read for the current query.',
|
|
108
|
+
inputSchema: {
|
|
109
|
+
query: z.string().optional().describe('Optional task, route, file path, or area query.'),
|
|
110
|
+
},
|
|
111
|
+
title: 'Proteum Instruction Routing',
|
|
112
|
+
},
|
|
113
|
+
async ({ query }) => jsonToolResult(await provider.instructionsResolve({ query })),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
server.registerTool(
|
|
117
|
+
'explain_summary',
|
|
118
|
+
{
|
|
119
|
+
annotations: readOnlyAnnotations,
|
|
120
|
+
description: 'Return a compact manifest summary or owner ranking without dumping the full generated manifest.',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
query: z.string().optional().describe('Optional owner query. Omit for the manifest summary.'),
|
|
123
|
+
},
|
|
124
|
+
title: 'Proteum Explain Summary',
|
|
125
|
+
},
|
|
126
|
+
async ({ query }) => jsonToolResult(await provider.explainSummary({ query })),
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
server.registerTool(
|
|
130
|
+
'doctor',
|
|
131
|
+
{
|
|
132
|
+
annotations: readOnlyAnnotations,
|
|
133
|
+
description: 'Return compact manifest diagnostics, optionally including generated-contract diagnostics.',
|
|
134
|
+
inputSchema: {
|
|
135
|
+
contracts: z.boolean().optional().describe('Include generated contract diagnostics.'),
|
|
136
|
+
},
|
|
137
|
+
title: 'Proteum Doctor',
|
|
138
|
+
},
|
|
139
|
+
async ({ contracts }) => jsonToolResult(await provider.doctor({ contracts })),
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
server.registerTool(
|
|
143
|
+
'diagnose',
|
|
144
|
+
{
|
|
145
|
+
annotations: readOnlyAnnotations,
|
|
146
|
+
description: 'Read the dev runtime composite diagnosis for an existing trace, route, request id, or query.',
|
|
147
|
+
inputSchema: {
|
|
148
|
+
logsLevel: logsLevelSchema,
|
|
149
|
+
logsLimit: z.number().int().min(0).max(100).optional(),
|
|
150
|
+
path: z.string().optional(),
|
|
151
|
+
query: z.string().optional(),
|
|
152
|
+
requestId: z.string().optional(),
|
|
153
|
+
},
|
|
154
|
+
title: 'Proteum Diagnose',
|
|
155
|
+
},
|
|
156
|
+
async ({ logsLevel, logsLimit, path, query, requestId }) =>
|
|
157
|
+
jsonToolResult(await provider.diagnose({ logsLevel, logsLimit, path, query, requestId })),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
server.registerTool(
|
|
161
|
+
'trace_latest',
|
|
162
|
+
{
|
|
163
|
+
annotations: readOnlyAnnotations,
|
|
164
|
+
description: 'Return a compact summary of the latest request trace, with optional paginated full detail.',
|
|
165
|
+
inputSchema: {
|
|
166
|
+
detail: detailSchema,
|
|
167
|
+
limit: positiveLimitSchema,
|
|
168
|
+
offset: offsetSchema,
|
|
169
|
+
},
|
|
170
|
+
title: 'Proteum Latest Trace',
|
|
171
|
+
},
|
|
172
|
+
async ({ detail, limit, offset }) => jsonToolResult(await provider.traceLatest({ detail, limit, offset })),
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
server.registerTool(
|
|
176
|
+
'trace_show',
|
|
177
|
+
{
|
|
178
|
+
annotations: readOnlyAnnotations,
|
|
179
|
+
description: 'Return a compact or paginated full summary of a specific request trace.',
|
|
180
|
+
inputSchema: {
|
|
181
|
+
detail: detailSchema,
|
|
182
|
+
limit: positiveLimitSchema,
|
|
183
|
+
offset: offsetSchema,
|
|
184
|
+
requestId: z.string().min(1),
|
|
185
|
+
},
|
|
186
|
+
title: 'Proteum Trace Show',
|
|
187
|
+
},
|
|
188
|
+
async ({ detail, limit, offset, requestId }) =>
|
|
189
|
+
jsonToolResult(await provider.traceShow({ detail, limit, offset, requestId })),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
server.registerTool(
|
|
193
|
+
'perf_top',
|
|
194
|
+
{
|
|
195
|
+
annotations: readOnlyAnnotations,
|
|
196
|
+
description: 'Return compact trace-derived performance rollups for hot routes, paths, or controllers.',
|
|
197
|
+
inputSchema: {
|
|
198
|
+
groupBy: z.enum(['path', 'route', 'controller']).optional(),
|
|
199
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
200
|
+
since: z.string().optional(),
|
|
201
|
+
},
|
|
202
|
+
title: 'Proteum Perf Top',
|
|
203
|
+
},
|
|
204
|
+
async ({ groupBy, limit, since }) => jsonToolResult(await provider.perfTop({ groupBy, limit, since })),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
server.registerTool(
|
|
208
|
+
'perf_request',
|
|
209
|
+
{
|
|
210
|
+
annotations: readOnlyAnnotations,
|
|
211
|
+
description: 'Return a compact waterfall and attribution summary for one traced request id or path.',
|
|
212
|
+
inputSchema: {
|
|
213
|
+
query: z.string().min(1).describe('Request id or path.'),
|
|
214
|
+
},
|
|
215
|
+
title: 'Proteum Perf Request',
|
|
216
|
+
},
|
|
217
|
+
async ({ query }) => jsonToolResult(await provider.perfRequest({ query })),
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
server.registerTool(
|
|
221
|
+
'logs_tail',
|
|
222
|
+
{
|
|
223
|
+
annotations: readOnlyAnnotations,
|
|
224
|
+
description: 'Return capped recent Proteum dev server logs.',
|
|
225
|
+
inputSchema: {
|
|
226
|
+
level: logsLevelSchema,
|
|
227
|
+
limit: z.number().int().min(0).max(100).optional(),
|
|
228
|
+
},
|
|
229
|
+
title: 'Proteum Logs Tail',
|
|
230
|
+
},
|
|
231
|
+
async ({ level, limit }) => jsonToolResult(await provider.logsTail({ level, limit })),
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
for (const [name, uri, description] of [
|
|
235
|
+
['runtime-status', 'proteum://runtime/status', 'Current compact runtime status.'],
|
|
236
|
+
['instructions-router', 'proteum://instructions/router', 'Current instruction routing contract.'],
|
|
237
|
+
['manifest-summary', 'proteum://manifest/summary', 'Compact generated manifest summary.'],
|
|
238
|
+
['trace-latest-summary', 'proteum://trace/latest/summary', 'Latest request trace summary.'],
|
|
239
|
+
['perf-top', 'proteum://perf/top', 'Current compact perf top rollup.'],
|
|
240
|
+
] as const) {
|
|
241
|
+
server.registerResource(
|
|
242
|
+
name,
|
|
243
|
+
uri,
|
|
244
|
+
{
|
|
245
|
+
description,
|
|
246
|
+
mimeType: 'application/json',
|
|
247
|
+
title: description,
|
|
248
|
+
},
|
|
249
|
+
async (resourceUri) => jsonResourceResult(resourceUri.href, await provider.readResource(uri)),
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return server;
|
|
254
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Agent Routing And Token Efficiency
|
|
2
|
+
|
|
3
|
+
Proteum routing and diagnostics CLI commands are agent-facing by default. The interactive `proteum dev` and user-facing `proteum build` surfaces keep their human presentation.
|
|
4
|
+
|
|
5
|
+
The optimized stack is:
|
|
6
|
+
|
|
7
|
+
- routed agent instructions for stable policy
|
|
8
|
+
- compact CLI for reproducible command-line checks
|
|
9
|
+
- MCP for repeated reads of the same project/runtime state
|
|
10
|
+
|
|
11
|
+
The routing strategy is:
|
|
12
|
+
|
|
13
|
+
1. Use instructions for hard safety rules and routing only.
|
|
14
|
+
2. Use MCP when available for repeated reads, runtime status, instruction routing, traces, perf, and logs.
|
|
15
|
+
3. Use `proteum orient <query>` or the MCP `orient` tool to resolve the task-specific owner, `mustRead` instruction files, and next command.
|
|
16
|
+
4. Use compact CLI output for reproducible terminal validation and CI-like checks.
|
|
17
|
+
5. Use `--full`, `--manifest`, `--events`, or MCP paginated `detail: "full"` only after compact output identifies the missing detail.
|
|
18
|
+
|
|
19
|
+
## Problem Resolved
|
|
20
|
+
|
|
21
|
+
Past agent workflows spent too much context on repeated instruction payloads, full manifest dumps, raw trace JSON, and broad source searches.
|
|
22
|
+
|
|
23
|
+
The measured Product diagnostic loop produced roughly tens of thousands of output tokens because agents combined:
|
|
24
|
+
|
|
25
|
+
- `dev list`
|
|
26
|
+
- `orient`
|
|
27
|
+
- full `diagnose`
|
|
28
|
+
- raw `trace latest`
|
|
29
|
+
- `perf request`
|
|
30
|
+
- `verify request`
|
|
31
|
+
- sometimes full `explain --json`
|
|
32
|
+
|
|
33
|
+
Managed project instructions also embedded the same Proteum corpus into multiple generated files, so reading a handful of local docs could repeat the same contract many times.
|
|
34
|
+
|
|
35
|
+
## CLI Contract
|
|
36
|
+
|
|
37
|
+
Default CLI output for agent commands is compact `proteum-agent-v1` JSON:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"ok": true,
|
|
42
|
+
"format": "proteum-agent-v1",
|
|
43
|
+
"summary": "...",
|
|
44
|
+
"data": {},
|
|
45
|
+
"nextActions": [],
|
|
46
|
+
"omitted": [],
|
|
47
|
+
"fullDetailCommand": "..."
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Use the compact commands first:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
proteum orient <route|file|controller|error>
|
|
55
|
+
proteum runtime status
|
|
56
|
+
proteum diagnose <target>
|
|
57
|
+
proteum perf request <requestId|path>
|
|
58
|
+
proteum trace latest
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use MCP for repeated reads when a client is available:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
proteum mcp
|
|
65
|
+
proteum mcp --url http://localhost:3101
|
|
66
|
+
proteum mcp --session-file var/run/proteum/dev/agents/task.json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
During `proteum dev`, the same read-only tool contract is available at:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
http://localhost:<port>/__proteum/mcp
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Prefer the dev-hosted MCP endpoint when the app is already running; prefer stdio `proteum mcp` when the agent environment launches MCP servers itself. Prefer CLI over MCP when the result must be reproducible as a shell command, part of verification, or copied into CI/debug instructions.
|
|
76
|
+
|
|
77
|
+
MCP output is compact `proteum-mcp-v1` JSON. It is intentionally single-line JSON, capped, and paginated for full trace detail. Do not expand MCP output just to make it look nicer for humans.
|
|
78
|
+
|
|
79
|
+
Use full-detail escape hatches only when needed:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
proteum explain --manifest
|
|
83
|
+
proteum orient <query> --full
|
|
84
|
+
proteum diagnose <target> --full
|
|
85
|
+
proteum trace show <requestId> --events
|
|
86
|
+
proteum perf request <requestId> --full
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Instruction Contract
|
|
90
|
+
|
|
91
|
+
Managed `AGENTS.md` files now carry a compact router instead of the full instruction corpus.
|
|
92
|
+
|
|
93
|
+
Area files carry only their own source content:
|
|
94
|
+
|
|
95
|
+
- `diagnostics.md`: raw errors, failing routes, traces, perf, reproduction
|
|
96
|
+
- `optimizations.md`: package, runtime, build, and optimization decisions
|
|
97
|
+
- `CODING_STYLE.md`: implementation style before editing
|
|
98
|
+
- `client/AGENTS.md`: client code
|
|
99
|
+
- `client/pages/AGENTS.md`: page route/data/render rules
|
|
100
|
+
- `server/services/AGENTS.md`: services
|
|
101
|
+
- `server/routes/AGENTS.md`: manual routes
|
|
102
|
+
- `tests/e2e/AGENTS.md`: E2E workflow
|
|
103
|
+
- `tests/e2e/REAL_WORLD_JOURNEY_TESTS.md`: journey-test design
|
|
104
|
+
|
|
105
|
+
Agents should not read broad folders or every managed instruction file. They should read only `mustRead` from `orient`, plus conditional docs that match the current task.
|
|
106
|
+
|
|
107
|
+
The MCP `instructions_resolve` resource/tool exposes the same routing decision in compact JSON and is the lowest-token way to refresh instruction selection without rereading full docs.
|
|
108
|
+
|
|
109
|
+
## Benchmark Result
|
|
110
|
+
|
|
111
|
+
The latest Product `/domains` benchmark used routed instructions plus the compact CLI/MCP stack. Token estimates are `ceil(UTF-8 bytes / 4)` and measure output size only.
|
|
112
|
+
|
|
113
|
+
| Workflow | Approx output tokens | Elapsed |
|
|
114
|
+
| --- | ---: | ---: |
|
|
115
|
+
| Compact CLI single loop | 6,286 | 4,809 ms |
|
|
116
|
+
| Dev-hosted HTTP MCP single loop | 5,211 | 232 ms |
|
|
117
|
+
| Stdio MCP single loop | 5,526 | 900 ms |
|
|
118
|
+
| Compact CLI repeated reads x3 | 11,660 | 9,572 ms |
|
|
119
|
+
| Dev-hosted HTTP MCP repeated reads x3 | 10,537 | 214 ms |
|
|
120
|
+
|
|
121
|
+
The result confirms the intended routing:
|
|
122
|
+
|
|
123
|
+
- use CLI for reproducible verification and final command evidence
|
|
124
|
+
- use dev-hosted MCP for repeated runtime reads against an already running app
|
|
125
|
+
- use stdio MCP when the agent needs a launchable MCP server from an app/worktree
|
|
126
|
+
- use `instructions_resolve` to refresh routing instead of rereading instruction files
|
package/docs/dev-commands.md
CHANGED
|
@@ -79,6 +79,8 @@ The profiler also exposes the shared diagnostics surfaces for humans:
|
|
|
79
79
|
|
|
80
80
|
For the shared diagnostics contract, trace-derived perf contract, and the corresponding dev HTTP endpoints, see [diagnostics.md](diagnostics.md) and [request-tracing.md](request-tracing.md).
|
|
81
81
|
|
|
82
|
+
Command execution stays in the CLI, profiler, and dev command HTTP endpoints. The Proteum MCP surfaces are read-only; use MCP for repeated diagnostics, trace, perf, status, and log reads, not for running commands.
|
|
83
|
+
|
|
82
84
|
### HTTP Endpoints
|
|
83
85
|
|
|
84
86
|
The CLI remote mode and the profiler use the same dev-only endpoints:
|
package/docs/dev-sessions.md
CHANGED
|
@@ -78,13 +78,14 @@ curl -H "$(jq -r '.curlCookieHeader' session.json)" http://localhost:3101/api/Au
|
|
|
78
78
|
- Prefer `proteum session` over UI login automation when the goal is to test or debug protected application behavior.
|
|
79
79
|
- Prefer `proteum verify browser` for focused browser-visible verification, and `proteum e2e --port <port>` for targeted or full Playwright suites. When lower-level control is required, use direct Playwright with a disposable profile.
|
|
80
80
|
- Use UI login automation only when the auth UX itself is the feature under test.
|
|
81
|
-
- Pair it with `proteum diagnose` for a fast protected-route summary, `proteum perf request` for a one-request timing breakdown,
|
|
81
|
+
- Pair it with `proteum diagnose` for a fast protected-route summary, `proteum perf request` for a one-request timing breakdown, or MCP `diagnose`/`perf_request` for repeated reads against the same running app. Use `proteum trace show <requestId> --events` only when you need lower-level request events.
|
|
82
82
|
- Only the final verifier agent should usually run browser flows. Earlier agents should stay on `orient`, `verify owner`, `verify request`, and request-level diagnostics unless browser execution is required.
|
|
83
83
|
|
|
84
84
|
Typical flow:
|
|
85
85
|
|
|
86
86
|
```bash
|
|
87
87
|
proteum orient /dashboard
|
|
88
|
+
proteum runtime status
|
|
88
89
|
proteum session admin@example.com --role ADMIN --port 3101 --json > session.json
|
|
89
90
|
proteum e2e --port 3101 --session-email admin@example.com --session-role ADMIN tests/e2e/features/dashboard.spec.ts
|
|
90
91
|
proteum diagnose /dashboard --hit /dashboard --port 3101
|
package/docs/diagnostics.md
CHANGED
|
@@ -11,11 +11,15 @@ These are not separate models for different tools. `orient`, `explain`, and `doc
|
|
|
11
11
|
|
|
12
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`.
|
|
13
13
|
|
|
14
|
+
The diagnostics and routing CLI surfaces are optimized for agents by default. They return compact decision-ready output first and expose large raw detail only through explicit flags such as `--full`, `--manifest`, or `--events`.
|
|
15
|
+
|
|
16
|
+
For repeated agent reads, Proteum also exposes the same compact diagnostic contract through MCP. Use `proteum mcp` for stdio clients and `/__proteum/mcp` from a running `proteum dev` server for runtime-adjacent data. See [mcp.md](mcp.md).
|
|
17
|
+
|
|
14
18
|
## Shared Contract
|
|
15
19
|
|
|
16
20
|
The canonical snapshot lives in `./.proteum/manifest.json`.
|
|
17
21
|
|
|
18
|
-
Proteum uses that same manifest in
|
|
22
|
+
Proteum uses that same manifest in these places:
|
|
19
23
|
|
|
20
24
|
- `proteum orient` for owner lookup, guidance resolution, connected-boundary summary, and next-step suggestions
|
|
21
25
|
- `proteum explain` for human-readable and `--json` output
|
|
@@ -23,9 +27,10 @@ Proteum uses that same manifest in seven places:
|
|
|
23
27
|
- `proteum explain owner <query>` for ownership lookup over the manifest index
|
|
24
28
|
- `proteum doctor --contracts` for generated-artifact and manifest-owned source validation on disk
|
|
25
29
|
- the dev-only `__proteum/explain*` and `__proteum/doctor*` HTTP endpoints
|
|
30
|
+
- the dev-only `/__proteum/mcp` endpoint and `proteum mcp` stdio server
|
|
26
31
|
- the `Explain`, `Doctor`, and `Diagnose` tabs in the bottom profiler during `proteum dev`
|
|
27
32
|
|
|
28
|
-
This means the CLI, the dev HTTP endpoints, and the profiler all describe the same framework-owned snapshot before any live trace or log overlays are added.
|
|
33
|
+
This means the CLI, MCP, the dev HTTP endpoints, and the profiler all describe the same framework-owned snapshot before any live trace or log overlays are added.
|
|
29
34
|
|
|
30
35
|
If a command such as `proteum explain`, `proteum doctor`, `proteum diagnose`, or `proteum refresh` regenerates `.proteum/manifest.json`, the next CLI call, HTTP call, or profiler refresh will reflect that same updated snapshot.
|
|
31
36
|
|
|
@@ -39,11 +44,11 @@ proteum orient /api/Auth/CurrentUser
|
|
|
39
44
|
proteum explain
|
|
40
45
|
proteum explain owner /api/Auth/CurrentUser
|
|
41
46
|
proteum explain --routes --controllers --commands
|
|
42
|
-
proteum explain --
|
|
47
|
+
proteum explain --manifest
|
|
43
48
|
|
|
44
49
|
proteum doctor
|
|
45
50
|
proteum doctor --contracts
|
|
46
|
-
proteum doctor --
|
|
51
|
+
proteum doctor --full
|
|
47
52
|
proteum doctor --strict
|
|
48
53
|
|
|
49
54
|
proteum diagnose /
|
|
@@ -59,45 +64,79 @@ proteum perf top --since today
|
|
|
59
64
|
proteum perf request /dashboard --port 3101
|
|
60
65
|
proteum perf compare --baseline yesterday --target today --group-by route
|
|
61
66
|
proteum perf memory --since 1h --group-by controller
|
|
67
|
+
|
|
68
|
+
proteum runtime status
|
|
69
|
+
proteum mcp
|
|
70
|
+
proteum mcp --url http://localhost:3101
|
|
71
|
+
proteum mcp --session-file var/run/proteum/dev/agents/task.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Default compact command output follows this shape:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"ok": true,
|
|
79
|
+
"format": "proteum-agent-v1",
|
|
80
|
+
"summary": "...",
|
|
81
|
+
"data": {},
|
|
82
|
+
"nextActions": [],
|
|
83
|
+
"omitted": [],
|
|
84
|
+
"fullDetailCommand": "..."
|
|
85
|
+
}
|
|
62
86
|
```
|
|
63
87
|
|
|
64
|
-
`proteum orient
|
|
88
|
+
`proteum orient` emits compact agent JSON with:
|
|
65
89
|
|
|
66
90
|
- `query`
|
|
67
|
-
- `normalizedQuery`
|
|
68
91
|
- `app`
|
|
69
|
-
- `guidance`
|
|
70
92
|
- `owner`
|
|
93
|
+
- `instructions.mustRead`
|
|
94
|
+
- `instructions.readWhen`
|
|
71
95
|
- `connected`
|
|
72
|
-
- `
|
|
96
|
+
- `nextActions`
|
|
73
97
|
- `warnings`
|
|
74
98
|
|
|
75
|
-
`proteum
|
|
99
|
+
`proteum orient --full` emits the full orientation payload.
|
|
100
|
+
|
|
101
|
+
`proteum explain` emits a compact manifest summary. `proteum explain --manifest` emits the full generated manifest, and explicit section flags such as `--routes --controllers` emit those sections.
|
|
76
102
|
|
|
77
|
-
`proteum explain owner <query> --
|
|
103
|
+
`proteum explain owner <query>` emits compact owner ranking. `proteum explain owner <query> --full` keeps the existing full owner ranking shape and adds:
|
|
78
104
|
|
|
79
105
|
- `scopeLabel`
|
|
80
106
|
- `originHint`
|
|
81
107
|
|
|
82
|
-
`proteum doctor --
|
|
108
|
+
`proteum doctor` emits compact diagnostics. `proteum doctor --full` emits:
|
|
83
109
|
|
|
84
110
|
- `summary.errors`
|
|
85
111
|
- `summary.warnings`
|
|
86
112
|
- `summary.strictFailed`
|
|
87
113
|
- `diagnostics`
|
|
88
114
|
|
|
89
|
-
`proteum
|
|
115
|
+
`proteum runtime status` emits the current app manifest summary, tracked dev sessions, selected live session, health status, and a suggested next command. Use it before starting another dev server.
|
|
116
|
+
|
|
117
|
+
`proteum mcp` starts the read-only stdio MCP server. It exposes compact `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `doctor`, `diagnose`, `trace_*`, `perf_*`, and `logs_tail` tools without spawning CLI commands for each read.
|
|
118
|
+
|
|
119
|
+
MCP tool/resource output follows compact single-line `proteum-mcp-v1` JSON:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{"ok":true,"format":"proteum-mcp-v1","summary":"...","data":{},"nextActions":[],"omitted":[]}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Use MCP for repeated reads of the same app/runtime state. Keep CLI commands for reproducible validation, final evidence, and CI-like command output.
|
|
126
|
+
|
|
127
|
+
`proteum diagnose` emits a compact composite response with:
|
|
90
128
|
|
|
91
129
|
- `owner`
|
|
92
|
-
- `
|
|
130
|
+
- `instructions`
|
|
93
131
|
- `chain`
|
|
94
132
|
- `doctor`
|
|
95
133
|
- `contracts`
|
|
96
134
|
- `request`
|
|
97
|
-
- `attribution`
|
|
98
135
|
- `suspects`
|
|
99
136
|
- `serverLogs`
|
|
100
137
|
|
|
138
|
+
`proteum diagnose --full` emits the full lower-level composite response, including raw request trace payloads.
|
|
139
|
+
|
|
101
140
|
`proteum verify owner|request|browser --json` emits:
|
|
102
141
|
|
|
103
142
|
- `action`
|
|
@@ -115,6 +154,8 @@ proteum perf memory --since 1h --group-by controller
|
|
|
115
154
|
- `compare`: grouped baseline vs target deltas
|
|
116
155
|
- `memory`: grouped heap and RSS drift summaries
|
|
117
156
|
|
|
157
|
+
`proteum trace latest` and `proteum trace show <requestId>` emit compact trace summaries by default. Use `--events` or `--full` to print the raw event stream, payload summaries, and SQL text.
|
|
158
|
+
|
|
118
159
|
Focused verification defaults to the smallest trustworthy surface first:
|
|
119
160
|
|
|
120
161
|
- `verify owner`: orient the target, then choose request, command, or local owner-scoped diagnostics
|
|
@@ -137,6 +178,7 @@ In `profile: dev`, the running app exposes:
|
|
|
137
178
|
- `GET /__proteum/perf/compare`
|
|
138
179
|
- `GET /__proteum/perf/memory`
|
|
139
180
|
- `GET /__proteum/perf/request`
|
|
181
|
+
- `POST|GET|DELETE /__proteum/mcp`
|
|
140
182
|
|
|
141
183
|
`/__proteum/explain` supports optional section selection:
|
|
142
184
|
|
|
@@ -169,6 +211,8 @@ GET /__proteum/diagnose?query=/api/Auth/CurrentUser&logsLevel=warn&logsLimit=40
|
|
|
169
211
|
|
|
170
212
|
These endpoints are intended for local tooling and are not available in production.
|
|
171
213
|
|
|
214
|
+
`/__proteum/mcp` is the dev-hosted MCP transport. It exposes the same read-only tool/resource contract as `proteum mcp`, backed directly by the running app's diagnostics, trace, perf, and log stores. The `proteum dev` session UI and ready banner print this URL when the server is ready.
|
|
215
|
+
|
|
172
216
|
## Profiler
|
|
173
217
|
|
|
174
218
|
During `proteum dev`, the bottom profiler is the human-facing UI over the same dev diagnostics surfaces.
|
|
@@ -207,12 +251,13 @@ Treat these as framework contract failures first. The fix usually belongs at the
|
|
|
207
251
|
|
|
208
252
|
For AI coding agents or automation:
|
|
209
253
|
|
|
210
|
-
1. Start with `proteum orient <query>` when the target might be generated, connected, framework-owned, or
|
|
211
|
-
2. Read
|
|
212
|
-
3. Run `proteum
|
|
213
|
-
4. Use `proteum
|
|
214
|
-
5. Use `proteum
|
|
215
|
-
6.
|
|
216
|
-
7. Use `proteum
|
|
217
|
-
8.
|
|
218
|
-
9.
|
|
254
|
+
1. Start with `proteum orient <query>` or MCP `orient` when the target might be generated, connected, framework-owned, multi-repo, or instruction-ambiguous.
|
|
255
|
+
2. Read only `instructions.mustRead` from compact orientation output, or use MCP `instructions_resolve` to refresh the routed instruction set without rereading docs.
|
|
256
|
+
3. Run `proteum runtime status` before starting another dev server; use MCP `runtime_status` for repeated status reads.
|
|
257
|
+
4. Use `proteum diagnose <path> --port <port>` or MCP `diagnose` for the smallest trustworthy runtime surface before broad checks.
|
|
258
|
+
5. Use `proteum perf request <requestId|path>` or MCP `perf_request` for performance, CPU, SQL, render, cache, or connected-boundary questions.
|
|
259
|
+
6. Use `proteum trace show <requestId> --events` only when compact diagnose, perf, trace, or MCP output says lower-level event detail is needed.
|
|
260
|
+
7. Use `proteum explain --manifest` or read `./.proteum/manifest.json` only when compact `orient`/`explain`/MCP summary cannot answer the specific manifest question.
|
|
261
|
+
8. Use `proteum verify browser` for browser-visible verification, or `proteum e2e --port <port>` for targeted/full Playwright suites. Keep auth sourced from Proteum session helpers.
|
|
262
|
+
9. Run global checks second, not first. Unrelated diagnostics should remain visible but non-blocking during focused verification unless strict global mode is required.
|
|
263
|
+
10. Open the profiler only when a human-readable view helps; it should agree with the CLI and MCP after refresh.
|