@dokebi/cli 0.4.44 → 0.4.46

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
@@ -79,7 +79,7 @@ The `blog` plan, depending on the answers: `init` (when the folder is not a proj
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
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
- | `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 |
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`). A settings file with `dokebi-web.listen: false` (a worker process of the same code picked with `DOKEBI_CONFIG`, D-0221) skips HTTP as passed (`skipped: 'listen: false (dokebi-web): this process opens no port'`) and the preflight's port check; start still proves the app started (0.4.45) and returns at its ready signal instead of waiting out `--wait-ms` for a listening line that never comes (0.4.46). 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 |
package/catalog.json CHANGED
@@ -1,7 +1,7 @@
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.44",
4
+ "cli": "0.4.46",
5
5
  "core": {
6
6
  "package": "@dokebi/core",
7
7
  "version": "0.4.7"
@@ -820,7 +820,7 @@
820
820
  {
821
821
  "id": null,
822
822
  "package": "@dokebi/cli",
823
- "version": "0.4.44",
823
+ "version": "0.4.46",
824
824
  "kind": "cli",
825
825
  "summary": "Commands to create a project, browse the plugin catalog, run recipes, install plugins and verify (dokebi)",
826
826
  "description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
@@ -3666,7 +3666,7 @@
3666
3666
  {
3667
3667
  "id": "dokebi-web",
3668
3668
  "package": "@dokebi/web",
3669
- "version": "0.4.8",
3669
+ "version": "0.4.9",
3670
3670
  "kind": "plugin",
3671
3671
  "summary": "Fastify 5 HTTP server (503 before ready, health paths, drain, zero-downtime cluster replacement, security headers and overload protection on by default)",
3672
3672
  "description": "Fastify 5 HTTP server owned by a Dokebi app: 503 before ready, health routes, drain and cluster handover.",
package/dist/output.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const CLI_VERSION = "0.4.44";
1
+ export declare const CLI_VERSION = "0.4.46";
2
2
  export declare function envelope(command: string, result: unknown, ok?: boolean): object;
3
3
  export declare function failure(command: string, error: unknown, mutationStarted: boolean): object;
package/dist/output.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CliError } from './errors.js';
2
- export const CLI_VERSION = '0.4.44';
2
+ export const CLI_VERSION = '0.4.46';
3
3
  export function envelope(command, result, ok = true) {
4
4
  return { schemaVersion: 1, cliVersion: CLI_VERSION, command, ok, result, error: null };
5
5
  }
package/dist/server.d.ts CHANGED
@@ -157,6 +157,8 @@ export declare function listeningUrls(text: string): string[];
157
157
  * shown instead (the app already runs: this is no reason to fail the command).
158
158
  */
159
159
  export declare function appHostsOrNone(root: string): Promise<AppHosts>;
160
+ /** Whether the text has the web plugin's `WEB_NOT_LISTENING` line (`listen: false`, D-0221). */
161
+ export declare function notListening(text: string): boolean;
160
162
  export interface StopResult {
161
163
  readonly stopped: boolean;
162
164
  readonly pid?: number;
package/dist/server.js CHANGED
@@ -448,6 +448,20 @@ function pidState(pid, kill) {
448
448
  * reads, M50), for pid files that recorded none.
449
449
  */
450
450
  async function configuredUrl(root) {
451
+ const web = await configuredWeb(root);
452
+ // D-0221: `listen: false` opens no port, whatever port is configured.
453
+ if (!web || web.listen === false || typeof web.port !== 'number' || web.port <= 0)
454
+ return undefined;
455
+ const host = typeof web.host !== 'string' || ['0.0.0.0', '::', '[::]'].includes(web.host)
456
+ ? '127.0.0.1'
457
+ : web.host;
458
+ return `http://${host.includes(':') ? `[${host}]` : host}:${web.port}`;
459
+ }
460
+ /**
461
+ * `options.dokebi-web` of the settings file the app reads (DOKEBI_CONFIG, else dokebi.yaml);
462
+ * undefined when it cannot be read or parsed (doctor reports that).
463
+ */
464
+ async function configuredWeb(root) {
451
465
  let source;
452
466
  try {
453
467
  source = (await readProjectSettings(root)).source;
@@ -457,23 +471,16 @@ async function configuredUrl(root) {
457
471
  reportError('CONFIG_READ_FAILED', 'Unable to read the settings file of the project', error);
458
472
  return undefined;
459
473
  }
460
- let web;
461
474
  try {
462
- web = (parseProjectConfig(source).options['dokebi-web'] ?? {});
475
+ return (parseProjectConfig(source).options['dokebi-web'] ?? {});
463
476
  }
464
477
  catch (error) {
465
- // doctor reports an invalid dokebi.yaml; here it only means there is no address to try.
466
- debug('dokebi.yaml could not be parsed; no configured address', {
478
+ // doctor reports an invalid dokebi.yaml; here it only means there are no web settings.
479
+ debug('dokebi.yaml could not be parsed; no configured web settings', {
467
480
  error: describeError(error),
468
481
  });
469
482
  return undefined;
470
483
  }
471
- if (typeof web.port !== 'number' || web.port <= 0)
472
- return undefined;
473
- const host = typeof web.host !== 'string' || ['0.0.0.0', '::', '[::]'].includes(web.host)
474
- ? '127.0.0.1'
475
- : web.host;
476
- return `http://${host.includes(':') ? `[${host}]` : host}:${web.port}`;
477
484
  }
478
485
  /** One challenge request; resolves with the answer header (undefined when there is none). */
479
486
  function challenge(url, value, timeoutMs) {
@@ -1009,19 +1016,47 @@ export async function appHostsOrNone(root) {
1009
1016
  * listening line through the log, a path with more hops (the logger's worker thread; a cluster's
1010
1017
  * primary relaying whole lines, M51): the line can reach app.log just after the message. So with
1011
1018
  * @dokebi/web in the project the log is read again until the line is there or the start's own
1012
- * deadline passes; a project without web logs no such line and is read once.
1019
+ * deadline passes; a project without web logs no such line and is read once. A process that
1020
+ * opens no port (`dokebi-web.listen: false`, D-0221) never logs it either: its settings, or its
1021
+ * `WEB_NOT_LISTENING` line, end the wait at once.
1013
1022
  */
1014
1023
  async function listeningAfterStart(root, log, offset, deadline) {
1015
- let listen = await startedUrls(log, offset);
1016
- if (listen.length || !hasWebDependency(root))
1017
- return listen;
1018
- while (!listen.length && performance.now() < deadline) {
1024
+ let read = await startedLog(log, offset);
1025
+ if (read.listen.length || !hasWebDependency(root))
1026
+ return read.listen;
1027
+ if ((await configuredWeb(root))?.listen === false) {
1028
+ debug('The settings say dokebi-web.listen: false; no listening line to wait for', { log });
1029
+ return [];
1030
+ }
1031
+ while (!read.listen.length && !read.notListening && performance.now() < deadline) {
1019
1032
  await delay(25);
1020
- listen = await startedUrls(log, offset);
1033
+ read = await startedLog(log, offset);
1021
1034
  }
1022
- if (!listen.length)
1035
+ if (read.listen.length)
1036
+ return read.listen;
1037
+ if (read.notListening)
1038
+ debug('The app logged WEB_NOT_LISTENING; it opens no port', { log });
1039
+ else
1023
1040
  debug('No web listening line in the log before the start deadline', { log });
1024
- return listen;
1041
+ return [];
1042
+ }
1043
+ /** Whether the text has the web plugin's `WEB_NOT_LISTENING` line (`listen: false`, D-0221). */
1044
+ export function notListening(text) {
1045
+ for (const line of text.split('\n')) {
1046
+ if (!line.includes('WEB_NOT_LISTENING'))
1047
+ continue;
1048
+ try {
1049
+ if (JSON.parse(line).code === 'WEB_NOT_LISTENING')
1050
+ return true;
1051
+ }
1052
+ catch (error) {
1053
+ // Plain output of the app that mentions the code is not the plugin's record.
1054
+ debug('Skipped a non-JSON log line while looking for WEB_NOT_LISTENING', {
1055
+ error: error instanceof Error ? error.message : String(error),
1056
+ });
1057
+ }
1058
+ }
1059
+ return false;
1025
1060
  }
1026
1061
  /** Whether package.json depends on @dokebi/web (a malformed one counts as no). */
1027
1062
  function hasWebDependency(root) {
@@ -1036,16 +1071,17 @@ function hasWebDependency(root) {
1036
1071
  return false;
1037
1072
  }
1038
1073
  }
1039
- async function startedUrls(log, offset) {
1074
+ async function startedLog(log, offset) {
1040
1075
  try {
1041
1076
  const bytes = await readFile(log);
1042
1077
  // A rotation since the start moved the lines: read the whole current file then.
1043
- return listeningUrls((bytes.length >= offset ? bytes.subarray(offset) : bytes).toString('utf8'));
1078
+ const text = (bytes.length >= offset ? bytes.subarray(offset) : bytes).toString('utf8');
1079
+ return { listen: listeningUrls(text), notListening: notListening(text) };
1044
1080
  }
1045
1081
  catch (error) {
1046
1082
  if (!isMissing(error))
1047
1083
  reportError('LOG_READ_FAILED', 'Unable to read the app log', error);
1048
- return [];
1084
+ return { listen: [], notListening: false };
1049
1085
  }
1050
1086
  }
1051
1087
  export async function stop(root, timeoutMs = 30_000, force = false,
package/dist/verify.js CHANGED
@@ -277,6 +277,7 @@ async function settings(root) {
277
277
  vite,
278
278
  web: {
279
279
  installed: ids.has('dokebi-web'),
280
+ listen: web.listen !== false,
280
281
  port: typeof web.port === 'number' ? web.port : 0,
281
282
  host: typeof web.host === 'string' ? web.host : '127.0.0.1',
282
283
  ready: web.healthRoutes === false ? null : (web.healthRoutes?.ready ?? '/health/ready'),
@@ -524,7 +525,10 @@ export async function verify(root, options = {}) {
524
525
  message: `The app already runs (pid ${running.pid}); verify does not stop it`,
525
526
  fix: 'npx dokebi stop',
526
527
  });
527
- else if (project.web.installed && project.web.port > 0 && (await portInUse(project.web.port)))
528
+ else if (project.web.installed &&
529
+ project.web.listen &&
530
+ project.web.port > 0 &&
531
+ (await portInUse(project.web.port)))
528
532
  problems.push(await webPortProblem(project.web.port, (await readAppliedRecipes(root)).at(-1)?.answersFrom === 'defaults'));
529
533
  for (const db of project.dbUrls)
530
534
  if (db.missing)
@@ -571,32 +575,36 @@ export async function verify(root, options = {}) {
571
575
  : project.web.host;
572
576
  const listen = started?.listen.length
573
577
  ? started.listen
574
- : project.web.installed && project.web.port > 0
578
+ : project.web.installed && project.web.listen && project.web.port > 0
575
579
  ? [`http://${host.includes(':') ? `[${host}]` : host}:${project.web.port}`]
576
580
  : [];
577
581
  try {
578
582
  await run('http', !project.web.installed
579
583
  ? skip('no web plugin')
580
- : !started?.ready
581
- ? // Nothing of ours answers: whatever is on the port proves nothing (AI-M02).
582
- async () => ({
583
- ok: false,
584
- skipped: 'the app did not start',
585
- code: 'NOT_STARTED',
586
- message: 'No HTTP check ran: the app verify starts did not start (see the start check)',
587
- })
588
- : async () => {
589
- // Connect to the listening address; the Host header of each app domain picks the
590
- // app (the readiness route answers every host).
591
- const base = listen.find((url) => url.includes('127.0.0.1')) ?? listen[0];
592
- if (!base)
593
- return {
584
+ : !project.web.listen
585
+ ? // D-0221: a worker process (`dokebi-web.listen: false`) has no address to check; the
586
+ // start check proved it started.
587
+ skip('listen: false (dokebi-web): this process opens no port')
588
+ : !started?.ready
589
+ ? // Nothing of ours answers: whatever is on the port proves nothing (AI-M02).
590
+ async () => ({
594
591
  ok: false,
595
- code: 'URL_UNKNOWN',
596
- message: 'No address: the web listening line is missing and options.dokebi-web.port is 0',
597
- };
598
- return httpChecks(base, { ready: project.web.ready, domains: project.domains }, token);
599
- });
592
+ skipped: 'the app did not start',
593
+ code: 'NOT_STARTED',
594
+ message: 'No HTTP check ran: the app verify starts did not start (see the start check)',
595
+ })
596
+ : async () => {
597
+ // Connect to the listening address; the Host header of each app domain picks the
598
+ // app (the readiness route answers every host).
599
+ const base = listen.find((url) => url.includes('127.0.0.1')) ?? listen[0];
600
+ if (!base)
601
+ return {
602
+ ok: false,
603
+ code: 'URL_UNKNOWN',
604
+ message: 'No address: the web listening line is missing and options.dokebi-web.port is 0',
605
+ };
606
+ return httpChecks(base, { ready: project.web.ready, domains: project.domains }, token);
607
+ });
600
608
  }
601
609
  finally {
602
610
  await run('stop', started
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dokebi/cli",
3
- "version": "0.4.44",
3
+ "version": "0.4.46",
4
4
  "description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
5
5
  "keywords": [
6
6
  "dokebi",