proteum 2.5.3 → 2.5.4

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/README.md CHANGED
@@ -471,7 +471,7 @@ proteum create service Conversion/Plans
471
471
 
472
472
  Every `proteum dev` start runs the same idempotent instruction check. It updates missing or stale managed sections automatically and prompts only when a blocked path would need to be replaced.
473
473
 
474
- `proteum worktree init` writes `.proteum/worktree-bootstrap.json` for app roots under `/.codex/worktrees/`. The marker records `.env` copy status, refresh and dependency results, runtime status, key file hashes, and the active Proteum version. `proteum dev`, `proteum refresh`, `proteum runtime status`, `proteum verify`, and MCP `workflow_start` block inside Codex worktrees until the marker is fresh. Run `npx proteum worktree init --source <source-app-root>` for a new worktree, or add `--refresh` when stale state is reported. `PROTEUM_ALLOW_UNBOOTSTRAPPED_WORKTREE=1` bypasses the block but remains visible in runtime status, doctor, and MCP output.
474
+ `proteum worktree init` writes `.proteum/worktree-bootstrap.json` for app roots under `/.codex/worktrees/`. The marker records `.env` copy status, refresh and dependency results, runtime status, key file hashes, and the active Proteum version. In monorepos with root tooling such as `prisma.config.ts` or npm workspaces, bootstrap also ensures the workspace-root `.env` exists, copying the source root `.env` when available or falling back to the source app `.env`. `proteum dev`, `proteum refresh`, `proteum runtime status`, `proteum verify`, and MCP `workflow_start` block inside Codex worktrees until the marker is fresh. Run `npx proteum worktree init --source <source-app-root>` for a new worktree, or add `--refresh` when stale state is reported. `PROTEUM_ALLOW_UNBOOTSTRAPPED_WORKTREE=1` bypasses the block but remains visible in runtime status, doctor, and MCP output.
475
475
 
476
476
  `proteum connect`, `proteum explain`, `proteum doctor`, and `proteum diagnose` share the same generated manifest and contract state. `proteum perf` uses the same dev request-trace store as the profiler `Perf` tab. `proteum runtime status` also inspects the configured router/HMR ports and returns an exact Start Dev action, so agents do not need to `curl` page routes to identify port owners. `proteum dev` exposes the app-root MCP contract at `/__proteum/mcp` and ensures one managed machine MCP daemon is running; `proteum mcp` is the machine-scope router agents register once. Agents should start with MCP `workflow_start`, use offline candidates to choose the correct app root when no dev server is live, then route repeated reads by the returned live `projectId`. For the full diagnostics and tracing model, see [docs/diagnostics.md](docs/diagnostics.md), [docs/mcp.md](docs/mcp.md), and [docs/request-tracing.md](docs/request-tracing.md).
477
477
 
@@ -53,7 +53,7 @@ Managed compact root routers must use trigger -> canonical instruction file refe
53
53
 
54
54
  [optional body]
