proteum 2.4.1 → 2.4.3

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 CHANGED
@@ -63,9 +63,9 @@ npx prisma migrate dev --config ./prisma.config.ts --name <migration name>
63
63
  - `/Users/gaetan/Desktop/Projets/klair.work/apps/worker`
64
64
  - Inspect how the relevant reference apps currently use the touched feature, runtime, API, compiler behavior, or generated output before proposing or implementing changes.
65
65
  - Keep the developer-facing contract synchronized when framework work changes CLI commands, profiler capabilities, or the `proteum dev` banner. Update the live surfaces together in the same pass: CLI command/help definitions, profiler panels and dev-only endpoints, banner text/examples, and the most relevant agent docs that describe them, especially `AGENTS.md`, `agents/project/AGENTS.md`, `agents/project/root/AGENTS.md`, `agents/project/app-root/AGENTS.md`, `agents/project/diagnostics.md`, and any narrower `agents/project/**/AGENTS.md` file that mentions the changed workflow.
66
- - Proteum MCP contract: `proteum mcp` is the machine-scope router agents register once, and `proteum dev` exposes each app runtime at `/__proteum/mcp`. `proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon. Agents should start with MCP `workflow_start` using `cwd` or a known `projectId`; ambiguous routing or offline app candidates use `project_resolve { cwd }`, and follow-up live app tools require the returned `projectId`. Dev-hosted app tools are already rooted to their own runtime. Keep MCP tools/resources compact, typed, capped, paginated for full trace detail, and read-only unless a future task explicitly expands the mutation contract. MCP payloads are compact single-line `proteum-mcp-v1` JSON, not pretty-printed human output. Do not implement MCP tools as thin CLI process wrappers when the data is available through manifest readers, tracked sessions, or dev runtime registries.
66
+ - Proteum MCP contract: `proteum mcp` is the machine-scope router agents register once, and `proteum dev` exposes each app runtime at `/__proteum/mcp`. `proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon. Agents should start with MCP `workflow_start` using `cwd` or a known `projectId`; ambiguous routing or offline app candidates use `project_resolve { cwd }`, and follow-up live app tools require the returned `projectId`. Dev-hosted app tools are already rooted to their own runtime. Keep MCP tools/resources compact, typed, capped, paginated for full trace detail, and read-only unless a future task explicitly expands the mutation contract. The database diagnostic exception is still read-only: MCP `db_query` and CLI `proteum db query` allow one capped `SELECT`, `SHOW`, or `EXPLAIN` statement only and return rows plus elapsed milliseconds. MCP payloads are compact single-line `proteum-mcp-v1` JSON, not pretty-printed human output. Do not implement MCP tools as thin CLI process wrappers when the data is available through manifest readers, tracked sessions, or dev runtime registries.
67
67
  - Keep the same-system trace contract explicit when request instrumentation changes: `TRACE_*` controls the retained dev trace store plus the trace/perf CLI, dev-only HTTP endpoints, and bottom profiler, while `ENABLE_PROFILER` enables the reduced request-local `request.profiling` snapshot and `request.finished` hook payload without retaining finished requests globally unless dev trace is also enabled.
68
- - Current CLI banner contract: only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and include the active Proteum installation method. Any extra argument or option skips the banner. Only `proteum dev` clears the interactive terminal before rendering, exposes `CTRL+R` reload plus `CTRL+C` shutdown hotkeys in its session UI, and reports connected app names plus successful connected `/ping` checks in the ready banner. Every `proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
68
+ - Current CLI banner contract: only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and include the active Proteum installation method. Any extra argument or option skips the welcome banner. Terminal `proteum mcp` may print a compact central MCP ready banner when it starts or reuses the managed daemon. Only `proteum dev` clears the interactive terminal before rendering, exposes `CTRL+R` reload plus `CTRL+C` shutdown hotkeys in its session UI, and reports connected app names plus successful connected `/ping` checks in the ready banner. Every `proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
69
69
  - Keep core changes aligned with the explicit controller/page architecture in `agents/project/root/AGENTS.md` and its standalone composition in `agents/project/AGENTS.md`.
70
70
  - Prefer removing framework magic when the same result can be expressed with explicit contracts, generated code, or typed context.
71
71
  - Apply the pruning rules from `agents/project/optimizations.md`, especially for webpack plugins, Babel plugins, aliases, helpers, runtime services, and npm packages that are not meaningfully used by both apps.
@@ -15,6 +15,12 @@ Managed compact root routers must use trigger -> canonical instruction file refe
15
15
 
16
16
  ## Fast Triggers
17
17
 
18
+ - If `cwd` is inside `/.codex/worktrees/`, run Worktree Preflight before implementation:
19
+ - Copy `.env` from the main worktree when missing.
20
+ - Run `npx proteum refresh`.
21
+ - Run `npm i` when dependencies are missing or stale.
22
+ - Run `npx proteum runtime status`.
23
+ - For runtime-visible work, start or reuse one tracked `npx proteum dev` session using the Task Lifecycle launch workflow.
18
24
  - If you are working in a newly created Proteum worktree, before following the rest of these instructions:
19
25
  - Copy `.env` from the main worktree.
20
26
  - Run `npx proteum refresh`.
