@dokebi/cli 0.4.29 → 0.4.30

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/AI.md CHANGED
@@ -77,14 +77,14 @@ The `blog` plan, depending on the answers: `init` (when the folder is not a proj
77
77
  | `dokebi config unset <id>[.<path>]...` | Removes options ([D-0153](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0153-config-unset.md)) from dokebi.yaml and from dokebi.example.yaml where the sample has them, in one transaction, with the mappings left empty (the plugin section stays): `{ removed: [{ option, files }], changed, warnings?, configRequired? }`. Values are never printed. A path that is not set is the warning `OPTION_NOT_SET` (a repeated call changes nothing); a secret may be removed (warning `SECRET_REMOVED`: what it signed no longer verifies; to replace one use `config secret --rotate`). The plugin need not be installed (a section `dokebi remove` kept). `logging.<path>` removes from `options.logging`, list items by `name` (else `type`) or index (`config unset logging.targets.studio` removes that target); an item that is not there is `OPTION_NOT_SET`. The removal may only leave missing required values (`configRequired`) or issues the options already had (warning `OPTIONS_STILL_INVALID` with the next `hint`); a new issue is `INVALID_PLUGIN_OPTIONS` and nothing is written. Use it for a key a plugin does not know: `INVALID_PLUGIN_OPTIONS` (from add, config set, doctor) names `npx dokebi config unset <id>.<key>` in its `fix`, and a key that moved to another plugin (`dokebi-web.files` → `dokebi-static.mounts`, D-0147) says where it went and the commands that carry it over A section a file still holds as written is that section, never the plugin the name belongs to: in a sample with the old `options.dokebi-logger` (now `options.logging`), `config unset dokebi-logger.level` removes that old key and warns `SECTION_NOT_READ`, and the live `logging.level` stays (AI-M47 report: it removed the live one before); with no such section the plugin id is `PATH_MISMATCH` (name it `logging.<path>`). List indexes and names are of each file as it is before the call, whichever name reaches the section; one item named twice (`logging.targets.studio` and its index) is removed once. A section alone (`config unset dokebi-logger`) removes a whole section nothing reads; a plugin's, the settings' or a core section (`logging`, `reload`) that way is `INVALID_SET` |
78
78
  | `dokebi config secrets` | The secret option paths the app needs, **by name, never values** ([D-0184](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0184-production-deploy.md)): `{ file, secretsFile, listed, secrets[{path, source, listed, required, type}], missing }` from the settings the app reads (`DOKEBI_CONFIG`, else dokebi.yaml) merged with the secrets file `DOKEBI_SECRETS` names. `source` is `config`, `secrets` or `null` (not set: absent, empty or a `<placeholder>`); `listed` means the document's `secrets:` list names it (the app refuses to start without it), `required` that an installed plugin's install plan generates it (`dokebi-session.secrets`). A secret inside a list item is named by the item where the settings name it (`logging.targets.studio.token` for `logging.targets.1.token`: its `name`, else the `type` of an item without a name, when no other item shares it): the key a secrets file fills that field with, the list staying in the settings (@dokebi/config 0.4.4). `type` is the option's JSON Schema type (`string`; `array` for a list such as `dokebi-session.secrets`, `dokebi-auth.secrets`, `dokebi-csrf.secrets`, `dokebi-mail.secrets`; several as a list; `null` without a schema): a tool that writes the secrets file writes an `array` as a YAML list, even of one value (a text there is `INVALID_PLUGIN_OPTIONS`). Exit 1 with `ok: false` while `missing` is not empty. Warnings `SECRET_IN_CONFIG_FILE` (with `DOKEBI_SECRETS` set, the settings file still holds a secret) and `SECRETS_PLAN_UNREADABLE` (a plugin's install module could not run: npm install). A secrets file readable by others, the same option in both files, or a list item the settings do not have, fails as the app would (`CONFIG_SECRETS_UNSAFE`, `CONFIG_SECRETS_CONFLICT`, `CONFIG_SECRETS_UNMATCHED`) |
79
79
  | `dokebi deploy init [--target <systemd\|compose>] [--instance <name>]... [--port <n>] [--dry-run]` | **An existing project made ready for a server** (D-0184, §11): per instance (with @dokebi/web: `production` port 3000, `staging` 3001, another name needs `--port`, two instances never share a port: `PORT_IN_USE`; without it nothing listens: no port (0, `— (no web server)` in DEPLOY.md) and `--port` is `USAGE`) `deploy/<instance>/dokebi.example.yaml` (the sample without its secrets, with the instance's web host/port/trustProxy, storage folder and a `secrets:` list), `deploy/<instance>/secrets.example.yaml` (the secret paths with placeholders; a secret inside a list item is that field only, named by the item: `logging.targets.studio.token`, the list staying in the settings sample), `deploy/systemd/<app>-<instance>.service` (or `deploy/compose/<instance>.yaml` with `--target compose`, and Dockerfile/.dockerignore when missing), with @dokebi/db also `deploy/systemd/<app>-<instance>-backup.service`/`.timer`, `deploy/backup.mjs` and `deploy/restore-drill.mjs`, and `DEPLOY.md`. Result `{ app, target, instances[{instance, port, unit, settings, secrets, code, data, logs, backups, database}], secrets, changed, unchanged, kept }`. A second run changes nothing; a file you edited since is kept (`kept`, warning `DEPLOY_FILE_KEPT`); an untouched one is rewritten (DEPLOY.md gains a new instance). Errors `NOT_A_PROJECT`, `APP_NAME_INVALID` (package.json name), `EXAMPLE_MISSING`, `PORT_REQUIRED`, `PORT_IN_USE`, `OPTIONS_SCHEMA_UNREADABLE` (npm install first: without a plugin's schema its secrets cannot be told apart) |