55
55
  ```
56
- Then treat `commit` as conversation-wide and cross-project, not task-scoped. Before staging or committing, run the repository's non-coverage commit gate when it defines one, such as `npm run check:commit`; otherwise run targeted lint, typecheck, and test commands. Report any blocker instead of committing through a failed commit gate. Identify every affected git repository or worktree touched during that span, stage all conversation-related changed files in each affected repository or worktree with `git add` while still avoiding unrelated pre-existing user changes or incidental untracked files, and create one `git commit` per affected repository or worktree. Do not omit linked local dependencies, framework repos, connected projects, or producer apps when they were changed to make the delivered behavior actually work. Do not stop at only suggesting the message.
56
+ Then treat `commit` as conversation-wide and cross-project, not task-scoped. Do not run any check, lint, typecheck, test, coverage, or commit gate as part of this exact `commit` workflow unless the user explicitly asks for those checks in the same request. Identify every affected git repository or worktree touched during that span, stage all conversation-related changed files in each affected repository or worktree with `git add` while still avoiding unrelated pre-existing user changes or incidental untracked files, and create one `git commit` per affected repository or worktree. Do not omit linked local dependencies, framework repos, connected projects, or producer apps when they were changed to make the delivered behavior actually work. Do not stop at only suggesting the message.
57
57
  After providing a commit message or after creating a commit, immediately follow it with this exact prompt and obey it:
58
58
  `Explain in short minimalistic and few bullet points what we changed in this thread, like you would do to your grandma. Start with a verb in the past.`
59
59
 
@@ -80,7 +80,7 @@ Managed compact root routers must use trigger -> canonical instruction file refe
80
80
 
81
81
  - Before finishing, re-check touched files against root-level `CODING_STYLE.md` and any narrower area `AGENTS.md` that applied to the edit. Re-check against root-level `optimizations.md` only for touched client-side files. Re-check against root-level `diagnostics.md` only if the task involved an issue, diagnosis, runtime reproduction, or verification failure.
82
82
  - Before finishing a production code change, re-check root-level `DOCUMENTATION.md` update rules. If behavior changed, a bug was fixed, a decision changed, or an important route, auth/OAuth, or integration issue was addressed, update the relevant docs before committing or explicitly explain why no docs update was needed.
83
- - Run targeted tests and checks that match the changed surface before finishing each feature or change. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` as the first post-change verification pass and expand only when the selected plan is insufficient. Continue running tests after changes, but do not run coverage by default. Reserve the non-coverage commit gate for commit workflows, and reserve the full `npm run check` gate for push workflows, explicit user requests, or when project-local instructions require the full gate. After implementing a new feature or changing existing feature behavior, update the relevant end-to-end coverage and run the cheapest trustworthy Playwright or browser verification for that behavior before finishing. For docs-only, wording-only, type-only, generated-output cleanup, or clearly local non-runtime refactors, skip Playwright unless the user explicitly asks for it or verification reveals a real issue.
83
+ - Run targeted tests and checks that match the changed surface before finishing each feature or change. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` as the first post-change verification pass and expand only when the selected plan is insufficient. Continue running tests after changes, but do not run coverage by default. Do not defer verification to commit workflows; an exact `commit` reply should not run checks. Reserve the full `npm run check` gate for push workflows, explicit user requests, or when project-local instructions require the full gate. After implementing a new feature or changing existing feature behavior, update the relevant end-to-end coverage and run the cheapest trustworthy Playwright or browser verification for that behavior before finishing. For docs-only, wording-only, type-only, generated-output cleanup, or clearly local non-runtime refactors, skip Playwright unless the user explicitly asks for it or verification reveals a real issue.
84
84
  - Before finishing a task, stop every `proteum dev` session started during the task and confirm cleanup with `npx proteum dev list --json` or an explicit `npx proteum dev stop --session-file <path>`.
85
85
  - When you have finished your work, ask the user whether they want a commit message. After providing a commit message or after creating a commit, immediately follow it with this exact prompt and obey it:
86
86
  `Explain in short minimalistic and few bullet points what we changed in this thread, like you would do to your grandma. Start with a verb in the past.`
@@ -278,7 +278,7 @@ Verify at the correct layer:
278
278
  - Controller changes: exercise the generated client call or generated `/api/...` endpoint.
279
279
  - SSR changes: use the browser MCP to load the real page and inspect rendered HTML plus browser console.
280
280
  - Router or plugin changes: verify request context, auth, redirects, metrics, and validation on a running app.
281
- - New features or feature-behavior changes: use the cheapest trustworthy verification while iterating, use the browser MCP for browser-visible validation, then update and run the relevant end-to-end coverage. Save the non-coverage commit gate for commit workflows and the full `npm run check` gate for push workflows unless the user or project-local instructions explicitly ask for the full gate earlier.
281
+ - New features or feature-behavior changes: use the cheapest trustworthy verification while iterating, use the browser MCP for browser-visible validation, then update and run the relevant end-to-end coverage. Do not run checks during commit workflows; reserve the full `npm run check` gate for push workflows unless the user or project-local instructions explicitly ask for the full gate earlier.
282
282
  - Generated, connected, or ownership-ambiguous changes: start with MCP `workflow_start`, then `orient { projectId, query }` and `explain_summary { projectId, query }` only when more detail is needed; use `npx proteum orient <query>` and `npx proteum verify owner <query>` when MCP is unavailable or terminal evidence is required.
283
283
  - Browser-visible issues: use the browser MCP after request-level verification is insufficient. Use `npx proteum e2e --port <port> ...` only when automated end-to-end coverage or a Playwright suite is required.
284
284
  - Raw browser execution outside end-to-end suites: use the browser MCP only. Keep Playwright in `npx proteum e2e --port <port>` for targeted/full end-to-end suites.
@@ -325,7 +325,7 @@ Verify at the correct layer:
325
325
  - For read-only SQL diagnosis, use MCP `db_query` or `npx proteum db query "<sql>"`; only one capped `SELECT`, `SHOW`, or `EXPLAIN` statement is allowed.
326
326
  - Do not run `prisma *` yourself. If a schema change requires migration, ask the user to run `npx prisma migrate dev --config ./prisma.config.ts --name <migration name>` and wait for `continue`.
327
327
  - Do not run `git restore` or `git reset`.
328
- - Do not run write-mode git commands by default. The built-in exception is an exact `commit` reply, which allows `git add` and `git commit` in every affected repository or worktree touched during the whole conversation after the repository's non-coverage commit gate passes when it defines one, such as `npm run check:commit`. Any other write-mode git action requires an explicit user request. Before any explicit push, run `npm run check` in every affected repository or worktree that defines it and report any blocker instead of pushing through a failed check.
328
+ - Do not run write-mode git commands by default. The built-in exception is an exact `commit` reply, which allows `git add` and `git commit` in every affected repository or worktree touched during the whole conversation. An exact `commit` reply does not allow check, lint, typecheck, test, coverage, or commit-gate commands unless the user explicitly requests them in the same message. Any other write-mode git action requires an explicit user request. Before any explicit push, run `npm run check` in every affected repository or worktree that defines it and report any blocker instead of pushing through a failed check.
329
329
 
330
330
  ## Appendix
331
331
 
@@ -423,7 +423,7 @@ Agents working in generated Proteum projects must use this delivery workflow for
423
423
  4. Targeted validation: refresh generated framework contracts after route, page, controller, service, command, or config changes, then run the targeted tests/checks that match the changed surface.
424
424
  5. Validate unit + E2E: run the relevant unit tests and real-world journey E2E checks before calling the work complete.
425
425
 
426
- Unit test expectation: production changes must always add or update focused unit tests and run the targeted unit or integration tests that match the changed behavior. Do not run coverage after every change by default. Reserve whole-project coverage for the repository's full `npm run check` gate during push workflows or when the user explicitly requests it; do not run coverage for commit-only workflows by default. Any excluded generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested must be documented in the completion note.
426
+ Unit test expectation: production changes must always add or update focused unit tests and run the targeted unit or integration tests that match the changed behavior. Do not run coverage after every change by default. Reserve whole-project coverage for the repository's full `npm run check` gate during push workflows or when the user explicitly requests it; do not run checks for commit-only workflows unless the user explicitly requests them. Any excluded generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested must be documented in the completion note.
427
427
 
428
428
  E2E expectation: real-world journeys must follow the project-local instructions in `tests/e2e/REAL_WORLD_JOURNEY_TESTS.md`. These tests should model complete user workflows, role transitions, permissions, state changes, and cross-view consistency rather than isolated happy paths.
429
429
 
@@ -8,7 +8,7 @@ This file is the source of truth for codex coding style instructions in Proteum-
8
8
  - Write clean, consistent, readable code with a tab size of 4.
9
9
  - Keep functions and methods short.
10
10
  - Every time possible, create reusable functions and components instead of repeating.
11
- - Before finishing a feature or change, review touched files against this document and run targeted lint/typecheck/tests for the changed surface. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` as the first post-change verification pass. Do not run coverage by default after ordinary changes. Run the repository's non-coverage commit gate before committing, and run the full `npm run check` gate before pushing or when the user explicitly asks for it; coding-style regressions are defects, not optional cleanup.
11
+ - Before finishing a feature or change, review touched files against this document and run targeted lint/typecheck/tests for the changed surface. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` as the first post-change verification pass. Do not run coverage by default after ordinary changes. Do not run check, lint, typecheck, test, coverage, or commit-gate commands as part of a commit-only workflow; run the full `npm run check` gate before pushing or when the user explicitly asks for it. Coding-style regressions are defects, not optional cleanup.
12
12
 
13
13
  ## Type safety
14
14
 
@@ -64,7 +64,7 @@ This file is the canonical source of truth for diagnostics, temporary instrument
64
64
  - For browser regressions, prefer a browser MCP repro first and add targeted Playwright E2E coverage only when the user asks for automated coverage, when a stable regression path needs automation, or when browser MCP verification is insufficient.
65
65
  - Only the final verifier agent should usually run browser flows. Earlier agents should stay on `orient`, `verify owner`, `verify request`, `diagnose`, and command-level checks unless browser execution is the only trustworthy reproducer.
66
66
  - Treat server startup failures, runtime errors, browser console errors or warnings, and Playwright failures as blocking unless they are clearly unrelated to the change.
67
- - When the touched surface can affect coding-style enforcement, run the targeted lint or typecheck command for that surface before finishing. Run the repository's non-coverage commit gate before committing, and run the full `npm run check` gate before pushing or when explicitly requested.
67
+ - When the touched surface can affect coding-style enforcement, run the targeted lint or typecheck command for that surface before finishing. Do not run check, lint, typecheck, test, coverage, or commit-gate commands as part of a commit-only workflow. Run the full `npm run check` gate before pushing or when explicitly requested.
68
68
  - If the task started any long-lived `proteum dev` server, stop it explicitly with `npx proteum dev stop --session-file <path>` or `npx proteum dev stop --all --stale`, then confirm the remaining tracked sessions with `npx proteum dev list --json`.
69
69
  - Add `data-testid` when stable selectors are missing instead of relying on brittle text or DOM-shape selectors.
70
70
  - If an isolated test misses prerequisite state, run the smallest broader scope that reproduces the real setup.
@@ -65,8 +65,8 @@ Managed compact root routers must use trigger -> canonical instruction file refe
65
65
 
66
66
  - Before finishing, re-check touched files against root-level `CODING_STYLE.md` and any narrower area `AGENTS.md` that applied to the edit. Re-check against root-level `optimizations.md` only for touched client-side files. Re-check against root-level `diagnostics.md` only if the task involved an issue, diagnosis, runtime reproduction, or verification failure.
67
67
  - Before finishing a production code change, re-check root-level `DOCUMENTATION.md` update rules. If behavior changed, a bug was fixed, a decision changed, or an important route, auth/OAuth, or integration issue was addressed, update the relevant docs before committing or explicitly explain why no docs update was needed.
68
- - For production changes, always add or update focused unit tests and run the targeted unit or integration tests that match the changed behavior. Do not run coverage after every ordinary change by default. Reserve whole-project coverage for the repository's full `npm run check` gate during push workflows or when the user explicitly requests it; do not run coverage for commit-only workflows by default. Document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions.
69
- - Run targeted tests and checks that match the changed surface before finishing each feature or change. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` as the first post-change verification pass and expand only when the selected plan is insufficient. Continue running tests after changes, but do not run coverage by default. Reserve the non-coverage commit gate for commit workflows, and reserve the full `npm run check` gate for push workflows, explicit user requests, or when project-local instructions require the full gate. After implementing a new feature or changing existing feature behavior, update the relevant end-to-end coverage and run the cheapest trustworthy Playwright or browser verification for that behavior before finishing. For docs-only, wording-only, type-only, generated-output cleanup, or clearly local non-runtime refactors, skip Playwright unless the user explicitly asks for it or verification reveals a real issue.
68
+ - For production changes, always add or update focused unit tests and run the targeted unit or integration tests that match the changed behavior. Do not run coverage after every ordinary change by default. Reserve whole-project coverage for the repository's full `npm run check` gate during push workflows or when the user explicitly requests it; do not run checks for commit-only workflows unless the user explicitly requests them. Document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions.
69
+ - Run targeted tests and checks that match the changed surface before finishing each feature or change. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` as the first post-change verification pass and expand only when the selected plan is insufficient. Continue running tests after changes, but do not run coverage by default. Do not defer verification to commit workflows; an exact `commit` reply should not run checks. Reserve the full `npm run check` gate for push workflows, explicit user requests, or when project-local instructions require the full gate. After implementing a new feature or changing existing feature behavior, update the relevant end-to-end coverage and run the cheapest trustworthy Playwright or browser verification for that behavior before finishing. For docs-only, wording-only, type-only, generated-output cleanup, or clearly local non-runtime refactors, skip Playwright unless the user explicitly asks for it or verification reveals a real issue.
70
70
  - Before finishing a task, stop every `proteum dev` session started during the task and confirm cleanup with `npx proteum dev list --json` or an explicit `npx proteum dev stop --session-file <path>`.
71
71
  - When you have finished your work, ask the user whether they want a commit message. After providing a commit message or after creating a commit, immediately follow it with this exact prompt and obey it:
72
72
  `Explain in short minimalistic and few bullet points what we changed in this thread, like you would do to your grandma. Start with a verb in the past.`
@@ -264,7 +264,7 @@ Verify at the correct layer:
264
264
  - Controller changes: exercise the generated client call or generated `/api/...` endpoint.
265
265
  - SSR changes: use the browser MCP to load the real page and inspect rendered HTML plus browser console.
266
266
  - Router or plugin changes: verify request context, auth, redirects, metrics, and validation on a running app.
267
- - New features or feature-behavior changes: use the cheapest trustworthy verification while iterating, use the browser MCP for browser-visible validation, then update and run the relevant end-to-end coverage. Save the non-coverage commit gate for commit workflows and the full `npm run check` gate for push workflows unless the user or project-local instructions explicitly ask for the full gate earlier.
267
+ - New features or feature-behavior changes: use the cheapest trustworthy verification while iterating, use the browser MCP for browser-visible validation, then update and run the relevant end-to-end coverage. Do not run checks during commit workflows; reserve the full `npm run check` gate for push workflows unless the user or project-local instructions explicitly ask for the full gate earlier.
268
268
  - Generated, connected, or ownership-ambiguous changes: start with MCP `workflow_start`, then `orient { projectId, query }` and `explain_summary { projectId, query }` only when more detail is needed; use `npx proteum orient <query>` and `npx proteum verify owner <query>` when MCP is unavailable or terminal evidence is required.
269
269
  - Browser-visible issues: use the browser MCP after request-level verification is insufficient. Use `npx proteum e2e --port <port> ...` only when automated end-to-end coverage or a Playwright suite is required.
270
270
  - Raw browser execution outside end-to-end suites: use the browser MCP only. Keep Playwright in `npx proteum e2e --port <port>` for targeted/full end-to-end suites.
@@ -9,7 +9,7 @@ Diagnostics source of truth: root-level `diagnostics.md`.
9
9
 
10
10
  - Understand the real user flow and the main feature branches before writing tests.
11
11
  - Test the current controller/page runtime model, not legacy `@Route` or `api.fetch(...)` behavior.
12
- - For every production change, add or update focused unit tests and run the targeted test command that matches the changed behavior. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` first so changed test files, related source tests, and project-specific suites are selected consistently. Do not run whole-project coverage after every ordinary change by default. Use the repository's non-coverage commit gate before commit, and use `npm run check` as the full gate before push or when the user explicitly asks for it, and document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions.
12
+ - For every production change, add or update focused unit tests and run the targeted test command that matches the changed behavior. When the repository defines `proteum.verify.config.ts`, use `npx proteum verify changed` first so changed test files, related source tests, and project-specific suites are selected consistently. Do not run whole-project coverage after every ordinary change by default. Do not run checks as part of a commit-only workflow; use `npm run check` as the full gate before push or when the user explicitly asks for it, and document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions.
13
13
  - Verify routing, controllers, SSR, and router plugins against a running app when behavior depends on real request handling.