@@ -24,10 +30,10 @@ Managed compact root routers must use trigger -> canonical instruction file refe
24
30
  - If the user pastes raw errors without asking for a fix, do not implement changes yet. First run the task-safe local reproduction path: identify the likely app, route, command, or request from the error, boot or reuse the relevant dev server with the elevated-permissions workflow in `Task Lifecycle`, reproduce the failing surface locally, and inspect server output, browser console output, diagnostics, traces, or the smallest relevant command result. If the error does not identify enough context to reproduce, say what is missing and use the available local evidence before guessing. Then list likely causes and, for each one, give probability, why, and how to fix it. After this, every time you implement a fix:
25
31
  - test, re-run analysis and give a comparison table of before and after
26
32
  - re-print the complete list of suggested fixes, but strike the ones we already implemented or not necessary anymore
27
- - If the user asks to implement a feature, first inspect the relevant existing surface and state any implementation problem, pain point, attention point, or question you see. If a concern is blocking, or it can materially change product behavior, API shape, architecture, data model, cost, privacy, security, or UX, ask before editing; otherwise state the assumption and continue implementing.
33
+ - 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.
28
34
  - 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.
29
35
  - 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.
30
- - 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`, and `logs_tail` for read-only runtime/status/orientation/owner/route/trace/perf/log 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.
36
+ - 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.
31
37
  - MCP payloads are compact single-line `proteum-mcp-v1` JSON with capped and paginated detail. Do not expand MCP output for human readability.
32
38
  - For every non-trivial coding task, load and follow root-level `DOCUMENTATION.md` before coding.
33
39
  - If the user reports an issue, or the agent encounters one during exploration, implementation, verification, or runtime reproduction, load and follow root-level `diagnostics.md`.
@@ -56,18 +62,20 @@ Managed compact root routers must use trigger -> canonical instruction file refe
56
62
 
57
63
  ### Before Editing
58
64
 
65
+ - Before editing in a `.codex/worktrees` worktree, complete Worktree Preflight from Fast Triggers.
59
66
  - Before changing any file, load root-level `CODING_STYLE.md` and any narrower area `AGENTS.md` that applies to the touched files. Do not spend response space explicitly acknowledging those reads unless the user asks.
60
67
 
61
68
  ### During Implementation
62
69
 
63
70
  - After running `npx proteum create ...`, adapt the generated code to the real feature instead of leaving placeholder logic in place.
71
+ - If any inconsistency, ambiguity, conflicting source, missing information, or implementation detail needing clarification appears while coding, stop editing immediately, ask the user what decision to take, and resume only after the user answers. Do not silently choose a default or keep implementing under a guessed assumption.
64
72
  - When starting a long-lived dev server for an agent task, always request elevated permissions and run `npx proteum dev` outside the sandbox. Use an explicit task/thread-scoped session file such as `var/run/proteum/dev/agents/<task>.json`, inspect `npx proteum runtime status` first, then use its exact Start Dev next action so occupied router/HMR ports are avoided. Do not `curl` normal page routes to identify a port owner; use Proteum runtime status or dev-only `/__proteum/*` endpoints. After the server is ready, print the live server URL as a clickable Markdown link.
65
73
  - Use `--replace-existing` only when restarting the exact session file started by the current thread/task. Never replace another live session that belongs to a user, another thread, or an unknown owner.
66
74
  - Do not start a second `npx proteum dev` server in the same worktree, and do not start a second managed MCP daemon. If machine MCP routing fails, run `npx proteum mcp status` and `npx proteum runtime status` from the intended app root; if no live session exists, use the exact MCP offline or runtime-status next action instead of assuming the manifest default port. 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. Do not run diagnose, trace, or perf reads while runtime health is unreachable. Then retry MCP `workflow_start` and use the returned `projectId`.
67
75
  - If the current app depends on local `file:` connected projects, boot every connected producer app too, each with its own task-scoped session file and free port, and run every one of those `proteum dev` processes with elevated permissions outside the sandbox before starting or verifying the consumer app.
68
76
  - During `npx proteum dev`, the app exposes the read-only Proteum MCP runtime endpoint at `/__proteum/mcp`; use it for repeated agent reads instead of spawning equivalent diagnostics commands. For route/page/controller ownership, prefer MCP `workflow_start`, `route_candidates { projectId, query }`, or `explain_summary { projectId, query }` over broad `npx proteum explain --routes --controllers --full` dumps.
69
77
  - For browser validation, use the browser MCP against the running app. Keep Playwright inside `npx proteum e2e --port <port>` for targeted/full end-to-end suites. Bootstrap protected browser MCP state with `npx proteum session`; bootstrap protected E2E runs with `npx proteum e2e --session-email <email> --session-role <role>`.
70
- - Current CLI banner contract: only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and include the active Proteum installation method. Any extra argument or option skips the banner. Only `proteum dev` clears the interactive terminal before rendering, exposes `CTRL+R` reload plus `CTRL+C` shutdown hotkeys in its session UI, and reports connected app names plus successful connected `/ping` checks in the ready banner. Every `proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
78
+ - Current CLI banner contract: only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and include the active Proteum installation method. Any extra argument or option skips the welcome banner. Terminal `proteum mcp` may print a compact central MCP ready banner when it starts or reuses the managed daemon. Only `proteum dev` clears the interactive terminal before rendering, exposes `CTRL+R` reload plus `CTRL+C` shutdown hotkeys in its session UI, and reports connected app names plus successful connected `/ping` checks in the ready banner. Every `proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
71
79
 
72
80
  ### Before Finishing
73
81
 
@@ -231,6 +239,7 @@ Verify at the correct layer:
231
239
  ## Hard Stops
232
240
 
233
241
  - Never run schema-mutating SQL such as `ALTER TABLE`, `CREATE TABLE`, `DROP TABLE`, or `CREATE INDEX` to change database structure.
242
+ - 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.
234
243
  - 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`.
235
244
  - Do not run `git restore` or `git reset`.
236
245
  - 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.
@@ -331,7 +340,7 @@ Agents working in generated Proteum projects must use this delivery workflow for
331
340
  4. Proteum check: refresh and validate generated framework contracts after route, page, controller, service, command, or config changes.
332
341
  5. Validate unit + E2E: run the relevant unit tests and real-world journey E2E checks before calling the work complete.
333
342
 
334
- Unit test expectation: production changes must always add or update focused unit tests for the touched behavior when applicable. Target 100% meaningful unit coverage for changed production paths. 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.
343
+ Unit test expectation: production changes must always add or update focused unit tests and maintain 100% whole-project Vitest unit coverage. Before claiming implementation work complete, run `npx vitest run --coverage` from the repository root and make sure global statements, branches, functions, and lines all meet the configured 100% thresholds. MCP endpoint-reference coverage, touched-path-only coverage, and focused test passes are not substitutes for whole-project Vitest coverage. 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, and agents must not claim the project has full unit coverage when an exception remains.
335
344
 
336
345
  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.
337
346
 
@@ -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`, and `logs_tail`.
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`.
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`.
@@ -18,7 +18,7 @@ This file is the canonical source of truth for diagnostics, temporary instrument
18
18
 
19
19
  - For long-lived dev reproductions, always request elevated permissions and run `npx proteum dev` outside the sandbox. Use an explicit task/thread-scoped session file, inspect `npx proteum runtime status` first, then use its exact next action so occupied router/HMR ports and untracked same-app runtimes are handled without page-body probes. After the server is ready, print the live server URL as a clickable Markdown link.
20
20
  - Use `--replace-existing` only when restarting the exact session file started by the current thread/task. Never replace another live session that belongs to a user, another thread, or an unknown owner.
21
- - Only the bare `npx proteum build` and bare `npx proteum dev` commands print the welcome banner and active Proteum installation method. Any extra argument or option skips the banner. Only `npx proteum dev` clears the interactive terminal before rendering and reports connected app names plus successful connected `/ping` checks in the ready banner; keep that in mind when capturing or comparing command logs during diagnosis. Every `npx proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
21
+ - Only the bare `npx proteum build` and bare `npx proteum dev` commands print the welcome banner and active Proteum installation method. Any extra argument or option skips the welcome banner. Terminal `npx proteum mcp` may print a compact central MCP ready banner when it starts or reuses the managed daemon. Only `npx proteum dev` clears the interactive terminal before rendering and reports connected app names plus successful connected `/ping` checks in the ready banner; keep that in mind when capturing or comparing command logs during diagnosis. Every `npx proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
22
22
  - During `npx proteum dev`, the running app exposes the read-only Proteum MCP transport at `/__proteum/mcp`. Use it for runtime-adjacent agent reads instead of repeatedly spawning equivalent CLI diagnostics.
23
23
  - If machine MCP routing fails, run `npx proteum mcp status` and `npx proteum runtime status` from the intended app root. If no live session exists, use the exact MCP offline or runtime-status next action so occupied router/HMR ports are avoided. If the same app already responds on the configured port without live tracking, use or repair that runtime instead of starting another server. Do not `curl` normal page routes to identify which app owns a port; use runtime status or Proteum dev-only endpoints. If a live session exists but runtime/MCP is unreachable, stop the listed session file first, then start dev again. Do not start a second dev server in the same worktree, and do not start a second managed MCP daemon. Do not run diagnose, trace, or perf reads while runtime health is unreachable. Then retry MCP `workflow_start` and use the returned `projectId`.
24
24
  - For ownership or repo discovery questions, start with MCP `workflow_start`; use MCP `route_candidates { projectId, query }`, MCP `orient { projectId, query }`, and MCP `explain_summary { projectId, query }` only when the bootstrap owner summary is insufficient. Use `npx proteum orient <query>` or `npx proteum explain owner <query>` only when MCP is unavailable or terminal evidence is required.
@@ -39,7 +39,7 @@ This file is the canonical source of truth for diagnostics, temporary instrument
39
39
  ## Temporary Instrumentation
40
40
 
41
41
  - When manifest inspection, trace data, browser console output, and server errors are still insufficient, add temporary targeted logs in the code to confirm control flow, payload shape, query shape, or branch selection.
42
- - If SQL is needed during diagnosis, keep it read-only. Never use SQL to change database structure or execute schema-mutating DDL.
42
+ - If SQL is needed during diagnosis, use MCP `db_query { projectId, sql }` or `npx proteum db query "<sql>"` against a running dev server. Keep it read-only: only one capped `SELECT`, `SHOW`, or `EXPLAIN` statement is allowed, and the response includes rows, columns, elapsed milliseconds, and cap metadata. Never use SQL to change database structure or execute schema-mutating DDL.
43
43
  - Keep temporary logs narrow, contextual, and easy to remove. Do not leave broad debug noise in shared execution paths.
44
44
  - Re-run only the smallest relevant repro, request, or test after adding temporary instrumentation.
45
45
  - Temporary logs added in the code for diagnosis must be cleaned at the end of tests or the repro cycle and must never be committed.
@@ -19,7 +19,7 @@ When tradeoffs exist inside optimization work, optimize in this order:
19
19
  - Prefer established, flexible, well-typed, widely adopted, actively maintained packages.
20
20
  - Build custom or keep custom infrastructure only when packages would clearly hurt bundle size, SSR behavior, performance, typing quality, flexibility, licensing, explicit contracts, or long-term maintainability.
21
21
  - If you choose custom over a package, state briefly why.
22
- - For agent-facing repeated diagnostics, prefer the read-only Proteum MCP surface over adding broader CLI output. MCP should expose compact single-line `proteum-mcp-v1` JSON with capped, typed, paginated reads; the CLI should stay compact and reproducible.
22
+ - For agent-facing repeated diagnostics, prefer the read-only Proteum MCP surface over adding broader CLI output. MCP should expose compact single-line `proteum-mcp-v1` JSON with capped, typed, paginated reads; the CLI should stay compact and reproducible. Database diagnostics are limited to one capped `SELECT`, `SHOW`, or `EXPLAIN` read through MCP `db_query` or CLI `proteum db query`.
23
23
 
24
24
  ## SSR And Page Size
25
25
 
@@ -15,10 +15,10 @@ Managed compact root routers must use trigger -> canonical instruction file refe
15
15
  ## Fast Triggers
16
16
 
17
17
  - If the user pastes raw errors without asking for a fix, do not implement changes yet. First run the task-safe local reproduction path: identify the likely app, route, command, or request from the error, boot or reuse the relevant dev server with the elevated-permissions workflow in `Task Lifecycle`, reproduce the failing surface locally, and inspect server output, browser console output, diagnostics, traces, or the smallest relevant command result. If the error does not identify enough context to reproduce, say what is missing and use the available local evidence before guessing. Then list likely causes and, for each one, give probability, why, and how to fix it.
18
- - If the user asks to implement a feature, first inspect the relevant existing surface and state any implementation problem, pain point, attention point, or question you see. If a concern is blocking, or it can materially change product behavior, API shape, architecture, data model, cost, privacy, security, or UX, ask before editing; otherwise state the assumption and continue implementing.
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`, and `logs_tail` for read-only runtime/status/orientation/owner/route/trace/perf/log 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, 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
  - If the user reports an issue, or the agent encounters one during exploration, implementation, verification, or runtime reproduction, load and follow root-level `diagnostics.md`.
@@ -51,18 +51,19 @@ Managed compact root routers must use trigger -> canonical instruction file refe
51
51
  ### During Implementation
52
52
 
53
53
  - After running `npx proteum create ...`, adapt the generated code to the real feature instead of leaving placeholder logic in place.
54
+ - If any inconsistency, ambiguity, conflicting source, missing information, or implementation detail needing clarification appears while coding, stop editing immediately, ask the user what decision to take, and resume only after the user answers. Do not silently choose a default or keep implementing under a guessed assumption.
54
55
  - When starting a long-lived dev server for an agent task, always request elevated permissions and run `npx proteum dev` outside the sandbox. Use an explicit task/thread-scoped session file such as `var/run/proteum/dev/agents/<task>.json`, inspect `npx proteum runtime status` first, then use its exact Start Dev next action so occupied router/HMR ports are avoided. Do not `curl` normal page routes to identify a port owner; use Proteum runtime status or dev-only `/__proteum/*` endpoints. After the server is ready, print the live server URL as a clickable Markdown link.
55
56
  - Use `--replace-existing` only when restarting the exact session file started by the current thread/task. Never replace another live session that belongs to a user, another thread, or an unknown owner.
56
57
  - Do not start a second `npx proteum dev` server in the same worktree, and do not start a second managed MCP daemon. If machine MCP routing fails, run `npx proteum mcp status` and `npx proteum runtime status` from the intended app root; if no live session exists, use the exact MCP offline or runtime-status next action instead of assuming the manifest default port. 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. Do not run diagnose, trace, or perf reads while runtime health is unreachable. Then retry MCP `workflow_start` and use the returned `projectId`.
57
58
  - If the current app depends on local `file:` connected projects, boot every connected producer app too, each with its own task-scoped session file and free port, and run every one of those `proteum dev` processes with elevated permissions outside the sandbox before starting or verifying the consumer app.
58
59
  - During `npx proteum dev`, the app exposes the read-only Proteum MCP runtime endpoint at `/__proteum/mcp`; use it for repeated agent reads instead of spawning equivalent diagnostics commands. For route/page/controller ownership, prefer MCP `workflow_start`, `route_candidates { projectId, query }`, or `explain_summary { projectId, query }` over broad `npx proteum explain --routes --controllers --full` dumps.
59
60
  - For browser validation, use the browser MCP against the running app. Keep Playwright inside `npx proteum e2e --port <port>` for targeted/full end-to-end suites. Bootstrap protected browser MCP state with `npx proteum session`; bootstrap protected E2E runs with `npx proteum e2e --session-email <email> --session-role <role>`.
60
- - Current CLI banner contract: only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and include the active Proteum installation method. Any extra argument or option skips the banner. Only `proteum dev` clears the interactive terminal before rendering, exposes `CTRL+R` reload plus `CTRL+C` shutdown hotkeys in its session UI, and reports connected app names plus successful connected `/ping` checks in the ready banner. Every `proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
61
+ - Current CLI banner contract: only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and include the active Proteum installation method. Any extra argument or option skips the welcome banner. Terminal `proteum mcp` may print a compact central MCP ready banner when it starts or reuses the managed daemon. Only `proteum dev` clears the interactive terminal before rendering, exposes `CTRL+R` reload plus `CTRL+C` shutdown hotkeys in its session UI, and reports connected app names plus successful connected `/ping` checks in the ready banner. Every `proteum dev` start ensures tracked instruction files contain the current managed `# Proteum Instructions` section before the dev loop begins.
61
62
 
62
63
  ### Before Finishing
63
64
 
64
65
  - 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.
65
- - For production changes, always add or update focused unit tests for the touched behavior when applicable. Target 100% meaningful unit coverage for changed production paths, and document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested.
66
+ - For production changes, always add or update focused unit tests and maintain 100% whole-project Vitest unit coverage. Before claiming implementation work complete, run `npx vitest run --coverage` from the repository root and make sure global statements, branches, functions, and lines all meet the configured 100% thresholds. MCP endpoint-reference coverage, touched-path-only coverage, and focused test passes are not substitutes for whole-project Vitest coverage. Document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions, and do not claim the project has full unit coverage when an exception remains.
66
67
  - Run the full project `npx proteum check` before finishing each feature or change. Targeted lint, typecheck, diagnose, request, browser, or E2E runs are still useful while iterating, but they do not replace the final full check. After implementing a new feature or changing existing feature behavior, always update the end-to-end coverage for that behavior and run the full Playwright test suite before finishing. For docs-only, wording-only, type-only, test-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.
67
68
  - 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>`.
68
69
  - 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:
@@ -222,6 +223,7 @@ Verify at the correct layer:
222
223
  ## Hard Stops
223
224
 
224
225
  - Never run schema-mutating SQL such as `ALTER TABLE`, `CREATE TABLE`, `DROP TABLE`, or `CREATE INDEX` to change database structure.
226
+ - 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.
225
227
  - 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`.
226
228
  - Do not run `git restore` or `git reset`.
227
229
  - 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.
@@ -31,6 +31,7 @@ Diagnostics source of truth: root-level `diagnostics.md`.
31
31
  - In database queries, prefer explicit `select` or narrow `include`.
32
32
  - For database structure changes, edit the app's `schema.prisma` only. Never create or edit migration files manually.
33
33
  - Never use raw SQL DDL or other schema-mutating SQL to change database structure.
34
+ - 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.
34
35
  - Prefer inferred return types such as `Awaited<ReturnType<MyService['methodName']>>` over manual DTO duplication.
35
36
 
36
37
  ## Errors
@@ -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 when applicable. Target 100% meaningful coverage for changed production paths, and document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested.
12
+ - For every production change, add or update focused unit tests and maintain 100% whole-project Vitest unit coverage. Before claiming implementation work complete, run `npx vitest run --coverage` from the repository root and make sure global statements, branches, functions, and lines all meet the configured 100% thresholds. MCP endpoint-reference coverage, touched-path-only coverage, and focused test passes are not substitutes for whole-project Vitest coverage. Document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions, and do not claim the project has full unit coverage when an exception remains.
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.
@@ -0,0 +1,160 @@
1
+ import fs from 'fs-extra';
2
+ import got from 'got';
3
+ import path from 'path';
4
+ import { UsageError } from 'clipanion';
5
+
6
+ import cli from '..';
7
+ import {
8
+ defaultDatabaseReadTimeoutMs,
9
+ maxDatabaseReadLimit,
10
+ maxDatabaseReadTimeoutMs,
11
+ type TDatabaseReadQueryResponse,
12
+ } from '../../common/dev/database';
13
+ import { printAgentResponse, printJson, quoteCommandArgument } from '../utils/agentOutput';
14
+
15
+ type TDbAction = 'query';
16
+
17
+ const allowedActions = new Set<TDbAction>(['query']);
18
+ const normalizeBaseUrl = (value: string) => value.replace(/\/+$/, '');
19
+
20
+ const getRouterPortFromManifest = () => {
21
+ const manifestFilepath = path.join(cli.args.workdir as string, '.proteum', 'manifest.json');
22
+ if (!fs.existsSync(manifestFilepath)) return undefined;
23
+
24
+ const manifest = fs.readJsonSync(manifestFilepath, { throws: false }) as
25
+ | { env?: { resolved?: { routerPort?: number } } }
26
+ | undefined;
27
+ const port = manifest?.env?.resolved?.routerPort;
28
+
29
+ if (typeof port !== 'number' || port <= 0) return undefined;
30
+
31
+ return String(port);
32
+ };
33
+
34
+ const getRouterPort = () => {
35
+ const overridePort = typeof cli.args.port === 'string' && cli.args.port ? cli.args.port : '';
36
+ if (overridePort) return overridePort;
37
+
38
+ const envPort = process.env.PORT?.trim();
39
+ if (envPort) return envPort;
40
+
41
+ const manifestPort = getRouterPortFromManifest();
42
+ if (manifestPort) return manifestPort;
43
+
44
+ throw new UsageError(
45
+ `Could not determine the router port from PORT or .proteum/manifest.json in ${cli.args.workdir as string}. Pass --port or --url explicitly.`,
46
+ );
47
+ };
48
+
49
+ const getRouterBaseUrls = () => {
50
+ const explicitUrl = typeof cli.args.url === 'string' && cli.args.url ? cli.args.url.trim() : '';
51
+ if (explicitUrl) return [normalizeBaseUrl(explicitUrl)];
52
+
53
+ const port = getRouterPort();
54
+ return [...new Set([`http://127.0.0.1:${port}`, `http://localhost:${port}`, `http://[::1]:${port}`])];
55
+ };
56
+
57
+ const parsePositiveInteger = (value: unknown, label: string, max: number) => {
58
+ if (typeof value !== 'string' || !value.trim()) return undefined;
59
+
60
+ const parsed = Number(value);
61
+ if (!Number.isInteger(parsed) || parsed <= 0) throw new UsageError(`${label} must be a positive integer.`);
62
+ if (parsed > max) throw new UsageError(`${label} must be ${max} or lower.`);
63
+
64
+ return parsed;
65
+ };
66
+
67
+ const requestJson = async <TResponse>(pathname: string, json: object) => {
68
+ const attempts: string[] = [];
69
+
70
+ for (const baseUrl of getRouterBaseUrls()) {
71
+ try {
72
+ const response = await got(`${baseUrl}${pathname}`, {
73
+ method: 'POST',
74
+ json,
75
+ responseType: 'json',
76
+ retry: { limit: 0 },
77
+ throwHttpErrors: false,
78
+ });
79
+
80
+ if (response.statusCode >= 400) {
81
+ const body = response.body as { error?: string } | undefined;
82
+ throw new UsageError(body?.error || `Database query failed with status ${response.statusCode}.`);
83
+ }
84
+
85
+ return response.body as TResponse;
86
+ } catch (error) {
87
+ if (error instanceof UsageError) throw error;
88
+
89
+ const message = error instanceof Error ? error.message : String(error);
90
+ attempts.push(`${baseUrl}${pathname}: ${message}`);
91
+ }
92
+ }
93
+
94
+ throw new UsageError(
95
+ [
96
+ 'Could not reach the Proteum database diagnostics server.',
97
+ ...attempts.map((attempt) => `- ${attempt}`),
98
+ 'Make sure the app is running with `proteum dev`, or pass `--url http://host:port` if it is bound elsewhere.',
99
+ ].join('\n'),
100
+ );
101
+ };
102
+
103
+ const buildFullCommand = (sql: string) =>
104
+ [
105
+ 'proteum db query',
106
+ quoteCommandArgument(sql),
107
+ typeof cli.args.limit === 'string' && cli.args.limit ? `--limit ${cli.args.limit}` : '',
108
+ typeof cli.args.timeout === 'string' && cli.args.timeout ? `--timeout ${cli.args.timeout}` : '',
109
+ typeof cli.args.port === 'string' && cli.args.port ? `--port ${cli.args.port}` : '',
110
+ typeof cli.args.url === 'string' && cli.args.url ? `--url ${quoteCommandArgument(cli.args.url)}` : '',
111
+ '--full',
112
+ ]
113
+ .filter(Boolean)
114
+ .join(' ');
115
+
116
+ export const run = async () => {
117
+ const action = typeof cli.args.action === 'string' && cli.args.action ? cli.args.action : 'query';
118
+ if (!allowedActions.has(action as TDbAction)) {
119
+ throw new UsageError(`Unsupported db action "${action}". Expected: query.`);
120
+ }
121
+
122
+ const sql = typeof cli.args.sql === 'string' ? cli.args.sql.trim() : '';
123
+ if (!sql) throw new UsageError('A SELECT, SHOW, or EXPLAIN SQL statement is required.');
124
+
125
+ const limit = parsePositiveInteger(cli.args.limit, '--limit', maxDatabaseReadLimit);
126
+ const timeoutMs = parsePositiveInteger(cli.args.timeout, '--timeout', maxDatabaseReadTimeoutMs);
127
+ const response = await requestJson<TDatabaseReadQueryResponse>('/__proteum/db/query', {
128
+ sql,
129
+ ...(limit !== undefined ? { limit } : {}),
130
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
131
+ });
132
+
133
+ if (cli.args.full === true) {
134
+ printJson(response);
135
+ return;
136
+ }
137
+
138
+ printAgentResponse({
139
+ summary: `${response.kind.toUpperCase()} returned ${response.rows.length}/${response.rowCount} rows in ${response.elapsedMs} ms${response.limited ? ` (limited to ${response.limit})` : ''}.`,
140
+ data: {
141
+ kind: response.kind,
142
+ elapsedMs: response.elapsedMs,
143
+ rowCount: response.rowCount,
144
+ returnedRowCount: response.rows.length,
145
+ limit: response.limit,
146
+ limited: response.limited,
147
+ columns: response.columns,
148
+ rows: response.rows,
149
+ },
150
+ fullDetailCommand: buildFullCommand(sql),
151
+ omitted: response.limited
152
+ ? [
153
+ {
154
+ reason: `Rows are capped at ${response.limit}. Raise --limit up to ${maxDatabaseReadLimit} or narrow the query for more detail.`,
155
+ command: `proteum db query ${quoteCommandArgument(sql)} --limit ${Math.min(response.limit * 2, maxDatabaseReadLimit)} --timeout ${timeoutMs || defaultDatabaseReadTimeoutMs}`,
156
+ },
157
+ ]
158
+ : undefined,
159
+ });
160
+ };
@@ -6,6 +6,7 @@ import {
6
6
  resolveMachineMcpDaemonPort,
7
7
  stopMachineMcpDaemonProcess,
8
8
  } from '../runtime/mcpDaemon';
9
+ import { renderMcpDaemonBanner } from '../presentation/mcp';
9
10
 
10
11
  const printJson = (payload: unknown) => {
11
12
  process.stdout.write(JSON.stringify(payload, null, 2) + '\n');
@@ -53,11 +54,19 @@ const runDaemon = async () => {
53
54
  return;
54
55
  }
55
56
 
56
- console.info(`Proteum machine MCP daemon is already running at ${existing.record.mcpUrl} (pid ${existing.record.pid}).`);
57
+ console.info(
58
+ await renderMcpDaemonBanner({
59
+ mcpUrl: existing.record.mcpUrl,
60
+ pid: existing.record.pid,
61
+ state: 'connected',
62
+ }),
63
+ );
57
64
  return;
58
65
  }
59
66
 
60
67
  const port = resolveMachineMcpDaemonPort(typeof cli.args.port === 'string' ? cli.args.port : undefined);
68
+ const mcpUrl = `http://127.0.0.1:${port}/mcp`;
69
+ const healthUrl = `http://127.0.0.1:${port}/health`;
61
70
 
62
71
  await startProteumMachineMcpRouterHttp({
63
72
  port,
@@ -69,12 +78,18 @@ const runDaemon = async () => {
69
78
  started: true,
70
79
  daemon: {
71
80
  pid: process.pid,
72
- mcpUrl: `http://127.0.0.1:${port}/mcp`,
73
- healthUrl: `http://127.0.0.1:${port}/health`,
81
+ mcpUrl,
82
+ healthUrl,
74
83
  },
75
84
  });
76
85
  } else {
77
- console.info(`Proteum machine MCP daemon started at http://127.0.0.1:${port}/mcp.`);
86
+ console.info(
87
+ await renderMcpDaemonBanner({
88
+ mcpUrl,
89
+ pid: process.pid,
90
+ state: 'started',
91
+ }),
92
+ );
78
93
  }
79
94
  };
80
95
 
@@ -91,9 +106,11 @@ const ensureDaemon = async () => {
91
106
 
92
107
  if (result.inspection.record) {
93
108
  console.info(
94
- result.started
95
- ? `Proteum machine MCP daemon started at ${result.inspection.record.mcpUrl}.`
96
- : `Proteum machine MCP daemon is already running at ${result.inspection.record.mcpUrl}.`,
109
+ await renderMcpDaemonBanner({
110
+ mcpUrl: result.inspection.record.mcpUrl,
111
+ pid: result.inspection.record.pid,
112
+ state: result.started ? 'started' : 'connected',
113
+ }),
97
114
  );
98
115
  }
99
116
  };
package/cli/mcp/router.ts CHANGED
@@ -58,6 +58,8 @@ const readOnlyAnnotations = {
58
58
  };
59
59
 
60
60
  const detailSchema = z.enum(['compact', 'full']).optional();
61
+ const databaseLimitSchema = z.number().int().min(1).max(500).optional();
62
+ const databaseTimeoutSchema = z.number().int().min(100).max(30_000).optional();
61
63
  const logsLevelSchema = z.enum(['silly', 'log', 'info', 'warn', 'error']).optional();
62
64
  const offsetSchema = z.number().int().min(0).max(10_000).optional();
63
65
  const positiveLimitSchema = z.number().int().min(1).max(100).optional();
@@ -824,6 +826,22 @@ export const createProteumMachineMcpServer = ({ createDevMcpClient, version }: T
824
826
  async (input) => await forwardTool('logs_tail', input),
825
827
  );
826
828
 
829
+ server.registerTool(
830
+ 'db_query',
831
+ {
832
+ annotations: readOnlyAnnotations,
833
+ description: 'Run one capped read-only database diagnostic query for one live Proteum project.',
834
+ inputSchema: {
835
+ limit: databaseLimitSchema,
836
+ projectId: projectIdSchema,
837
+ sql: z.string().min(1).describe('One SELECT, SHOW, or EXPLAIN SQL statement.'),
838
+ timeoutMs: databaseTimeoutSchema,
839
+ },
840
+ title: 'Proteum Database Query',
841
+ },
842
+ async (input) => await forwardTool('db_query', input),
843
+ );
844
+
827
845
  const closeServer = server.close.bind(server);
828
846
  server.close = async () => {
829
847
  await closeAllClients();
@@ -21,6 +21,7 @@ export const proteumCommandNames = [
21
21
  'orient',
22
22
  'diagnose',
23
23
  'perf',
24
+ 'db',
24
25
  'runtime',
25
26
  'mcp',
26
27
  'trace',
@@ -59,7 +60,7 @@ export const proteumRecommendedFlow: TRow[] = [
59
60
  export const proteumCommandGroups: Array<{ title: string; names: TProteumCommandName[] }> = [
60
61
  { title: 'Daily workflow', names: ['dev', 'refresh', 'build'] },
61
62
  { title: 'Quality gates', names: ['typecheck', 'lint', 'check', 'e2e'] },
62
- { title: 'Manifest and contracts', names: ['connect', 'doctor', 'explain', 'orient', 'diagnose', 'perf', 'runtime', 'mcp', 'trace', 'command', 'session', 'verify'] },
63
+ { title: 'Manifest and contracts', names: ['connect', 'doctor', 'explain', 'orient', 'diagnose', 'perf', 'db', 'runtime', 'mcp', 'trace', 'command', 'session', 'verify'] },
63
64
  { title: 'Project scaffolding', names: ['init', 'configure', 'create', 'migrate'] },
64
65
  ];
65
66
 
@@ -452,6 +453,26 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
452
453
  ],
453
454
  status: 'experimental',
454
455
  },
456
+ db: {
457
+ name: 'db',
458
+ category: 'Manifest and contracts',
459
+ summary: 'Run one capped read-only database diagnostic query against a running Proteum dev server.',
460
+ usage: 'proteum db [query] <sql> [--limit <rows>] [--timeout <ms>] [--port <port>|--url <baseUrl>] [--full]',
461
+ bestFor:
462
+ 'Inspecting live MySQL, MariaDB, or PostgreSQL state during diagnosis without giving agents a write-capable SQL execution surface.',
463
+ examples: [
464
+ { description: 'Run a small SELECT diagnostic', command: 'proteum db query "SELECT id, email FROM User LIMIT 5"' },
465
+ { description: 'Inspect table metadata', command: 'proteum db "SELECT table_name FROM information_schema.tables LIMIT 20"' },
466
+ { description: 'Explain a query plan', command: 'proteum db query "EXPLAIN SELECT * FROM User WHERE id = 1"' },
467
+ ],
468
+ notes: [
469
+ 'Only SELECT, SHOW, and EXPLAIN statements are allowed.',
470
+ 'The dev runtime executes the query with the app DATABASE_URL and returns rows, columns, elapsedMs, and cap metadata.',
471
+ 'Multi-statement SQL, EXPLAIN ANALYZE, locking reads, file-read functions, SELECT INTO OUTFILE, sleep, and benchmark functions are rejected.',
472
+ 'Default output is compact `proteum-agent-v1` JSON with capped rows; use `--full` for the raw dev endpoint payload.',
473
+ ],
474
+ status: 'experimental',
475
+ },
455
476
  runtime: {
456
477
  name: 'runtime',
457
478
  category: 'Manifest and contracts',
@@ -487,6 +508,7 @@ export const proteumCommands: Record<TProteumCommandName, TProteumCommandDoc> =
487
508
  ],
488
509
  notes: [
489
510
  '`proteum dev` ensures one managed machine MCP daemon is running before the app dev loop starts.',
511
+ 'Terminal `proteum mcp` prints a compact central MCP banner with the Streamable HTTP URL for client setup.',
490
512
  '`proteum mcp` is a router, not an app dev server. It discovers live `proteum dev` sessions from the machine registry and can resolve offline app candidates from `cwd`.',
491
513
  'Agents should call MCP `workflow_start` with `cwd` or a known `projectId`; use `project_resolve { cwd }` when routing is ambiguous or no live dev server exists yet.',
492
514
  'When an offline app candidate is returned, start exactly one `proteum dev` from that app root before runtime diagnose, trace, or perf reads.',
@@ -135,7 +135,7 @@ export const renderCliOverview = async ({
135
135
  indent: ' ',
136
136
  nextIndent: ' ',
137
137
  }),
138
- wrapText('Only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and active Proteum installation method. Any extra argument or option skips the banner. `proteum dev` is the only command that clears the interactive terminal before rendering its session UI.', {
138
+ wrapText('Only the bare `proteum build` and bare `proteum dev` commands print the welcome banner and active Proteum installation method. Any extra argument or option skips the welcome banner. `proteum mcp` may print a compact central MCP ready banner when it starts or reuses the daemon. `proteum dev` is the only command that clears the interactive terminal before rendering its session UI.', {
139
139
  indent: ' ',
140
140
  nextIndent: ' ',
141
141
  }),
@@ -0,0 +1,27 @@
1
+ import { CliReact, renderInk } from './ink';
2
+
3
+ export type TMcpDaemonBannerState = 'started' | 'connected';
4
+
5
+ export const renderMcpDaemonBanner = async ({
6
+ mcpUrl,
7
+ pid,
8
+ state,
9
+ }: {
10
+ mcpUrl: string;
11
+ pid?: number;
12
+ state: TMcpDaemonBannerState;
13
+ }) =>
14
+ renderInk(({ Box, Text }) => {
15
+ const createElement = CliReact.createElement;
16
+ const summary =
17
+ state === 'started' ? 'Launched central MCP server.' : 'Connected to central MCP server.';
18
+ const pidLabel = pid ? ` pid ${pid}` : '';
19
+
20
+ return createElement(
21
+ Box,
22
+ { borderStyle: 'round', borderColor: 'cyan', paddingX: 2, paddingY: 0, flexDirection: 'column' },
23
+ createElement(Text, { bold: true, backgroundColor: 'cyan', color: 'black' }, ' CENTRAL MCP READY '),
24
+ createElement(Text, { bold: true, color: 'cyan' }, `${summary}${pidLabel}`),
25
+ createElement(Text, { dimColor: true }, `Connect MCP client (HTTP): ${mcpUrl}`),
26
+ );
27
+ });