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
@@ -5,6 +5,7 @@ import type { TRow } from './layout';
5
5
 
6
6
  export const proteumCommandNames = [
7
7
  'init',
8
+ 'create',
8
9
  'dev',
9
10
  'refresh',
10
11
  'build',
@@ -13,6 +14,8 @@ export const proteumCommandNames = [
13
14
  'check',
14
15
  'doctor',
15
16
  'explain',
17
+ 'trace',
18
+ 'command',
16
19
  ] as const;
17
20
 
18
21
  export type TProteumCommandName = (typeof proteumCommandNames)[number];
@@ -45,21 +48,56 @@ export const proteumRecommendedFlow: TRow[] = [
45
48
  export const proteumCommandGroups: Array<{ title: string; names: TProteumCommandName[] }> = [
46
49
  { title: 'Daily workflow', names: ['dev', 'refresh', 'build'] },
47
50
  { title: 'Quality gates', names: ['typecheck', 'lint', 'check'] },
48
- { title: 'Manifest and contracts', names: ['doctor', 'explain'] },
49
- { title: 'Project scaffolding', names: ['init'] },
51
+ { title: 'Manifest and contracts', names: ['doctor', 'explain', 'trace', 'command'] },
52
+ { title: 'Project scaffolding', names: ['init', 'create'] },
50
53
  ];
51
54
 
52
55
  export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> = {
53
56
  init: {
54
57
  name: 'init',
55
58
  category: 'Project scaffolding',
56
- summary: 'Scaffold a new Proteum project.',
57
- usage: 'proteum init',
58
- bestFor: 'Bootstrap a new app when the Proteum scaffold assets are installed in the current package.',
59
- examples: [{ description: 'Create a new app interactively', command: 'proteum init' }],
59
+ summary: 'Scaffold a new Proteum app with deterministic built-in templates.',
60
+ usage: 'proteum init [directory] [--name <name>] [--identifier <identifier>] [--port <port>] [--install] [--dry-run] [--json]',
61
+ bestFor: 'Bootstrapping a new app in a way that is explicit, machine-readable, and safe for LLM coding agents.',
62
+ examples: [
63
+ { description: 'Create a new app in ./my-app', command: 'proteum init my-app --name "My App"' },
64
+ {
65
+ description: 'Scaffold an app and install dependencies immediately',
66
+ command: 'proteum init my-app --name "My App" --install',
67
+ },
68
+ {
69
+ description: 'Emit scaffold details as JSON for an agent',
70
+ command: 'proteum init my-app --name "My App" --json',
71
+ },
72
+ {
73
+ description: 'Preview the full app scaffold without writing files',
74
+ command: 'proteum init my-app --name "My App" --dry-run --json',
75
+ },
76
+ ],
60
77
  notes: [
61
- 'This command is still experimental.',
62
- 'In source checkouts it requires `cli/skeleton` to exist.',
78
+ 'When Proteum is invoked from a local framework checkout, init writes a file: dependency to that checkout by default.',
79
+ 'Use `--dry-run --json` when an agent needs a machine-readable app scaffold plan before writing files.',
80
+ 'Without `--install`, init only writes files and does not touch the network.',
81
+ ],
82
+ status: 'experimental',
83
+ },
84
+ create: {
85
+ name: 'create',
86
+ category: 'Project scaffolding',
87
+ summary: 'Generate a page, controller, command, route, or root service inside a Proteum app.',
88
+ usage: 'proteum create <page|controller|command|route|service> <target> [--route <url>] [--method <name>] [--http-method <verb>] [--dry-run] [--json]',
89
+ bestFor: 'Fast deterministic scaffolding inside an existing Proteum app without inventing file layouts or boilerplate by hand.',
90
+ examples: [
91
+ { description: 'Create a new SSR page', command: 'proteum create page marketing/faq --route /faq' },
92
+ { description: 'Create a new controller', command: 'proteum create controller Founder/projects --method list' },
93
+ { description: 'Create a new command', command: 'proteum create command diagnostics --method ping' },
94
+ { description: 'Preview a new route without writing files', command: 'proteum create route webhooks/stripe --dry-run --json' },
95
+ { description: 'Create and register a new root service', command: 'proteum create service Conversion/Plans' },
96
+ ],
97
+ notes: [
98
+ 'Page scaffolds write `client/pages/**/index.tsx` and default the route path from the logical target path unless `--route` is provided.',
99
+ 'Service scaffolds create `server/services/**/index.ts`, `service.json`, a config export under `server/config/*.ts`, and then try to register the new root service in `server/index.ts`.',
100
+ 'Use `--dry-run --json` when an agent needs a machine-readable plan before writing files.',
63
101
  ],
64
102
  status: 'experimental',
65
103
  },
@@ -170,20 +208,72 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
170
208
  name: 'explain',
171
209
  category: 'Manifest and contracts',
172
210
  summary: 'Explain the generated Proteum manifest.',
173
- usage: 'proteum explain [--all|--app|--conventions|--env|--services|--controllers|--routes|--layouts|--diagnostics] [--json]',
211
+ usage: 'proteum explain [--all|--app|--conventions|--env|--services|--controllers|--commands|--routes|--layouts|--diagnostics] [--json]',
174
212
  bestFor:
175
- 'Inspecting how source files became generated routes, controllers, layouts, services, and diagnostics without reading compiler internals.',
213
+ 'Inspecting how source files became generated routes, controllers, commands, layouts, services, and diagnostics without reading compiler internals.',
176
214
  examples: [
177
215
  { description: 'Show the default human summary', command: 'proteum explain' },
178
216
  {
179
- description: 'Inspect generated routes and controllers together',
180
- command: 'proteum explain --routes --controllers',
217
+ description: 'Inspect generated routes, controllers, and commands together',
218
+ command: 'proteum explain --routes --controllers --commands',
181
219
  },
182
220
  { description: 'Emit the selected manifest sections as JSON', command: 'proteum explain --routes --json' },
183
221
  ],
184
222
  notes: ['Legacy positional section selection remains supported, for example `proteum explain routes services`.'],
185
223
  status: 'stable',
186
224
  },
225
+ trace: {
226
+ name: 'trace',
227
+ category: 'Manifest and contracts',
228
+ summary: 'Inspect live in-memory request traces from a running Proteum dev server.',
229
+ usage: 'proteum trace [latest|show <requestId>|requests|arm|export <requestId>] [--port <port>|--url <baseUrl>] [--json]',
230
+ bestFor:
231
+ 'Debugging route resolution, context creation, SSR payloads, renders, and runtime errors without attaching a debugger.',
232
+ examples: [
233
+ { description: 'Show the latest request trace', command: 'proteum trace latest' },
234
+ { description: 'List recent trace summaries', command: 'proteum trace requests' },
235
+ { description: 'Arm the next request for deep capture', command: 'proteum trace arm --capture deep' },
236
+ { description: 'Export a request trace to disk', command: 'proteum trace export <requestId>' },
237
+ { description: 'Target a custom dev base URL directly', command: 'proteum trace latest --url http://127.0.0.1:3010' },
238
+ ],
239
+ notes: [
240
+ 'This command talks to the running app over the dev-only `__proteum/trace` HTTP endpoints.',
241
+ 'Traces are stored in a bounded in-memory buffer with payload summarization and sensitive-field redaction.',
242
+ 'Use `--port` when the app is not running on the router port declared in `PORT`, or `--url` when the host itself is non-standard.',
243
+ ],
244
+ status: 'experimental',
245
+ },
246
+ command: {
247
+ name: 'command',
248
+ category: 'Manifest and contracts',
249
+ summary: 'Run a dev-only app command from /commands or against an existing dev instance.',
250
+ usage: 'proteum command <path> [--port <port>|--url <baseUrl>] [--json]',
251
+ bestFor:
252
+ 'Internal testing, debugging, and one-off service execution that should not be exposed as a normal controller or route.',
253
+ examples: [
254
+ {
255
+ description: 'Run a local command through a temporary bundled dev server',
256
+ command: 'proteum command proteum/diagnostics/ping',
257
+ },
258
+ {
259
+ description: 'Run a command against an existing dev server',
260
+ command: 'proteum command proteum/diagnostics/ping --port 3101',
261
+ },
262
+ {
263
+ description: 'Emit the command execution as JSON',
264
+ command: 'proteum command proteum/diagnostics/ping --json',
265
+ },
266
+ ],
267
+ notes: [
268
+ 'Commands live under `./commands/**/*.ts` and default-export a class that extends `{ Commands }` from `@server/app/commands`.',
269
+ 'Methods are addressed by file path plus method name, mirroring controller path generation.',
270
+ 'Proteum creates `./commands/tsconfig.json` and `.proteum/server/commands.d.ts` so `/commands` gets a command-specific alias/type project.',
271
+ 'Prefer `extends Commands` directly inside `/commands`; importing the app class is still supported through a generated command-only `@/server/index` type alias.',
272
+ 'Without `--port` or `--url`, Proteum refreshes generated artifacts, builds the dev output, starts a temporary local dev server, runs the command, and exits.',
273
+ 'With `--port` or `--url`, Proteum talks to the running app over the dev-only `__proteum/commands` HTTP endpoints.',
274
+ ],
275
+ status: 'experimental',
276
+ },
187
277
  };
188
278
 
189
279
  export const isLikelyProteumAppRoot = (workdir: string) =>
@@ -194,8 +284,8 @@ export const isLikelyProteumAppRoot = (workdir: string) =>
194
284
 
195
285
  export const getInitAvailabilityNote = (initAvailable: boolean) =>
196
286
  initAvailable
197
- ? 'Scaffold assets are installed in this checkout.'
198
- : 'This checkout does not include `cli/skeleton`, so `proteum init` is unavailable until the scaffold assets are restored.';
287
+ ? 'Init is built into the CLI and does not depend on external scaffold assets.'
288
+ : 'Init scaffolding is currently unavailable in this checkout.';
199
289
 
200
290
  export const createClipanionUsage = (command: TProteumCommandDoc) => ({
201
291
  category: command.category,
@@ -11,6 +11,8 @@ const ProteumWordmark = [
11
11
  String.raw`|_| |_| \_\\___/ |_| |_____|\___/|_| |_|`,
12
12
  ];
13
13
 
14
+ const ProteumTagline = 'Agent-first SSR compiler and server loop.';
15
+
14
16
  export const renderDevSession = async ({
15
17
  appName,
16
18
  appRoot,
@@ -32,9 +34,9 @@ export const renderDevSession = async ({
32
34
  return createElement(
33
35
  Box,
34
36
  { borderStyle: 'round', borderColor: 'cyan', paddingX: 2, paddingY: 0, flexDirection: 'column' },
35
- createElement(Text, { bold: true, color: 'green' }, 'PROTEUM DEV'),
36
- createElement(Text, { dimColor: true }, 'Agent-first SSR compiler and server loop.'),
37
- createElement(Box, { flexDirection: 'column', marginTop: 1 }, ...wordmark),
37
+ createElement(Text, { bold: true, backgroundColor: 'cyan', color: 'black' }, ' WELCOME TO '),
38
+ createElement(Box, { flexDirection: 'column' }, ...wordmark),
39
+ createElement(Text, { dimColor: true }, ProteumTagline),
38
40
  );
39
41
  }),
40
42
  renderRows(
@@ -43,6 +45,8 @@ export const renderDevSession = async ({
43
45
  { label: 'root', value: appRoot },
44
46
  { label: 'router', value: `http://localhost:${routerPort}` },
45
47
  { label: 'hmr', value: `http://localhost:${devEventPort}/__proteum_hmr` },
48
+ { label: 'trace', value: `proteum trace latest --port ${routerPort}` },
49
+ { label: 'trace deep', value: `proteum trace arm --capture deep --port ${routerPort}` },
46
50
  { label: 'hotkeys', value: 'Ctrl+R reload, Ctrl+C stop' },
47
51
  ],
48
52
  { minLabelWidth: 12, maxLabelWidth: 12 },
@@ -52,9 +56,11 @@ export const renderDevSession = async ({
52
56
  export const renderServerReadyBanner = async ({
53
57
  appName,
54
58
  publicUrl,
59
+ routerPort,
55
60
  }: {
56
61
  appName: string;
57
62
  publicUrl: string;
63
+ routerPort: number;
58
64
  }) =>
59
65
  renderInk(({ Box, Text }) => {
60
66
  const createElement = React.createElement;
@@ -66,5 +72,18 @@ export const renderServerReadyBanner = async ({
66
72
  createElement(Text, { bold: true, color: 'green' }, appName),
67
73
  createElement(Text, { bold: true }, publicUrl),
68
74
  createElement(Text, { dimColor: true }, 'SSR server is listening for requests and hot reloads.'),
75
+ createElement(Text, { dimColor: true }, `Trace latest: proteum trace latest --port ${routerPort}`),
76
+ );
77
+ });
78
+
79
+ export const renderDevShutdownBanner = async () =>
80
+ renderInk(({ Box, Text }) => {
81
+ const createElement = React.createElement;
82
+
83
+ return createElement(
84
+ Box,
85
+ { borderStyle: 'round', borderColor: 'yellow', paddingX: 2, paddingY: 0, flexDirection: 'column' },
86
+ createElement(Text, { bold: true, backgroundColor: 'yellow', color: 'black' }, ' SHUTTING DOWN '),
87
+ createElement(Text, { bold: true, color: 'yellow' }, 'Thank you for developping with Proteum'),
69
88
  );
70
89
  });