proteum 2.5.9 → 2.5.11
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 +4 -4
- package/agents/project/AGENTS.md +131 -91
- package/agents/project/CODING_STYLE.md +69 -40
- package/agents/project/DOCUMENTATION.md +19 -2
- package/agents/project/client/AGENTS.md +0 -1
- package/agents/project/diagnostics.md +6 -5
- package/agents/project/optimizations.md +1 -7
- package/agents/project/server/services/AGENTS.md +1 -3
- package/agents/project/tests/AGENTS.md +3 -3
- package/cli/commands/docs.ts +223 -0
- package/cli/commands/session.ts +36 -5
- package/cli/commands/verify.ts +6 -1
- package/cli/compiler/client/index.ts +11 -4
- package/cli/compiler/common/uiSingletons.ts +76 -0
- package/cli/compiler/server/index.ts +34 -12
- package/cli/presentation/commands.ts +20 -1
- package/cli/runtime/commands.ts +20 -0
- package/cli/scaffold/index.ts +3 -0
- package/cli/scaffold/templates.ts +62 -6
- package/cli/utils/agents.ts +2 -2
- package/cli/verification/changed.ts +21 -0
- package/client/dev/profiler/index.tsx +761 -455
- package/common/dev/mcpPayloads.ts +86 -8
- package/common/dev/session.ts +32 -0
- package/common/errors/index.tsx +0 -1
- package/docAnchors.js +135 -0
- package/docs/agent-routing.md +2 -2
- package/eslint.js +264 -1
- package/package.json +1 -1
- package/server/app/container/console/index.ts +0 -17
- package/server/services/router/http/index.ts +130 -33
- package/tests/agents-utils.test.cjs +0 -4
- package/tests/dev-session-login-url.test.cjs +33 -0
- package/tests/doc-anchors.test.cjs +115 -0
- package/tests/docs-check.test.cjs +138 -0
- package/tests/eslint-rules.test.cjs +235 -2
- package/tests/mcp.test.cjs +109 -0
- package/tests/ui-singletons.test.cjs +104 -0
- package/tests/verify-changed.test.cjs +51 -3
- package/agents/project/app-root/AGENTS.md +0 -14
- package/agents/project/root/AGENTS.md +0 -399
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Proteum Core
|
|
2
2
|
|
|
3
|
-
This file governs work in the Proteum framework repository itself. For downstream app rules, use `agents/project/AGENTS.md
|
|
3
|
+
This file governs work in the Proteum framework repository itself. For downstream app rules, use `agents/project/AGENTS.md`; it is the single canonical project contract, and `proteum configure agents` deploys it through the generated root router in both standalone and monorepo modes.
|
|
4
4
|
Role: keep only framework-repo instructions here.
|
|
5
5
|
Keep here: core-repo priorities, framework change workflow, reference-app validation, and framework-specific constraints.
|
|
6
6
|
Do not put here: downstream app implementation contracts, area-specific app rules, or repeated content that belongs in `agents/project/**`.
|
|
@@ -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
|
|
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` — or several when the changes span clearly separable concerns (independent features, an unrelated fix, a refactor separable from a behavior change), each commit staging only the files that belong to its concern and carrying its own message. 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
|
|
|
@@ -62,11 +62,11 @@ npx prisma migrate dev --config ./prisma.config.ts --name <migration name>
|
|
|
62
62
|
- `/Users/gaetan/Desktop/Projets/klair.work/apps/api`
|
|
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
|
-
- 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/
|
|
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/diagnostics.md`, and any narrower `agents/project/**/AGENTS.md` file that mentions the changed workflow.
|
|
66
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
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 and `CLAUDE.md` symlinks point to sibling `AGENTS.md` files before the dev loop begins.
|
|
69
|
-
- Keep core changes aligned with the explicit controller/page architecture in `agents/project/
|
|
69
|
+
- Keep core changes aligned with the explicit controller/page architecture 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.
|
|
72
72
|
- Remove dead docs, flags, helper files, and compatibility branches in the same pass when safe.
|
package/agents/project/AGENTS.md
CHANGED
|
@@ -1,87 +1,116 @@
|
|
|
1
1
|
# Proteum Project Contract
|
|
2
2
|
|
|
3
|
-
This is the canonical
|
|
4
|
-
|
|
5
|
-
Role: keep only project-wide app rules here when one root `AGENTS.md` must carry both the reusable Proteum contract and the app-root addendum.
|
|
6
|
-
Keep here: cross-cutting project workflow, architecture contracts, shared typing rules, and rules that apply across client, server, pages, and tests.
|
|
3
|
+
This is the canonical project contract for Proteum-based projects shipped with Proteum. Narrower `AGENTS.md` files in this folder add area-specific rules on top of this file.
|
|
4
|
+
Role: cross-cutting project workflow, architecture contracts, and rules that apply across client, server, pages, and tests.
|
|
7
5
|
Do not put here: documentation-driven coding workflow, detailed diagnostics workflow, optimization checklists, coding-style details, or narrow area-specific instructions that belong in `DOCUMENTATION.md`, `diagnostics.md`, `optimizations.md`, `CODING_STYLE.md`, `client/AGENTS.md`, `client/pages/AGENTS.md`, `server/routes/AGENTS.md`, `server/services/AGENTS.md`, or `tests/AGENTS.md`.
|
|
6
|
+
Every rule has exactly one canonical home. When another section or file needs a rule defined elsewhere, it points to the canonical home instead of restating it.
|
|
8
7
|
|
|
9
8
|
Documentation source of truth: root-level `DOCUMENTATION.md`.
|
|
10
9
|
Optimization source of truth: root-level `optimizations.md`.
|
|
11
10
|
Diagnostics source of truth: root-level `diagnostics.md`.
|
|
12
|
-
Coding style source of truth: root-level `CODING_STYLE.md
|
|
11
|
+
Coding style source of truth: root-level `CODING_STYLE.md` (style, formatting, file organization, typing, comments).
|
|
13
12
|
|
|
14
13
|
Managed compact root routers must use trigger -> canonical instruction file references, not copied summaries of this contract. If a trigger points here, load this full file before acting and keep the source rule here.
|
|
15
14
|
|
|
16
15
|
## Fast Triggers
|
|
17
16
|
|
|
18
|
-
- If `cwd` is inside `/.codex/worktrees
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
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.
|
|
24
|
-
- If you are working in a newly created Proteum worktree, before following the rest of these instructions:
|
|
25
|
-
- Run `npx proteum worktree init --source <source-app-root>`.
|
|
26
|
-
- Read and acknowledge the applicable `AGENTS.md` files.
|
|
27
|
-
- Run the dev server with the task-safe elevated-permissions launch workflow from `Task Lifecycle`, keep it running so user can see the results by himself, and print the live server URL as a clickable Markdown link.
|
|
28
|
-
- 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:
|
|
29
|
-
- test, re-run analysis and give a comparison table of before and after
|
|
30
|
-
- re-print the complete list of suggested fixes, but strike the ones we already implemented or not necessary anymore
|
|
17
|
+
- If `cwd` is inside `/.codex/worktrees/` or you are working in a newly created Proteum worktree, run the `Worktree Preflight` in `Task Lifecycle` before implementation.
|
|
18
|
+
- If the user pastes raw errors without asking for a fix, do not implement changes yet. Reproduce locally first using the `Initial Triage` workflow in root-level `diagnostics.md`, then list likely causes and, for each one, give probability, why, and how to fix it. After this, every time you implement a fix:
|
|
19
|
+
- test, re-run the analysis, and give a comparison table of before and after
|
|
20
|
+
- re-print the complete list of suggested fixes, but strike the ones already implemented or no longer necessary
|
|
31
21
|
- 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
|
-
- If the task is ambiguous, generated, connected, or multi-repo,
|
|
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, 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
|
-
- MCP payloads are compact single-line `proteum-mcp-v1` JSON with capped and paginated detail. Do not expand MCP output for human readability.
|
|
22
|
+
- If the task is ambiguous, generated, connected, or multi-repo, follow `MCP Orientation`.
|
|
36
23
|
- For every non-trivial coding task, load and follow root-level `DOCUMENTATION.md` before coding.
|
|
37
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.
|
|
38
|
-
- If the user reports an issue, or
|
|
25
|
+
- If the user reports an issue, or you encounter one during exploration, implementation, verification, or runtime reproduction, load and follow root-level `diagnostics.md`.
|
|
39
26
|
- If the task touches client-side files, especially `client/**` and page files, load and apply root-level `optimizations.md` only after implementation for post-implementation checking and optimization. Skip it at task start and skip it for server-only, test-only, doc-only, and non-client refactor tasks unless the user explicitly asks for optimization work.
|
|
40
27
|
- If the task changes UX, copy, onboarding, pricing, product semantics, or commercial positioning, use root-level `DOCUMENTATION.md` to choose the smallest relevant `./docs/` pack before editing. If a dev server is already running, print the live dev server URL as a clickable Markdown link.
|
|
41
28
|
- If the task needs new app or artifact boilerplate, prefer `npx proteum init ...` and `npx proteum create ...` before creating files by hand. Use `--dry-run --json` when an agent needs a machine-readable plan before writing files.
|
|
42
|
-
- If you changed `schema.prisma`,
|
|
43
|
-
```
|
|
44
|
-
cd <worktree path>
|
|
45
|
-
npx prisma migrate dev --config ./prisma.config.ts --name <migration name>
|
|
46
|
-
```
|
|
29
|
+
- If you changed `schema.prisma`, stop before testing or validation and follow the migration rule in `Hard Stops`.
|
|
47
30
|
- If you encounter `runtime/provider-hook-outside-provider`, `runtime/client-only-hook-in-ssr`, `runtime/router-context-outside-router`, or `runtime/connected-boundary-mismatch`, treat it as a framework contract failure first. Fix the provider, SSR/client, router, or connected boundary before assuming a local leaf-component bug.
|
|
48
|
-
- If the change is runtime-visible, request-time, router, SSR, browser-visible, or controller-behavior, use running-app verification
|
|
49
|
-
- If
|
|
50
|
-
- If the
|
|
51
|
-
|
|
52
|
-
<type>[optional scope]: <description>
|
|
31
|
+
- If the change is runtime-visible, request-time, router, SSR, browser-visible, or controller-behavior, use running-app verification per the `Verification Matrix`.
|
|
32
|
+
- If a new feature is visible in the UI or browser, run the mandatory browser MCP pass defined in the `Verification Policy` before finishing.
|
|
33
|
+
- If the change is docs-only, wording-only, type-only, test-only, generated-output cleanup, or a clearly local non-runtime refactor, use static verification only unless the user explicitly asks for runtime verification or you find a real issue.
|
|
34
|
+
- If the user replies exactly `commit`, follow `Commit Workflow`.
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
## MCP Orientation
|
|
37
|
+
|
|
38
|
+
Treat Proteum CLI and MCP output as the workflow router.
|
|
39
|
+
|
|
40
|
+
- When a Proteum MCP client is available, call MCP `workflow_start` first, with `cwd` or a known `projectId`.
|
|
41
|
+
- If `workflow_start` 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`.
|
|
42
|
+
- Pass the returned live `projectId` to every follow-up app-bound MCP tool.
|
|
43
|
+
- 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, and database reads.
|
|
44
|
+
- 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.
|
|
45
|
+
- 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.
|
|
46
|
+
- MCP payloads are compact single-line `proteum-mcp-v1` JSON with capped and paginated detail. Do not expand MCP output for human readability.
|
|
47
|
+
- 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.
|
|
48
|
+
- For route/page/controller ownership, prefer `workflow_start`, `route_candidates { projectId, query }`, or `explain_summary { projectId, query }` over broad `npx proteum explain --routes --controllers --full` dumps.
|
|
49
|
+
- `npx proteum dev` ensures one managed machine MCP daemon is running; do not start a second managed daemon.
|
|
50
|
+
- Use CLI commands such as `npx proteum orient <query>` when MCP is unavailable, when terminal evidence is required, or when you need reproducible terminal validation, dev/build/check workflows, fallback repair, or output to share with a human.
|
|
59
51
|
|
|
60
52
|
## Task Lifecycle
|
|
61
53
|
|
|
54
|
+
### Worktree Preflight
|
|
55
|
+
|
|
56
|
+
- Run `npx proteum worktree init --source <source-app-root>` when the bootstrap marker is missing, or add `--refresh` when Proteum reports stale bootstrap state.
|
|
57
|
+
- Use `--skip-deps --reason "..."` only when dependency installation is intentionally skipped.
|
|
58
|
+
- Read and acknowledge the applicable `AGENTS.md` files.
|
|
59
|
+
- Run `npx proteum runtime status`.
|
|
60
|
+
- For runtime-visible work, start or reuse one tracked `npx proteum dev` session using the launch workflow in `During Implementation`, keep it running so the user can see the results, and print the live server URL as a clickable Markdown link.
|
|
61
|
+
|
|
62
62
|
### Before Editing
|
|
63
63
|
|
|
64
|
-
-
|
|
64
|
+
- Complete `Worktree Preflight` when working inside a `.codex/worktrees` worktree.
|
|
65
65
|
- 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.
|
|
66
66
|
|
|
67
67
|
### During Implementation
|
|
68
68
|
|
|
69
69
|
- After running `npx proteum create ...`, adapt the generated code to the real feature instead of leaving placeholder logic in place.
|
|
70
70
|
- 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.
|
|
71
|
-
- When starting a long-lived dev server for an agent task
|
|
71
|
+
- When starting a long-lived dev server for an agent task:
|
|
72
|
+
- Always request elevated permissions and run `npx proteum dev` outside the sandbox.
|
|
73
|
+
- Use an explicit task/thread-scoped session file such as `var/run/proteum/dev/agents/<task>.json`.
|
|
74
|
+
- Inspect `npx proteum runtime status` first, then use its exact Start Dev next action so occupied router/HMR ports are avoided.
|
|
75
|
+
- Do not `curl` normal page routes to identify a port owner; use Proteum runtime status or dev-only `/__proteum/*` endpoints.
|
|
76
|
+
- After the server is ready, print the live server URL as a clickable Markdown link.
|
|
72
77
|
- 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.
|
|
73
|
-
- Do not start a second `npx proteum dev` server in the same worktree
|
|
78
|
+
- Do not start a second `npx proteum dev` server in the same worktree. If MCP routing fails, the runtime is unreachable, or an untracked runtime already answers on the configured port, follow the `Runtime Diagnostics` repair workflow in root-level `diagnostics.md` instead of starting another server.
|
|
74
79
|
- 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.
|
|
75
|
-
-
|
|
76
|
-
- 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>`.
|
|
77
|
-
- 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 and `CLAUDE.md` symlinks point to sibling `AGENTS.md` files before the dev loop begins.
|
|
80
|
+
- 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. Before every browser MCP pass, bootstrap the browser with the project instructions' admin account via `npx proteum session <admin-email> --role GOD` or its `browserLoginUrl`, unless the task is explicitly testing auth, login, anonymous, or non-admin behavior. If the project instructions do not declare an admin email for local validation, stop and ask before running the browser pass. Bootstrap protected E2E runs with `npx proteum e2e --session-email <email> --session-role <role>`.
|
|
78
81
|
|
|
79
82
|
### Before Finishing
|
|
80
83
|
|
|
81
|
-
-
|
|
84
|
+
- Re-check touched files against root-level `CODING_STYLE.md`, including its self-check list, and any narrower area `AGENTS.md` that applied to the edit. Re-check root-level `optimizations.md` only for touched client-side files. Re-check root-level `diagnostics.md` only if the task involved an issue, diagnosis, runtime reproduction, or verification failure.
|
|
85
|
+
- Scan the final diff for missing decision comments: every non-obvious choice, workaround, magic value, and bug fix must carry a why-comment per the `Decision and context comments` section of `CODING_STYLE.md`. A missing why-comment is a defect to fix before finishing, not optional polish.
|
|
82
86
|
- 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
|
-
-
|
|
84
|
-
- When you have finished your work, ask the user whether they want a commit message
|
|
87
|
+
- Apply the `Verification Policy` to the changed surface.
|
|
88
|
+
- When you have finished your work, ask the user whether they want a commit message, then follow `Commit Workflow`.
|
|
89
|
+
|
|
90
|
+
## Commit Workflow
|
|
91
|
+
|
|
92
|
+
This is the canonical git workflow. It applies when the user replies exactly `commit`, and after any commit message you provide.
|
|
93
|
+
|
|
94
|
+
- Scope: conversation-wide and cross-project, not task-scoped. Cover all changes made since the last `commit` and, if there has been no prior `commit`, since the beginning of the whole conversation.
|
|
95
|
+
- Splitting: default to one commit per affected repository or worktree. When the covered changes span clearly separable concerns — independent features, an unrelated fix, a refactor separable from a behavior change — create one commit per concern in that repository, each staging only the files that belong to it. Do not split when the changes only make sense together.
|
|
96
|
+
- Message: one top-level short sentence (up to 100 characters) per commit, covering that commit's changes, strictly using the Conventional Commits specification:
|
|
97
|
+
```
|
|
98
|
+
<type>[optional scope]: <description>
|
|
99
|
+
|
|
100
|
+
[optional body]
|
|
101
|
+
```
|
|
102
|
+
- Commit-time verification, before staging or committing:
|
|
103
|
+
- Downstream Proteum apps: run only `proteum refresh`, then the targeted lint, typecheck, and test commands that match the conversation changes, in parallel.
|
|
104
|
+
- The Proteum framework repository itself: skip the downstream verification above and use the framework repo `AGENTS.md` commit workflow.
|
|
105
|
+
- 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.
|
|
106
|
+
- Report any blocker instead of committing through failed commit-time verification.
|
|
107
|
+
- Staging and committing:
|
|
108
|
+
- Identify every affected git repository or worktree touched during that span.
|
|
109
|
+
- Stage all conversation-related changed files in each affected repository or worktree with `git add`, while avoiding unrelated pre-existing user changes and incidental untracked files.
|
|
110
|
+
- Create one `git commit` per affected repository or worktree, or several per repository when the splitting rule above applies.
|
|
111
|
+
- Do not omit linked local dependencies, framework repos, connected projects, or producer apps when they were changed to make the delivered behavior actually work.
|
|
112
|
+
- Do not stop at only suggesting the message.
|
|
113
|
+
- After providing a commit message or after creating a commit, immediately follow it with this exact prompt and obey it:
|
|
85
114
|
`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.`
|
|
86
115
|
|
|
87
116
|
## Core Contracts
|
|
@@ -93,9 +122,7 @@ Managed compact root routers must use trigger -> canonical instruction file refe
|
|
|
93
122
|
- Manual HTTP endpoints live only in `server/routes/**`.
|
|
94
123
|
- Controllers declare input on `defineAction({ input, handler })`; handlers receive parsed `input` in context.
|
|
95
124
|
- Request-scoped state lives only on action handler context and manual-route handler context objects.
|
|
96
|
-
-
|
|
97
|
-
- Prefer a deep tree grouped by business concern instead of long file names.
|
|
98
|
-
- Use the default `*.ts` or `*.tsx` file unless an `*.ssr.ts` or `*.ssr.tsx` variant is truly required.
|
|
125
|
+
- File organization, typing, formatting, and commenting rules live in root-level `CODING_STYLE.md`.
|
|
99
126
|
- Never edit generated files under `.proteum`.
|
|
100
127
|
- When a task changes database structure, edit the app's `schema.prisma` only.
|
|
101
128
|
- Never create or edit migration files manually.
|
|
@@ -268,17 +295,31 @@ export default defineServerRoute({
|
|
|
268
295
|
- `@client/...`, `@server/...`, `@common/...`: Proteum core modules
|
|
269
296
|
- `@generated/*`: generated app surfaces
|
|
270
297
|
|
|
271
|
-
## Verification
|
|
298
|
+
## Verification
|
|
299
|
+
|
|
300
|
+
### Verification Policy
|
|
301
|
+
|
|
302
|
+
This is the canonical post-change verification policy. Other instruction files point here instead of restating it.
|
|
303
|
+
|
|
304
|
+
- Use the cheapest trustworthy verification that matches the changed surface, including targeted tests for changed behavior.
|
|
305
|
+
- When the repository defines `proteum.verify.config.ts`, run `npx proteum verify changed` as the first post-change verification pass and expand only when the selected plan is insufficient.
|
|
306
|
+
- Applicable production changes must always add or update focused unit tests and run the targeted unit or integration tests that match the changed behavior. Document any generated files, migrations, framework shims, unreachable defensive branches, or changes that cannot reasonably be unit-tested as explicit exceptions in the completion note.
|
|
307
|
+
- After implementing a new feature that is visible in the UI or browser, run a browser MCP pass against the real page before finishing. This is mandatory even when `npx proteum verify changed`, request diagnostics, lint, or typecheck pass; inspect the rendered page, the primary interaction or state, browser console output, and relevant server output for blocking errors.
|
|
308
|
+
- After implementing a new feature or changing existing feature behavior, update the relevant end-to-end coverage. Run targeted `npx proteum e2e --port <port> ...` when the behavior needs automated browser assertions or journey coverage.
|
|
309
|
+
- For docs-only, wording-only, type-only, test-only, generated-output cleanup, or clearly local non-runtime refactors, use static verification only and skip Playwright unless the user explicitly asks for it or verification reveals a real issue.
|
|
310
|
+
- Do not run coverage by default after ordinary changes. Reserve whole-project coverage and the full `npm run check` gate for push workflows, explicit user requests, or when project-local instructions require the full gate.
|
|
311
|
+
- Commit-time verification is defined in `Commit Workflow`.
|
|
312
|
+
|
|
313
|
+
### Verification Matrix
|
|
272
314
|
|
|
273
315
|
Verify at the correct layer:
|
|
274
316
|
|
|
275
|
-
- Default: use the cheapest trustworthy verification for the changed surface, including targeted tests for changed behavior. When `proteum.verify.config.ts` exists, start with `npx proteum verify changed`. Do not run coverage by default during ordinary change closeout.
|
|
276
317
|
- Route additions: boot the app and hit the real URL.
|
|
277
318
|
- Controller changes: exercise the generated client call or generated `/api/...` endpoint.
|
|
319
|
+
- New UI-visible features: run the mandatory browser MCP pass against the real page before finishing, using the project instructions' admin account through `npx proteum session <admin-email> --role GOD` or the emitted `browserLoginUrl` before opening the page unless the scenario is explicitly auth, anonymous, or non-admin.
|
|
278
320
|
- SSR changes: use the browser MCP to load the real page and inspect rendered HTML plus browser console.
|
|
279
321
|
- Router or plugin changes: verify request context, auth, redirects, metrics, and validation on a running app.
|
|
280
|
-
-
|
|
281
|
-
- 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.
|
|
322
|
+
- Generated, connected, or ownership-ambiguous changes: follow `MCP Orientation`; use `npx proteum orient <query>` and `npx proteum verify owner <query>` when MCP is unavailable or terminal evidence is required.
|
|
282
323
|
- 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.
|
|
283
324
|
- 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.
|
|
284
325
|
- For trace-first reproduction, session-based auth setup, temporary logs, and post-fix surface checks, follow root-level `diagnostics.md`.
|
|
@@ -293,16 +334,12 @@ Verify at the correct layer:
|
|
|
293
334
|
- When the task explicitly involves client-side optimization work, use root-level `optimizations.md` to decide whether custom infrastructure is justified over an existing package.
|
|
294
335
|
- When you choose custom over a package, explain the reason briefly.
|
|
295
336
|
|
|
296
|
-
### Catalogs
|
|
337
|
+
### Catalogs
|
|
297
338
|
|
|
298
339
|
- Keep one canonical catalog or registry file and import it everywhere else.
|
|
299
340
|
- Client-only catalogs live in `/client/catalogs/**`, server-only catalogs in `/server/catalogs/**`, and shared catalogs in `/common/catalogs/**`.
|
|
300
341
|
- Do not create nested `catalogs/` folders under pages, components, services, tests, or other feature folders.
|
|
301
|
-
-
|
|
302
|
-
- Do not introduce `any` or `unknown`, including through casts, helper aliases, or fallback generic defaults.
|
|
303
|
-
- Do not use `Reflect.get`, bracket access, broad `in` checks, or local loose reader helpers to bypass missing typings for app-owned data; fix the type contract or normalize once with a typed adapter at the boundary.
|
|
304
|
-
- Fix typing issues only on code you wrote.
|
|
305
|
-
- Never cast with `as any` or `as unknown`; fix the contract or add an explicit typed adapter.
|
|
342
|
+
- Typing rules, including the ban on `any`, `unknown`, and loose casts, live in root-level `CODING_STYLE.md`.
|
|
306
343
|
|
|
307
344
|
### Design Rules
|
|
308
345
|
|
|
@@ -322,9 +359,41 @@ Verify at the correct layer:
|
|
|
322
359
|
|
|
323
360
|
- Never run schema-mutating SQL such as `ALTER TABLE`, `CREATE TABLE`, `DROP TABLE`, or `CREATE INDEX` to change database structure.
|
|
324
361
|
- 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.
|
|
325
|
-
- Do not run `prisma *` yourself. If
|
|
362
|
+
- Do not run `prisma *` yourself. If you changed `schema.prisma`, do not start testing or validation yet. Ask the user to run the following command in the affected worktree directory, replacing the placeholders, and wait for the user to reply exactly `continue` before resuming validation or tests:
|
|
363
|
+
```
|
|
364
|
+
cd <worktree path>
|
|
365
|
+
npx prisma migrate dev --config ./prisma.config.ts --name <migration name>
|
|
366
|
+
```
|
|
326
367
|
- Do not run `git restore` or `git reset`.
|
|
327
|
-
- Do not run write-mode git commands by default. The built-in exception is
|
|
368
|
+
- Do not run write-mode git commands by default. The only built-in exception is the exact `commit` reply handled by `Commit Workflow`, which allows `git add` and `git commit` after its commit-time verification succeeds. Any other write-mode git action requires an explicit user request.
|
|
369
|
+
- 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.
|
|
370
|
+
|
|
371
|
+
## Delivery Workflow
|
|
372
|
+
|
|
373
|
+
Agents working in generated Proteum projects must use this delivery workflow for production code changes:
|
|
374
|
+
|
|
375
|
+
1. BDD / ATDD: translate the requested behavior into acceptance scenarios before changing implementation code.
|
|
376
|
+
2. TDD: write or update the smallest failing unit/integration test that proves the next behavior.
|
|
377
|
+
3. Implementation: make the narrowest production change that satisfies the failing test while preserving Proteum boundaries, recording non-obvious decisions as why-comments per `CODING_STYLE.md` while the reasoning is still in context.
|
|
378
|
+
4. Targeted validation: refresh generated framework contracts after route, page, controller, service, command, or config changes, then apply the `Verification Policy` to the changed surface.
|
|
379
|
+
5. Validate unit + E2E: run the relevant unit tests and real-world journey E2E checks before calling the work complete.
|
|
380
|
+
|
|
381
|
+
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.
|
|
382
|
+
|
|
383
|
+
Recommended validation sequence:
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
npm run refresh
|
|
387
|
+
npm run typecheck
|
|
388
|
+
npm run lint
|
|
389
|
+
npm run test
|
|
390
|
+
npm run test:integration
|
|
391
|
+
npx proteum check
|
|
392
|
+
npx proteum doctor --contracts --strict
|
|
393
|
+
npx proteum e2e --port <port>
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
When bundling, SSR, server startup, routing, or build-time behavior changes, also run the project build command before finishing.
|
|
328
397
|
|
|
329
398
|
## Appendix
|
|
330
399
|
|
|
@@ -411,32 +480,3 @@ Edit these only when required, and keep changes minimal and explicit:
|
|
|
411
480
|
- `PORT`, `ENV_*`, `URL`, `TRACE_*`, and `ENABLE_PROFILER` env setup
|
|
412
481
|
- Prisma-generated files
|
|
413
482
|
- symbolic links
|
|
414
|
-
|
|
415
|
-
## Delivery Workflow
|
|
416
|
-
|
|
417
|
-
Agents working in generated Proteum projects must use this delivery workflow for production code changes:
|
|
418
|
-
|
|
419
|
-
1. BDD / ATDD: translate the requested behavior into acceptance scenarios before changing implementation code.
|
|
420
|
-
2. TDD: write or update the smallest failing unit/integration test that proves the next behavior.
|
|
421
|
-
3. Implementation: make the narrowest production change that satisfies the failing test while preserving Proteum boundaries.
|
|
422
|
-
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.
|
|
423
|
-
5. Validate unit + E2E: run the relevant unit tests and real-world journey E2E checks before calling the work complete.
|
|
424
|
-
|
|
425
|
-
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.
|
|
426
|
-
|
|
427
|
-
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.
|
|
428
|
-
|
|
429
|
-
Recommended validation sequence:
|
|
430
|
-
|
|
431
|
-
```bash
|
|
432
|
-
npm run refresh
|
|
433
|
-
npm run typecheck
|
|
434
|
-
npm run lint
|
|
435
|
-
npm run test
|
|
436
|
-
npm run test:integration
|
|
437
|
-
npx proteum check
|
|
438
|
-
npx proteum doctor --contracts --strict
|
|
439
|
-
npx proteum e2e --port <port>
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
When bundling, SSR, server startup, routing, or build-time behavior changes, also run the project build command before finishing.
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# Coding style
|
|
2
2
|
|
|
3
|
-
This file is the
|
|
3
|
+
This file is the canonical coding-style contract for Proteum-based projects. It is loaded before editing any implementation file and re-checked before finishing. Keep workflow, verification, and architecture rules in `AGENTS.md`; keep only style, typing, formatting, and commenting rules here.
|
|
4
4
|
|
|
5
5
|
## Baseline
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Write code so the next reader — human or agent, with none of the current conversation's context — can recover every decision from the code and its comments.
|
|
8
8
|
- Write clean, consistent, readable code with a tab size of 4.
|
|
9
|
-
- Keep functions and methods short.
|
|
10
|
-
-
|
|
11
|
-
-
|
|
9
|
+
- Keep functions and methods short; extract a helper once a block needs its own explanation.
|
|
10
|
+
- Create reusable functions and components instead of repeating logic.
|
|
11
|
+
- Coding-style regressions are defects, not optional cleanup.
|
|
12
12
|
|
|
13
13
|
## Type safety
|
|
14
14
|
|
|
15
|
+
- Keep strong TypeScript typings; do not introduce `any` or `unknown`, including through casts, helper aliases, or fallback generic defaults.
|
|
16
|
+
- Never cast with `as any` or `as unknown`; fix the contract or add one explicit typed adapter at the boundary.
|
|
15
17
|
- Do not use `Reflect.get`, bracket access, broad `in` checks, or local loose reader helpers to bypass missing typings for app-owned data; fix the type contract or normalize once with a typed adapter at the boundary.
|
|
18
|
+
- Fix typing issues only on code you wrote.
|
|
16
19
|
|
|
17
20
|
## Formatting
|
|
18
21
|
|
|
@@ -30,7 +33,7 @@ This file is the source of truth for codex coding style instructions in Proteum-
|
|
|
30
33
|
- The default `*.ts` / `*.tsx` file is the browser implementation; use `*.ssr.ts` / `*.ssr.tsx` only for SSR-safe fallbacks.
|
|
31
34
|
- When implementing a feature that relies on a curated list of items, keep one canonical catalog or registry file and make all other code import it.
|
|
32
35
|
|
|
33
|
-
## Section comments
|
|
36
|
+
## Section comments
|
|
34
37
|
|
|
35
38
|
- Organize files with explicit banner comments:
|
|
36
39
|
|
|
@@ -40,38 +43,64 @@ This file is the source of truth for codex coding style instructions in Proteum-
|
|
|
40
43
|
----------------------------------*/
|
|
41
44
|
```
|
|
42
45
|
|
|
43
|
-
- Reuse project-native
|
|
44
|
-
- `DEPENDANCES`
|
|
45
|
-
- `TYPES`
|
|
46
|
-
- `HELPERS`
|
|
47
|
-
- `CONSTANTS`
|
|
48
|
-
- `COMPONENT`
|
|
49
|
-
- `SERVICE`
|
|
50
|
-
- `CONTROLEUR`
|
|
51
|
-
- `ROUTES`
|
|
52
|
-
- `PAGE`
|
|
53
|
-
- `CONFIG`
|
|
54
|
-
- `PUBLIC API`
|
|
55
|
-
- `API`
|
|
56
|
-
- `HOOKS`
|
|
57
|
-
- `LAYOUT`
|
|
58
|
-
- `CLASS`
|
|
59
|
-
- `MODULE`
|
|
60
|
-
- `STATE`
|
|
61
|
-
- `CONTEXT`
|
|
62
|
-
- `QUERIES`
|
|
63
|
-
- `SCHEMA`
|
|
64
|
-
- `SCHEMAS`
|
|
65
|
-
- `ROUTING`
|
|
66
|
-
- `RENDER`
|
|
67
|
-
- `EXPORTS`
|
|
68
|
-
- `UTILS`
|
|
69
|
-
- `CONTENT`
|
|
70
|
-
- `FILTERS`
|
|
71
|
-
- `STATS`
|
|
72
|
-
- `BUILDERS`
|
|
73
|
-
- `CATALOG`
|
|
74
|
-
- `CATALOG (SSOT)`
|
|
46
|
+
- Reuse the section names already used in the touched file or area first. Common project-native names include `DEPENDANCES`, `TYPES`, `CONSTANTS`, `HELPERS`, `SERVICE`, `CONTROLEUR`, `COMPONENT`, `HOOKS`, `STATE`, `CONFIG`, `ROUTES`, `RENDER`, `PUBLIC API`, `EXPORTS`, and `CATALOG (SSOT)`.
|
|
75
47
|
- File-specific section names are allowed when they improve navigation, for example `ROUTE: ...`, `COMPONENT: ...`, or `VIEW: ...`.
|
|
76
|
-
|
|
77
|
-
|
|
48
|
+
|
|
49
|
+
## Decision and context comments
|
|
50
|
+
|
|
51
|
+
Comments are the project's in-place memory: they carry decisions and constraints to the next agent or developer, who will have none of the current context. The code says what; comments say why.
|
|
52
|
+
|
|
53
|
+
- Comment every non-obvious implementation choice at the decision site: why this approach, which constraint forced it, and which alternative was rejected and why when a real alternative was considered.
|
|
54
|
+
- When fixing a bug, comment the invariant that must not regress next to the fixed code, and reference the fix note under `docs/fixes/**` when one exists.
|
|
55
|
+
- A workaround must name what it works around (dependency and version, upstream issue, browser or runtime quirk) and the condition under which it can be removed.
|
|
56
|
+
- Comment magic values, ordering requirements, timing assumptions, and intentional deviations from this document where they occur.
|
|
57
|
+
- When refactoring, move existing why-comments with the code they explain; delete one only when its reason no longer exists.
|
|
58
|
+
- Do not add noisy comments that restate obvious code; a comment that paraphrases the next line is a defect.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Bad: restates the code, carries no decision
|
|
62
|
+
// increment the retry counter
|
|
63
|
+
retries++;
|
|
64
|
+
|
|
65
|
+
// Good: records the constraint and the decision
|
|
66
|
+
// Stripe webhooks can arrive out of order; process by event.created, not arrival time.
|
|
67
|
+
// Decision: sort in memory instead of queueing — volume stays under ~100 events/min.
|
|
68
|
+
// See docs/fixes/2026-06-02-stripe-replay.md.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Doc anchors
|
|
72
|
+
|
|
73
|
+
A why-comment explains one decision. A doc anchor connects the file to the durable documentation that governs it, so an agent that opens the file finds the feature pack, the decision record and the invariant without searching the corpus first.
|
|
74
|
+
|
|
75
|
+
Write anchors in a leading block comment:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
/**
|
|
79
|
+
* @docs docs/features/search
|
|
80
|
+
* @adr ADR-0004
|
|
81
|
+
* @fix docs/fixes/2026-06-09-keyword-search-semantic-order.md
|
|
82
|
+
* @rule Composite ordering stays alias-aware. Never rewrite ORDER BY with regex.
|
|
83
|
+
*/
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- `@docs` points at the feature pack that owns the file. Required on every file that default-exports `definePageRoute`, `defineController`, `defineServerRoute`, or `defineServerRoutes`. Error routes are exempt: they render a status message and carry no feature-specific rule, so requiring a pack for one would manufacture documentation. Add an anchor to an error route only when it really does carry a rule.
|
|
87
|
+
- `@adr` and `@fix` point at the decision record and fix note that constrain the file. Add them where the decision or the bug actually lives, not on every file in the area.
|
|
88
|
+
- `@rule` states the invariant inline, in full. It is the one anchor that carries content rather than a pointer, because the rule is what an agent needs at the moment of editing. A `@rule` that only says `todo` or repeats the linked title is a defect.
|
|
89
|
+
- Anchors are not a substitute for the documents. Narrative, alternatives, benchmarks and acceptance stay under `docs/**`; the anchor carries the pointer and the single-sentence rule.
|
|
90
|
+
|
|
91
|
+
Two ESLint rules enforce this. `proteum/require-doc-anchor` reports definition files with no `@docs`, and warns by default so an adopting project sees its backlog without a failing build; pass `docAnchors: 'error'` to `createProteumEslintConfig` once the backfill is done. `proteum/valid-doc-anchor` always errors, because an anchor pointing at a deleted document is worse than no anchor.
|
|
92
|
+
|
|
93
|
+
The read-only MCP owner payloads return these anchors alongside `explain_summary`, `orient`, `route_candidates`, `diagnose`, and `workflow_start`, so the documentation reaches the agent in the same response that identifies the owner.
|
|
94
|
+
|
|
95
|
+
`proteum docs check` verifies the whole corpus in both directions: it fails on an anchor that no longer resolves, and reports as a backlog every fix note carrying an `Agent warning` that no code anchors, plus every feature pack nothing points at. `proteum verify changed` selects it automatically whenever `docs/**` or a source file changes, so a renamed document cannot silently orphan an anchor.
|
|
96
|
+
|
|
97
|
+
## Self-check before finishing
|
|
98
|
+
|
|
99
|
+
Re-scan every touched file against this list before declaring the work done:
|
|
100
|
+
|
|
101
|
+
- No `any`, `unknown`, or casts introduced; contracts fixed at the boundary.
|
|
102
|
+
- New code sits under the right banner section, and section names still match their content.
|
|
103
|
+
- Every non-obvious decision, workaround, magic value, and bug fix has a why-comment at the site.
|
|
104
|
+
- Every touched definition file carries a `@docs` anchor, and any fix or decision applied in this pass left a `@rule` anchor at the code site it constrains.
|
|
105
|
+
- No comments that restate code; no leftover debug logs or commented-out code.
|
|
106
|
+
- Repeated logic extracted; one class or component per file; catalogs stay canonical.
|
|
@@ -37,6 +37,8 @@ Do not code from assumptions when a source-of-truth document exists.
|
|
|
37
37
|
|
|
38
38
|
Do not duplicate rules across documents. Link to the source of truth when needed.
|
|
39
39
|
|
|
40
|
+
Documentation must be reachable from the code it governs. Every document written under these rules names the code it affects; the code must point back with a doc anchor, so the next agent finds the governing document by opening the file rather than by searching the corpus. Anchors carry pointers plus the single-sentence invariant, never the narrative. The format and the lint rules that enforce it are in `CODING_STYLE.md`.
|
|
41
|
+
|
|
40
42
|
---
|
|
41
43
|
|
|
42
44
|
# 2. Always read these first
|
|
@@ -86,6 +88,7 @@ docs/features/<feature>/acceptance.md
|
|
|
86
88
|
docs/testing/regression-tests.md if a regression test was added
|
|
87
89
|
docs/decisions/ if a major decision changed
|
|
88
90
|
docs/fixes/ if a bug or regression was fixed
|
|
91
|
+
@docs anchor on each definition file the feature owns
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
---
|
|
@@ -108,6 +111,7 @@ After fixing the bug, update:
|
|
|
108
111
|
docs/fixes/YYYY-MM-DD-short-bug-name.md
|
|
109
112
|
docs/testing/regression-tests.md
|
|
110
113
|
affected feature edge-cases.md if a new edge case was discovered
|
|
114
|
+
@rule and @fix anchors at the code site that regressed
|
|
111
115
|
```
|
|
112
116
|
|
|
113
117
|
A bug fix is incomplete if:
|
|
@@ -117,6 +121,7 @@ the root cause is not documented
|
|
|
117
121
|
the implemented solution is not documented
|
|
118
122
|
the regression test is not linked
|
|
119
123
|
future agents cannot tell what pattern must not return
|
|
124
|
+
the invariant lives only in the fix note and not at the code site that regressed
|
|
120
125
|
```
|
|
121
126
|
|
|
122
127
|
---
|
|
@@ -847,12 +852,18 @@ tests/regression/<area>/<bug-name>.test.ts
|
|
|
847
852
|
|
|
848
853
|
## New rule added
|
|
849
854
|
|
|
850
|
-
What should future agents follow?
|
|
855
|
+
What should future agents follow? Both sections below are mandatory, and each one must also be mirrored to a `@rule` doc anchor at the code site it constrains. A rule that lives only in this note reaches no agent editing that file.
|
|
851
856
|
|
|
852
857
|
## Agent warning
|
|
853
858
|
|
|
854
859
|
What pattern must not be reintroduced?
|
|
855
860
|
|
|
861
|
+
## Code anchor
|
|
862
|
+
|
|
863
|
+
```txt
|
|
864
|
+
path/to/file the @rule and @fix anchors added there
|
|
865
|
+
```
|
|
866
|
+
|
|
856
867
|
## Related docs
|
|
857
868
|
|
|
858
869
|
- docs/features/<feature>/
|
|
@@ -1004,11 +1015,17 @@ tests/performance/<benchmark>.test.ts
|
|
|
1004
1015
|
|
|
1005
1016
|
## New rule added
|
|
1006
1017
|
|
|
1007
|
-
What should future agents follow?
|
|
1018
|
+
What should future agents follow? Both sections below are mandatory, and each one must also be mirrored to a `@rule` doc anchor at the code site it constrains. A rule that lives only in this note reaches no agent editing that file.
|
|
1008
1019
|
|
|
1009
1020
|
## Agent warning
|
|
1010
1021
|
|
|
1011
1022
|
What pattern must not be reintroduced?
|
|
1023
|
+
|
|
1024
|
+
## Code anchor
|
|
1025
|
+
|
|
1026
|
+
```txt
|
|
1027
|
+
path/to/file the @rule and @fix anchors added there
|
|
1028
|
+
```
|
|
1012
1029
|
````
|
|
1013
1030
|
|
|
1014
1031
|
---
|
|
@@ -42,7 +42,6 @@ Coding style source of truth: root-level `CODING_STYLE.md`.
|
|
|
42
42
|
|
|
43
43
|
- Do not add `React` imports just for JSX.
|
|
44
44
|
- Do not use `React.useCallback` unless it is necessary or already common in the touched area.
|
|
45
|
-
- Keep one component per file.
|
|
46
45
|
- Load data and define handlers in the directly concerned component when that keeps ownership clearer.
|
|
47
46
|
- Keep curated lists, option registries, and UI copy catalogs under `/client/catalogs/**`.
|
|
48
47
|
- Follow the section-comment format from the root-level `CODING_STYLE.md`.
|