14
14
  - After implementing a new feature or changing existing feature behavior, update the end-to-end coverage for that behavior and run the full Playwright suite before finishing. Prefer `npx proteum e2e --port <port>` for Playwright runs so base URLs and auth tokens are passed through Proteum-managed child env instead of shell-leading environment assignments. Use a browser MCP repro against a running app during iteration when it is the fastest trustworthy loop.
15
15
  - Exercise real URLs, generated controller calls, or real browser flows instead of re-deriving framework internals in tests.
@@ -166,6 +166,7 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
166
166
  notes: [
167
167
  'Bootstrap writes `.proteum/worktree-bootstrap.json` with hashes, step timestamps, dependency status, runtime status, and Proteum version.',
168
168
  'When `.env` is missing, `--source` is required and must point to an app root with a readable `.env`.',
169
+ 'For monorepos with root tooling, bootstrap also ensures the workspace-root `.env` exists from the source root or source app env.',
169
170
  'Guarded commands block inside `/.codex/worktrees/` until bootstrap is complete or explicitly bypassed with `PROTEUM_ALLOW_UNBOOTSTRAPPED_WORKTREE=1`.',
170
171
  '`worktree create` preserves the source app root path relative to the source repository root, so monorepo app roots are bootstrapped in the matching target location.',
171
172
  ],
