proteum 2.1.7 → 2.1.9

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/cli/paths.ts CHANGED
@@ -35,6 +35,29 @@ export type TPathInfos = {
35
35
  isIndex: boolean;
36
36
  };
37
37
 
38
+ export type TResolvedPackageBinary = {
39
+ packageName: string;
40
+ packageRoot: string;
41
+ binPath: string;
42
+ command: string;
43
+ args: string[];
44
+ };
45
+
46
+ export type TFrameworkInstallGraph = {
47
+ activeRoot: string;
48
+ installedRoot?: string;
49
+ appNodeModulesRoot: string;
50
+ frameworkNodeModulesRoot: string;
51
+ };
52
+
53
+ export type TFrameworkInstallMode = 'npm' | 'npm-link' | 'path' | 'workspace' | 'global' | 'checkout';
54
+
55
+ export type TFrameworkInstallInfo = {
56
+ mode: TFrameworkInstallMode;
57
+ summary: string;
58
+ dependencySpec?: string;
59
+ };
60
+
38
61
  /*----------------------------------
39
62
  - CONFIG
40
63
  ----------------------------------*/
@@ -51,7 +74,60 @@ const safeRealpath = (filepath: string) => {
51
74
  }
52
75
  };
53
76
 
54
- const resolveCoreRoot = (appRoot: string) => {
77
+ const readPackageJson = (filepath: string) => {
78
+ try {
79
+ return JSON.parse(fs.readFileSync(filepath, 'utf8')) as Record<string, unknown>;
80
+ } catch {
81
+ return undefined;
82
+ }
83
+ };
84
+
85
+ const readPackageDependencySpec = (appRoot: string, packageName: string) => {
86
+ const packageJson = readPackageJson(path.join(appRoot, 'package.json'));
87
+ if (!packageJson) return undefined;
88
+
89
+ const dependencySections = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'] as const;
90
+
91
+ for (const section of dependencySections) {
92
+ const dependencies = packageJson[section];
93
+ if (!dependencies || typeof dependencies !== 'object' || Array.isArray(dependencies)) continue;
94
+
95
+ const dependencySpec = (dependencies as Record<string, unknown>)[packageName];
96
+ if (typeof dependencySpec !== 'string' || dependencySpec.trim() === '') continue;
97
+
98
+ return dependencySpec.trim();
99
+ }
100
+
101
+ return undefined;
102
+ };
103
+
104
+ const findVisibleNodeModulesRoot = (startPath: string): string | undefined => {
105
+ let currentPath = path.resolve(startPath);
106
+
107
+ while (true) {
108
+ const candidate = path.join(currentPath, 'node_modules');
109
+ if (fs.existsSync(candidate)) return candidate;
110
+
111
+ const parentPath = path.dirname(currentPath);
112
+ if (parentPath === currentPath) return undefined;
113
+ currentPath = parentPath;
114
+ }
115
+ };
116
+
117
+ const findVisiblePackageInstall = (startPath: string, packageName: string): string | undefined => {
118
+ let currentPath = path.resolve(startPath);
119
+
120
+ while (true) {
121
+ const candidate = path.join(currentPath, 'node_modules', packageName);
122
+ if (fs.existsSync(candidate)) return candidate;
123
+
124
+ const parentPath = path.dirname(currentPath);
125
+ if (parentPath === currentPath) return undefined;
126
+ currentPath = parentPath;
127
+ }
128
+ };
129
+
130
+ const resolveCoreRoot = (appRoot: string): string => {
55
131
  const currentPackageRoot = path.resolve(__dirname, '..');
56
132
  const currentBin = path.join(currentPackageRoot, 'cli', 'bin.js');
57
133
  const invokedScript = process.argv[1] ? safeRealpath(process.argv[1]) : '';
@@ -59,8 +135,8 @@ const resolveCoreRoot = (appRoot: string) => {
59
135
 
60
136
  if (invokedCurrentPackage) return currentPackageRoot;
61
137
 
62
- const localInstall = path.join(appRoot, 'node_modules', 'proteum');
63
- if (fs.existsSync(localInstall)) return localInstall;
138
+ const installedFrameworkRoot = findVisiblePackageInstall(appRoot, 'proteum');
139
+ if (installedFrameworkRoot) return installedFrameworkRoot;
64
140
 
65
141
  // When running `npx`/global installs, there may be no local `node_modules/proteum` yet.
66
142
  // Fall back to the installed package root (this file lives in `<root>/cli`).
@@ -69,9 +145,101 @@ const resolveCoreRoot = (appRoot: string) => {
69
145
 
70
146
  const normalizeImportPath = (value: string) => value.replace(/\\/g, '/');
71
147
 
148
+ const resolveAppNodeModulesRoot = (appRoot: string): string => {
149
+ const installedRoot = findVisiblePackageInstall(appRoot, 'proteum');
150
+
151
+ return (
152
+ (installedRoot ? path.dirname(installedRoot) : undefined) ||
153
+ findVisibleNodeModulesRoot(appRoot) ||
154
+ path.join(appRoot, 'node_modules')
155
+ );
156
+ };
157
+
158
+ const resolveFrameworkInstallRoot = (appRoot: string): string =>
159
+ findVisiblePackageInstall(appRoot, 'proteum') || path.join(resolveAppNodeModulesRoot(appRoot), 'proteum');
160
+
161
+ const resolveFrameworkInstallGraph = (appRoot: string, activeRoot: string): TFrameworkInstallGraph => {
162
+ const installedRoot = findVisiblePackageInstall(appRoot, 'proteum');
163
+
164
+ return {
165
+ activeRoot,
166
+ installedRoot,
167
+ appNodeModulesRoot: resolveAppNodeModulesRoot(appRoot),
168
+ frameworkNodeModulesRoot: findVisibleNodeModulesRoot(activeRoot) || path.join(activeRoot, 'node_modules'),
169
+ };
170
+ };
171
+
172
+ const resolvePackageJsonPath = (packageName: string, searchPaths: string[]): string =>
173
+ require.resolve(`${packageName}/package.json`, { paths: searchPaths });
174
+
72
175
  const filenameToImportName = (value: string) =>
73
176
  normalizeImportPath(value).replace(/[^A-Za-z0-9_]+/g, '_');
74
177
 
178
+ export const resolveFrameworkInstallInfo = ({
179
+ appRoot,
180
+ framework,
181
+ }: {
182
+ appRoot: string;
183
+ framework: TFrameworkInstallGraph;
184
+ }): TFrameworkInstallInfo => {
185
+ const dependencySpec = readPackageDependencySpec(appRoot, 'proteum');
186
+ const installedRoot = framework.installedRoot ? path.resolve(framework.installedRoot) : undefined;
187
+ const normalizedActiveRoot = normalizeImportPath(safeRealpath(framework.activeRoot));
188
+ const installedRootIsSymlink =
189
+ installedRoot !== undefined &&
190
+ (() => {
191
+ try {
192
+ return fs.lstatSync(installedRoot).isSymbolicLink();
193
+ } catch {
194
+ return false;
195
+ }
196
+ })();
197
+
198
+ if (dependencySpec?.startsWith('file:') || dependencySpec?.startsWith('link:')) {
199
+ return {
200
+ mode: 'path',
201
+ summary: `path (${dependencySpec})`,
202
+ dependencySpec,
203
+ };
204
+ }
205
+
206
+ if (dependencySpec?.startsWith('workspace:')) {
207
+ return {
208
+ mode: 'workspace',
209
+ summary: `workspace (${dependencySpec})`,
210
+ dependencySpec,
211
+ };
212
+ }
213
+
214
+ if (installedRootIsSymlink) {
215
+ return {
216
+ mode: 'npm-link',
217
+ summary: 'npm link',
218
+ dependencySpec,
219
+ };
220
+ }
221
+
222
+ if (dependencySpec) {
223
+ return {
224
+ mode: 'npm',
225
+ summary: `npm (${dependencySpec})`,
226
+ dependencySpec,
227
+ };
228
+ }
229
+
230
+ if (!normalizedActiveRoot.includes('/node_modules/')) {
231
+ return {
232
+ mode: 'checkout',
233
+ summary: 'local checkout',
234
+ };
235
+ }
236
+
237
+ return {
238
+ mode: 'global',
239
+ summary: 'global install',
240
+ };
241
+ };
242
+
75
243
  /*----------------------------------
76
244
  - LIB
77
245
  ----------------------------------*/
@@ -79,13 +247,15 @@ export default class Paths {
79
247
  /*----------------------------------
80
248
  - LISTE
81
249
  ----------------------------------*/
82
-
83
- public constructor(
84
- public appRoot: string,
85
- public coreRoot = resolveCoreRoot(appRoot),
86
- ) {}
87
-
88
- public core = { cli: path.resolve(__dirname, '.'), root: this.coreRoot, pages: this.coreRoot + '/client/pages' };
250
+ public coreRoot: string;
251
+ public framework: TFrameworkInstallGraph;
252
+ public core: { cli: string; root: string; pages: string };
253
+
254
+ public constructor(public appRoot: string, coreRoot = resolveCoreRoot(appRoot)) {
255
+ this.coreRoot = coreRoot;
256
+ this.framework = resolveFrameworkInstallGraph(appRoot, coreRoot);
257
+ this.core = { cli: path.resolve(__dirname, '.'), root: this.coreRoot, pages: this.coreRoot + '/client/pages' };
258
+ }
89
259
 
90
260
  /*----------------------------------
91
261
  - EXTRACTION
@@ -171,4 +341,124 @@ export default class Paths {
171
341
  //console.log('Applying Aliases ...', aliases.forModuleAlias());
172
342
  moduleAlias.addAliases(aliases.forModuleAlias());
173
343
  }
344
+
345
+ public getFrameworkRoots(): string[] {
346
+ return [
347
+ this.framework.activeRoot,
348
+ ...(this.framework.installedRoot ? [this.framework.installedRoot] : []),
349
+ ].filter((rootPath, index, list) => list.indexOf(rootPath) === index && fs.existsSync(rootPath));
350
+ }
351
+
352
+ public getFrameworkInstallRoot(): string {
353
+ return this.getFrameworkInstallRootForAppRoot(this.appRoot);
354
+ }
355
+
356
+ public getFrameworkInstallRootForAppRoot(appRoot: string): string {
357
+ return resolveFrameworkInstallRoot(appRoot);
358
+ }
359
+
360
+ public getAppNodeModulesRootForAppRoot(appRoot: string): string {
361
+ return resolveAppNodeModulesRoot(appRoot);
362
+ }
363
+
364
+ public relativePathFromFile(targetFile: string, absolutePath: string): string {
365
+ return this.relativePathFromDirectory(path.dirname(targetFile), absolutePath);
366
+ }
367
+
368
+ public relativePathFromDirectory(targetDirectory: string, absolutePath: string): string {
369
+ const relativePath = normalizeImportPath(path.relative(targetDirectory, absolutePath));
370
+ if (relativePath === '') return '.';
371
+ if (!relativePath.startsWith('.')) return `./${relativePath}`;
372
+ return relativePath;
373
+ }
374
+
375
+ public relativeFrameworkPathFrom(targetFile: string, ...segments: string[]): string {
376
+ return this.relativePathFromFile(targetFile, path.join(this.getFrameworkInstallRoot(), ...segments));
377
+ }
378
+
379
+ public relativeAppNodeModulesPathFrom(targetFile: string, ...segments: string[]): string {
380
+ return this.relativePathFromFile(targetFile, path.join(this.framework.appNodeModulesRoot, ...segments));
381
+ }
382
+
383
+ public relativeFrameworkPathFromDirectory(targetDirectory: string, ...segments: string[]): string {
384
+ return this.relativePathFromDirectory(targetDirectory, path.join(this.getFrameworkInstallRoot(), ...segments));
385
+ }
386
+
387
+ public relativeAppNodeModulesPathFromDirectory(targetDirectory: string, ...segments: string[]): string {
388
+ return this.relativePathFromDirectory(targetDirectory, path.join(this.framework.appNodeModulesRoot, ...segments));
389
+ }
390
+
391
+ public relativeFrameworkTsconfigPathFrom(targetFile: string): string {
392
+ return this.relativeFrameworkPathFrom(targetFile, 'tsconfig.common.json');
393
+ }
394
+
395
+ public relativeFrameworkPathForAppRoot(appRoot: string, targetFile: string, ...segments: string[]): string {
396
+ return this.relativePathFromFile(targetFile, path.join(this.getFrameworkInstallRootForAppRoot(appRoot), ...segments));
397
+ }
398
+
399
+ public relativeFrameworkPathFromDirectoryForAppRoot(
400
+ appRoot: string,
401
+ targetDirectory: string,
402
+ ...segments: string[]
403
+ ): string {
404
+ return this.relativePathFromDirectory(
405
+ targetDirectory,
406
+ path.join(this.getFrameworkInstallRootForAppRoot(appRoot), ...segments),
407
+ );
408
+ }
409
+
410
+ public relativeAppNodeModulesPathFromDirectoryForAppRoot(
411
+ appRoot: string,
412
+ targetDirectory: string,
413
+ ...segments: string[]
414
+ ): string {
415
+ return this.relativePathFromDirectory(
416
+ targetDirectory,
417
+ path.join(this.getAppNodeModulesRootForAppRoot(appRoot), ...segments),
418
+ );
419
+ }
420
+
421
+ public resolvePackageRoot(packageName: string, { preferApp = true }: { preferApp?: boolean } = {}): string {
422
+ const searchPaths = preferApp
423
+ ? [this.appRoot, this.framework.activeRoot]
424
+ : [this.framework.activeRoot, this.appRoot];
425
+ return path.dirname(resolvePackageJsonPath(packageName, searchPaths));
426
+ }
427
+
428
+ public resolveRequest(request: string, { preferApp = true }: { preferApp?: boolean } = {}): string {
429
+ const searchPaths = preferApp
430
+ ? [this.appRoot, this.framework.activeRoot]
431
+ : [this.framework.activeRoot, this.appRoot];
432
+ return require.resolve(request, { paths: searchPaths });
433
+ }
434
+
435
+ public resolveBinary(
436
+ packageName: string,
437
+ binName = packageName,
438
+ { preferApp = true }: { preferApp?: boolean } = {},
439
+ ): TResolvedPackageBinary {
440
+ const packageRoot = this.resolvePackageRoot(packageName, { preferApp });
441
+ const packageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')) as {
442
+ bin?: string | Record<string, string>;
443
+ };
444
+ const binField = packageJson.bin;
445
+ const relativeBinPath =
446
+ typeof binField === 'string'
447
+ ? binField
448
+ : binField?.[binName] || binField?.[packageName];
449
+
450
+ if (!relativeBinPath) {
451
+ throw new Error(`Unable to resolve binary "${binName}" from package "${packageName}".`);
452
+ }
453
+
454
+ const binPath = path.resolve(packageRoot, relativeBinPath);
455
+
456
+ return {
457
+ packageName,
458
+ packageRoot,
459
+ binPath,
460
+ command: process.execPath,
461
+ args: [binPath],
462
+ };
463
+ }
174
464
  }
@@ -110,18 +110,37 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
110
110
  name: 'dev',
111
111
  category: 'Daily workflow',
112
112
  summary: 'Start the local compiler, SSR server, and hot reload loop.',
113
- usage: 'proteum dev [--port <port>] [--cache|--no-cache]',
113
+ usage: 'proteum dev [list|stop] [--port <port>] [--session-file <path>] [--replace-existing] [--all] [--stale] [--json] [--cache|--no-cache]',
114
114
  bestFor:
115
115
  'Day-to-day app work. This is the main entrypoint used by the current reference apps during local development.',
116
116
  examples: [
117
117
  { description: 'Start the app on its configured router port', command: 'proteum dev' },
118
- { description: 'Run a second Proteum app on another port', command: 'proteum dev --port 3101' },
118
+ { description: 'Replace the tracked dev session on another port', command: 'proteum dev --port 3101 --replace-existing' },
119
+ {
120
+ description: 'Start a tracked dev session with an explicit session file for an agent task',
121
+ command: 'proteum dev --port 3101 --session-file var/run/proteum/dev/agents/task.json --replace-existing',
122
+ },
123
+ {
124
+ description: 'List tracked Proteum dev sessions as JSON',
125
+ command: 'proteum dev list --json',
126
+ },
127
+ {
128
+ description: 'Stop every stale tracked dev session for the current app',
129
+ command: 'proteum dev stop --all --stale',
130
+ },
119
131
  {
120
132
  description: 'Disable the filesystem cache while debugging compiler state',
121
133
  command: 'proteum dev --no-cache',
122
134
  },
123
135
  ],
124
- notes: ['Legacy single-dash long options remain supported, for example `proteum dev -port 3001`.'],
136
+ notes: [
137
+ 'Proteum writes a machine-readable dev session file under `var/run/proteum/dev/<port>.json` by default; override it with `--session-file` when an agent needs a stable path.',
138
+ 'Use `--replace-existing` when retries should stop the previously tracked matching session before starting a new one.',
139
+ '`proteum dev list` inspects tracked sessions for the current app root. Add `--stale` to show only orphaned or dead sessions.',
140
+ '`proteum dev stop` targets the current session file by default. Add `--all` to stop every tracked session for the current app root.',
141
+ '`proteum dev` clears the interactive terminal once at startup, then shows `CTRL+R` reload and `CTRL+C` shutdown hotkeys in the session banner.',
142
+ 'Legacy single-dash long options remain supported, for example `proteum dev -port 3001`.',
143
+ ],
125
144
  status: 'stable',
126
145
  },
127
146
  refresh: {
@@ -141,7 +160,7 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
141
160
  name: 'build',
142
161
  category: 'Daily workflow',
143
162
  summary: 'Build the application.',
144
- usage: 'proteum build [--prod] [--strict] [--cache] [--analyze] [--port <port>]',
163
+ usage: 'proteum build [--prod] [--strict] [--cache] [--analyze] [--analyze-serve] [--analyze-host <host>] [--analyze-port <port|auto>] [--port <port>]',
145
164
  bestFor: 'CI, release builds, and local verification of the production server and client output.',
146
165
  examples: [
147
166
  { description: 'Run the normal production build', command: 'proteum build --prod' },
@@ -150,10 +169,17 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
150
169
  command: 'proteum build --prod --strict',
151
170
  },
152
171
  { description: 'Generate bundle analysis artifacts', command: 'proteum build --prod --analyze' },
172
+ {
173
+ description: 'Serve the bundle analysis at a local URL and let the OS choose the port',
174
+ command: 'proteum build --prod --analyze --analyze-serve --analyze-port auto',
175
+ },
153
176
  { description: 'Reuse the filesystem cache during builds', command: 'proteum build --prod --cache' },
154
177
  ],
155
178
  notes: [
156
179
  'Legacy positional booleans remain supported, for example `proteum build prod strict analyze`.',
180
+ '`--analyze` alone emits `bin/bundle-analysis/client.html` and `client-stats.json`.',
181
+ '`--analyze-serve` switches the analyzer to HTTP server mode and keeps the process open until you stop it.',
182
+ '`--analyze-host` and `--analyze-port` require `--analyze-serve`; use `auto` to let the OS assign a free port.',
157
183
  'Use `--strict` when the build must refresh generated typings and fail on any TypeScript error before compilation starts.',
158
184
  'The production output is emitted under `bin/`.',
159
185
  ],
@@ -1,17 +1,12 @@
1
1
  const React = require('react') as typeof import('react');
2
2
 
3
+ import type { TServerReadyConnectedProject } from '../../common/dev/serverHotReload';
3
4
  import { renderRows } from './layout';
4
5
  import { renderInk } from './ink';
6
+ import { renderWelcomePanel } from './welcome';
5
7
 
6
- const ProteumWordmark = [
7
- String.raw` ____ ____ ___ _____ _____ _ _ __ __`,
8
- String.raw`| _ \| _ \ / _ \_ _| ____| | | | \/ |`,
9
- String.raw`| |_) | |_) | | | || | | _| | | | | |\/| |`,
10
- String.raw`| __/| _ <| |_| || | | |___| |_| | | | |`,
11
- String.raw`|_| |_| \_\\___/ |_| |_____|\___/|_| |_|`,
12
- ];
13
-
14
- const ProteumTagline = 'Agent-first SSR compiler and server loop.';
8
+ const formatConnectedProjectLabel = (connectedProject: TServerReadyConnectedProject) =>
9
+ `${connectedProject.namespace} -> ${connectedProject.name}`;
15
10
 
16
11
  export const renderDevSession = async ({
17
12
  appName,
@@ -19,6 +14,7 @@ export const renderDevSession = async ({
19
14
  routerPort,
20
15
  devEventPort,
21
16
  connectedProjects,
17
+ proteumInstallSummary,
22
18
  proteumVersion,
23
19
  }: {
24
20
  appName: string;
@@ -26,24 +22,14 @@ export const renderDevSession = async ({
26
22
  routerPort: number;
27
23
  devEventPort: number;
28
24
  connectedProjects?: Array<{ namespace: string; urlInternal: string }>;
25
+ proteumInstallSummary?: string;
29
26
  proteumVersion: string;
30
27
  }) =>
31
28
  [
32
- await renderInk(({ Box, Text }) => {
33
- const createElement = React.createElement;
34
- const wordmark = ProteumWordmark.map((line) =>
35
- createElement(Text, { key: line, bold: true, color: 'blue' }, line),
36
- );
37
- const versionLabel = proteumVersion ? `v${proteumVersion}` : '';
38
-
39
- return createElement(
40
- Box,
41
- { borderStyle: 'round', borderColor: 'blue', paddingX: 2, paddingY: 0, flexDirection: 'column' },
42
- createElement(Text, { bold: true, backgroundColor: 'blue', color: 'white' }, ' WELCOME TO '),
43
- createElement(Box, { flexDirection: 'column' }, ...wordmark),
44
- versionLabel ? createElement(Text, { bold: true, color: 'blue' }, versionLabel) : null,
45
- createElement(Text, { dimColor: true }, ProteumTagline),
46
- );
29
+ await renderWelcomePanel({
30
+ installSummary: proteumInstallSummary,
31
+ version: proteumVersion,
32
+ tagline: 'Agent-first SSR compiler and server loop.',
47
33
  }),
48
34
  renderRows(
49
35
  [
@@ -61,7 +47,8 @@ export const renderDevSession = async ({
61
47
  { label: 'perf', value: `proteum perf top --port ${routerPort}` },
62
48
  { label: 'trace', value: `proteum trace latest --port ${routerPort}` },
63
49
  { label: 'trace deep', value: `proteum trace arm --capture deep --port ${routerPort}` },
64
- { label: 'hotkeys', value: 'Ctrl+R reload, Ctrl+C stop' },
50
+ { label: 'reload', value: 'CTRL+R' },
51
+ { label: 'shutdown', value: 'CTRL+C' },
65
52
  ],
66
53
  { minLabelWidth: 12, maxLabelWidth: 12 },
67
54
  ),
@@ -71,15 +58,16 @@ export const renderServerReadyBanner = async ({
71
58
  appName,
72
59
  publicUrl,
73
60
  routerPort,
74
- connectedProjectsCount,
61
+ connectedProjects,
75
62
  }: {
76
63
  appName: string;
77
64
  publicUrl: string;
78
65
  routerPort: number;
79
- connectedProjectsCount?: number;
66
+ connectedProjects?: TServerReadyConnectedProject[];
80
67
  }) =>
81
68
  renderInk(({ Box, Text }) => {
82
69
  const createElement = React.createElement;
70
+ const verifiedConnectedProjects = connectedProjects || [];
83
71
 
84
72
  return createElement(
85
73
  Box,
@@ -88,13 +76,20 @@ export const renderServerReadyBanner = async ({
88
76
  createElement(Text, { bold: true, color: 'green' }, appName),
89
77
  createElement(Text, { bold: true }, publicUrl),
90
78
  createElement(Text, { dimColor: true }, 'SSR server is listening for requests and hot reloads.'),
91
- connectedProjectsCount
79
+ verifiedConnectedProjects.length > 0
92
80
  ? createElement(
93
81
  Text,
94
82
  { dimColor: true },
95
- `Connected projects: ${connectedProjectsCount}`,
83
+ `Connected apps: ${verifiedConnectedProjects.map((connectedProject) => formatConnectedProjectLabel(connectedProject)).join(', ')}`,
96
84
  )
97
85
  : null,
86
+ ...verifiedConnectedProjects.map((connectedProject) =>
87
+ createElement(
88
+ Text,
89
+ { key: `connected-ping-${connectedProject.namespace}`, dimColor: true },
90
+ `Ping OK: ${formatConnectedProjectLabel(connectedProject)} responded to /api/__proteum/connected/ping`,
91
+ ),
92
+ ),
98
93
  createElement(Text, { dimColor: true }, `Diagnose /: proteum diagnose / --port ${routerPort}`),
99
94
  createElement(Text, { dimColor: true }, `Perf top: proteum perf top --port ${routerPort}`),
100
95
  createElement(Text, { dimColor: true }, `Trace latest: proteum trace latest --port ${routerPort}`),
@@ -135,6 +135,10 @@ export const renderCliOverview = async ({
135
135
  indent: ' ',
136
136
  nextIndent: ' ',
137
137
  }),
138
+ wrapText('Every Proteum CLI invocation prints the welcome banner. `proteum dev` is the only command that clears the interactive terminal before rendering its session UI.', {
139
+ indent: ' ',
140
+ nextIndent: ' ',
141
+ }),
138
142
  wrapText('Legacy single-dash flags and positional booleans remain accepted for older app scripts, but new docs should prefer modern long flags.', {
139
143
  indent: ' ',
140
144
  nextIndent: ' ',
@@ -0,0 +1,69 @@
1
+ const React = require('react') as typeof import('react');
2
+
3
+ import { renderRows } from './layout';
4
+ import { renderInk } from './ink';
5
+
6
+ const ProteumWordmark = [
7
+ String.raw` ____ ____ ___ _____ _____ _ _ __ __`,
8
+ String.raw`| _ \| _ \ / _ \_ _| ____| | | | \/ |`,
9
+ String.raw`| |_) | |_) | | | || | | _| | | | | |\/| |`,
10
+ String.raw`| __/| _ <| |_| || | | |___| |_| | | | |`,
11
+ String.raw`|_| |_| \_\\___/ |_| |_____|\___/|_| |_|`,
12
+ ];
13
+
14
+ export const clearInteractiveConsole = () => {
15
+ if (process.stdout.isTTY !== true || process.env.TERM === 'dumb') return;
16
+
17
+ process.stdout.write('\x1B[2J\x1B[3J\x1B[H');
18
+ };
19
+
20
+ export const renderWelcomePanel = async ({
21
+ installSummary,
22
+ version,
23
+ tagline,
24
+ }: {
25
+ installSummary?: string;
26
+ version: string;
27
+ tagline: string;
28
+ }) =>
29
+ renderInk(({ Box, Text }) => {
30
+ const createElement = React.createElement;
31
+ const wordmark = ProteumWordmark.map((line) =>
32
+ createElement(Text, { key: line, bold: true, color: 'blue' }, line),
33
+ );
34
+ const versionLabel = version ? `v${version}` : '';
35
+
36
+ return createElement(
37
+ Box,
38
+ { borderStyle: 'round', borderColor: 'blue', paddingX: 2, paddingY: 0, flexDirection: 'column' },
39
+ createElement(Text, { bold: true, backgroundColor: 'blue', color: 'white' }, ' WELCOME TO '),
40
+ createElement(Box, { flexDirection: 'column' }, ...wordmark),
41
+ versionLabel ? createElement(Text, { bold: true, color: 'blue' }, versionLabel) : null,
42
+ installSummary ? createElement(Text, { dimColor: true }, `Installed via ${installSummary}`) : null,
43
+ createElement(Text, { dimColor: true }, tagline),
44
+ );
45
+ });
46
+
47
+ export const renderCliWelcomeBanner = async ({
48
+ command,
49
+ installSummary,
50
+ version,
51
+ }: {
52
+ command: string;
53
+ installSummary?: string;
54
+ version: string;
55
+ }) =>
56
+ [
57
+ await renderWelcomePanel({
58
+ installSummary,
59
+ version,
60
+ tagline: 'Explicit SSR / SEO / TypeScript framework for agent-friendly apps.',
61
+ }),
62
+ renderRows(
63
+ [
64
+ { label: 'command', value: command },
65
+ { label: 'shutdown', value: 'CTRL+C' },
66
+ ],
67
+ { minLabelWidth: 10, maxLabelWidth: 10 },
68
+ ),
69
+ ].join('\n\n');
@@ -79,13 +79,38 @@ class DevCommand extends ProteumCommand {
79
79
 
80
80
  public static usage = buildUsage('dev');
81
81
 
82
+ public json = Option.Boolean('--json', false, { description: 'Print machine-readable dev session output.' });
82
83
  public port = Option.String('--port', { description: 'Override the router port.' });
83
84
  public cache = Option.Boolean('--cache', true, { description: 'Enable filesystem caching.' });
84
- public legacyArgs = Option.Rest();
85
+ public sessionFile = Option.String('--session-file', {
86
+ description: 'Override the dev session file path used for list, stop, or the active dev server.',
87
+ });
88
+ public replaceExisting = Option.Boolean('--replace-existing', false, {
89
+ description: 'Stop the existing matching dev session before starting a new one.',
90
+ });
91
+ public all = Option.Boolean('--all', false, {
92
+ description: 'When used with `dev stop`, stop every tracked dev session for the current app root.',
93
+ });
94
+ public stale = Option.Boolean('--stale', false, {
95
+ description: 'Filter `dev list` or `dev stop --all` to stale tracked sessions only.',
96
+ });
97
+ public args = Option.Rest();
85
98
 
86
99
  public async execute() {
87
- assertNoLegacyArgs('dev', this.legacyArgs);
88
- this.setCliArgs({ port: this.port ?? '', cache: this.cache });
100
+ const [maybeAction = '', ...restArgs] = this.args;
101
+ const action = maybeAction === 'list' || maybeAction === 'stop' ? maybeAction : '';
102
+
103
+ assertNoLegacyArgs('dev', action ? restArgs : this.args);
104
+ this.setCliArgs({
105
+ action: action || 'start',
106
+ port: this.port ?? '',
107
+ cache: this.cache,
108
+ json: this.json,
109
+ sessionFile: this.sessionFile ?? '',
110
+ replaceExisting: this.replaceExisting,
111
+ all: this.all,
112
+ stale: this.stale,
113
+ });
89
114
  await runCommandModule(() => import('../commands/dev'));
90
115
  }
91
116
  }
@@ -113,6 +138,15 @@ class BuildCommand extends ProteumCommand {
113
138
  public prod = Option.Boolean('--prod', false, { description: 'Build in production mode.' });
114
139
  public cache = Option.Boolean('--cache', false, { description: 'Enable filesystem caching during the build.' });
115
140
  public analyze = Option.Boolean('--analyze', false, { description: 'Emit the client bundle analysis report.' });
141
+ public analyzeServe = Option.Boolean('--analyze-serve', false, {
142
+ description: 'Serve the bundle analysis over HTTP instead of only writing a static report.',
143
+ });
144
+ public analyzeHost = Option.String('--analyze-host', {
145
+ description: 'Host used by the analyzer HTTP server when `--analyze-serve` is enabled.',
146
+ });
147
+ public analyzePort = Option.String('--analyze-port', {
148
+ description: 'Port used by the analyzer HTTP server when `--analyze-serve` is enabled. Use `auto` for an ephemeral port.',
149
+ });
116
150
  public strict = Option.Boolean('--strict', false, {
117
151
  description: 'Refresh generated typings and fail the build if TypeScript reports any error.',
118
152
  });
@@ -125,6 +159,9 @@ class BuildCommand extends ProteumCommand {
125
159
  prod: this.prod,
126
160
  cache: this.cache,
127
161
  analyze: this.analyze,
162
+ analyzeServe: this.analyzeServe,
163
+ analyzeHost: this.analyzeHost ?? '',
164
+ analyzePort: this.analyzePort ?? '',
128
165
  strict: this.strict,
129
166
  } satisfies TArgsObject;
130
167