80
- | `dokebi deploy proxy --caddy\|--nginx --domain <host>... [--instance <name>] [--dry-run]` | The reverse proxy file of an instance (D-0184): `deploy/proxy/<app>-<instance>.Caddyfile` or `.nginx.conf`, from `deploy/<instance>/dokebi.example.yaml` (port, health routes, body limit, request timeout): TLS (Caddy's automatic certificates; nginx with certbot's paths and an http → https redirect), `X-Forwarded-For/Proto/Host`, WebSocket upgrades, unbuffered SSE (the app sends `X-Accel-Buffering: no`) and a long read timeout when the app keeps streams (SSE, WebSocket, MCP), `/health/live` and `/health/ready` passed through uncached, the app's own `Cache-Control` and compression left as they are. Warnings `TRUST_PROXY_MISSING` (the sample's `dokebi-web.trustProxy` lacks 127.0.0.1 or ::1) and `DOMAIN_NOT_MAPPED` (a domain not in `dokebi-app.domains`). Errors `WEB_NOT_INSTALLED`, `INSTANCE_UNKNOWN` (deploy init first) |
80
+ | `dokebi deploy proxy --caddy\|--nginx --domain <host>... [--instance <name>] [--dry-run]` | The reverse proxy file of an instance (D-0184): `deploy/proxy/<app>-<instance>.Caddyfile` or `.nginx.conf`, from `deploy/<instance>/dokebi.example.yaml` (port, health routes, body limit, request timeout): TLS (Caddy's automatic certificates; nginx with certbot's paths and an http → https redirect), `X-Forwarded-For/Proto/Host`, WebSocket upgrades (nginx: other requests send no `Connection` upstream, so `keepalive 16` reuses connections, idle for at most 60 s, below the app's 72 s), unbuffered SSE (the app sends `X-Accel-Buffering: no`) and a long read timeout when the app keeps streams (SSE, WebSocket, MCP), only the listed names (nginx answers another `Host` with 421; Caddy serves only its site names), `/health/live` and `/health/ready` passed through with one `Cache-Control: no-store` (the app's own replaced), the app's own `Cache-Control` and compression left as they are. Warnings `TRUST_PROXY_MISSING` (the sample's `dokebi-web.trustProxy` lacks 127.0.0.1 or ::1) and `DOMAIN_NOT_MAPPED` (a domain not in `dokebi-app.domains`). Errors `WEB_NOT_INSTALLED`, `INSTANCE_UNKNOWN` (deploy init first) |
81
81
  | `dokebi dev-infra [up\|start\|stop\|down\|status] [--file <path>] [--db-port <n>] [--dry-run]` | Without an action: prepare compose.yaml and the database URL in dokebi.yaml; no .env is generated. With an action: run Docker Compose using the YAML password in the child environment only. Repeat --file for additional Compose files. down retains data volumes. --db-port and --dry-run apply only to preparation. On a kept compose.yaml (`COMPOSE_KEPT`, its published port is the URL's) `--db-port <n>` changes only the published host port of `services.db` in it (every other byte of the file stays) and the URL in dokebi.yaml, with the warning `COMPOSE_PORT_CHANGED` (`hint`: `dev-infra up` recreates a running container on the new port and keeps its data volume); a taken port is `PORT_IN_USE`. A port entry the CLI cannot read (a variable, a range) refuses `--db-port` with `COMPOSE_PORT_UNKNOWN` (`details.file`, `details.fix`: set the entry yourself) and nothing is written; without the flag the run keeps the URL's port and warns `COMPOSE_PORT_UNKNOWN`. A MongoDB is a single-node replica set (`rs0`, D-0103): the generated mongod gets `--replSet rs0` and a key file made inside the container at each start (mongod needs one for a replica set with authentication), the healthcheck initiates the set once and passes when the member is the writable primary (so `up` returns when transactions work), and the URL ends with `replicaSet=rs0&directConnection=true`; `service.replicaSet` says so. A kept compose.yaml whose server is standalone (written before) keeps a standalone URL and gives the warning `DEV_INFRA_STANDALONE`, whose `hint` is the switch: `dev-infra down`, move compose.yaml away, `dev-infra --db-port <its port>`, `dev-infra up` (password and data volume kept). `DEV_INFRA_CONFIG_INVALID` means the main database URL is invalid/unset; `DEV_INFRA_FAILED` means the Compose action failed. |
82
82
  | `dokebi verify [--wait-ms <n>] [--test-timeout-ms <n>]` · `verify --remote <https-url> [--timeout-ms <ms>]` | With `--remote` (D-0184) only that site is checked, nothing local runs: `{ ok, url, checks[{name, ok, warning?, status?, detail, ms}], certificate? }` with the checks `tls` (the certificate is valid for the host; under 14 days left is a warning), `redirect` (http answers a redirect to https; a warning otherwise), `live` and `ready` (the health routes of the settings when run in a project, else `/health/live` and `/health/ready`, must answer 200), `headers` (HSTS and `X-Content-Type-Options: nosniff`; on an HTML answer also `X-Frame-Options` or CSP `frame-ancestors`, and `Referrer-Policy` (a warning); `X-Powered-By` fails; HSTS under 180 days is a warning); exit 1 when a check fails. Without it: `{ ok, checks[{name, ok, skipped?, ms, code?, message?, details?}], urls[], listen[], tests?, tellUser?, relay?, finalReport?, warnings? }` (`warnings`: `ENV_DOKEBI_CONFIG_IGNORED` when `.env` sets `DOKEBI_CONFIG`, §2.2): doctor → check (`dokebi check` below, reusing the doctor result) → typecheck (skipped without the script) → build (Vite) → test (the package.json `test` script, skipped without one: `no test script`; see **Tests in verify** below) → preflight (`ALREADY_RUNNING`, `PORT_IN_USE`, `DB_URL_MISSING`; a taken web port is the user's call as in the recipe preflight: the problem has `alternative` (the first free port after it), `fix` (`npx dokebi config set dokebi-web.port=<alternative>`), `waitForUser`, `question` and `next`, and the result repeats `waitForUser`, `question` and `next`; `waitForUser` is false when the last recipe ran with `--defaults`) → start (`--wait-ms`, default 30000) → HTTP (connects to the listening address: `/health/ready`, and `GET /` with the Host header of every app domain; with neither a readiness route (`healthRoutes: false`) nor an app domain, one identity probe `GET /` that passes with any status below 500 carrying this run's header, so HTTP never passes without a request: `details.requests[].identity: true`; each request must complete within 5 s, a response cut off or never finished is `HTTP_FAILED`) → stop. `urls` are the addresses the app answers (see `start`), `listen` the bound addresses. `ok` only when everything passes (otherwise exit 1). A doctor or preflight failure skips the start; a check failure does not. It never stops an app that already runs. **HTTP counts only answers from the app verify started**: it passes a random token in `DOKEBI_VERIFY_TOKEN` and @dokebi/web echoes it in the response header `x-dokebi-verify` (only while that variable is set, no cost in production). An answer without the token comes from another server on the port: `FOREIGN_SERVER` (`details.requests[].instance: other`). When the app did not start, HTTP is skipped and fails (`NOT_STARTED`). stop ends the processes verify started by the pid start returned (no `ps` needed, works in a sandbox); `APP_EXITED` when the app ended by itself first, `STOP_FAILED` when a signal cannot be sent; a SIGINT, SIGTERM or SIGHUP to verify while its app runs stops that app first (forced after 5 s), then verify ends as the signal says (also while the start step still waits for the app: nothing it started is left running). With `ok: true` and an applied recipe (`.dokebi/recipe.json`), `tellUser: string[]` holds the lines your final message must include (each choice with who made it: `<id> = <value>: your answer`, `: chosen by the AI (you left the choice to it)` followed by `: <aiReason>` when you gave one, `: chosen by default (<reason>)`; then the notices); a notice that names the app address (the admin login) is filled in with the address the app has now (`urls`, else `dokebi-web.port`), so a later port change shows the new one; with them comes `relay: { tellUser: 'verbatim', instruction }` (AI-M05 F6): copy the lines unchanged into your final message, never translated, reworded or summarized, and add your own summary only after them; when verify also has `finalReport`, the instruction adds that the table or list a heading announces (Database practice, Silenced check rules) is written right under it in the same message — a results file or a link does not replace it; the human output ends with them under `Tell the user exactly these lines.` and the same instruction. An EJS blog without @dokebi/session gets a notice that offers it to the user (AI-M05 F3: with `--defaults` the next step says not to add it, since the defaults are the plan; with `--answers-from user` the next step says to ask first). Without a recipe record there is no `tellUser`. With `ok: true` and @dokebi/db installed, `finalReport: string[]` (D-0105 §4) says what your final message must also contain, written by you rather than copied: the table of section 6 of `node_modules/@dokebi/db/AI.md`, one row per rule with the queries or jobs it applies to, the measurement and the verdict (pass, or the fix you made) (a results file does not replace it); the human output lists it under `Your final message must also contain:`, and when there are `tellUser` lines they end with a heading for each (`Database practice (@dokebi/db AI.md section 6): the table below, here in this message, has one row per rule of that section (6.1 Cost follows the page, not the table; …), …`, naming the rules of the installed AI.md, `Silenced check rules (dokebi-check allow markers), each followed below, here in this message, by why the rule does not apply there: …`): relay them as they are and write the table or the reasons under them |
83
83
  | `dokebi mail preview <name> [--locale <locale>]` | Render preview.json without network connections or data hooks; JSON includes subject, html, text and locale |
84
84
  | `dokebi describe [--with-db] [--timeout-ms <ms>]` | What the app has, without serving (D-0077): it loads the project like `start` (the settings file — `DOKEBI_CONFIG`, else dokebi.yaml —, `src/dokebi.generated.ts`, the project's `.env` under the environment, the doctor check first: `START_CHECK_FAILED`) in core's describe mode: every plugin's setup runs, no start or ready hook, so nothing listens, no database, Redis or NATS connection is opened and no job is bound. `--json` is `{ schemaVersion: 1, app: { name, core, plugins[{name, version, described}], apps[], domains[], unknownDomain, web, session, csrf, auth, … }, routes[{method, url, id?, app?, host?, constraints?, schema?{body, querystring, params, headers, response}, config?{auth, can, roles, csrf, …}, auth?{mode, realm, via, can?}, seal?, health?}], pages[{app, engine: ejs\|inertia, template, name, file}], jobs[], schedules[], errors[{code, status, message, hint?}], config: { keys[], env[{name, plugin, purpose}] }, db: { connections[{name, adapter, startup?, dialect?, schemas?, tables?, collections?, unavailable?}], unavailable? }, unavailable[{plugin, section?, code, reason}], warnings?, ms }`, checked by the JSON Schema `describe.schema.json` of this package. `route.auth` is the login rule @dokebi/auth applies (its `default` included); `config.keys` are option paths and `config.env` variable names, **never a value**; `errors` are the codes of `src/shared/errors.ts`. A plugin whose setup fails is listed in `unavailable` (with the plugins that need it, `DEPENDENCY_UNAVAILABLE`) and the rest is still described; a database, Redis, NATS, SMTP or S3 that is not running is never the reason (D-0133: plugins on never-connected clients still set up; a nats event bus refuses only `publish`, with `DESCRIBING`), while a real configuration error (an unknown connection name, a connection of the wrong kind) still is. Without `--with-db` the tables are not read (`db.unavailable` says so; describe mode never connects). **`--with-db`** adds a separate step that connects: for each dokebi-db connection it runs the project's `dokebi-migrate schema --connection <name> --json` (@dokebi/migrate 0.4.2) and puts its `dialect` and `tables` (columns with type, nullable, default, identity, generated; primary key, unique, indexes, foreign keys, checks; `isMigrationHistory` on `dokebi_migrations`) or MongoDB `collections` into `db.connections[]`; a connection it cannot read (not listed in `options.dokebi-migrate.connections`, @dokebi/migrate missing, the database refused, `--timeout-ms` passed) gets its own `unavailable` reason and describe still answers. `startup: 'optional'` marks a connection dokebi.yaml lets the app run without ([D-0127](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0127-optional-db-startup.md); the default `required` is left out); `dokebi-migrate schema` opens it as required, so while it is down it is `unavailable` with the open or check error, and `drift` lists it in `unavailable`. No URL or password is printed. Run it before writing a migration so you change what the database really has. Errors: `DESCRIBE_TIMEOUT` (default 30000 ms), `DESCRIBE_FAILED` (the app exited first; `details.output` holds its last lines), `DESCRIBE_UNSUPPORTED` (@dokebi/core older than 0.4.2), or the app's own code (`INVALID_PLUGIN_OPTIONS`, …). Read it before you change an app you did not write |
85
85
  | `dokebi describe --openapi [--app <name>]` | OpenAPI 3.1 of the same description (D-0077 C), **one document per app** (route ids are unique per app): `info.title` the app, `servers` its domains (`http://<host>:<port>` for local hosts, `https://<host>` otherwise), `operationId` the route `config.id` (`<id>_<method>` on every operation when the id names several: a route of several methods, or the routes of one plugin route key such as `oauth.authorize_get` and `oauth.authorize_post`, D-0142), else `<method>_<path>` (`get_posts_id`), numbered `_2` on a collision. Request parameters and bodies (JSON, and form bodies with `formBody`) and responses come from the route schemas (draft-07 `items` tuples, `dependencies`, `nullable` and local `#/definitions` refs rewritten for JSON Schema 2020-12; a ref to an `addSchema` schema becomes an open schema with `x-dokebi-ref`). `components.schemas.DokebiError` is the D-0074 body; operations list 422 `VALIDATION_FAILED` (body or query schema), 400 `INVALID_REQUEST` (params or headers schema), 401 `UNAUTHENTICATED` (a login needed), 403 `FORBIDDEN` (`roles` or `can`) and 403 `CSRF_FAILED` (POST, PUT, PATCH, DELETE under @dokebi/csrf unless `config.csrf: false` or `exclude`, with the token header). Security: `cookieAuth` (the session cookie) and `bearerAuth` (`via: token` or `any`), `{}` added for `optional`; `x-dokebi-auth` keeps `{ mode, realm, via, roles?, can? }` (also `routes[].auth.roles` in `--json`). Health and Vite dev routes are left out; routes outside apps are in every app's document. The app's `defineErrors` codes are `x-dokebi-errors`. Without `--app` and with several apps: `{ apps: { <name>: document } }`; an unknown name is `UNKNOWN_APP`. Without `--json` the document is printed as JSON |
86
86
  | `dokebi drift --expected <file> [--timeout-ms <ms>]` | The databases against an expected file (D-0120): `<file>` is JSON of the describe shape, written by hand or by a design tool (only `db.connections` is read; a whole `describe --with-db --json` envelope works too). The actual side is `describe --with-db` (it connects the same way). Only what the file names is compared: each connection, its `tables` (or MongoDB `collections`) when the file lists them, a table's `columns` when it lists them, and a column's `comment` when it is a non-empty string (empty, `null` or absent means "not decided" and is not compared; whitespace runs and the ends are normalized). `--json` is `{ ok, drift[{kind, connection, target, expected_value, code_value}], unavailable[{connection, reason}], compared{connections, tables, columns, comments}, ms }`; `kind` is `connection`, `table`, `collection`, `column` or `column_comment`; `target` is the connection, `<table>` (`<schema>.<table>` outside the first PostgreSQL schema) or `<table>.<column>`; `expected_value` null = only the database has it, `code_value` null = the database has it not (for `column_comment`: no comment). `dokebi_migrations` is never compared. A connection that cannot be read is in `unavailable` and nothing is compared for it. `ok` only without drift and unavailable connections (otherwise exit 1). A comment comes from the migrations: PostgreSQL `COMMENT ON COLUMN <table>.<column> IS '<text>'` (`IS NULL` removes it), MySQL and MariaDB `COMMENT '<text>'` in the column definition (`ALTER TABLE … MODIFY` repeats the whole definition); `describe --with-db` shows it as `columns[].comment`. MongoDB has no column comments. Errors: `DRIFT_EXPECTED_INVALID` (the file cannot be read, is not JSON or not of the describe shape; `details.path`), and those of describe |
87
- | `dokebi check` | User-code conventions (D-0072). `{ ok, problems[{rule, severity?, file, line, message, fix}], allowed[{rule, file, line, reason}], files, rules, typescript, ms: { total, typescript } }` (`allowed`: every `// dokebi-check: allow <rule> <reason>` marker with a reason under `src/`, the problems silenced on purpose; the human output prints one `allowed` line each, and verify ok asks the final message to list them), exit 1 on a problem (a `severity: 'warning'` problem is reported but never fails: `ok` stays true). The human output prints `file:line rule message` and a `fix:` line per problem, then a summary (`check ok` or `check FAILED: N problems`, files, time). Rules: `empty-catch` (an empty `catch`, `.catch(() => {})`, an empty onRejected of `then`, an empty `on('error', …)`, and the same handlers when they only give back nothing: `() => undefined`, `() => null`, `() => void 0`, `{ return; }`; a fallback value such as `() => false` is not flagged), `missing-cause` (a `catch` that throws a new error and never reads the one it caught — `catch { throw new X() }`, `catch { throw fail() }` (a call that makes the error counts the same) or a named error left unused: the original message and stack are lost; fix `catch (error) { throw new X(…, { cause: error }) }`; a destructured binding counts as read, and throws inside nested functions are not the catch's; D-0118), `floating-promise` (a statement that calls something returning a Promise without await, return, `void` or `.catch`; the project's TypeScript decides the type; `test()` of node:test is exempt), `non-erasable-syntax` (enum, namespaces with values, parameter properties, decorators, `import x =`, `export =`, `<T>x`), `private-import` (a path of `@dokebi/*` outside its exports, such as `@dokebi/core/dist/…`), `missing-package` (an @dokebi package that is not installed → `add`; a feature Dokebi does not have → the absent `instead`; an unknown name), `generated-file` (doctor `MODIFIED_REGISTRATION`, `GUIDE_BLOCK_MODIFIED` and `MODIFIED_TEMPLATE` of CLI-owned files), `secret-in-config` (an option the plugin schema marks secret (`writeOnly`, such as `dokebi-session.secrets`), a plugin check `SECRET_IN_CONFIG`, or any dokebi.yaml value that is a URL with a password such as `postgres://user:password@host`, while dokebi.yaml could be committed; the value is never shown). Warning (D-0074): `inertia-form-only` — an Inertia form submit (`form.post/put/patch/delete/submit(…)` of a `useForm(…)` result, `router.post/put/patch/delete(…)`) whose options are missing or an object literal without `only`; the GET after its redirect would send every prop of the page again. Fix: `form.post(url, { only: ['<props it changes>'] })` (`errors` always comes along). It reads the text of `src/**` files that import `@inertiajs/` (the `<script>` blocks of .vue and .svelte files; comments and strings masked); calls inside a template attribute are not read, and options passed as a variable or with a spread are taken as fine. Security rules (D-0076 §6), on only when their plugin is installed: `plain-password-compare` (an error, with @dokebi/auth) — a value whose name has the word password, passwd, passphrase, pass, pw or pwd compared with `===`, `!==`, `==` or `!=` (not with `''`, `null`, `undefined`, a boolean, a number or `typeof`, and not a password with its confirmation field such as `passwordConfirm` and not two values that both come from the request input, such as `next !== body.confirmPassword` where `next` was read from `body`: a field of `body`, `query`, `params` or a form, or a local made from one; a typed value against a stored one, such as `body.password !== user.passwordHash` (a hash, a field of a user, row, account or credentials object, or a local loaded from one) stays an error), or passed to node:crypto `timingSafeEqual`, `scrypt`, `pbkdf2`, `argon2`, the `update()` of `createHash`/`createHmac`, or a `bcrypt`/`argon2` package; fix: `request.auth.attempt` and `passwords.verify`/`passwords.hash`. `form-without-csrf` (a warning, with @dokebi/csrf) — an EJS `<form method="post">` (any case) without `csrf.field` (also `csrf?.field`) or a `_csrf` field up to its `</form>` (a multipart form may carry `?_csrf=` in its action); fix: `<%- data.csrf.field %>`; EJS is read as text, so a form split over includes is not seen as one. `csrf-exempt-unverified` (a warning, with @dokebi/csrf) — a route `config: { csrf: false }` whose registration call (and its handler functions named in the same file) shows no `rawBody`, signature check (`signature`, `createHmac`, `timingSafeEqual`, `.verify(`), `seal` or @dokebi/auth token refresh (`tokens.refresh(`), and whose `config` has no `oauth` and no `auth: { via: 'token' }` (Bearer only; `via: 'any'` or `'session'` does not count); fix: send the token, or verify the sender. `unknown-error-code` (a warning, [D-0077](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0077-app-self-description.md) D, only when `src/shared/errors.ts` exports a `defineErrors({ … })` result written as an object literal) — app code under `src/apps/` or `src/shared/modules/` that writes an error code as a string: `new DokebiError('CODE', …)`, `Object.assign(new Error(…), { code: 'CODE' })`, `throw { code: 'CODE' }` or `.send({ error: 'CODE' })`. A code missing from the list is unknown (fix: add it to the list and throw `errors.CODE()`), a listed one is written by hand (fix: `throw errors.CODE()`, with the import path from that file). The codes of web, auth and csrf answers (`VALIDATION_FAILED`, `NOT_FOUND`, `INVALID_REQUEST`, `INTERNAL_SERVER_ERROR`, `UNAUTHENTICATED`, `FORBIDDEN`, `CSRF_FAILED`) are fine. The list is read from the file's syntax tree, never by running it; a spread or a computed key turns the rule off. Background work ([D-0103](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0105-check-background-timers-and-structure.md) §1): `background-timer` (an error) — server code under `src/` (not `views/` or `public/`; tests are not read) that runs periodic work on its own timer instead of @dokebi/scheduler and @dokebi/job: any `setInterval` (global, `node:timers`, or the async iterator of `node:timers/promises`), and a `setTimeout` or `setImmediate` whose callback comes back to a function around the call through the functions and methods of the same file (`const tick = () => { …; setTimeout(tick, ms) }`, `#schedule() { setTimeout(() => this.#tick()) }` with `#tick` calling `#schedule`). Fine: one-shot delays and time limits (`setTimeout(() => controller.abort(), ms)`, `new Promise((resolve) => setTimeout(resolve, ms))`), awaited sleeps of `node:timers/promises` (`await setTimeout(ms, undefined, { signal })` between bounded batches of a job handler), and timers inside a function that takes a `request`, `req`, `reply`, `res`, `response`, `socket`, `ws`, `websocket` or `stream` parameter or is passed to a route method (`get`, `post`, …, `route`), unless the timer is stored where it outlives that function: `this.ticker = setInterval(…)` (also `??=`, `||=`) or a variable declared outside it is reported (one worker-wide timer the first request starts). Fix: a job handler registered in the setup of the module that owns the work (`queue(<queue>).handle(<type>, …)`) and an entry of `options.dokebi-scheduler.schedules`. Structure warnings (D-0103 §2–§3): `responsibility-size` — a model (`…/models/…`) with at least 400 code lines (blank and comment-only lines do not count) over at least 8 tables or collections (names after FROM, JOIN, INTO and UPDATE in SQL text, CTE names and upsert columns excluded; Mongo `.collection('x')` and a local helper that wraps it; Kysely `selectFrom`/`insertInto`/`updateTable`/`deleteFrom`), a controller with at least 20 route handlers (public methods and function-valued fields) or 300 code lines, and a service class with at least 5 methods that only pass their parameters on to one call on a field (`return this.model.list(user, filter)`) when they are at least 60% of its methods; files whose first lines say `@generated`, `generated by` or `do not edit` are not read. `memory-filtered-page` — in a model or service, rows an awaited query returned that are skipped by comparing a field of the row with an input of the function and then cut to a page (`for (const row of rows) { if (row.status !== filter.status) continue; …; if (page.length === size) break; }`, or `rows.filter((row) => row.org === input.org).slice(…)`); fix: the filter in the query's WHERE with an index that ends in the sort key, and LIMIT the page size + 1. A search that checks its other terms on a capped candidate set (@dokebi/db AI.md 6.10) compares no input and is not matched; the rule sees only these two shapes, so a clean result does not prove the lists are paged in the database. Dev files ([D-0129](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0129-inertia-dev-file-policy.md)): `vite-dev-files` (a warning, in a project with an Inertia app or @dokebi/template-inertia) — the `vite.config.*` does not use `dokebiInertia()` (a plain `vite` then serves the whole project root: dokebi.yaml, .env, the server code), sets `server.fs.strict: false`, sets `server.fs.deny` (a list of its own replaces Vite's defaults where the framework's policy does not run), or an `allow` list names the project root or server code (`'.'`, `'src'`, `'tests'`, `'scripts'`, `'tools'`, `process.cwd()`, `__dirname`, `searchForWorkspaceRoot(…)`); fix: keep `dokebiInertia()` and drop `server.fs`, add browser folders with `dokebiInertia({ allow: [...] })` and entries with `dokebiInertia({ deny: [...] })`. @dokebi/template-inertia enforces the policy anyway (strict on, its deny entries kept); `formatter-migrations` (a warning, D-0145, when the migrations folder `<dokebi-migrate directory>/migrations` exists) — a code formatter of the project would format it: prettier (a config, a `prettier` key or dependency in package.json) without the folder in `.prettierignore`, biome without `!<folder>` in `files.includes` (biome 1: the folder in `files.ignore`), ESLint with formatting rules (eslint-plugin-prettier, `@stylistic`) whose config does not name it; an applied migration must keep its contents (a reformat is warned as `MIGRATE_REFORMATTED` by @dokebi/migrate, an edit refused); fix: the ignore entry the problem names (`npx dokebi add` writes it for prettier and biome); the rule says that the config asks for less. `formatter-generated` (a warning, R1 measurement) — the same formatters would format `src/dokebi.generated.ts`, which the CLI writes and compares with its record: a reformatted copy is doctor `MODIFIED_REGISTRATION` and add, upgrade and remove refuse to run; fix: `src/dokebi.generated.ts` in `.prettierignore`, `"!src/dokebi.generated.ts"` in biome `files.includes` (`npx dokebi add` writes both). `asset-in-views` (a warning, R1 measurement) — a browser file (a style sheet, an image, a font) in the views of an EJS app (`src/apps/<app>/views/`; an Inertia app with `views/app.js` is not read): move it to `src/apps/<app>/public/` and link `/assets/<path>`, which @dokebi/app serves through @dokebi/static. `asset-route` (a warning, R6 measurement) — a GET or HEAD route of server code for a browser file (`.css`, an image, a font): its path is a fixed file name (`/site.css`), or ends in such an extension and its handler reads a file itself (`createReadStream`, `readFile`, `readFileSync`); such a route sends the file without the validator, 304 and Range of `public/`; fix: put the file in `src/apps/<app>/public/` (a file a package ships, such as a font of @dokebi/font-noto-kr, is copied there with its licence file) and link `/assets/<path>`; a file the route makes per request takes `// dokebi-check: allow asset-route <reason>`. `seal-head-copied` (a warning, R7 measurement; only with @dokebi/app) — a file under `src/` (`.ts`, `.js`, `.mjs`, `.ejs`, `.html`; not in a comment) that loads `/dokebi/seal/forms.mjs` itself, a copied seal `<script>` or import map: write `<%- data.seal?.head ?? '' %>` in the layout of an app page, and for a page rendered outside an app route (an oauth consent page) take `context.getDependency(apps).seal(request).head` (`AppGroupApi` of @dokebi/app ^0.4.5, empty on a plain host); a page that is no app page takes `// dokebi-check: allow seal-head-copied <reason>`. `i18n-missing-key` (a warning, community request A2; only with @dokebi/i18n and `src/shared/locales/`) — a fixed translation key a page or server code asks for (`t('ns.a.b')`, `$t(…)`, `request.i18n.t(…)` in `.vue`, `.ts`, `.js`, `.ejs` under `src/`; the first part a namespace of the catalogs) that the catalogs of the default locale (`dokebi-i18n.defaultLocale` of dokebi.yaml, `en`) lack — the end of every fallback chain, so @dokebi/i18n throws `MISSING_MESSAGE` for it (everywhere but under `npx dokebi dev`) in each locale without it; a key only the default locale has falls back and is not reported; keys built at run time, keys with an explicit default (`t('k', 'Text')`) and lines in a comment are not read, and a catalog that is not JSON is reported; fix: add the key to `src/shared/locales/<default locale>/<namespace>.json`; a key another catalog provides takes `// dokebi-check: allow i18n-missing-key <reason>`. With catalog layers (D-0181) code under `src/apps/<app>/` is checked against that app's layer, the modules and the shared catalogs, other code against the modules and the shared ones. `i18n-layer-override` (a warning) — one key in one language in two layers: an app's `src/apps/<app>/locales/` over a module's `src/shared/modules/<module>/locales/` or the shared `src/shared/locales/`, a module's over the shared ones, or two modules (the first by name wins, always reported); fix: list an intended override in the overriding file's top-level `"$overrides": ["key", …]` (keys inside the namespace), otherwise rename the key or remove it from one layer; a listed key that overrides nothing is reported too. `i18n-layer-missing` (a warning) — a layer gives keys in one language and lacks them in another language of the project, one problem per layer, language and namespace; fix: add them to that file or remove them from the layer's other languages. `shared-state-memory` (an error, [D-0161](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0161-shared-state-redis.md)) — `options.application-runtime.workers` above 1 while an installed plugin keeps the state its workers share in process memory: the dokebi-session store, dokebi-auth `tokens` or `throttle.store`, the dokebi-oauth store, the dokebi-rate-limit driver (`local`), dokebi-seal `nonces` that are not shared, or a dokebi-websocket-hub not in `mode: cluster`; the plugins refuse to start that way in a cluster worker and in production. Fix: `{ driver: redis, connection: <the project's dokebi-redis connection> }` for each (`npx dokebi add @dokebi/redis` first when there is none); the problem's line is that option in dokebi.yaml. `console-output` (a warning, D-0151) — server code under `src/` (not `views/` or `public/`) that calls `console.log`, `console.info`, `console.warn`, `console.error`, `console.debug`, `console.trace`, `process.stdout.write` or `process.stderr.write`: those lines skip the logger level, the redaction and the targets (the rotated files, the JSON lines `dokebi logs` reads); fix: `context.logger.log(level, 'Fixed message', { code, … })` in a plugin or module hook, `app.logger` in `src/main.ts`. A command line tool of the project that prints its results takes `// dokebi-check: allow console-output <reason>` before its first statement (it covers the whole file), or on or above one line. The framework's own sources pass the same rule as the `check:console` gate. `polling-loop` (an error no marker silences, AI-M35) — a loop that sleeps inside a task started in the background (an immediately invoked async function, or a function the file calls without awaiting or returning it), such as `(async () => { while (!stopped) { await step(); await sleep(ms); } })()` in a module's `start`: move it to an @dokebi/outbox handler (one coalesced item per owner and window) or a @dokebi/job handler with a schedule; per-process upkeep uses a timer (`background-timer` with a marker), never a sleeping loop. A `setInterval` or self-rescheduling timer whose callback reaches database work (a `query`, `execute` or `transaction` call, or a call on a model, repository, pool, client, transaction or outbox object, through the functions of the same file) is reported as `polling-loop` too, marker or not. `in-process-queue` (a warning, AI-M35) — the resolve of a `new Promise` stored in a collection (`.push`, `.unshift`, `.set`, `.add`), directly or through a variable that holds it (`const pending = { input, resolve }`), to be called later: callers wait in a queue of one worker without a bound or deadline; send the work at once and let the pool's `waitTimeoutMs` bound the wait (503 with Retry-After). `wait-count-refusal` (a warning, @dokebi/db AI.md 1.2 and 6.4) — server code under `src/` that compares how many callers wait for a pool connection with a number (pg `pool.waitingCount`, mariadb `pool.taskQueueSize()`, MongoDB `waitQueueSize`, mysql2 `pool._connectionQueue.length`): the count of waiters is not overload, so refusing on it refuses work the database can still do; fix: bound the wait by its deadline (`waitTimeoutMs`, then 503 with Retry-After) and shed a tenant by time, not by waiters; a metric or log line that only reports the number takes `// dokebi-check: allow wait-count-refusal <reason>`. `private-pool` (an error, AI-M37) — server code under `src/` outside `src/infra/db/` that makes a database pool or client with the driver itself (`new Pool`/`new Client` of `pg`, `createPool`/`createConnection`/`createPoolCluster` of `mysql2` and `mariadb`, `new MongoClient` of `mongodb`): it escapes dokebi.yaml (its size and `waitTimeoutMs`, past which the caller gets 503 with Retry-After), the connection sum and the cleanup at stop (M37: private pools with a 30 s wait held callers for 22–51 s); fix: the configured connection (`context.getDependency(db).connection(main)`), `derive('main', { purpose, overrides: { max } })` for a pool of one kind of work, or one more connection in dokebi.yaml; a connection that must stay outside (a LISTEN client) takes `// dokebi-check: allow private-pool <reason>`. `overload-off` (an error, AI-M37) — a route `config: { overload: false }`: under a burst its callers queue behind a stalled worker instead of getting 503 `OVERLOADED` with Retry-After (@dokebi/web AI.md 2.5); fix: remove it (raise `overload.maxEventLoopDelayMs` if it refuses too early); a metrics scrape or an operator status page takes `// dokebi-check: allow overload-off <reason>`. `readiness-off` (an error, M51) — a route `config: { readiness: false }`: it is served while a required dependency is down and while the app drains, so an API route runs its handler against a missing database or Redis; fix: remove it; a metrics scrape or status page that must answer during an outage takes `// dokebi-check: allow readiness-off <reason>`. `fixed-owner-cap` (a warning, AI-M37) — a per-owner count of requests in progress (a Map entry that goes up and down by one, read into a variable) compared with a fixed limit by an `if` that throws or returns, without a free or idle connection in the condition: it refuses work while the database is idle; fix: the owner share of @dokebi/db, `share(main).enter(owner)`, which refuses only while the pool is full (@dokebi/db AI.md 6.4, D-0156); a budget that bounds something else (the report CPU budget of db AI.md 6.9, a plan's quota) takes `// dokebi-check: allow fixed-owner-cap <reason>`. `undeclared-section` (a warning, D-0155) — a section of dokebi.yaml nothing declares (code reads `options.<name>` by hand); fix: `npx dokebi settings add <name>`. `template-fix-missing` (a warning) — doctor's `TEMPLATE_FIX_MISSING` and `RELOAD_NOT_WIRED`: a copied template file lacks a later fix, or an entry passes no `configFile`; fix: doctor's hint. `module-point-not-installed` (D-0130) — a point in `contributes` of `defineModule` imported from an `@dokebi/*` plugin package that is in node_modules but not installed in the project (`dokebi add`): nothing registers its collector, so the app drops the values (warn `POINT_NOT_COLLECTED`); fix: `npx dokebi add <package>` or remove the point (a plugin you register yourself takes the allow marker with a reason). When an empty catch, a background promise, a full-page form submit (a login) or one of the security cases is really intended, put `// dokebi-check: allow <rule> <reason>` on that line or the line above (EJS: `<%# dokebi-check: allow form-without-csrf <reason> %>` on the line above the form; only `empty-catch`, `missing-cause`, `floating-promise`, `inertia-form-only`, `unknown-error-code`, the three security rules, the two mail warnings, the three D-0103 rules, `untyped-browser-import`, `vite-dev-files`, `module-point-not-installed`, `asset-route`, `seal-head-copied`, `i18n-missing-key`, `console-output`, `wait-count-refusal`, `in-process-queue`, `fixed-owner-cap`, `private-pool` and `overload-off` — for example a per-process eviction of in-memory state that no job can reach; without a reason the marker is ignored). The sources are the program of `tsconfig.json` (generated files, `.d.ts` and node_modules excluded), read with the API of the TypeScript 7 installed in the project (`typescript/unstable/sync`). Browser code outside that program is read too (D-0120): the `<script>` and `<script setup>` blocks (`lang` ts or js) of every `.vue` file under `src/`, and the `.js`/`.mjs` files under a `views/` folder (files above 1 MiB are skipped). They get `empty-catch`, `missing-cause` and `floating-promise` only, typed by a second program that extends `tsconfig.json` but resolves imports as the bundler does (`moduleResolution: bundler`, `module: esnext`, the DOM in `lib`; relative imports resolve from the file's folder). An import whose bound names all have no type (the module did not resolve) is the warning `untyped-browser-import` on its line, since floating-promise cannot judge what comes from it; an import of a `.vue`, style, image or JSON file and `import type` are not judged; a module that really has no types takes `// dokebi-check: allow untyped-browser-import <reason>`, and the problems name the `.vue` or `.js` file and its line; the markers work the same inside a script block. A browser promise left floating is an unhandled rejection the page never handles: `await` it, or end it with `.catch(error => …)` that shows or reports the error. When it cannot be loaded `TYPESCRIPT_UNAVAILABLE` (`npm install`), when tsconfig cannot be opened `TSCONFIG_INVALID` |
87
+ | `dokebi check` | User-code conventions (D-0072). `{ ok, problems[{rule, severity?, file, line, message, fix}], allowed[{rule, file, line, reason}], files, rules, typescript, ms: { total, typescript } }` (`allowed`: every `// dokebi-check: allow <rule> <reason>` marker with a reason under `src/`, the problems silenced on purpose; the human output prints one `allowed` line each, and verify ok asks the final message to list them), exit 1 on a problem (a `severity: 'warning'` problem is reported but never fails: `ok` stays true). The human output prints `file:line rule message` and a `fix:` line per problem, then a summary (`check ok` or `check FAILED: N problems`, files, time). Rules: `empty-catch` (an empty `catch`, `.catch(() => {})`, an empty onRejected of `then`, an empty `on('error', …)`, and the same handlers when they only give back nothing: `() => undefined`, `() => null`, `() => void 0`, `{ return; }`; a fallback value such as `() => false` is not flagged), `missing-cause` (a `catch` that throws a new error and never reads the one it caught — `catch { throw new X() }`, `catch { throw fail() }` (a call that makes the error counts the same) or a named error left unused: the original message and stack are lost; fix `catch (error) { throw new X(…, { cause: error }) }`; a destructured binding counts as read, and throws inside nested functions are not the catch's; D-0118), `floating-promise` (a statement that calls something returning a Promise without await, return, `void` or `.catch`; the project's TypeScript decides the type; `test()` of node:test is exempt), `non-erasable-syntax` (enum, namespaces with values, parameter properties, decorators, `import x =`, `export =`, `<T>x`), `private-import` (a path of `@dokebi/*` outside its exports, such as `@dokebi/core/dist/…`), `missing-package` (an @dokebi package that is not installed → `add`; a feature Dokebi does not have → the absent `instead`; an unknown name), `generated-file` (doctor `MODIFIED_REGISTRATION`, `GUIDE_BLOCK_MODIFIED` and `MODIFIED_TEMPLATE` of CLI-owned files), `secret-in-config` (an option the plugin schema marks secret (`writeOnly`, such as `dokebi-session.secrets`), a plugin check `SECRET_IN_CONFIG`, or any dokebi.yaml value that is a URL with a password such as `postgres://user:password@host`, while dokebi.yaml could be committed; the value is never shown). Warning (D-0074): `inertia-form-only` — an Inertia form submit (`form.post/put/patch/delete/submit(…)` of a `useForm(…)` result, `router.post/put/patch/delete(…)`) whose options are missing or an object literal without `only`; the GET after its redirect would send every prop of the page again. Fix: `form.post(url, { only: ['<props it changes>'] })` (`errors` always comes along). It reads the text of `src/**` files that import `@inertiajs/` (the `<script>` blocks of .vue and .svelte files; comments and strings masked); calls inside a template attribute are not read, and options passed as a variable or with a spread are taken as fine. Security rules (D-0076 §6), on only when their plugin is installed: `plain-password-compare` (an error, with @dokebi/auth) — a value whose name has the word password, passwd, passphrase, pass, pw or pwd compared with `===`, `!==`, `==` or `!=` (not with `''`, `null`, `undefined`, a boolean, a number or `typeof`, and not a password with its confirmation field such as `passwordConfirm` and not two values that both come from the request input, such as `next !== body.confirmPassword` where `next` was read from `body`: a field of `body`, `query`, `params` or a form, or a local made from one; a typed value against a stored one, such as `body.password !== user.passwordHash` (a hash, a field of a user, row, account or credentials object, or a local loaded from one) stays an error), or passed to node:crypto `timingSafeEqual`, `scrypt`, `pbkdf2`, `argon2`, the `update()` of `createHash`/`createHmac`, or a `bcrypt`/`argon2` package; fix: `request.auth.attempt` and `passwords.verify`/`passwords.hash`. `form-without-csrf` (a warning, with @dokebi/csrf) — an EJS `<form method="post">` (any case) without `csrf.field` (also `csrf?.field`) or a `_csrf` field up to its `</form>` (a multipart form may carry `?_csrf=` in its action); fix: `<%- data.csrf.field %>`; EJS is read as text, so a form split over includes is not seen as one. `csrf-exempt-unverified` (a warning, with @dokebi/csrf) — a route `config: { csrf: false }` whose registration call (and its handler functions named in the same file) shows no `rawBody`, signature check (`signature`, `createHmac`, `timingSafeEqual`, `.verify(`), `seal` or @dokebi/auth token refresh (`tokens.refresh(`), and whose `config` has no `oauth` and no `auth: { via: 'token' }` (Bearer only; `via: 'any'` or `'session'` does not count); fix: send the token, or verify the sender. `unknown-error-code` (a warning, [D-0077](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0077-app-self-description.md) D, only when `src/shared/errors.ts` exports a `defineErrors({ … })` result written as an object literal) — app code under `src/apps/` or `src/shared/modules/` that writes an error code as a string: `new DokebiError('CODE', …)`, `Object.assign(new Error(…), { code: 'CODE' })`, `throw { code: 'CODE' }` or `.send({ error: 'CODE' })`. A code missing from the list is unknown (fix: add it to the list and throw `errors.CODE()`), a listed one is written by hand (fix: `throw errors.CODE()`, with the import path from that file). The codes of web, auth and csrf answers (`VALIDATION_FAILED`, `NOT_FOUND`, `INVALID_REQUEST`, `INTERNAL_SERVER_ERROR`, `UNAUTHENTICATED`, `FORBIDDEN`, `CSRF_FAILED`) are fine. The list is read from the file's syntax tree, never by running it; a spread or a computed key turns the rule off. Background work ([D-0103](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0105-check-background-timers-and-structure.md) §1): `background-timer` (an error) — server code under `src/` (not `views/` or `public/`; tests are not read) that runs periodic work on its own timer instead of @dokebi/scheduler and @dokebi/job: any `setInterval` (global, `node:timers`, or the async iterator of `node:timers/promises`), and a `setTimeout` or `setImmediate` whose callback comes back to a function around the call through the functions and methods of the same file (`const tick = () => { …; setTimeout(tick, ms) }`, `#schedule() { setTimeout(() => this.#tick()) }` with `#tick` calling `#schedule`). Fine: one-shot delays and time limits (`setTimeout(() => controller.abort(), ms)`, `new Promise((resolve) => setTimeout(resolve, ms))`), awaited sleeps of `node:timers/promises` (`await setTimeout(ms, undefined, { signal })` between bounded batches of a job handler), and timers inside a function that takes a `request`, `req`, `reply`, `res`, `response`, `socket`, `ws`, `websocket` or `stream` parameter or is passed to a route method (`get`, `post`, …, `route`), unless the timer is stored where it outlives that function: `this.ticker = setInterval(…)` (also `??=`, `||=`) or a variable declared outside it is reported (one worker-wide timer the first request starts). Fix: a job handler registered in the setup of the module that owns the work (`queue(<queue>).handle(<type>, …)`) and an entry of `options.dokebi-scheduler.schedules`. Structure warnings (D-0103 §2–§3): `responsibility-size` — a model (`…/models/…`) with at least 400 code lines (blank and comment-only lines do not count) over at least 8 tables or collections (names after FROM, JOIN, INTO and UPDATE in SQL text, CTE names and upsert columns excluded; Mongo `.collection('x')` and a local helper that wraps it; Kysely `selectFrom`/`insertInto`/`updateTable`/`deleteFrom`), a controller with at least 20 route handlers (public methods and function-valued fields) or 300 code lines, and a service class with at least 5 methods that only pass their parameters on to one call on a field (`return this.model.list(user, filter)`) when they are at least 60% of its methods; files whose first lines say `@generated`, `generated by` or `do not edit` are not read. `memory-filtered-page` — in a model or service, rows an awaited query returned that are skipped by comparing a field of the row with an input of the function and then cut to a page (`for (const row of rows) { if (row.status !== filter.status) continue; …; if (page.length === size) break; }`, or `rows.filter((row) => row.org === input.org).slice(…)`); fix: the filter in the query's WHERE with an index that ends in the sort key, and LIMIT the page size + 1. A search that checks its other terms on a capped candidate set (@dokebi/db AI.md 6.10) compares no input and is not matched; the rule sees only these two shapes, so a clean result does not prove the lists are paged in the database. Dev files ([D-0129](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0129-inertia-dev-file-policy.md)): `vite-dev-files` (a warning, in a project with an Inertia app or @dokebi/template-inertia) — the `vite.config.*` does not use `dokebiInertia()` (a plain `vite` then serves the whole project root: dokebi.yaml, .env, the server code), sets `server.fs.strict: false`, sets `server.fs.deny` (a list of its own replaces Vite's defaults where the framework's policy does not run), or an `allow` list names the project root or server code (`'.'`, `'src'`, `'tests'`, `'scripts'`, `'tools'`, `process.cwd()`, `__dirname`, `searchForWorkspaceRoot(…)`); fix: keep `dokebiInertia()` and drop `server.fs`, add browser folders with `dokebiInertia({ allow: [...] })` and entries with `dokebiInertia({ deny: [...] })`. @dokebi/template-inertia enforces the policy anyway (strict on, its deny entries kept); `formatter-migrations` (a warning, D-0145, when the migrations folder `<dokebi-migrate directory>/migrations` exists) — a code formatter of the project would format it: prettier (a config, a `prettier` key or dependency in package.json) without the folder in `.prettierignore`, biome without `!<folder>` in `files.includes` (biome 1: the folder in `files.ignore`), ESLint with formatting rules (eslint-plugin-prettier, `@stylistic`) whose config does not name it; an applied migration must keep its contents (a reformat is warned as `MIGRATE_REFORMATTED` by @dokebi/migrate, an edit refused); fix: the ignore entry the problem names (`npx dokebi add` writes it for prettier and biome); the rule says that the config asks for less. `formatter-generated` (a warning, R1 measurement) — the same formatters would format `src/dokebi.generated.ts`, which the CLI writes and compares with its record: a reformatted copy is doctor `MODIFIED_REGISTRATION` and add, upgrade and remove refuse to run; fix: `src/dokebi.generated.ts` in `.prettierignore`, `"!src/dokebi.generated.ts"` in biome `files.includes` (`npx dokebi add` writes both). `asset-in-views` (a warning, R1 measurement) — a browser file (a style sheet, an image, a font) in the views of an EJS app (`src/apps/<app>/views/`; an Inertia app with `views/app.js` is not read): move it to `src/apps/<app>/public/` and link `/assets/<path>`, which @dokebi/app serves through @dokebi/static. `asset-route` (a warning, R6 measurement) — a GET or HEAD route of server code (a `get` or `head` call with a path and a handler; a lookup by one key such as `manifest.get('main.css')` is none) for a browser file (`.css`, an image, a font): its path is a fixed file name (`/site.css`), or ends in such an extension and its handler reads a file itself (`createReadStream`, `readFile`, `readFileSync`); such a route sends the file without the validator, 304 and Range of `public/`; fix: put the file in `src/apps/<app>/public/` (a file a package ships, such as a font of @dokebi/font-noto-kr, is copied there with its licence file) and link `/assets/<path>`; a file the route makes per request takes `// dokebi-check: allow asset-route <reason>`. `seal-head-copied` (a warning, R7 measurement; only with @dokebi/app) — a file under `src/` (`.ts`, `.js`, `.mjs`, `.ejs`, `.html`; not in a comment) that loads `/dokebi/seal/forms.mjs` itself, a copied seal `<script>` or import map: write `<%- data.seal?.head ?? '' %>` in the layout of an app page, and for a page rendered outside an app route (an oauth consent page) take `context.getDependency(apps).seal(request).head` (`AppGroupApi` of @dokebi/app ^0.4.5, empty on a plain host); a page that is no app page takes `// dokebi-check: allow seal-head-copied <reason>`. `i18n-missing-key` (a warning, community request A2; only with @dokebi/i18n and `src/shared/locales/`) — a fixed translation key a page or server code asks for (`t('ns.a.b')`, `$t(…)`, `request.i18n.t(…)` in `.vue`, `.ts`, `.js`, `.ejs` under `src/`; the first part a namespace of the catalogs) that the catalogs of the default locale (`dokebi-i18n.defaultLocale` of dokebi.yaml, `en`) lack — the end of every fallback chain, so @dokebi/i18n throws `MISSING_MESSAGE` for it (everywhere but under `npx dokebi dev`) in each locale without it; a key only the default locale has falls back and is not reported; keys built at run time, keys with an explicit default (`t('k', 'Text')`) and lines in a comment are not read; locale folders and the default locale are read as @dokebi/i18n reads them (`Intl.Locale(name).baseName`: a folder `en-us` is the locale `en-US`), and a catalog that is not JSON or a folder that is no locale (or a second folder of one locale) is reported; fix: add the key to `src/shared/locales/<default locale>/<namespace>.json`; a key another catalog provides takes `// dokebi-check: allow i18n-missing-key <reason>`. With catalog layers (D-0181) code under `src/apps/<app>/` is checked against that app's layer, the modules and the shared catalogs, other code against the modules and the shared ones. `i18n-layer-override` (a warning) — one key in one language in two layers: an app's `src/apps/<app>/locales/` over a module's `src/shared/modules/<module>/locales/` or the shared `src/shared/locales/`, a module's over the shared ones, or two modules (the first by name wins, always reported); fix: list an intended override in the overriding file's top-level `"$overrides": ["key", …]` (keys inside the namespace), otherwise rename the key or remove it from one layer; a listed key that overrides nothing is reported too. `i18n-layer-missing` (a warning) — a layer gives keys in one language and lacks them in another language of the project, one problem per layer, language and namespace; fix: add them to that file or remove them from the layer's other languages. `shared-state-memory` (an error, [D-0161](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0161-shared-state-redis.md)) — `options.application-runtime.workers` above 1 while an installed plugin keeps the state its workers share in process memory: the dokebi-session store, dokebi-auth `tokens` or `throttle.store`, the dokebi-oauth store, the dokebi-rate-limit driver (`local`), dokebi-seal `nonces` that are not shared, or a dokebi-websocket-hub not in `mode: cluster`; the plugins refuse to start that way in a cluster worker and in production. Fix: `{ driver: redis, connection: <the project's dokebi-redis connection> }` for each (`npx dokebi add @dokebi/redis` first when there is none); the problem's line is that option in dokebi.yaml. `console-output` (a warning, D-0151) — server code under `src/` (not `views/` or `public/`) that calls `console.log`, `console.info`, `console.warn`, `console.error`, `console.debug`, `console.trace`, `process.stdout.write` or `process.stderr.write`: those lines skip the logger level, the redaction and the targets (the rotated files, the JSON lines `dokebi logs` reads); fix: `context.logger.log(level, 'Fixed message', { code, … })` in a plugin or module hook, `app.logger` in `src/main.ts`. A command line tool of the project that prints its results takes `// dokebi-check: allow console-output <reason>` before its first statement (it covers the whole file), or on or above one line. The framework's own sources pass the same rule as the `check:console` gate. `polling-loop` (an error no marker silences, AI-M35) — a loop that sleeps inside a task started in the background (an immediately invoked async function, or a function the file calls without awaiting or returning it), such as `(async () => { while (!stopped) { await step(); await sleep(ms); } })()` in a module's `start`: move it to an @dokebi/outbox handler (one coalesced item per owner and window) or a @dokebi/job handler with a schedule; per-process upkeep uses a timer (`background-timer` with a marker), never a sleeping loop. A `setInterval` or self-rescheduling timer whose callback reaches database work (a `query`, `execute` or `transaction` call, or a call on a model, repository, pool, client, transaction or outbox object, through the functions of the same file) is reported as `polling-loop` too, marker or not. `in-process-queue` (a warning, AI-M35) — the resolve of a `new Promise` stored in a collection (`.push`, `.unshift`, `.set`, `.add`), directly or through a variable that holds it (`const pending = { input, resolve }`), to be called later: callers wait in a queue of one worker without a bound or deadline; send the work at once and let the pool's `waitTimeoutMs` bound the wait (503 with Retry-After). `wait-count-refusal` (a warning, @dokebi/db AI.md 1.2 and 6.4) — server code under `src/` that compares how many callers wait for a pool connection with a number (pg `pool.waitingCount`, mariadb `pool.taskQueueSize()`, MongoDB `waitQueueSize`, mysql2 `pool._connectionQueue.length`): the count of waiters is not overload, so refusing on it refuses work the database can still do; fix: bound the wait by its deadline (`waitTimeoutMs`, then 503 with Retry-After) and shed a tenant by time, not by waiters; a metric or log line that only reports the number takes `// dokebi-check: allow wait-count-refusal <reason>`. `private-pool` (an error, AI-M37) — server code under `src/` outside `src/infra/db/` that makes a database pool or client with the driver itself (`new Pool`/`new Client` of `pg`, `createPool`/`createConnection`/`createPoolCluster` of `mysql2` and `mariadb`, `new MongoClient` of `mongodb`): it escapes dokebi.yaml (its size and `waitTimeoutMs`, past which the caller gets 503 with Retry-After), the connection sum and the cleanup at stop (M37: private pools with a 30 s wait held callers for 22–51 s); fix: the configured connection (`context.getDependency(db).connection(main)`), `derive('main', { purpose, overrides: { max } })` for a pool of one kind of work, or one more connection in dokebi.yaml; a connection that must stay outside (a LISTEN client) takes `// dokebi-check: allow private-pool <reason>`. `overload-off` (an error, AI-M37) — a route `config: { overload: false }`: under a burst its callers queue behind a stalled worker instead of getting 503 `OVERLOADED` with Retry-After (@dokebi/web AI.md 2.5); fix: remove it (raise `overload.maxEventLoopDelayMs` if it refuses too early); a metrics scrape or an operator status page takes `// dokebi-check: allow overload-off <reason>`. `readiness-off` (an error, M51) — a route `config: { readiness: false }`: it is served while a required dependency is down and while the app drains, so an API route runs its handler against a missing database or Redis; fix: remove it; a metrics scrape or status page that must answer during an outage takes `// dokebi-check: allow readiness-off <reason>`. `fixed-owner-cap` (a warning, AI-M37) — a per-owner count of requests in progress (a Map entry that goes up and down by one, read into a variable) compared with a fixed limit by an `if` that throws or returns, without a free or idle connection in the condition: it refuses work while the database is idle; fix: the owner share of @dokebi/db, `share(main).enter(owner)`, which refuses only while the pool is full (@dokebi/db AI.md 6.4, D-0156); a budget that bounds something else (the report CPU budget of db AI.md 6.9, a plan's quota) takes `// dokebi-check: allow fixed-owner-cap <reason>`. `undeclared-section` (a warning, D-0155) — a section of dokebi.yaml nothing declares (code reads `options.<name>` by hand); fix: `npx dokebi settings add <name>`. `template-fix-missing` (a warning) — doctor's `TEMPLATE_FIX_MISSING` and `RELOAD_NOT_WIRED`: a copied template file lacks a later fix, or an entry passes no `configFile`; fix: doctor's hint. `module-point-not-installed` (D-0130) — a point in `contributes` of `defineModule` imported from an `@dokebi/*` plugin package that is in node_modules but not installed in the project (`dokebi add`): nothing registers its collector, so the app drops the values (warn `POINT_NOT_COLLECTED`); fix: `npx dokebi add <package>` or remove the point (a plugin you register yourself takes the allow marker with a reason). When an empty catch, a background promise, a full-page form submit (a login) or one of the security cases is really intended, put `// dokebi-check: allow <rule> <reason>` on that line or the line above (EJS: `<%# dokebi-check: allow form-without-csrf <reason> %>` on the line above the form; only `empty-catch`, `missing-cause`, `floating-promise`, `inertia-form-only`, `unknown-error-code`, the three security rules, the two mail warnings, the three D-0103 rules, `untyped-browser-import`, `vite-dev-files`, `module-point-not-installed`, `asset-route`, `seal-head-copied`, `i18n-missing-key`, `console-output`, `wait-count-refusal`, `in-process-queue`, `fixed-owner-cap`, `private-pool` and `overload-off` — for example a per-process eviction of in-memory state that no job can reach; without a reason the marker is ignored). The sources are the program of `tsconfig.json` (generated files, `.d.ts` and node_modules excluded), read with the API of the TypeScript 7 installed in the project (`typescript/unstable/sync`). Browser code outside that program is read too (D-0120): the `<script>` and `<script setup>` blocks (`lang` ts or js) of every `.vue` file under `src/`, and the `.js`/`.mjs` files under a `views/` folder (files above 1 MiB are skipped). They get `empty-catch`, `missing-cause` and `floating-promise` only, typed by a second program that extends `tsconfig.json` but resolves imports as the bundler does (`moduleResolution: bundler`, `module: esnext`, the DOM in `lib`; relative imports resolve from the file's folder). An import whose bound names all have no type (the module did not resolve) is the warning `untyped-browser-import` on its line, since floating-promise cannot judge what comes from it; an import of a `.vue`, style, image or JSON file and `import type` are not judged; a module that really has no types takes `// dokebi-check: allow untyped-browser-import <reason>`, and the problems name the `.vue` or `.js` file and its line; the markers work the same inside a script block. A browser promise left floating is an unhandled rejection the page never handles: `await` it, or end it with `.catch(error => …)` that shows or reports the error. When it cannot be loaded `TYPESCRIPT_UNAVAILABLE` (`npm install`), when tsconfig cannot be opened `TSCONFIG_INVALID` |
88
88
  | `dokebi upgrade <plugin id> [--to <version\|package\|tgz>] [--dry-run]` | Change the version. Do not use remove and add instead. Without `--to` it picks the highest version that fits the core and the installed packages, as `add` does (`NEWER_VERSION_HELD_BACK` names a newer one and what it waits for; the same version again changes nothing); an unreachable registry or a workspace package takes npm's `latest`. The copies of templates the project owns (the @dokebi/db adapters, `vite.config.ts` and `vite.ssr.config.ts`) are never rewritten: fixes of the new templates they lack are the warnings `TEMPLATE_FIX_MISSING` (`path`, `plugin`, `hint`: the change to make), as doctor reports them. With the same version and a changed manifest it applies the manifest again (D-0037, `reason: MANIFEST_CHANGED`); with the same version and manifest but other package content (an unpublished version rebuilt, given as `--to <tgz>`; the package-lock integrity differs) it installs the new code (`reason: PACKAGE_CHANGED`) — the way to replace a local snapshot. After package.json moved several plugins at once, upgrade them one by one, dependencies first: each result lists the ones still to do as `MANIFEST_CHANGED` warnings with their `hint`. A required plugin the new version needs and the project lacks is installed with it, as `add` would (`autoInstalled`, D-0116), when its manifest names the package and it needs no choice or settings; otherwise nothing is written and it is `MISSING_DEPENDENCY` (`mutation: none`) whose `details.fix` is the command to run first (`npx dokebi add <package>`, then the same upgrade again) |
89
89
  | `dokebi remove <plugin id> [--dry-run]` | Remove a plugin. `REVERSE_DEPENDENCY` when a remaining plugin depends on it, `REQUIRED_PLUGIN` for a required part. An id that is not installed is no change; the package name of an installed plugin is `UNKNOWN_PLUGIN` (`details.fix`: `npx dokebi remove <id>`) |
90
90
  | `dokebi migrate [--dry-run]` | Move a 0.1.x project with JSON settings to YAML |
@@ -245,7 +245,7 @@ Every command also works in an npm workspace member folder. Packages are found t
245
245
  - The dokebi.yaml and dokebi.example.yaml that `init` writes have `options.logging: { level: info }` and a commented `plugins` example. `options.logging` is the log setting core reads, and the options of @dokebi/logger (its targets) when it is installed; adding the logger writes its `targets` into both files (an older project whose sample lacks them: `npx dokebi config diff --write`). Existing projects are not changed automatically: `npx dokebi config set logging.level=info` adds it (`logging.plugins.<plugin>=<level>` a plugin level), with or without the logger.
246
246
  - At run time `DOKEBI_LOG_LEVEL` wins over the YAML (`DOKEBI_LOG_LEVEL=debug npx dokebi dev`).
247
247
  - With `DOKEBI_LOG_LEVEL=debug` the CLI itself writes its decisions about npm runs, install modules, transaction rollbacks and start/stop to stderr, one JSON line each. Errors it recovers from (an unreadable pid file, a workspace package.json and the like) are written to stderr as one `level: error` line (`code`, `error`) at any level. stdout (the `--json` envelope) does not change.
248
- - Warnings: `COMPOSE_VARIABLES_UNSET` (doctor and `dev-infra`: compose.yaml needs variables without a default that `dev-infra up` does not set — it passes the passwords of dokebi.yaml (`DOKEBI_DB_PASSWORD`, and for every connection `DOKEBI_<PLUGIN>_<CONNECTION>_PASSWORD` or `_TOKEN`, without the connection for `main`: `DOKEBI_REDIS_PASSWORD`; D-0165) and Compose reads `.env` — so `dev-infra up` would fail; `details.variables`, `hint`: give each a default `${NAME:-value}` or set it in `.env`; the `dev-infra up` next step says so first), `COMPOSE_PUBLISHES_APP_PORT` (doctor: a compose.yaml service publishes the port of `options.dokebi-web.port`, so `dev-infra up` starts it and `start`, `dev` and `verify` find the port taken; `details.services`, `details.port`; compose.yaml is the development infrastructure — a container of the app goes in its own Compose file such as `compose.deploy.yaml`), `COMPOSE_BUILDS_APP` (doctor: a compose.yaml service is built from the project folder — `build: .`, or `build:` with `context: .` or none — so it is the app itself, also when its port is a variable the port rule cannot read: `dev-infra up` builds and starts it with the infrastructure; `details.services`, `details.variables` (the unset variables only those services use); the same fix: its own Compose file), `ENV_DOKEBI_CONFIG_IGNORED` (a `.env` line sets `DOKEBI_CONFIG`, which the app does not get from `.env`; `path` `.env:<line>`, §2.2), `LOGGER_NOT_INSTALLED` (D-0151: init could not add @dokebi/logger; `hint` names the error code, `nextSteps` the command), `LOGGER_MAIN_MANUAL` (D-0151: `add @dokebi/logger` found a `src/main.ts` of your own without `createLogger(`; `hint` is the line to write: `new Application({ config: document.options, logger: createLogger(document.options) })` with `createLogger` from `./dokebi.generated.ts`; an unchanged generated one is rewritten), `OPTION_NOT_SET`, `SECTION_NOT_READ` (config unset: the typed section is an old one a file still holds, removed as written; the plugin reads another section such as `options.logging`), `SECRET_REMOVED`, `OPTIONS_STILL_INVALID` (`config unset`, D-0153), `BUILD_SCRIPT_KEPT`, `TYPECHECK_SCRIPT_KEPT` (`app add --inertia` kept a `typecheck` script of the project's own: add the Vue check, `node typecheck-vue.mjs -p tsconfig.vue.json`, to it), `VITE_PLUGIN_MISSING` (an Inertia app added to a project whose own vite config lacks `dokebiInertia()`), `INERTIA_PLUGIN_MISSING`, `SEAL_PLUGIN_MISSING`, `FORMATTER_FORMATS_MIGRATIONS` (D-0145: a formatter `add` cannot configure would format the migrations folder, a biome.jsonc with comments or an ESLint config with formatting rules; `path` the config, `hint` the entry to add — `add` itself writes a CLI-owned entry into `.prettierignore` and `!<folder>` into a plain biome.json `files.includes`, in the shape biome prints), `FORMATTER_FORMATS_GENERATED` (the same for `src/dokebi.generated.ts`, which `add` keeps out of prettier and plain biome.json too), `VIEW_SOURCE_UNSTATED` (D-0098: an EJS app, from `app add` or the first app of `add @dokebi/app`, without `--answers-from user` or `--ai-chose view`), `EXAMPLE_MISSING`, `EXAMPLE_INVALID`, `THIRD_PARTY_PACKAGE`, `CATALOG_OFFLINE`, `DEPRECATED_VERSION`, `GUIDE_BLOCK_MISSING` (also a doctor warning), `GUIDE_PROJECT_BLOCK_INVALID` (also a doctor warning: AGENTS.md was left as it is), `ADAPTER_FILE_KEPT`, `CONNECTIONS_KEPT`, `CONNECTION_KEPT`, `COMPOSE_KEPT`, `COMPOSE_PORT_CHANGED`, `COMPOSE_PORT_UNKNOWN`, `URL_REPLACED`, `SECRET_KEPT`.
248
+ - Warnings: `COMPOSE_VARIABLES_UNSET` (doctor and `dev-infra`: compose.yaml needs variables without a default that `dev-infra up` does not set — it passes the passwords of dokebi.yaml (`DOKEBI_DB_PASSWORD`, and for every connection `DOKEBI_<PLUGIN>_<CONNECTION>_PASSWORD` or `_TOKEN`, without the connection for `main`: `DOKEBI_REDIS_PASSWORD`; D-0165) and Compose reads `.env` — `${NAME:?…}` makes `dev-infra up` fail, and a bare `${NAME}` becomes an empty value with only a Compose warning, which breaks a port or a password; a variable in a YAML comment is not counted; `details.variables`, `hint`: give each a default `${NAME:-value}` or set it in `.env`; the `dev-infra up` next step says so first), `COMPOSE_PUBLISHES_APP_PORT` (doctor: a compose.yaml service publishes the port of `options.dokebi-web.port`, so `dev-infra up` starts it and `start`, `dev` and `verify` find the port taken; `details.services`, `details.port`; compose.yaml is the development infrastructure — a container of the app goes in its own Compose file such as `compose.deploy.yaml`), `COMPOSE_BUILDS_APP` (doctor: a compose.yaml service is built from the project folder — `build: .`, or `build:` with `context: .` or none — so it is the app itself, also when its port is a variable the port rule cannot read: `dev-infra up` builds and starts it with the infrastructure; `details.services`, `details.variables` (the unset variables only those services use); the same fix: its own Compose file), `ENV_DOKEBI_CONFIG_IGNORED` (a `.env` line sets `DOKEBI_CONFIG`, which the app does not get from `.env`; `path` `.env:<line>`, §2.2), `LOGGER_NOT_INSTALLED` (D-0151: init could not add @dokebi/logger; `hint` names the error code, `nextSteps` the command), `LOGGER_MAIN_MANUAL` (D-0151: `add @dokebi/logger` found a `src/main.ts` of your own without `createLogger(`; `hint` is the line to write: `new Application({ config: document.options, logger: createLogger(document.options) })` with `createLogger` from `./dokebi.generated.ts`; an unchanged generated one is rewritten), `OPTION_NOT_SET`, `SECTION_NOT_READ` (config unset: the typed section is an old one a file still holds, removed as written; the plugin reads another section such as `options.logging`), `SECRET_REMOVED`, `OPTIONS_STILL_INVALID` (`config unset`, D-0153), `BUILD_SCRIPT_KEPT`, `TYPECHECK_SCRIPT_KEPT` (`app add --inertia` kept a `typecheck` script of the project's own: add the Vue check, `node typecheck-vue.mjs -p tsconfig.vue.json`, to it), `VITE_PLUGIN_MISSING` (an Inertia app added to a project whose own vite config lacks `dokebiInertia()`), `INERTIA_PLUGIN_MISSING`, `SEAL_PLUGIN_MISSING`, `FORMATTER_FORMATS_MIGRATIONS` (D-0145: a formatter `add` cannot configure would format the migrations folder, a biome.jsonc with comments or an ESLint config with formatting rules; `path` the config, `hint` the entry to add — `add` itself writes a CLI-owned entry into `.prettierignore` and `!<folder>` into a plain biome.json `files.includes`, in the shape biome prints), `FORMATTER_FORMATS_GENERATED` (the same for `src/dokebi.generated.ts`, which `add` keeps out of prettier and plain biome.json too), `VIEW_SOURCE_UNSTATED` (D-0098: an EJS app, from `app add` or the first app of `add @dokebi/app`, without `--answers-from user` or `--ai-chose view`), `EXAMPLE_MISSING`, `EXAMPLE_INVALID`, `THIRD_PARTY_PACKAGE`, `CATALOG_OFFLINE`, `DEPRECATED_VERSION`, `GUIDE_BLOCK_MISSING` (also a doctor warning), `GUIDE_PROJECT_BLOCK_INVALID` (also a doctor warning: AGENTS.md was left as it is), `ADAPTER_FILE_KEPT`, `CONNECTIONS_KEPT`, `CONNECTION_KEPT`, `COMPOSE_KEPT`, `COMPOSE_PORT_CHANGED`, `COMPOSE_PORT_UNKNOWN`, `URL_REPLACED`, `SECRET_KEPT`.
249
249
 
250
250
  ### Start screen (logo)
251
251
 
@@ -291,7 +291,7 @@ One server, several instances (a staging and a production one), installed from t
291
291
  4. Before a start, on the server: `NODE_ENV=production DOKEBI_CONFIG=… DOKEBI_SECRETS=… npx -y @dokebi/cli doctor --production --json`.
292
292
  5. A release, in DEPLOY.md's order: a new release folder (`npm ci`, `npm run build --if-present`, `npm prune --omit=dev`) → `npx dokebi-migrate up --phase pre-deploy --json` (exit 0, else stop; `LOCK_TIMEOUT`: another run holds the lock) → switch `current` and restart → `npx -y @dokebi/cli verify --remote https://<domain> --json` → `npx dokebi-migrate up --json` (post-deploy). Rollback: `current` back to the previous release; the pre-deploy migrations only added, so the database stays.
293
293
  6. `npx dokebi deploy proxy --caddy --domain <host> --instance <name>` (or `--nginx`) for the reverse proxy.
294
- 7. Backups (@dokebi/db): the timer runs `node deploy/backup.mjs` daily (`pg_dump -Fc` or `mongodump --archive --gzip` of every postgres or mongodb connection, mode 0600, the newest of 7 days, 4 weeks and 6 months kept, passwords only in the environment or a 0600 file, one JSON line); `node deploy/restore-drill.mjs` with `DOKEBI_RESTORE_URL` (a scratch database) proves the newest backup restores, monthly. Copy the backups off the server. MySQL and MariaDB: `mysqldump --single-transaction` from your scheduler (not scripted).
294
+ 7. Backups (@dokebi/db): the timer runs `node deploy/backup.mjs` daily (`pg_dump -Fc` or `mongodump --archive --gzip` of every postgres or mongodb connection, mode 0600, the newest of 7 days, 4 weeks and 6 months kept, passwords only in the environment or a 0600 file, one JSON line); `node deploy/restore-drill.mjs` with `DOKEBI_RESTORE_URL` (a new, empty scratch database: the live database, by any spelling of its URL, and a database that holds a table or collection are refused) proves the newest backup restores, monthly. Copy the backups off the server. MySQL and MariaDB: `mysqldump --single-transaction` from your scheduler (not scripted).
295
295
 
296
296
  `examples/77-production-deploy` runs all of it on one machine (the app in production behind TLS, nginx and Caddy checking the generated files, a backup and a restore drill on PostgreSQL).
297
297
 
package/catalog.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "$comment": "Generated by scripts/catalog/build.ts from package.json dokebiCatalog fields and packages/cli/catalog-src (D-0065). Do not edit; run node scripts/catalog/build.ts.",
3
3
  "schemaVersion": 1,
4
- "cli": "0.4.29",
4
+ "cli": "0.4.30",
5
5
  "core": {
6
6
  "package": "@dokebi/core",
7
- "version": "0.4.5"
7
+ "version": "0.4.6"
8
8
  },
9
9
  "capabilities": {
10
10
  "admin.ui": {
@@ -415,7 +415,7 @@
415
415
  {
416
416
  "id": "dokebi-audit",
417
417
  "package": "@dokebi/audit",
418
- "version": "0.1.0",
418
+ "version": "0.1.1",
419
419
  "kind": "plugin",
420
420
  "summary": "Audit and activity logs in your database: written in the change's transaction, a declared code tree, the actor from auth or an OAuth grant (AI clients by name), masking before the write, indexed keyset lists, retention",
421
421
  "description": "Audit and activity logs for Dokebi: rows written in the change's transaction, a declared code tree, the actor from auth or an OAuth grant, masking before the write, indexed keyset lists and retention.",
@@ -578,7 +578,7 @@
578
578
  {
579
579
  "id": "dokebi-bulk-send",
580
580
  "package": "@dokebi/bulk-send",
581
- "version": "0.1.0",
581
+ "version": "0.1.1",
582
582
  "kind": "plugin",
583
583
  "summary": "Bulk sends over @dokebi/outbox: a send row, recipient rows per person and channel fixed when it goes (excluded and failed with reasons), channels and audiences your app registers (mail through @dokebi/mail, an inbox of your own), scheduling and cancel, progress per channel, stop, and failed deliveries sent again",
584
584
  "description": "Bulk sends for Dokebi over @dokebi/outbox: recipient rows fixed when a send goes, channels and audiences your app registers, scheduling and cancel, progress per channel, stop, and failures sent again.",
@@ -713,7 +713,7 @@
713
713
  {
714
714
  "id": null,
715
715
  "package": "@dokebi/cli",
716
- "version": "0.4.29",
716
+ "version": "0.4.30",
717
717
  "kind": "cli",
718
718
  "summary": "Commands to create a project, browse the plugin catalog, run recipes, install plugins and verify (dokebi)",
719
719
  "description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
@@ -751,7 +751,7 @@
751
751
  {
752
752
  "id": null,
753
753
  "package": "@dokebi/cluster",
754
- "version": "0.4.1",
754
+ "version": "0.4.2",
755
755
  "kind": "library",
756
756
  "summary": "Runner that starts several app workers from a node:cluster parent process, watches them and replaces them one by one",
757
757
  "description": "node:cluster runner for Dokebi: starts, watches and rolls independent application workers.",
@@ -785,7 +785,7 @@
785
785
  {
786
786
  "id": "dokebi-config",
787
787
  "package": "@dokebi/config",
788
- "version": "0.4.4",
788
+ "version": "0.4.5",
789
789
  "kind": "required",
790
790
  "summary": "Required part of the core that reads and validates dokebi.yaml into read-only settings per app (installed automatically)",
791
791
  "description": "Validated immutable YAML configuration for Dokebi applications.",
@@ -860,7 +860,7 @@
860
860
  {
861
861
  "id": null,
862
862
  "package": "@dokebi/core",
863
- "version": "0.4.5",
863
+ "version": "0.4.6",
864
864
  "kind": "core",
865
865
  "summary": "Application core: settings loading, plugin registration, lifecycle, logger and shared libraries (required)",
866
866
  "description": "Minimal composable Node.js application and plugin lifecycle framework.",
@@ -1007,7 +1007,7 @@
1007
1007
  {
1008
1008
  "id": "dokebi-db",
1009
1009
  "package": "@dokebi/db",
1010
- "version": "0.4.1",
1010
+ "version": "0.4.2",
1011
1011
  "kind": "plugin",
1012
1012
  "summary": "Named database connections (pools) with readiness checks and shutdown; you use the driver API as it is",
1013
1013
  "description": "Named database connections for Dokebi: create, readiness check and close pools of pg, mysql2, mariadb or mongodb.",
@@ -1265,7 +1265,7 @@
1265
1265
  {
1266
1266
  "id": "dokebi-files",
1267
1267
  "package": "@dokebi/files",
1268
- "version": "0.1.0",
1268
+ "version": "0.1.1",
1269
1269
  "kind": "plugin",
1270
1270
  "summary": "A record of every stored file: uploads recorded without an owner, claimed by a feature in its transaction, removals whose bytes go after the commit through @dokebi/outbox, unowned files swept after a grace, read rules per owner type in front of downloads and thumbnails, lists by owner, kind and time",
1271
1271
  "description": "A record of every stored file for Dokebi: owners claimed in the caller's transaction, removals whose bytes are deleted after the commit (@dokebi/outbox), a sweep of unowned files after a grace, read rules per owner type, uploads, downloads and thumbnails behind them.",
@@ -1461,7 +1461,7 @@
1461
1461
  {
1462
1462
  "id": "dokebi-i18n",
1463
1463
  "package": "@dokebi/i18n",
1464
- "version": "0.2.0",
1464
+ "version": "0.2.1",
1465
1465
  "kind": "plugin",
1466
1466
  "summary": "Compiled translations, locale negotiation, cardinal plurals and named number/date formats",
1467
1467
  "description": "Compiled translation catalogs, locale negotiation, cardinal plurals and named Intl formats.",
@@ -1517,7 +1517,7 @@
1517
1517
  {
1518
1518
  "id": "dokebi-image",
1519
1519
  "package": "@dokebi/image",
1520
- "version": "0.1.0",
1520
+ "version": "0.1.1",
1521
1521
  "kind": "plugin",
1522
1522
  "summary": "Server-side WebP thumbnails of stored png, jpeg, gif, webp and avif images, made once and deleted with their source",
1523
1523
  "description": "Bounded server-side WebP thumbnails of stored images, made once and deleted with their source.",
@@ -1585,7 +1585,7 @@
1585
1585
  {
1586
1586
  "id": "dokebi-job",
1587
1587
  "package": "@dokebi/job",
1588
- "version": "0.4.3",
1588
+ "version": "0.4.4",
1589
1589
  "kind": "plugin",
1590
1590
  "summary": "NATS JetStream job queue (at least once, retries, DLQ)",
1591
1591
  "description": "Bounded durable jobs over the Dokebi NATS provider: retries, delayed redelivery and a dead-letter stream.",
@@ -1974,7 +1974,7 @@
1974
1974
  {
1975
1975
  "id": "dokebi-migrate",
1976
1976
  "package": "@dokebi/migrate",
1977
- "version": "0.4.3",
1977
+ "version": "0.4.4",
1978
1978
  "kind": "plugin",
1979
1979
  "summary": "Migration and seed runner for dokebi-db connections (dokebi-migrate up in the deploy step)",
1980
1980
  "description": "Migrations and seeds for dokebi-db connections: history and lock for PostgreSQL, MySQL, MariaDB and MongoDB, run from the deployment.",
@@ -2417,7 +2417,7 @@
2417
2417
  {
2418
2418
  "id": "dokebi-permissions",
2419
2419
  "package": "@dokebi/permissions",
2420
- "version": "0.1.0",
2420
+ "version": "0.1.1",
2421
2421
  "kind": "plugin",
2422
2422
  "summary": "Roles, grades and scoped permissions: keys declared in code, grants saved in your database in the caller's transaction, can(actor, key, target) from memory over the holding tree (all, subtree, direct, own), list conditions as SQL, every worker refreshed by a revision; plugs into @dokebi/auth's authorize",
2423
2423
  "description": "Roles, grades and scoped permissions for Dokebi: permissions declared in code, grants saved in your database in the caller's transaction, checks from memory over the holding tree (all, subtree, direct, own), list conditions as SQL, every worker refreshed by a revision.",
@@ -2556,7 +2556,7 @@
2556
2556
  {
2557
2557
  "id": null,
2558
2558
  "package": "@dokebi/rich-text",
2559
- "version": "0.1.0",
2559
+ "version": "0.1.1",
2560
2560
  "kind": "library",
2561
2561
  "summary": "Editor documents (Tiptap or ProseMirror JSON) checked whole against a declared schema of nodes, marks, links and image sources, with coded 422 errors, then safe HTML, plain text and excerpts",
2562
2562
  "description": "Rich text documents for Dokebi: editor JSON (Tiptap, ProseMirror) checked whole against a declared schema with coded 422 errors, then safe HTML, plain text and excerpts.",
@@ -2592,7 +2592,7 @@
2592
2592
  {
2593
2593
  "id": "dokebi-rollups",
2594
2594
  "package": "@dokebi/rollups",
2595
- "version": "0.1.0",
2595
+ "version": "0.1.1",
2596
2596
  "kind": "plugin",
2597
2597
  "summary": "Report roll-ups by @dokebi/db AI.md 6.9: facts recorded as small rows in the caller's transaction (no hot row), folded in parallel by outbox lanes into UTC hour rows and day and month rows per whole-hour time zone (rebuilt from the hours when a zone is added), bounded reads with an as-of time, running totals and a report budget (429, 503)",
2598
2598
  "description": "Report roll-ups for Dokebi by @dokebi/db AI.md 6.9: facts recorded as small rows in the caller's transaction, folded by outbox lanes into UTC hour rows and day and month rows per time zone, bounded reads with an as-of time and a report budget.",
@@ -2686,7 +2686,7 @@
2686
2686
  {
2687
2687
  "id": "dokebi-runtime-settings",
2688
2688
  "package": "@dokebi/runtime-settings",
2689
- "version": "0.1.0",
2689
+ "version": "0.1.1",
2690
2690
  "kind": "plugin",
2691
2691
  "summary": "Settings operators change while the app runs: definitions in code (a group tree, text, number, numbers per choice, boolean, select, multiselect, json and file with rules, choices from your data), common and personal values saved in your database in the caller's transaction (the changes answered for the audit log), common values read from memory, every worker refreshed by a revision",
2692
2692
  "description": "Settings operators change while the app runs, for Dokebi: definitions in code (a group tree, nine types with rules, choices from your data), common and personal values in your database saved in the caller's transaction, common values read from memory, every worker refreshed by a revision.",
@@ -2835,7 +2835,7 @@
2835
2835
  {
2836
2836
  "id": "dokebi-search",
2837
2837
  "package": "@dokebi/search",
2838
- "version": "0.1.0",
2838
+ "version": "0.1.1",
2839
2839
  "kind": "plugin",
2840
2840
  "summary": "Search in your lists that stays bounded on a growing table: a term table in display order written in the text's transaction, Korean word prefixes, the rarest word leads, capped requests and searches with a signed cursor; answers item ids",
2841
2841
  "description": "Search in an application's lists for Dokebi by @dokebi/db AI.md 6.10: a term table in display order written in the text's transaction, Korean word prefixes, the rarest word leads, bounded requests and searches with a signed cursor.",
@@ -2888,7 +2888,7 @@
2888
2888
  {
2889
2889
  "id": "dokebi-session",
2890
2890
  "package": "@dokebi/session",
2891
- "version": "0.4.5",
2891
+ "version": "0.4.6",
2892
2892
  "kind": "plugin",
2893
2893
  "summary": "Server-side sessions for @dokebi/web (signed cookie, memory or redis store, flash)",
2894
2894
  "description": "Server-side sessions for @dokebi/web: signed cookie, memory or Redis store, flash.",
@@ -2960,7 +2960,7 @@
2960
2960
  {
2961
2961
  "id": "dokebi-sse",
2962
2962
  "package": "@dokebi/sse",
2963
- "version": "0.4.3",
2963
+ "version": "0.4.4",
2964
2964
  "kind": "plugin",
2965
2965
  "summary": "Server-sent events (SSE) streams and rooms, delivery across workers, and a browser client",
2966
2966
  "description": "Server-sent events for @dokebi/web: authenticated streams, rooms, cross-worker fan-out over @dokebi/event-bus, and a browser client",
@@ -3172,7 +3172,7 @@
3172
3172
  {
3173
3173
  "id": "dokebi-template-inertia",
3174
3174
  "package": "@dokebi/template-inertia",
3175
- "version": "0.4.4",
3175
+ "version": "0.4.5",
3176
3176
  "kind": "plugin",
3177
3177
  "summary": "Inertia (v3) server adapter: Vue 3 views, Vite build files and optional server-side rendering (SSR)",
3178
3178
  "description": "Inertia v3 server adapter for Dokebi: page JSON, Vite manifest assets and optional server-side rendering.",
@@ -3266,7 +3266,7 @@
3266
3266
  {
3267
3267
  "id": "dokebi-tree",
3268
3268
  "package": "@dokebi/tree",
3269
- "version": "0.1.0",
3269
+ "version": "0.1.1",
3270
3270
  "kind": "plugin",
3271
3271
  "summary": "Trees in your own tables (categories, a members' holding tree): materialized paths kept on place and move, a subtree moved in one UPDATE in the caller's transaction and never under itself, sibling order with the parent locked, ancestors, subtree SQL conditions, and keyset pages in tree order that keep their parent context",
3272
3272
  "description": "Trees in your own tables for Dokebi: materialized paths, places and subtree moves in the caller's transaction (never under itself), sibling order, ancestors, subtree conditions, and pages in tree order that keep their parent context.",
@@ -3322,7 +3322,7 @@
3322
3322
  {
3323
3323
  "id": "dokebi-two-factor",
3324
3324
  "package": "@dokebi/two-factor",
3325
- "version": "0.1.0",
3325
+ "version": "0.1.1",
3326
3326
  "kind": "plugin",
3327
3327
  "summary": "Two-factor sign-in for @dokebi/auth: TOTP codes of authenticator apps (secrets encrypted at rest, a code good once), ten recovery codes kept as HMACs, a second step after the password, remembered devices, lockout after wrong codes, and a code confirmation for the re-authentication page",
3328
3328
  "description": "Two-factor sign-in for @dokebi/auth: TOTP codes of authenticator apps (secrets encrypted at rest), recovery codes stored as HMACs, a second step after the password, remembered devices, lockout, and a code confirmation for re-authentication.",
@@ -3386,7 +3386,7 @@
3386
3386
  {
3387
3387
  "id": "dokebi-web",
3388
3388
  "package": "@dokebi/web",
3389
- "version": "0.4.3",
3389
+ "version": "0.4.4",
3390
3390
  "kind": "plugin",
3391
3391
  "summary": "Fastify 5 HTTP server (503 before ready, health paths, drain, zero-downtime cluster replacement, security headers and overload protection on by default)",
3392
3392
  "description": "Fastify 5 HTTP server owned by a Dokebi app: 503 before ready, health routes, drain and cluster handover.",
@@ -146,7 +146,10 @@ export function assetRouteRules(file, kinds, report) {
146
146
  const visit = (node) => {
147
147
  if (node.kind === kinds.CallExpression &&
148
148
  field(node, 'expression')?.kind === kinds.PropertyAccessExpression &&
149
- /^(?:get|head)$/.test(called(node) ?? '')) {
149
+ /^(?:get|head)$/.test(called(node) ?? '') &&
150
+ // A route takes a path and a handler; a lookup by one key (`manifest.get('src/main.css')`,
151
+ // a Map, FormData or Headers) is no route (audit R8-g5b-4).
152
+ nodes(node, 'arguments').length >= 2) {
150
153
  const path = nodes(node, 'arguments')[0];
151
154
  const last = tail(path);
152
155
  if (path && last && ASSET.test(last)) {
@@ -12,7 +12,10 @@ interface Layer {
12
12
  readonly kind: 'app' | 'module' | 'shared';
13
13
  readonly name: string;
14
14
  readonly folder: string;
15
+ /** By canonical locale (`en-US` for a folder `en-us`), as @dokebi/i18n reads the folders. */
15
16
  readonly files: ReadonlyMap<string, ReadonlyMap<string, CatalogFile>>;
17
+ /** The folder name of each canonical locale, as it is spelled on disk. */
18
+ readonly folders: ReadonlyMap<string, string>;
16
19
  }
17
20
  /** i18n-layer-override: a key of one language in two layers, unless the overriding file lists it. */
18
21
  export declare function overrideProblems(shared: Layer | undefined, modules: readonly Layer[], apps: readonly Layer[]): Problem[];
@@ -21,7 +24,9 @@ export declare function layerMissingProblems(layers: readonly Layer[], locales:
21
24
  /** The problems of one file's text against the catalogs (the path is project-relative). */
22
25
  export declare function missingKeyProblems(path: string, text: string, catalogs: ReadonlyMap<string, ReadonlySet<string>>,
23
26
  /** dokebi-i18n defaultLocale: the end of every fallback chain. */
24
- defaultLocale?: string): Problem[];
27
+ defaultLocale?: string,
28
+ /** The shared catalogs' folder of the default locale as spelled on disk (`en-us`). */
29
+ defaultFolder?: string): Problem[];
25
30
  /** The translation rules over the catalogs and the files under `src/` (only with @dokebi/i18n). */
26
31
  export declare function missingKeysProblems(root: string, skip: (path: string) => boolean): Promise<Problem[]>;
27
32
  export {};
@@ -56,6 +56,23 @@ function flatten(value, prefix, keys, top = true) {
56
56
  flatten(child, `${prefix}.${key}`, keys, false);
57
57
  }
58
58
  }
59
+ /**
60
+ * A locale as @dokebi/i18n reads a folder name or defaultLocale (`Intl.Locale(name).baseName`:
61
+ * `en-us` is `en-US`), or undefined when it is none (audit R8-g5b-2: `en-us` folders with
62
+ * `defaultLocale: en-US` made every key "missing in the default locale").
63
+ */
64
+ function canonicalLocale(name) {
65
+ if (name.length < 2 || name.length > 128)
66
+ return undefined;
67
+ try {
68
+ return new Intl.Locale(name).baseName;
69
+ }
70
+ catch (error) {
71
+ if (error instanceof RangeError)
72
+ return undefined;
73
+ throw error;
74
+ }
75
+ }
59
76
  /** The files of one locales folder (`<locale>/<namespace>.json`); unreadable JSON is reported. */
60
77
  async function readLayer(root, kind, name, folder, broken) {
61
78
  let locales;
@@ -69,9 +86,23 @@ async function readLayer(root, kind, name, folder, broken) {
69
86
  throw error;
70
87
  }
71
88
  const files = new Map();
89
+ const folders = new Map();
72
90
  for (const locale of locales) {
73
91
  if (!locale.isDirectory())
74
92
  continue;
93
+ const canonical = canonicalLocale(locale.name);
94
+ if (canonical === undefined || folders.has(canonical)) {
95
+ broken.push({
96
+ rule: RULE,
97
+ severity: 'warning',
98
+ file: `${folder}/${locale.name}`,
99
+ line: 1,
100
+ message: `${folder}/${locale.name} is ${canonical === undefined ? 'not a BCP 47 locale' : `a second folder of the locale ${canonical} (${folders.get(canonical)})`}: its keys are not compared, and @dokebi/i18n refuses it at start`,
101
+ fix: 'name each locales folder by one BCP 47 locale (en, en-US, ko-KR)',
102
+ });
103
+ continue;
104
+ }
105
+ folders.set(canonical, locale.name);
75
106
  const byNamespace = new Map();
76
107
  for (const file of await readdir(join(root, folder, locale.name), { withFileTypes: true })) {
77
108
  if (!file.isFile() || !file.name.endsWith('.json'))
@@ -105,9 +136,9 @@ async function readLayer(root, kind, name, folder, broken) {
105
136
  : []);
106
137
  byNamespace.set(namespace, { path, text, keys, overrides });
107
138
  }
108
- files.set(locale.name, byNamespace);
139
+ files.set(canonical, byNamespace);
109
140
  }
110
- return files.size ? { kind, name, folder, files } : undefined;
141
+ return files.size ? { kind, name, folder, files, folders } : undefined;
111
142
  }
112
143
  /** The named folders of `parent` that have a locales folder, as layers in name order. */
113
144
  async function namedLayers(root, parent, kind, broken) {
@@ -234,7 +265,7 @@ export function layerMissingProblems(layers, locales) {
234
265
  const missing = [...keys].filter((key) => !has.has(key)).sort();
235
266
  if (!missing.length)
236
267
  continue;
237
- const path = `${layer.folder}/${locale}/${namespace}.json`;
268
+ const path = `${layer.folder}/${layer.folders.get(locale) ?? locale}/${namespace}.json`;
238
269
  const named = missing.slice(0, NAMED).join(', ');
239
270
  problems.push({
240
271
  rule: MISSING,
@@ -251,7 +282,9 @@ export function layerMissingProblems(layers, locales) {
251
282
  /** The problems of one file's text against the catalogs (the path is project-relative). */
252
283
  export function missingKeyProblems(path, text, catalogs,
253
284
  /** dokebi-i18n defaultLocale: the end of every fallback chain. */
254
- defaultLocale = 'en') {
285
+ defaultLocale = 'en',
286
+ /** The shared catalogs' folder of the default locale as spelled on disk (`en-us`). */
287
+ defaultFolder = defaultLocale) {
255
288
  // A key the default locale has never throws (every lookup chain ends there); one it lacks
256
289
  // throws in every locale that lacks it too.
257
290
  const fallback = catalogs.get(defaultLocale);
@@ -286,7 +319,7 @@ defaultLocale = 'en') {
286
319
  file: path,
287
320
  line,
288
321
  message: `${path} asks for the translation ${key}, which ${having.length ? `only the ${having.join(', ')} catalog${having.length > 1 ? 's have' : ' has'}, not the default locale ${defaultLocale}` : 'no catalog has'}: @dokebi/i18n throws MISSING_MESSAGE for it${having.length ? ' in the other locales' : ''} (under npx dokebi dev the page shows the key)${marker ? ' (the dokebi-check marker has no reason, so it does not count)' : ''}`,
289
- fix: `add ${key.slice(namespace.length + 1)} to ${LOCALES}/${defaultLocale}/${namespace}.json (the fallback of every locale; or to the locales folder of its app or module), or correct the key`,
322
+ fix: `add ${key.slice(namespace.length + 1)} to ${LOCALES}/${defaultFolder}/${namespace}.json (the fallback of every locale; or to the locales folder of its app or module), or correct the key`,
290
323
  });
291
324
  }
292
325
  }
@@ -306,7 +339,9 @@ async function defaultLocaleOf(root) {
306
339
  try {
307
340
  const options = parseProjectConfig(source).options;
308
341
  const section = options['dokebi-i18n'];
309
- return typeof section?.defaultLocale === 'string' ? section.defaultLocale : 'en';
342
+ return typeof section?.defaultLocale === 'string'
343
+ ? (canonicalLocale(section.defaultLocale) ?? section.defaultLocale)
344
+ : 'en';
310
345
  }
311
346
  catch (error) {
312
347
  debug('check: i18n default locale not read, en assumed', { error: error.message });
@@ -340,7 +375,7 @@ export async function missingKeysProblems(root, skip) {
340
375
  files++;
341
376
  const app = /^src\/apps\/([^/]+)\//.exec(path)?.[1];
342
377
  const catalogs = (app !== undefined && scoped.get(app)) || scoped.get('');
343
- problems.push(...missingKeyProblems(path, text, catalogs, fallback));
378
+ problems.push(...missingKeyProblems(path, text, catalogs, fallback, shared?.folders.get(fallback)));
344
379
  }
345
380
  debug('check: translation keys', {
346
381
  files,
@@ -19,10 +19,14 @@ const FORMS = '/dokebi/seal/forms.mjs';
19
19
  /** Files larger than this are not read (generated bundles, data). */
20
20
  const MAX_BYTES = 1024 * 1024;
21
21
  export const SEAL_HEAD_FIX = "write <%- data.seal?.head ?? '' %> in the <head> of the layout of an app page; a page rendered outside an app route (an oauth consent page) takes context.getDependency(apps).seal(request).head (AppGroupApi of @dokebi/app ^0.4.5, empty on a plain host). A page that is no app page at all takes // dokebi-check: allow seal-head-copied <reason>";
22
- /** True when the text before `index` on its line opens a comment. */
22
+ /**
23
+ * True when the text before `index` on its line opens a comment. The `//` of a URL
24
+ * (`https://host/…`, a scheme-relative `"//host/…"`) opens none (audit R8-g5b-3: a copy with the
25
+ * app's origin was not reported).
26
+ */
23
27
  function inComment(line, column) {
24
28
  const before = line.slice(0, column);
25
- return /^\s*(?:\*|\/\*)/.test(line) || before.includes('//') || before.includes('<%#');
29
+ return (/^\s*(?:\*|\/\*)/.test(line) || /(?:^|[^:'"`=/])\/\//.test(before) || before.includes('<%#'));
26
30
  }
27
31
  /** The seal head problems of one file's text (the path is project-relative, with `/`). */
28
32
  export function sealHeadProblems(path, text) {