proteum 2.5.4 → 2.5.6
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 +1 -1
- package/README.md +11 -10
- package/agents/project/AGENTS.md +6 -6
- package/agents/project/CODING_STYLE.md +1 -1
- package/agents/project/diagnostics.md +2 -2
- package/agents/project/root/AGENTS.md +6 -6
- package/agents/project/tests/AGENTS.md +1 -1
- package/cli/commands/configure.ts +63 -4
- package/cli/index.ts +24 -18
- package/cli/mcp/router.ts +61 -15
- package/cli/presentation/commands.ts +13 -8
- package/cli/runtime/freshCopyPreflight.ts +767 -0
- package/cli/runtime/monorepoCommands.ts +625 -0
- package/cli/runtime/worktreeBootstrap.ts +163 -0
- package/cli/utils/agents.ts +156 -38
- package/docs/agent-routing.md +3 -3
- package/docs/diagnostics.md +2 -2
- package/docs/mcp.md +7 -6
- package/docs/request-tracing.md +1 -1
- package/package.json +1 -1
- package/tests/agents-utils.test.cjs +63 -3
- package/tests/cli-mcp-command.test.cjs +60 -11
- package/tests/mcp.test.cjs +98 -1
- package/tests/worktree-bootstrap.test.cjs +98 -0
package/AGENTS.md
CHANGED
|
@@ -45,7 +45,7 @@ npx prisma migrate dev --config ./prisma.config.ts --name <migration name>
|
|
|
45
45
|
|
|
46
46
|
[optional body]
|
|
47
47
|
```
|
|
48
|
-
If the user replies exactly `commit`, treat it as conversation-wide and cross-project, not task-scoped. Identify every affected git repository or worktree touched since the last `commit` and, if there has been no prior `commit`, since the beginning of the whole conversation. In each affected repository or worktree, stage all conversation-related changed files with `git add` while still excluding unrelated pre-existing user changes or incidental untracked files, then create one `git commit`. Do not omit linked local dependencies, framework repos, connected projects, or producer apps when they were changed to make the delivered behavior actually work.
|
|
48
|
+
If the user replies exactly `commit`, treat it as conversation-wide and cross-project, not task-scoped. Identify every affected git repository or worktree touched since the last `commit` and, if there has been no prior `commit`, since the beginning of the whole conversation. In each affected repository or worktree, stage all conversation-related changed files with `git add` while still excluding unrelated pre-existing user changes or incidental untracked files, then create one `git commit`. Do not run downstream project commit-time verification such as `proteum refresh`, targeted lint, typecheck, or test commands when committing this framework repository itself unless the user explicitly asks for those checks. Do not omit linked local dependencies, framework repos, connected projects, or producer apps when they were changed to make the delivered behavior actually work.
|
|
49
49
|
When the user asks to push, explain the currently unpushed commits in short, minimalistic bullet points in plain language, like you would do to your grandma. Start each bullet with a verb in the past.
|
|
50
50
|
When an optional commit body is useful, write it as a short, minimalistic bullet list explaining what changed in this thread in plain language, like you would do to your grandma. Start each bullet with a verb in the past. Do not print a separate prompt asking for that explanation.
|
|
51
51
|
|
package/README.md
CHANGED
|
@@ -473,7 +473,7 @@ Every `proteum dev` start runs the same idempotent instruction check. It updates
|
|
|
473
473
|
|
|
474
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
|
-
`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).
|
|
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 and `data.readiness` to choose and prepare 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
|
|
|
478
478
|
## Dev Commands
|
|
479
479
|
|
|
@@ -597,15 +597,16 @@ Proteum answers those questions with explicit artifacts:
|
|
|
597
597
|
If you are an LLM or automation agent, start here:
|
|
598
598
|
|
|
599
599
|
1. Use `proteum mcp` as the one registered MCP server; `proteum dev` ensures the managed machine daemon is running.
|
|
600
|
-
2. Call MCP `workflow_start` with `cwd` or a known `projectId`; if it is ambiguous or returns offline app candidates, use `project_resolve { cwd }`, choose the intended app root, follow its port-inspected next
|
|
601
|
-
3. If the
|
|
602
|
-
4.
|
|
603
|
-
5.
|
|
604
|
-
6.
|
|
605
|
-
7. Use
|
|
606
|
-
8.
|
|
607
|
-
9.
|
|
608
|
-
10.
|
|
600
|
+
2. Call MCP `workflow_start` with `cwd` or a known `projectId`; if it is ambiguous or returns offline app candidates, use `project_resolve { cwd }`, choose the intended app root, follow its fresh-copy readiness and port-inspected next actions when needed, then retry `workflow_start`.
|
|
601
|
+
3. If `workflow_start` returns `data.readiness.state="blocked"`, resolve the returned setup actions first. The read-only readiness preflight covers app/root `.env`, dependency install root, generated manifest state, local connected producer apps, Prisma/client readiness, redacted database URL shape, local database TCP reachability, and exact safe setup commands.
|
|
602
|
+
4. If the app root is inside `/.codex/worktrees/` and `workflow_start` or a guarded CLI command reports missing/stale bootstrap, run the returned `npx proteum worktree init --source <source-app-root>` command before runtime reads.
|
|
603
|
+
5. Use the returned live `projectId` with MCP `runtime_status`, `orient`, `instructions_resolve`, `route_candidates`, `explain_summary`, `diagnose`, `trace_show`, `perf_request`, and `logs_tail` before CLI equivalents for repeated read-only app state.
|
|
604
|
+
6. Treat returned instruction previews as the allowed scope for read-only discovery and diagnostics. Read full file contents only before edits or git writes, when `fullRead`/`fullReadPolicy` requires it, or when compact previews are insufficient.
|
|
605
|
+
7. Use compact CLI commands for fallback, `dev`, `build`, `check`, `verify`, migrations, E2E, and final reproducible terminal evidence.
|
|
606
|
+
8. Use `proteum diagnose`, `proteum perf`, and compact `proteum trace` for reproducible command evidence when MCP is unavailable or the terminal output itself is needed.
|
|
607
|
+
9. If machine MCP routing fails, run `proteum mcp status` and `proteum runtime status` from the intended app root; if no live session exists, use the exact MCP offline or runtime-status next action. If the same app already responds on the configured port without live tracking, use or repair that runtime instead of starting another server. If a live session exists but runtime/MCP is unreachable, stop the listed session file first, then start dev again and retry `workflow_start`. Do not run diagnose, trace, or perf reads while runtime health is unreachable, and do not `curl` normal page routes to identify port ownership.
|
|
608
|
+
10. Inspect `server/index.ts`, controllers, services, or pages only after the routing/diagnostic surfaces identify the relevant owner. Do not run broad owner searches after MCP already returned the route/page/controller owner.
|
|
609
|
+
11. If the task touches a protected route or controller in dev and login UX is not the feature under test, use `proteum e2e --session-email <email> --session-role <role>` for Playwright suites or `proteum session <email> --role <role>` before direct HTTP calls.
|
|
609
610
|
|
|
610
611
|
For implementation rules in a real Proteum app, treat the routed local `AGENTS.md` files plus `proteum orient`, compact CLI diagnostics, and MCP repeated-read surfaces as the task contract. This README is the framework overview, not the project-local instruction layer.
|
|
611
612
|
|
package/agents/project/AGENTS.md
CHANGED
|
@@ -31,7 +31,7 @@ Managed compact root routers must use trigger -> canonical instruction file refe
|
|
|
31
31
|
- If the user asks to implement a feature, first inspect the relevant existing surface and state any implementation problem, pain point, attention point, inconsistency, missing information, or question you see. If anything needs clarification or a decision, pause before editing, ask the user what decision to take, and resume only after the user answers.
|
|
32
32
|
- If the task is ambiguous, generated, connected, or multi-repo, start with MCP `workflow_start` and then MCP `orient { projectId, query }` only if the bootstrap did not return a sufficient owner or next action; use `npx proteum orient <query>` only when MCP is unavailable or terminal evidence is required.
|
|
33
33
|
- Treat Proteum CLI and MCP output as the workflow router. Treat instruction previews returned by MCP `workflow_start` or `instructions_resolve { projectId }` as the allowed instruction scope for read-only discovery and diagnostics. Read full file contents only before edits or git writes, when returned `fullRead`/`fullReadPolicy` requires it, or when the compact preview is insufficient. Do not read broad instruction folders or every managed instruction file up front.
|
|
34
|
-
- When a Proteum MCP client is available, first call MCP `workflow_start` with `cwd` or a known `projectId`. If it is ambiguous or returns offline app candidates, call `project_resolve { cwd }`, select the intended app root, start exactly one dev server from that app root when needed, then retry `workflow_start`. Pass the returned live `projectId` to every follow-up app-bound MCP tool. `npx proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon. Prefer MCP `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `route_candidates`, `doctor`, `diagnose`, `trace_show`, `perf_request`, `logs_tail`, and `db_query` for read-only runtime/status/orientation/owner/route/trace/perf/log/database reads. Do not run CLI equivalents after a successful MCP result for the same read. Do not run broad source searches for route/page/controller ownership after MCP returns the owner. Use CLI commands when you need reproducible terminal validation, dev/build/check workflows, fallback repair, or output to share with a human.
|
|
34
|
+
- When a Proteum MCP client is available, first call MCP `workflow_start` with `cwd` or a known `projectId`. If it is ambiguous or returns offline app candidates, call `project_resolve { cwd }`, select the intended app root, resolve any returned `data.readiness.state="blocked"` fresh-copy setup actions, start exactly one dev server from that app root when needed, then retry `workflow_start`. Pass the returned live `projectId` to every follow-up app-bound MCP tool. `npx proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon. Prefer MCP `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `route_candidates`, `doctor`, `diagnose`, `trace_show`, `perf_request`, `logs_tail`, and `db_query` for read-only runtime/status/orientation/owner/route/trace/perf/log/database reads. Do not run CLI equivalents after a successful MCP result for the same read. Do not run broad source searches for route/page/controller ownership after MCP returns the owner. Use CLI commands when you need reproducible terminal validation, dev/build/check workflows, fallback repair, or output to share with a human.
|
|
35
35
|
- MCP payloads are compact single-line `proteum-mcp-v1` JSON with capped and paginated detail. Do not expand MCP output for human readability.
|
|
36
36
|
- For every non-trivial coding task, load and follow root-level `DOCUMENTATION.md` before coding.
|
|
37
37
|
- For bug fixes, regressions, incidents, broken public routes, auth/OAuth failures, integration failures, or production behavior fixes, load and follow root-level `DOCUMENTATION.md` before coding so the relevant fix note, regression-test docs, ADR, or explicit skip reason is handled in the same change.
|
|
@@ -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.
|
|
56
|
+
Then treat `commit` as conversation-wide and cross-project, not task-scoped. For downstream Proteum apps, before staging or committing, run only this commit-time verification: `proteum refresh`, then the targeted lint, typecheck, and test commands that match the conversation changes in parallel. Skip this downstream app verification when the affected repository is the Proteum framework repository itself; use the framework repo `AGENTS.md` commit workflow there. Do not run coverage, full `npm run check`, repository `check:commit`, unrelated broad suites, or any other check unless the user explicitly asks for it in the same request. Report any blocker instead of committing through failed commit-time verification. 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.
|
|
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. Downstream app commit workflows run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; framework-repo commit workflows skip this downstream app verification. 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.
|
|
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. During downstream app commit workflows, run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; skip this verification for framework-repo commits and 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
|
|
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 applicable commit-time verification succeeds. For downstream apps, commit-time verification is limited to `proteum refresh`, then targeted lint, typecheck, and test commands in parallel. For the Proteum framework repository itself, skip this downstream app verification and use the framework repo `AGENTS.md` commit workflow. This exception does not allow coverage, full `npm run check`, repository `check:commit`, unrelated broad suites, or other checks 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;
|
|
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; downstream app commit-only workflows run `proteum refresh`, then targeted lint, typecheck, and test commands in parallel unless the user explicitly requests more, while framework-repo commits skip this downstream app verification. 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.
|
|
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. Downstream app commit-only workflows run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; framework-repo commit workflows skip this downstream app verification. 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
|
|
|
@@ -4,7 +4,7 @@ This file is the canonical source of truth for diagnostics, temporary instrument
|
|
|
4
4
|
|
|
5
5
|
## Initial Triage
|
|
6
6
|
|
|
7
|
-
- Start with compact machine-readable app state before reading large parts of the codebase. When a Proteum MCP client is available, call MCP `workflow_start` with `cwd` or a known `projectId`; if it is ambiguous or returns offline app candidates, call `project_resolve { cwd }`, select the intended app root, start exactly one dev server from that app root when needed, then retry `workflow_start`. Use the returned live `projectId` for follow-up MCP `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `route_candidates`, `doctor`, `diagnose`, `trace_latest`, `trace_show`, `perf_top`, `perf_request`, `logs_tail`, and `db_query`.
|
|
7
|
+
- Start with compact machine-readable app state before reading large parts of the codebase. When a Proteum MCP client is available, call MCP `workflow_start` with `cwd` or a known `projectId`; if it is ambiguous or returns offline app candidates, call `project_resolve { cwd }`, select the intended app root, resolve any returned `data.readiness.state="blocked"` fresh-copy setup actions, start exactly one dev server from that app root when needed, then retry `workflow_start`. Use the returned live `projectId` for follow-up MCP `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `route_candidates`, `doctor`, `diagnose`, `trace_latest`, `trace_show`, `perf_top`, `perf_request`, `logs_tail`, and `db_query`.
|
|
8
8
|
- Do not run CLI equivalents after a successful MCP result for the same read. Do not run broad source searches for route/page/controller ownership after MCP returns the owner. Use compact CLI commands such as `npx proteum orient <query>`, `npx proteum runtime status`, `npx proteum connect`, `npx proteum explain`, `npx proteum doctor`, and `npx proteum doctor --contracts` when MCP is unavailable, when generated artifacts or manifest-owned files may be stale, or when you need a reproducible shell command, validation step, or CI-like output.
|
|
9
9
|
- MCP payloads are compact `proteum-mcp-v1` JSON and are capped/paginated by default. Use selected instruction previews for read-only discovery and diagnostics; read full files or request full MCP detail only when returned `fullRead`/`fullReadPolicy` or omitted-detail hints require it.
|
|
10
10
|
- Use full-detail escape hatches only after compact output identifies the missing detail: `npx proteum explain --manifest`, `npx proteum diagnose <target> --full`, `npx proteum trace show <requestId> --events`, or `npx proteum perf request <requestId> --full`.
|
|
@@ -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.
|
|
67
|
+
- When the touched surface can affect coding-style enforcement, run the targeted lint or typecheck command for that surface before finishing. Downstream app commit-only workflows run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; framework-repo commit workflows skip this downstream app verification. 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.
|
|
@@ -18,7 +18,7 @@ Managed compact root routers must use trigger -> canonical instruction file refe
|
|
|
18
18
|
- If the user asks to implement a feature, first inspect the relevant existing surface and state any implementation problem, pain point, attention point, inconsistency, missing information, or question you see. If anything needs clarification or a decision, pause before editing, ask the user what decision to take, and resume only after the user answers.
|
|
19
19
|
- If the task is ambiguous, generated, connected, or multi-repo, start with MCP `workflow_start` and then MCP `orient { projectId, query }` only if the bootstrap did not return a sufficient owner or next action; use `npx proteum orient <query>` only when MCP is unavailable or terminal evidence is required.
|
|
20
20
|
- Treat Proteum CLI and MCP output as the workflow router. Treat instruction previews returned by MCP `workflow_start` or `instructions_resolve { projectId }` as the allowed instruction scope for read-only discovery and diagnostics. Read full file contents only before edits or git writes, when returned `fullRead`/`fullReadPolicy` requires it, or when the compact preview is insufficient. Do not read broad instruction folders or every managed instruction file up front.
|
|
21
|
-
- When a Proteum MCP client is available, first call MCP `workflow_start` with `cwd` or a known `projectId`. If it is ambiguous or returns offline app candidates, call `project_resolve { cwd }`, select the intended app root, start exactly one dev server from that app root when needed, then retry `workflow_start`. Pass the returned live `projectId` to every follow-up app-bound MCP tool. `npx proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon. Prefer MCP `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `route_candidates`, `doctor`, `diagnose`, `trace_show`, `perf_request`, `logs_tail`, and `db_query` for read-only runtime/status/orientation/owner/route/trace/perf/log/database reads. Do not run CLI equivalents after a successful MCP result for the same read. Do not run broad source searches for route/page/controller ownership after MCP returns the owner. Use CLI commands when you need reproducible terminal validation, dev/build/check workflows, fallback repair, or output to share with a human.
|
|
21
|
+
- When a Proteum MCP client is available, first call MCP `workflow_start` with `cwd` or a known `projectId`. If it is ambiguous or returns offline app candidates, call `project_resolve { cwd }`, select the intended app root, resolve any returned `data.readiness.state="blocked"` fresh-copy setup actions, start exactly one dev server from that app root when needed, then retry `workflow_start`. Pass the returned live `projectId` to every follow-up app-bound MCP tool. `npx proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon. Prefer MCP `runtime_status`, `orient`, `instructions_resolve`, `explain_summary`, `route_candidates`, `doctor`, `diagnose`, `trace_show`, `perf_request`, `logs_tail`, and `db_query` for read-only runtime/status/orientation/owner/route/trace/perf/log/database reads. Do not run CLI equivalents after a successful MCP result for the same read. Do not run broad source searches for route/page/controller ownership after MCP returns the owner. Use CLI commands when you need reproducible terminal validation, dev/build/check workflows, fallback repair, or output to share with a human.
|
|
22
22
|
- MCP payloads are compact single-line `proteum-mcp-v1` JSON with capped and paginated detail. Do not expand MCP output for human readability.
|
|
23
23
|
- For every non-trivial coding task, load and follow root-level `DOCUMENTATION.md` before coding.
|
|
24
24
|
- For bug fixes, regressions, incidents, broken public routes, auth/OAuth failures, integration failures, or production behavior fixes, load and follow root-level `DOCUMENTATION.md` before coding so the relevant fix note, regression-test docs, ADR, or explicit skip reason is handled in the same change.
|
|
@@ -39,7 +39,7 @@ Managed compact root routers must use trigger -> canonical instruction file refe
|
|
|
39
39
|
|
|
40
40
|
[optional body]
|
|
41
41
|
```
|
|
42
|
-
Then treat `commit` as conversation-wide and cross-project, not task-scoped. 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.
|
|
42
|
+
Then treat `commit` as conversation-wide and cross-project, not task-scoped. For downstream Proteum apps, before staging or committing, run only this commit-time verification: `proteum refresh`, then the targeted lint, typecheck, and test commands that match the conversation changes in parallel. Skip this downstream app verification when the affected repository is the Proteum framework repository itself; use the framework repo `AGENTS.md` commit workflow there. Do not run coverage, full `npm run check`, repository `check:commit`, unrelated broad suites, or any other check unless the user explicitly asks for it in the same request. Report any blocker instead of committing through failed commit-time verification. 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.
|
|
43
43
|
After providing a commit message or after creating a commit, immediately follow it with this exact prompt and obey it:
|
|
44
44
|
`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.`
|
|
45
45
|
|
|
@@ -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;
|
|
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.
|
|
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; downstream app commit-only workflows run `proteum refresh`, then targeted lint, typecheck, and test commands in parallel unless the user explicitly requests more, while framework-repo commits skip this downstream app verification. 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. Downstream app commit workflows run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; framework-repo commit workflows skip this downstream app verification. 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.
|
|
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. During downstream app commit workflows, run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; skip this verification for framework-repo commits and 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.
|
|
@@ -311,7 +311,7 @@ Verify at the correct layer:
|
|
|
311
311
|
- 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.
|
|
312
312
|
- 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`.
|
|
313
313
|
- Do not run `git restore` or `git reset`.
|
|
314
|
-
- 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. Any other write-mode git action requires an explicit user request.
|
|
314
|
+
- 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 applicable commit-time verification succeeds. For downstream apps, commit-time verification is limited to `proteum refresh`, then targeted lint, typecheck, and test commands in parallel. For the Proteum framework repository itself, skip this downstream app verification and use the framework repo `AGENTS.md` commit workflow. This exception does not allow coverage, full `npm run check`, repository `check:commit`, unrelated broad suites, or other checks unless the user explicitly requests them in the same message. Any other write-mode git action requires an explicit user request.
|
|
315
315
|
|
|
316
316
|
## Appendix
|
|
317
317
|
|
|
@@ -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.
|
|
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. Downstream app commit-only workflows run only `proteum refresh`, then targeted lint, typecheck, and test commands in parallel; framework-repo commit workflows skip this downstream app verification. 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.
|
|
@@ -14,10 +14,12 @@ import { renderRows } from '../presentation/layout';
|
|
|
14
14
|
import { isLikelyProteumAppRoot } from '../presentation/commands';
|
|
15
15
|
import { renderStep, renderSuccess, renderTitle, renderWarning } from '../presentation/ink';
|
|
16
16
|
import {
|
|
17
|
+
configureMonorepoProjectAgentInstructions,
|
|
17
18
|
configureProjectAgentInstructions,
|
|
18
19
|
findLikelyRepoRoot,
|
|
19
20
|
isInsideDirectory,
|
|
20
21
|
resolveCanonicalPath,
|
|
22
|
+
type TConfigureMonorepoProjectAgentInstructionsResult,
|
|
21
23
|
type TConfigureProjectAgentInstructionsResult,
|
|
22
24
|
} from '../utils/agents';
|
|
23
25
|
|
|
@@ -68,20 +70,22 @@ const promptMonorepoRoot = async ({
|
|
|
68
70
|
return resolveCanonicalPath(String(response.value || defaultRoot || ''));
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
const promptBlockedOverwritePaths = async (blockedPaths: string[]) => {
|
|
72
|
-
|
|
73
|
+
export const promptBlockedOverwritePaths = async (blockedPaths: string[]) => {
|
|
74
|
+
const uniqueBlockedPaths = [...new Set(blockedPaths)];
|
|
75
|
+
|
|
76
|
+
if (uniqueBlockedPaths.length === 0) return [];
|
|
73
77
|
|
|
74
78
|
console.info(await renderWarning('Proteum found existing paths that block managed instruction updates.'));
|
|
75
79
|
console.info(
|
|
76
80
|
[
|
|
77
81
|
'Choose whether to overwrite each path with a Proteum-managed instruction path:',
|
|
78
|
-
...
|
|
82
|
+
...uniqueBlockedPaths.map((entry) => `- ${entry}`),
|
|
79
83
|
].join('\n'),
|
|
80
84
|
);
|
|
81
85
|
|
|
82
86
|
const overwriteBlockedPaths: string[] = [];
|
|
83
87
|
|
|
84
|
-
for (const blockedPath of
|
|
88
|
+
for (const blockedPath of uniqueBlockedPaths) {
|
|
85
89
|
const response = await prompts(
|
|
86
90
|
{
|
|
87
91
|
type: 'confirm',
|
|
@@ -133,6 +137,12 @@ const renderConfigureResultSections = (result: TConfigureProjectAgentInstruction
|
|
|
133
137
|
return sections;
|
|
134
138
|
};
|
|
135
139
|
|
|
140
|
+
const renderConfigureMonorepoResultSections = (result: TConfigureMonorepoProjectAgentInstructionsResult) =>
|
|
141
|
+
renderConfigureResultSections({
|
|
142
|
+
...result,
|
|
143
|
+
appRoot: result.monorepoRoot,
|
|
144
|
+
});
|
|
145
|
+
|
|
136
146
|
/*----------------------------------
|
|
137
147
|
- COMMAND
|
|
138
148
|
----------------------------------*/
|
|
@@ -218,3 +228,52 @@ export const runConfigureAgentsWizard = async ({
|
|
|
218
228
|
|
|
219
229
|
if (sections.length > 0) console.info(`\n${sections.join('\n\n')}`);
|
|
220
230
|
};
|
|
231
|
+
|
|
232
|
+
export const runConfigureAgentsMonorepoWizard = async ({
|
|
233
|
+
appRoots,
|
|
234
|
+
coreRoot = cli.paths.core.root,
|
|
235
|
+
monorepoRoot,
|
|
236
|
+
}: {
|
|
237
|
+
appRoots: string[];
|
|
238
|
+
coreRoot?: string;
|
|
239
|
+
monorepoRoot: string;
|
|
240
|
+
}) => {
|
|
241
|
+
if (appRoots.length === 0) throw new UsageError(`No Proteum app roots were found under ${monorepoRoot}.`);
|
|
242
|
+
for (const appRoot of appRoots) assertProteumAppRoot(appRoot);
|
|
243
|
+
|
|
244
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
245
|
+
throw new UsageError('`proteum configure agents` is interactive and requires a TTY.');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
console.info(
|
|
249
|
+
[
|
|
250
|
+
await renderTitle('PROTEUM CONFIGURE AGENTS', 'Configure monorepo Proteum instruction files and Claude aliases.'),
|
|
251
|
+
renderRows([
|
|
252
|
+
{ label: 'monorepo root', value: monorepoRoot === process.cwd() ? '.' : monorepoRoot },
|
|
253
|
+
{ label: 'apps', value: String(appRoots.length) },
|
|
254
|
+
]),
|
|
255
|
+
].join('\n\n'),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const preview = configureMonorepoProjectAgentInstructions({
|
|
259
|
+
appRoots,
|
|
260
|
+
coreRoot,
|
|
261
|
+
dryRun: true,
|
|
262
|
+
monorepoRoot,
|
|
263
|
+
});
|
|
264
|
+
const overwriteBlockedPaths = await promptBlockedOverwritePaths(preview.blocked);
|
|
265
|
+
|
|
266
|
+
console.info(await renderStep('[1/1]', 'Writing monorepo root and app instruction files and Claude aliases.'));
|
|
267
|
+
|
|
268
|
+
const result = configureMonorepoProjectAgentInstructions({
|
|
269
|
+
appRoots,
|
|
270
|
+
coreRoot,
|
|
271
|
+
monorepoRoot,
|
|
272
|
+
overwriteBlockedPaths,
|
|
273
|
+
});
|
|
274
|
+
const sections = renderConfigureMonorepoResultSections(result);
|
|
275
|
+
|
|
276
|
+
console.info(await renderSuccess('Proteum-managed monorepo instruction files and Claude aliases are configured.'));
|
|
277
|
+
|
|
278
|
+
if (sections.length > 0) console.info(`\n${sections.join('\n\n')}`);
|
|
279
|
+
};
|
package/cli/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { renderCliOverview, renderCommandHelp, resolveCustomHelpRequest } from '
|
|
|
9
9
|
import { renderCliWelcomeBanner } from './presentation/welcome';
|
|
10
10
|
import { normalizeHelpArgv, normalizeLegacyArgv } from './runtime/argv';
|
|
11
11
|
import { createCli, registeredCommands } from './runtime/commands';
|
|
12
|
+
import { isMonorepoFanoutChild, maybeRunMonorepoCommand } from './runtime/monorepoCommands';
|
|
12
13
|
|
|
13
14
|
const formatInvocation = (argv: string[]) => ['proteum', ...argv].join(' ').trim();
|
|
14
15
|
|
|
@@ -21,6 +22,7 @@ const shouldRenderSharedWelcomeBanner = ({
|
|
|
21
22
|
argv: string[];
|
|
22
23
|
helpRequestKind: 'none' | 'overview' | 'command';
|
|
23
24
|
}) => {
|
|
25
|
+
if (isMonorepoFanoutChild()) return false;
|
|
24
26
|
if (helpRequestKind !== 'none') return false;
|
|
25
27
|
if (argv.length !== 1) return false;
|
|
26
28
|
|
|
@@ -32,27 +34,9 @@ const shouldRenderSharedWelcomeBanner = ({
|
|
|
32
34
|
export const runCli = async (argv: string[] = process.argv.slice(2)) => {
|
|
33
35
|
const normalizedArgv = normalizeHelpArgv(normalizeLegacyArgv(argv), proteumCommandNames);
|
|
34
36
|
const version = String(cli.packageJson.version || '');
|
|
35
|
-
const proteumInstall = resolveFrameworkInstallInfo({
|
|
36
|
-
appRoot: cli.paths.appRoot,
|
|
37
|
-
framework: cli.paths.framework,
|
|
38
|
-
});
|
|
39
37
|
const clipanion = createCli(version);
|
|
40
38
|
const initAvailable = true;
|
|
41
39
|
const helpRequest = resolveCustomHelpRequest(normalizedArgv);
|
|
42
|
-
const shouldRenderWelcomeBanner = shouldRenderSharedWelcomeBanner({
|
|
43
|
-
argv: normalizedArgv,
|
|
44
|
-
helpRequestKind: helpRequest.kind,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (shouldRenderWelcomeBanner) {
|
|
48
|
-
process.stderr.write(
|
|
49
|
-
`${await renderCliWelcomeBanner({
|
|
50
|
-
command: formatInvocation(normalizedArgv),
|
|
51
|
-
installSummary: proteumInstall.summary,
|
|
52
|
-
version,
|
|
53
|
-
})}\n\n`,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
40
|
|
|
57
41
|
if (helpRequest.kind === 'overview') {
|
|
58
42
|
process.stdout.write(
|
|
@@ -77,6 +61,28 @@ export const runCli = async (argv: string[] = process.argv.slice(2)) => {
|
|
|
77
61
|
return;
|
|
78
62
|
}
|
|
79
63
|
|
|
64
|
+
if (await maybeRunMonorepoCommand(normalizedArgv)) return;
|
|
65
|
+
|
|
66
|
+
const shouldRenderWelcomeBanner = shouldRenderSharedWelcomeBanner({
|
|
67
|
+
argv: normalizedArgv,
|
|
68
|
+
helpRequestKind: helpRequest.kind,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (shouldRenderWelcomeBanner) {
|
|
72
|
+
const proteumInstall = resolveFrameworkInstallInfo({
|
|
73
|
+
appRoot: cli.paths.appRoot,
|
|
74
|
+
framework: cli.paths.framework,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
process.stderr.write(
|
|
78
|
+
`${await renderCliWelcomeBanner({
|
|
79
|
+
command: formatInvocation(normalizedArgv),
|
|
80
|
+
installSummary: proteumInstall.summary,
|
|
81
|
+
version,
|
|
82
|
+
})}\n\n`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
80
86
|
await clipanion.runExit(normalizedArgv, Cli.defaultContext);
|
|
81
87
|
};
|
|
82
88
|
|
package/cli/mcp/router.ts
CHANGED
|
@@ -14,7 +14,12 @@ import { z } from 'zod/v4';
|
|
|
14
14
|
import { buildContractsDoctorResponse } from '../../common/dev/contractsDoctor';
|
|
15
15
|
import { buildDoctorResponse } from '../../common/dev/diagnostics';
|
|
16
16
|
import { explainOwner } from '../../common/dev/inspection';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
compactWorkflowStartResponse,
|
|
19
|
+
createMcpPayload,
|
|
20
|
+
stringifyMcpPayload,
|
|
21
|
+
type TProteumMcpNextAction,
|
|
22
|
+
} from '../../common/dev/mcpPayloads';
|
|
18
23
|
import { readProteumManifest } from '../compiler/common/proteumManifest';
|
|
19
24
|
import {
|
|
20
25
|
createMachineMcpDaemonRecord,
|
|
@@ -42,6 +47,7 @@ import {
|
|
|
42
47
|
createWorktreeBootstrapMcpBlockResponse,
|
|
43
48
|
getWorktreeBootstrapStatus,
|
|
44
49
|
} from '../runtime/worktreeBootstrap';
|
|
50
|
+
import { buildFreshCopyPreflight } from '../runtime/freshCopyPreflight';
|
|
45
51
|
|
|
46
52
|
type TDevMcpClient = {
|
|
47
53
|
callTool: (input: { arguments?: Record<string, unknown>; name: string }) => Promise<CallToolResult>;
|
|
@@ -102,6 +108,25 @@ const errorToolResult = (summary: string, data: Record<string, unknown> = {}) =>
|
|
|
102
108
|
true,
|
|
103
109
|
);
|
|
104
110
|
|
|
111
|
+
const dedupeNextActions = (actions: TProteumMcpNextAction[]) => {
|
|
112
|
+
const seen = new Set<string>();
|
|
113
|
+
const output: TProteumMcpNextAction[] = [];
|
|
114
|
+
|
|
115
|
+
for (const action of actions) {
|
|
116
|
+
const key = JSON.stringify({
|
|
117
|
+
command: action.command,
|
|
118
|
+
label: action.label,
|
|
119
|
+
tool: action.tool,
|
|
120
|
+
toolArgs: action.toolArgs,
|
|
121
|
+
});
|
|
122
|
+
if (seen.has(key)) continue;
|
|
123
|
+
seen.add(key);
|
|
124
|
+
output.push(action);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return output;
|
|
128
|
+
};
|
|
129
|
+
|
|
105
130
|
const compactProject = (record: TMachineDevSessionRecord) => ({
|
|
106
131
|
projectId: record.projectId,
|
|
107
132
|
appRoot: record.appRoot,
|
|
@@ -440,7 +465,7 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
|
|
|
440
465
|
}
|
|
441
466
|
};
|
|
442
467
|
|
|
443
|
-
const createOfflineWorkflowStartResult = (offline: TOfflineProject, input: Record<string, unknown>) => {
|
|
468
|
+
const createOfflineWorkflowStartResult = async (offline: TOfflineProject, input: Record<string, unknown>) => {
|
|
444
469
|
const bootstrapStatus = getWorktreeBootstrapStatus({ appRoot: offline.appRoot, proteumVersion: version });
|
|
445
470
|
if (bootstrapStatus.blocking) return jsonToolResult(createWorktreeBootstrapMcpBlockResponse(bootstrapStatus, offline), true);
|
|
446
471
|
|
|
@@ -448,25 +473,30 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
|
|
|
448
473
|
try {
|
|
449
474
|
manifest = readProteumManifest(offline.appRoot);
|
|
450
475
|
} catch (error) {
|
|
476
|
+
const preflight = await buildFreshCopyPreflight({
|
|
477
|
+
appRoot: offline.appRoot,
|
|
478
|
+
baseRoot: offline.appRoot,
|
|
479
|
+
});
|
|
480
|
+
|
|
451
481
|
return jsonToolResult(
|
|
452
482
|
createMcpPayload({
|
|
453
483
|
summary: `Matched offline Proteum app ${offline.appRoot}, but no readable manifest is available.`,
|
|
454
484
|
data: {
|
|
455
485
|
project: offline,
|
|
486
|
+
readiness: preflight.readiness,
|
|
487
|
+
worktreeBootstrap: compactWorktreeBootstrapStatus(bootstrapStatus),
|
|
456
488
|
error: error instanceof Error ? error.message : String(error),
|
|
457
489
|
},
|
|
458
|
-
nextActions: [
|
|
459
|
-
offline.nextAction,
|
|
460
|
-
{
|
|
461
|
-
label: 'Refresh Manifest',
|
|
462
|
-
command: 'npx proteum refresh',
|
|
463
|
-
reason: 'Generate the compact manifest before owner, route, or instruction routing reads.',
|
|
464
|
-
},
|
|
465
|
-
],
|
|
490
|
+
nextActions: dedupeNextActions([...preflight.nextActions, offline.nextAction]),
|
|
466
491
|
}),
|
|
467
492
|
);
|
|
468
493
|
}
|
|
469
494
|
|
|
495
|
+
const preflight = await buildFreshCopyPreflight({
|
|
496
|
+
appRoot: offline.appRoot,
|
|
497
|
+
baseRoot: offline.appRoot,
|
|
498
|
+
manifest,
|
|
499
|
+
});
|
|
470
500
|
const doctor = buildDoctorResponse(manifest);
|
|
471
501
|
const contracts = buildContractsDoctorResponse(manifest);
|
|
472
502
|
const route = typeof input.route === 'string' ? input.route : undefined;
|
|
@@ -495,15 +525,17 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
|
|
|
495
525
|
...payload,
|
|
496
526
|
data: {
|
|
497
527
|
project: offline,
|
|
528
|
+
readiness: preflight.readiness,
|
|
498
529
|
worktreeBootstrap: compactWorktreeBootstrapStatus(bootstrapStatus),
|
|
499
530
|
...payload.data,
|
|
500
531
|
},
|
|
501
|
-
nextActions: [
|
|
532
|
+
nextActions: dedupeNextActions([
|
|
533
|
+
...preflight.nextActions,
|
|
502
534
|
offline.nextAction,
|
|
503
535
|
...(Array.isArray(payload.nextActions)
|
|
504
536
|
? payload.nextActions.filter((action: { label?: unknown }) => action.label !== 'Start Dev')
|
|
505
537
|
: []),
|
|
506
|
-
],
|
|
538
|
+
]),
|
|
507
539
|
});
|
|
508
540
|
};
|
|
509
541
|
|
|
@@ -528,7 +560,7 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
|
|
|
528
560
|
const selectedMatch = matches[0];
|
|
529
561
|
const record = selectedMatch.record;
|
|
530
562
|
|
|
531
|
-
if (!record && selectedMatch.offline) return createOfflineWorkflowStartResult(selectedMatch.offline, input);
|
|
563
|
+
if (!record && selectedMatch.offline) return await createOfflineWorkflowStartResult(selectedMatch.offline, input);
|
|
532
564
|
if (!record) {
|
|
533
565
|
return errorToolResult('Could not resolve a live Proteum project for workflow_start. Call projects_list or project_resolve.', {
|
|
534
566
|
matches: matches.map((match) => match.project),
|
|
@@ -550,7 +582,20 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
|
|
|
550
582
|
if (result.content[0]?.type !== 'text') return result;
|
|
551
583
|
|
|
552
584
|
const payload = JSON.parse(result.content[0].text);
|
|
553
|
-
|
|
585
|
+
let preflight;
|
|
586
|
+
try {
|
|
587
|
+
preflight = await buildFreshCopyPreflight({
|
|
588
|
+
appRoot: record.appRoot,
|
|
589
|
+
baseRoot: record.appRoot,
|
|
590
|
+
manifest: readProteumManifest(record.appRoot),
|
|
591
|
+
});
|
|
592
|
+
} catch (_error) {
|
|
593
|
+
preflight = await buildFreshCopyPreflight({
|
|
594
|
+
appRoot: record.appRoot,
|
|
595
|
+
baseRoot: record.appRoot,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
const routedNextActions: TProteumMcpNextAction[] | undefined = Array.isArray(payload.nextActions)
|
|
554
599
|
? payload.nextActions.map((action: Record<string, unknown>) =>
|
|
555
600
|
action.tool && typeof action.tool === 'string'
|
|
556
601
|
? {
|
|
@@ -568,10 +613,11 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
|
|
|
568
613
|
...payload,
|
|
569
614
|
data: {
|
|
570
615
|
project: compactProject(record),
|
|
616
|
+
readiness: preflight.readiness,
|
|
571
617
|
worktreeBootstrap: compactWorktreeBootstrapStatus(bootstrapStatus),
|
|
572
618
|
...payload.data,
|
|
573
619
|
},
|
|
574
|
-
...
|
|
620
|
+
nextActions: dedupeNextActions([...preflight.nextActions, ...(routedNextActions || [])]),
|
|
575
621
|
});
|
|
576
622
|
} catch (error) {
|
|
577
623
|
await closeClient(record);
|