@@ -175,7 +175,7 @@ class WorktreeCommand extends ProteumCommand {
175
175
 
176
176
  public static usage = buildUsage('worktree');
177
177
 
178
- public source = Option.String('--source', { description: 'Source Proteum app root used for .env copy and worktree creation.' });
178
+ public source = Option.String('--source', { description: 'Source Proteum app root used for app/root .env copy and worktree creation.' });
179
179
  public branch = Option.String('--branch', { description: 'Branch name created by `worktree create`.' });
180
180
  public base = Option.String('--base', { description: 'Base ref used by `worktree create`.' });
181
181
  public refresh = Option.Boolean('--refresh', false, { description: 'Refresh an existing stale bootstrap marker.' });
@@ -23,6 +23,13 @@ export type TWorktreeBootstrapMarker = {
23
23
  copied: boolean;
24
24
  copiedAt?: string;
25
25
  present: boolean;
26
+ root?: {
27
+ copied: boolean;
28
+ copiedAt?: string;
29
+ filepath: string;
30
+ present: boolean;
31
+ source?: string;
32
+ };
26
33
  source?: string;
27
34
  };
28
35
  packageLockHash?: string;
@@ -84,6 +91,11 @@ type TWorktreeBootstrapInputs = {
84
91
  packageLockHash?: string;
85
92
  proteumConfigHash?: string;
86
93
  proteumVersion: string;
94
+ rootEnv?: {
95
+ filepath: string;
96
+ present: boolean;
97
+ required: boolean;
98
+ };
87
99
  };
88
100
 
89
101
  type TRunCaptureResult = {
@@ -159,6 +171,32 @@ const findVisibleDirectory = (startPath: string, directoryName: string) => {
159
171
  }
160
172
  };
161
173
 
174
+ const readJsonFile = (filepath: string) => {
175
+ try {
176
+ return fs.readJSONSync(filepath) as Record<string, unknown>;
177
+ } catch {
178
+ return {};
179
+ }
180
+ };
181
+
182
+ const hasWorkspaceRootTooling = (workspaceRoot: string) => {
183
+ if (fs.existsSync(path.join(workspaceRoot, 'prisma.config.ts'))) return true;
184
+
185
+ const packageJson = readJsonFile(path.join(workspaceRoot, 'package.json'));
186
+ return Array.isArray(packageJson.workspaces);
187
+ };
188
+
189
+ const resolveWorkspaceRootEnv = (appRoot: string) => {
190
+ const packageLockFilepath = findNearestExistingPath(appRoot, 'package-lock.json');
191
+ if (!packageLockFilepath) return undefined;
192
+
193
+ const workspaceRoot = path.dirname(packageLockFilepath);
194
+ if (workspaceRoot === normalizePath(appRoot)) return undefined;
195
+ if (!hasWorkspaceRootTooling(workspaceRoot)) return undefined;
196
+
197
+ return path.join(workspaceRoot, '.env');
198
+ };
199
+
162
200
  const hashFile = (filepath: string | undefined) => {
163
201
  if (!filepath || !fs.existsSync(filepath)) return undefined;
164
202
 
@@ -177,6 +215,7 @@ const readMarker = (markerFilepath: string) => {
177
215
 
178
216
  const readInputs = (appRoot: string, proteumVersion: string): TWorktreeBootstrapInputs => {
179
217
  const packageLockFilepath = findNearestExistingPath(appRoot, 'package-lock.json');
218
+ const rootEnvFilepath = resolveWorkspaceRootEnv(appRoot);
180
219
 
181
220
  return {
182
221
  agentsHash: hashFile(path.join(appRoot, 'AGENTS.md')),
@@ -186,6 +225,13 @@ const readInputs = (appRoot: string, proteumVersion: string): TWorktreeBootstrap
186
225
  packageLockHash: hashFile(packageLockFilepath),
187
226
  proteumConfigHash: hashFile(path.join(appRoot, 'proteum.config.ts')),
188
227
  proteumVersion,
228
+ rootEnv: rootEnvFilepath
229
+ ? {
230
+ filepath: rootEnvFilepath,
231
+ present: fs.existsSync(rootEnvFilepath),
232
+ required: true,
233
+ }
234
+ : undefined,
189
235
  };
190
236
  };
191
237
 
@@ -217,6 +263,8 @@ const collectStaleReasons = ({
217
263
  if (marker.agentsHash !== inputs.agentsHash)
218
264
  reasons.push({ code: 'worktree-bootstrap/agents-changed', message: 'AGENTS.md changed since bootstrap.' });
219
265
  if (!inputs.envPresent) reasons.push({ code: 'worktree-bootstrap/env-missing', message: '.env is missing.' });
266
+ if (inputs.rootEnv?.required && !inputs.rootEnv.present)
267
+ reasons.push({ code: 'worktree-bootstrap/root-env-missing', message: 'Workspace root .env is missing.' });
220
268
  if (!inputs.manifestPresent)
221
269
  reasons.push({ code: 'worktree-bootstrap/manifest-missing', message: '.proteum/manifest.json is missing.' });
222
270
  if (!inputs.nodeModulesPresent && !dependenciesWereIntentionallySkipped(marker, inputs))
@@ -309,18 +357,63 @@ const resolveDependencyAction = ({
309
357
  return 'up-to-date';
310
358
  };
311
359
 
360
+ const resolveSourceRootEnv = (source: string) => {
361
+ const sourceWorkspaceRootEnv = resolveWorkspaceRootEnv(source);
362
+ if (sourceWorkspaceRootEnv && fs.existsSync(sourceWorkspaceRootEnv)) return sourceWorkspaceRootEnv;
363
+
364
+ const sourceEnvFilepath = path.join(path.resolve(source), '.env');
365
+ return fs.existsSync(sourceEnvFilepath) ? sourceEnvFilepath : undefined;
366
+ };
367
+
312
368
  const requireSourceEnvWhenNeeded = ({ appRoot, source }: { appRoot: string; source?: string }) => {
313
369
  const envFilepath = path.join(appRoot, '.env');
314
- if (fs.existsSync(envFilepath)) return { copied: false, present: true, source: undefined };
370
+ const rootEnvFilepath = resolveWorkspaceRootEnv(appRoot);
371
+ let copied = false;
372
+ let copiedAt: string | undefined;
373
+ let sourceForEnv: string | undefined;
315
374
 
316
- if (!source) throw new Error('This worktree is missing .env. Pass --source <app-root> with a readable source .env.');
375
+ if (!fs.existsSync(envFilepath)) {
376
+ if (!source) throw new Error('This worktree is missing .env. Pass --source <app-root> with a readable source .env.');
317
377
 
318
- const sourceEnvFilepath = path.join(path.resolve(source), '.env');
319
- if (!fs.existsSync(sourceEnvFilepath)) throw new Error(`Source .env does not exist: ${sourceEnvFilepath}`);
378
+ const sourceEnvFilepath = path.join(path.resolve(source), '.env');
379
+ if (!fs.existsSync(sourceEnvFilepath)) throw new Error(`Source .env does not exist: ${sourceEnvFilepath}`);
320
380
 
321
- fs.copyFileSync(sourceEnvFilepath, envFilepath);
381
+ fs.copyFileSync(sourceEnvFilepath, envFilepath);
382
+ copied = true;
383
+ copiedAt = nowIso();
384
+ sourceForEnv = path.resolve(source);
385
+ }
322
386
 
323
- return { copied: true, copiedAt: nowIso(), present: true, source: path.resolve(source) };
387
+ const root: TWorktreeBootstrapMarker['env']['root'] | undefined = rootEnvFilepath
388
+ ? {
389
+ copied: false,
390
+ filepath: rootEnvFilepath,
391
+ present: fs.existsSync(rootEnvFilepath),
392
+ }
393
+ : undefined;
394
+
395
+ if (root && !root.present) {
396
+ if (!source) throw new Error('This worktree is missing workspace root .env. Pass --source <app-root> with a readable source .env.');
397
+
398
+ const sourceRootEnvFilepath = resolveSourceRootEnv(source);
399
+ if (!sourceRootEnvFilepath) {
400
+ throw new Error(`Source workspace root .env does not exist and source app .env is missing: ${path.resolve(source)}`);
401
+ }
402
+
403
+ fs.copyFileSync(sourceRootEnvFilepath, root.filepath);
404
+ root.copied = true;
405
+ root.copiedAt = nowIso();
406
+ root.present = true;
407
+ root.source = sourceRootEnvFilepath;
408
+ }
409
+
410
+ return {
411
+ copied,
412
+ ...(copiedAt ? { copiedAt } : {}),
413
+ present: fs.existsSync(envFilepath),
414
+ ...(root ? { root } : {}),
415
+ ...(sourceForEnv ? { source: sourceForEnv } : {}),
416
+ };
324
417
  };
325
418
 
326
419
  const writeMarker = (appRoot: string, marker: TWorktreeBootstrapMarker) => {
@@ -112,7 +112,7 @@ Default compact command output follows this shape:
112
112
 
113
113
  `proteum runtime status` emits the current app manifest summary, tracked dev sessions, selected live session, MCP URL, health status, configured router/HMR port inspection, and a suggested next command. Use it before starting another dev server, and use its Start Dev command instead of probing page bodies when the default port is occupied. If it reports that the same app already responds on the configured port without a live tracked session, use or repair that runtime instead of starting a second server.
114
114
 
115
- Inside `/.codex/worktrees/`, `proteum dev`, `proteum refresh`, `proteum runtime status`, `proteum verify`, and MCP `workflow_start` require a fresh `.proteum/worktree-bootstrap.json`. If the marker is missing, run `npx proteum worktree init --source <source-app-root>`. If hashes, `.env`, `.proteum/manifest.json`, `node_modules`, or the Proteum version are stale, run the returned `npx proteum worktree init --source <source-app-root> --refresh` command. `PROTEUM_ALLOW_UNBOOTSTRAPPED_WORKTREE=1` bypasses the block but remains visible in runtime status, doctor diagnostics, and MCP output.
115
+ Inside `/.codex/worktrees/`, `proteum dev`, `proteum refresh`, `proteum runtime status`, `proteum verify`, and MCP `workflow_start` require a fresh `.proteum/worktree-bootstrap.json`. If the marker is missing, run `npx proteum worktree init --source <source-app-root>`. If hashes, app `.env`, workspace-root `.env` for monorepos with root tooling, `.proteum/manifest.json`, `node_modules`, or the Proteum version are stale, run the returned `npx proteum worktree init --source <source-app-root> --refresh` command. `PROTEUM_ALLOW_UNBOOTSTRAPPED_WORKTREE=1` bypasses the block but remains visible in runtime status, doctor diagnostics, and MCP output.
116
116
 
117
117
  During `proteum dev`, `/__proteum/mcp` exposes compact `workflow_start`, `runtime_status`, `orient`, `instructions_resolve`, `route_candidates`, `explain_summary`, `doctor`, `diagnose`, `trace_*`, `perf_*`, and `logs_tail` tools without spawning CLI commands for each repeated read. `proteum dev` also ensures one managed machine `proteum mcp` daemon is running. Through the machine router, call `workflow_start` with `cwd` or a known `projectId`; if routing is ambiguous or returns offline app candidates, use `project_resolve { cwd }`, follow the selected app root's port-inspected next action when needed, then pass the selected live `projectId` to follow-up app-bound tools.
118
118
 
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.5.3",
4
+ "version": "2.5.4",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/proteum.git",
7
7
  "license": "MIT",
@@ -153,6 +153,81 @@ test('worktree bootstrap requires a source env only when .env is missing', async
153
153
  assert.equal(result.status.blocking, false);
154
154
  });
155
155
 
156
+ test('worktree bootstrap copies workspace root env for monorepo root tooling', async () => {
157
+ const targetRepoRoot = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'proteum-worktree-monorepo-')), '.codex', 'worktrees', 'fixture-repo');
158
+ const appRoot = path.join(targetRepoRoot, 'apps', 'product');
159
+ const sourceRepoRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'proteum-worktree-source-repo-'));
160
+ const sourceAppRoot = path.join(sourceRepoRoot, 'apps', 'product');
161
+
162
+ writeFile(path.join(targetRepoRoot, 'package.json'), '{"workspaces":["apps/*"]}\n');
163
+ writeFile(path.join(targetRepoRoot, 'package-lock.json'), '{"lockfileVersion":3}\n');
164
+ writeFile(path.join(targetRepoRoot, 'prisma.config.ts'), 'export default {};\n');
165
+ fs.mkdirSync(path.join(targetRepoRoot, 'node_modules'), { recursive: true });
166
+ writeFile(path.join(appRoot, 'package.json'), '{"name":"fixture-product"}\n');
167
+ writeFile(path.join(appRoot, 'proteum.config.ts'), 'export default {};\n');
168
+ writeFile(path.join(appRoot, 'AGENTS.md'), '# Agents\n');
169
+ writeFile(path.join(appRoot, '.proteum', 'manifest.json'), '{"version":10}\n');
170
+
171
+ writeFile(path.join(sourceRepoRoot, 'package.json'), '{"workspaces":["apps/*"]}\n');
172
+ writeFile(path.join(sourceRepoRoot, 'package-lock.json'), '{"lockfileVersion":3}\n');
173
+ writeFile(path.join(sourceRepoRoot, 'prisma.config.ts'), 'export default {};\n');
174
+ writeFile(path.join(sourceRepoRoot, '.env'), 'DATABASE_URL=postgres://root\n');
175
+ writeFile(path.join(sourceAppRoot, '.env'), 'PORT=3021\n');
176
+
177
+ const result = await runWorktreeBootstrapInit({
178
+ appRoot,
179
+ coreRoot,
180
+ proteumVersion: 'test',
181
+ runDependencies: noOpDeps,
182
+ runRefresh: noOpRefresh,
183
+ runRuntimeStatus: noOpRuntime,
184
+ source: sourceAppRoot,
185
+ });
186
+
187
+ assert.equal(fs.readFileSync(path.join(appRoot, '.env'), 'utf8'), 'PORT=3021\n');
188
+ assert.equal(fs.readFileSync(path.join(targetRepoRoot, '.env'), 'utf8'), 'DATABASE_URL=postgres://root\n');
189
+ assert.equal(result.marker.env.root.present, true);
190
+ assert.equal(result.marker.env.root.copied, true);
191
+ assert.equal(result.status.blocking, false);
192
+ });
193
+
194
+ test('worktree bootstrap falls back to source app env for missing workspace root env', async () => {
195
+ const targetRepoRoot = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'proteum-worktree-root-env-fallback-')), '.codex', 'worktrees', 'fixture-repo');
196
+ const appRoot = path.join(targetRepoRoot, 'apps', 'api');
197
+ const sourceRepoRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'proteum-worktree-source-repo-fallback-'));
198
+ const sourceAppRoot = path.join(sourceRepoRoot, 'apps', 'api');
199
+
200
+ writeFile(path.join(targetRepoRoot, 'package.json'), '{"workspaces":["apps/*"]}\n');
201
+ writeFile(path.join(targetRepoRoot, 'package-lock.json'), '{"lockfileVersion":3}\n');
202
+ writeFile(path.join(targetRepoRoot, 'prisma.config.ts'), 'export default {};\n');
203
+ fs.mkdirSync(path.join(targetRepoRoot, 'node_modules'), { recursive: true });
204
+ writeFile(path.join(appRoot, 'package.json'), '{"name":"fixture-api"}\n');
205
+ writeFile(path.join(appRoot, 'proteum.config.ts'), 'export default {};\n');
206
+ writeFile(path.join(appRoot, 'AGENTS.md'), '# Agents\n');
207
+ writeFile(path.join(appRoot, '.proteum', 'manifest.json'), '{"version":10}\n');
208
+
209
+ writeFile(path.join(sourceRepoRoot, 'package.json'), '{"workspaces":["apps/*"]}\n');
210
+ writeFile(path.join(sourceRepoRoot, 'package-lock.json'), '{"lockfileVersion":3}\n');
211
+ writeFile(path.join(sourceRepoRoot, 'prisma.config.ts'), 'export default {};\n');
212
+ writeFile(path.join(sourceAppRoot, '.env'), 'DATABASE_URL=postgres://app\nPORT=3022\n');
213
+
214
+ const result = await runWorktreeBootstrapInit({
215
+ appRoot,
216
+ coreRoot,
217
+ proteumVersion: 'test',
218
+ runDependencies: noOpDeps,
219
+ runRefresh: noOpRefresh,
220
+ runRuntimeStatus: noOpRuntime,
221
+ source: sourceAppRoot,
222
+ });
223
+
224
+ assert.equal(fs.readFileSync(path.join(appRoot, '.env'), 'utf8'), 'DATABASE_URL=postgres://app\nPORT=3022\n');
225
+ assert.equal(fs.readFileSync(path.join(targetRepoRoot, '.env'), 'utf8'), 'DATABASE_URL=postgres://app\nPORT=3022\n');
226
+ assert.equal(result.marker.env.root.present, true);
227
+ assert.equal(result.marker.env.root.source, path.join(sourceAppRoot, '.env'));
228
+ assert.equal(result.status.blocking, false);
229
+ });
230
+
156
231
  test('worktree bootstrap detects missing env manifest node_modules and version changes', async () => {
157
232
  const appRoot = createCodexAppRoot();
158
233
  writeBootstrapFixture(appRoot);