@dokebi/cli 0.4.52 → 0.4.54
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 +11 -8
- package/catalog.json +7 -7
- package/dist/bin.js +16 -2
- package/dist/capability-guide.js +2 -2
- package/dist/check/browser-sources.d.ts +9 -3
- package/dist/check/browser-sources.js +27 -9
- package/dist/check/formatter-rules.js +17 -14
- package/dist/check/index.js +9 -6
- package/dist/check/problems.d.ts +7 -1
- package/dist/check/problems.js +22 -1
- package/dist/check/project-rules.js +8 -0
- package/dist/check/shared-folder-rules.d.ts +3 -0
- package/dist/check/shared-folder-rules.js +50 -0
- package/dist/check/vite-rules.js +1 -1
- package/dist/commands.js +9 -0
- package/dist/filesystem.js +3 -1
- package/dist/formatter-ignore.d.ts +4 -0
- package/dist/formatter-ignore.js +14 -4
- package/dist/generator.d.ts +18 -1
- package/dist/generator.js +38 -1
- package/dist/layout.d.ts +9 -0
- package/dist/layout.js +19 -0
- package/dist/output.d.ts +1 -1
- package/dist/output.js +1 -1
- package/dist/project-guide.js +3 -3
- package/dist/project-inspector.js +34 -1
- package/dist/project.d.ts +6 -0
- package/dist/project.js +29 -3
- package/package.json +1 -1
package/AI.md
CHANGED
|
@@ -84,14 +84,14 @@ The `blog` plan, depending on the answers: `init` (when the folder is not a proj
|
|
|
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 (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` |
|
|
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). `shared-folder` (a warning, D-0226) — an entry right under `src/shared/` other than the folders `browser`, `locales`, `mail`, `models`, `modules`, `services`, `settings`, `views` and the file `errors.ts` (names that start with a dot are not read): server code of one feature goes into its module, code several features share into `src/shared/models/` or `services/`, browser code several apps or modules share into `src/shared/browser/`; it names a folder, so no marker silences it. `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 |
|
|
91
91
|
| `dokebi inspect [--verbose]` / `dokebi doctor [--production] [--verbose]` | `--production` (D-0184) adds the checks of a server, on the settings the app reads there (`DOKEBI_CONFIG` merged with `DOKEBI_SECRETS`; the plugins' option checks see the merged options too): `NODE_ENV_NOT_PRODUCTION` (error: run it as the service runs), `STATE_NOT_SHARED` (error: the per-process state D-0161 refuses in production — memory sessions, auth tokens and login counts, OAuth grants, local rate limits, a local WebSocket hub, seal nonces; a warning for local lock or cache backends), `TRANSPORT_NOT_FOR_PRODUCTION` (mail `log`/`capture`), `WEB_PORT_UNSET` (port 0), `TRUST_PROXY_EMPTY` and `WEB_LISTENS_EVERYWHERE` (warnings), `STORAGE_RELATIVE` (warning: a storage folder inside the release), `PLACEHOLDER_LEFT`, `CONFIG_SECRETS_MISSING`/`_UNSAFE`/`_CONFLICT`/`_UNMATCHED` (as the start would fail), `SECRETS_MISSING` (a plugin's generated secret is not set), `SECRET_IN_CONFIG_FILE` (warning), and with @dokebi/migrate `dokebi-migrate status --json` with those settings: `MIGRATIONS_PENDING` (error: pre-deploy files), `MIGRATIONS_POST_DEPLOY_PENDING` and `MIGRATION_FILE_MISSING` (warnings), `MIGRATIONS_UNCHECKED` (error: status could not run). Read-only diagnosis. doctor exits 1 on an error diagnostic. doctor also runs each installed plugin's own option rules once its section passes the schema (D-0162: the cross-field `checks` the schema cannot say, such as `dokebi-app.unknownDomain` must be `reject` or a key of `domains`), in the same permission-restricted child as install modules: a broken rule is `INVALID_PLUGIN_OPTIONS` with `details[{instancePath, keyword, message}]` (no values) and a `hint`, the error the app would stop with; `config set` refuses such a value the same way and writes nothing. All plugins are checked in one child; a plugin whose entry cannot run there is the warning `PLUGIN_OPTIONS_CHECK_FAILED` (`details.code`; start still checks its rules). The default human output is a summary (health, error and warning counts, one line per diagnostic and plugin); `--verbose` prints everything. `--json` is always complete, with `result.summary{healthy, errors, warnings, plugins, codes}` first. **File ownership (D-0065 §11)**: skeletons that plugins and the CLI create (the shared layout `src/shared/views/layouts/main.ejs`, entry files `src/infra/<name>/…`, `src/infra/worker/tasks.ts`, `src/infra/events/types.ts`, app and module files) are `owner: user`, so editing them is no diagnostic (upgrade keeps edited files); only editing a file a manifest declares `owner: "cli"` (a file that is generated again) is a `MODIFIED_TEMPLATE` warning (`hint`). **Locks**: inspect and doctor take no lock. While another command holds `.dokebi/lock` (a `--dry-run` too), `PROJECT_LOCKED` has `details{pid, running, since, transactions}` and a `hint`: with `running: true` that command is still working (its `.dokebi/transaction-*` is not reported as `RECOVERY_REQUIRED`), so run inspect again when it has ended; with `running: false` the change was interrupted (`RECOVERY_REQUIRED` too): ask the user, never delete the lock |
|
|
92
92
|
| `dokebi app add <name> [--domain <host>]... [--template <name>] [--inertia [--ssr]] [--view <ejs\|none>] [--seal] [--answers-from <user\|defaults>] [--ai-chose view] [--ai-reason view=<why>]` | The app `src/apps/<name>` (D-0030). Its view is a product choice whose default is Inertia + Vue (`--inertia`); without `--inertia` it is EJS, except in a project whose recipe built no browser screens (the api recipe records `view = none`): there the app has no views, only `app.ts` and a `routes.ts` whose `/` answers JSON, no EJS pages and no shared layout, and nothing is recorded for it (tellUser already says the recipe's `view = none`). `--view ejs` gives EJS pages there, `--view none` an app without views anywhere (recorded like EJS: who chose it); `--view` with `--inertia`, or `--view none` with `--template`, is `USAGE`. The result's `appView{value, from}` says what the app got (`ejs`, `none`, `inertia-vue`, `inertia-vue-ssr`; `from: recipe` when the project's recipe chose it). D-0098: the view is recorded in `.dokebi/recipe.json` (`choices`) with who chose it, and verify's `tellUser` says it: `--answers-from user` (the user or the request chose it), `--ai-chose view` with `--ai-reason view=<why>` (the user left it to you; `--answers-from defaults` means the same). An EJS app without either is recorded as unstated, the result warns `VIEW_SOURCE_UNSTATED`, and tellUser says `not the default view (Inertia + Vue), and who chose it was not recorded`; an Inertia app without either records nothing (the default). `--ai-chose` names only `view` (`AI_CHOICE_UNKNOWN`); `AI_REASON_WITHOUT_CHOICE` and `INVALID_AI_REASON` as for recipes. The first app that `add @dokebi/app` creates (`main`, EJS) is recorded as unstated too; for a browser app with the default view use `add @dokebi/app --no-first-app` and then `app add <name> --inertia`. `--inertia` prepares the Vue skeleton, the Vite build and the Vue type check (`typecheck` script, `tsconfig.vue.json`, `typecheck-vue.mjs`, `src/infra/inertia/page.d.ts` for the shared page props), `--ssr` server rendering (D-0039), `--seal` writes `seal: true` on its domains (a domain with dots cannot be a `config set` path; without `@dokebi/seal` the warning `SEAL_PLUGIN_MISSING`). `--ssr` with `--seal` (0.4.34, D-0195; needs @dokebi/template-inertia 0.4.6, an older one fails the start with `SEAL_SSR_CONFLICT`): only the pages a route renders with `{ public: true }` are server rendered there, plain and without the visitor's props; the others stay sealed. An `@dokebi/app` whose Inertia build template predates the Vue type check (0.4.2 and older) refuses `--inertia` before anything is written: `INVALID_MANIFEST` (phase `plan`, `details.missing`, `details.fix`: `npx dokebi upgrade dokebi-app`, then the same `app add`) |
|
|
93
93
|
| `dokebi app remove <name>` · `app link <app> <domain> [--template] [--seal]` · `app unlink <domain>` · `app list` | Manage apps and domains. `app remove` fails with `APP_IN_USE` while a domain still points to the app (unlink first); it removes the registration and `options.dokebi-app.apps.<name>` (D-0061 per-app settings) from dokebi.yaml and the sample (0.2.5; otherwise the next start fails with `UNKNOWN_APP`) and the app's recorded view from `.dokebi/recipe.json`. The folder stays (user code; the result lists it in `preserved` with the warning `APP_FOLDER_KEPT`) |
|
|
94
|
-
| `dokebi module add <name> [--no-views]` · `module remove` · `module list` | Feature modules `src/shared/modules/<name>` (D-0032). `--no-views`: the routes answer JSON |
|
|
94
|
+
| `dokebi module add <name> [--no-views]` · `module remove` · `module list` · `module sync` | Feature modules `src/shared/modules/<name>` (D-0032). `--no-views`: the routes answer JSON. Add and remove rewrite `src/dokebi.modules.generated.ts` (D-0227, §4); `sync` writes it from the registered modules, for a project made before cli 0.4.54 |
|
|
95
95
|
| `dokebi settings add <section>` · `settings sync` · `settings remove <section>` · `settings list` | The settings of the application itself in `options.<section>` (D-0155): `add` writes `src/shared/settings/<section>.ts` (core's `defineSettings` with a `defineOptions` declaration; an existing one default-exporting it is adopted), its schema `src/shared/settings/<section>.schema.json`, the defaults in dokebi.yaml and the example (with the `# reloadable` marks), and registers it, so the app checks the section at start and `config show/set/unset/secret`, doctor and reloads treat it like a plugin section. Code reads `<name>Settings.read(context.app.config)` (typed, cached per configuration, new after a reload). After changing the declaration run `settings sync` (doctor warns `SETTINGS_SCHEMA_STALE`). A value that is still the default the CLI wrote (the old schema's, such as the `pageSize: 50` and `workers: 2` placeholders of `settings add`) follows a changed default, in dokebi.yaml and the example (`sections[].followed`); a value set by hand stays. Then each section is checked against the new schema as doctor checks it: a missing required value is `configRequired`, anything else (a value set by hand above a lowered maximum, a value of an option the declaration dropped) is `INVALID_PLUGIN_OPTIONS` with `details.paths` and a `fix` (`npx dokebi config unset <paths>` or correct it by hand, then sync again), and nothing is written (AI-M49 D2: sync answered ok on what doctor and the app refuse). A section of a plugin, `logging` or `reload` is `SETTINGS_SECTION_CONFLICT`; `remove` keeps the files and the options. A section nothing declares has one code in every config command: `UNDECLARED_SECTION` (`UNKNOWN_PLUGIN` when the name is a plugin that is not installed); `config set` and `secret` refuse it, `config show` (text values hidden) and `unset` work on what is there and warn with it, and doctor and `dokebi check` (`undeclared-section`) report it |
|
|
96
96
|
| `dokebi dev` | Development run (in the foreground). The app leads a process group of its own: what it started and left running when it stops (a restart, Ctrl+C) or crashes is ended (SIGTERM, SIGKILL after 2 s) and dev says so, so a restart never meets a port a helper of the old app holds. When `src/` or `.env` change it drains and starts again; when only `dokebi.yaml` changed it first asks the running app to read it again (D-0154): every changed option reloadable → applied without a restart (`dokebi.yaml reloaded without a restart: <paths>`), an invalid file → the app keeps its settings, anything else (an option that needs a restart, an app without reloads) → a restart as before. With a Vite config and template-inertia ≥0.1.2 it serves views from the Vite dev server with `DOKEBI_VITE_DEV=1` for **HMR** (no build needed; `.vue` and `views/` changes need no restart, D-0045). With template-inertia 0.4.0 that Vite is one host process per dev session, shared by every cluster worker and kept across app restarts (`DOKEBI_VITE_DEV_URL`, `DOKEBI_VITE_DEV_KEY`, D-0045 addendum 3); with 0.1.2 to 0.3 it runs inside the app. With an older template-inertia: a watch build and restarts. The app gets `DOKEBI_DEV=1`, so a cluster app runs one worker (`DOKEBI_DEV_WORKERS`, D-0044, D-0045), and the project's `.env`, read again at every restart (§2.2). What dev shows (the app, Vite and its own `[dokebi dev]` lines) is also written to `.dokebi/run/dev.log` (the previous session and one past 16 MB move to `dev.log.1`) and dev writes its pid to `.dokebi/run/dev.pid`, so `dokebi logs [-f]` shows the dev session from another shell (D-0201); with a terminal the app gets `DOKEBI_LOG_COLOR=1`, so the logger keeps its colours through the pipe |
|
|
97
97
|
| `dokebi reload [--timeout-ms <ms>]` | Makes the background app (`dokebi start`) read dokebi.yaml again (D-0154): SIGHUP to the proven pid (through its log writer when this shell may not signal it), then the outcome the app wrote (`.dokebi/run/reload.json`, whatever its log level). `outcome: applied` (with `paths` and `revision`) or `unchanged`; `RELOAD_RESTART_REQUIRED` (`details.restartRequired`: nothing applied, restart to apply), `RELOAD_INVALID` (the app keeps its settings; `details` names the line or paths), `RELOAD_FAILED`, `RELOAD_UNSUPPORTED` (core older than 0.4.2, or `src/main.ts` gives the app no `configFile` or changed after the start: no signal is sent, it would end the app). Not running: exit 3. A running app also reads the file when it is saved (`options.reload.watch`) |
|
|
@@ -103,7 +103,7 @@ The `blog` plan, depending on the answers: `init` (when the folder is not a proj
|
|
|
103
103
|
- A failed test, or a non-zero exit, fails verify (`TEST_FAILED`: the message names the failing tests). The tests' stdout and stderr are never copied into the result; error lines are masked with every secret value verify knows (values of `.env`, environment variables named like a secret, secrets of the settings file as `config show` hides them, `user:password@`, `password=…`), and left out when those cannot be read. Processes the tests leave running are killed before the app starts.
|
|
104
104
|
- The human output adds one `FAIL <name> (<file>): <error>` line per failing test and a `tests: N passed, N failed, N skipped, N todo of N` line under the test check.
|
|
105
105
|
|
|
106
|
-
Most commands support `--json` (one machine document); interactive `dev`, `logs` and `start --foreground` do not. Only commands listed by help support `--dry-run` (plan only), including init, recipe, add, upgrade, remove, config diff (with `--write`)/set/unset/init/secret, dev-infra, migrate, app add/remove/link/unlink and
|
|
106
|
+
Most commands support `--json` (one machine document); interactive `dev`, `logs` and `start --foreground` do not. Only commands listed by help support `--dry-run` (plan only), including init, recipe, add, upgrade, remove, config diff (with `--write`)/set/unset/init/secret, dev-infra, migrate, app add/remove/link/unlink, module add/remove/sync and settings add/sync/remove (the first line of `--help` lists them from the usage lines). Any other command refuses `--dry-run` with `USAGE` naming them (`details.dryRunCommands`). `dokebi --help` prints one line per command; `dokebi <command> --help` prints that command with what each flag does and an example (exit 0). An unknown command is `UNKNOWN_COMMAND` (`details.suggestions` names similar commands, for example `help` → `--help`); a known command with wrong arguments is `USAGE` with its usage lines.
|
|
107
107
|
|
|
108
108
|
## 2. Work order (AI, adding one plugin outside a recipe)
|
|
109
109
|
|
|
@@ -178,15 +178,18 @@ One document on stdout: `{ schemaVersion, cliVersion, command, ok, result?, erro
|
|
|
178
178
|
| `dokebi.yaml` | user | The real settings and their secrets (`schemaVersion: 1`, `options.<plugin id>`). 0600, kept out of Git |
|
|
179
179
|
| `dokebi.example.yaml` | CLI | A sample with the schema descriptions as comments. Never holds secrets |
|
|
180
180
|
| `src/dokebi.generated.ts` · `.dokebi/state.json` | CLI | **Never edit by hand**. Editing is `MODIFIED_REGISTRATION` |
|
|
181
|
+
| `src/dokebi.modules.generated.ts` | CLI | The registered modules (D-0227, with `@dokebi/module`): `registeredModules` (`{ <name>: module }` in registration order) and the type `RegisteredModuleName`. It imports the modules only, so apps and project files import it where code needs every module (an app that mounts each one, permission keys or menu entries collected from each module's declarations); never keep a module list of your own (D-0032 §5). `module add`, `remove` and `sync` write it; an edited copy is doctor `MODULE_LIST_MODIFIED` (error), a missing one `MODULE_LIST_MISSING` (warning: `npx dokebi module sync`) |
|
|
181
182
|
| `src/main.ts` | user | The entry point (YAML loading → Application → create and register plugins → start). Every plugin factory checks its options against its own declaration: a wrong value stops the start with `INVALID_PLUGIN_OPTIONS` (`plugin`, `fix`, and the cause `INVALID_OPTIONS` naming `options.<plugin>.<path>`). The generated code carries no JSON Schema validator (D-0070) |
|
|
182
183
|
| `src/apps/<app>/` | user | One app (app.ts, routes.ts or routes/, controllers, services, models, validation, views) |
|
|
183
|
-
| `src/shared/modules/<module>/` | user | Feature modules (module.ts, routes.ts and the same folders); job handlers and event subscriptions are registered in the owning module's setup |
|
|
184
|
+
| `src/shared/modules/<module>/` | user | Feature modules (module.ts, routes.ts and the same folders); job handlers and event subscriptions are registered in the owning module's setup. Declarations the project adds to every module (menu entries, permission keys) are files at the module root named for what they declare (`menu.ts`, `permissions.ts`) that `module.ts` passes on; pages declared but not built yet are routes (`routes.ts`) (D-0227). A pure rule the module's server code and its pages both use (a code check, a rich-text schema) stays in its `validation/`, imports neither Node nor browser APIs, and the pages import it with a relative path |
|
|
184
185
|
| `src/shared/{models,services,views,locales,mail}/` · `src/shared/errors.ts` | user | Shared models and services, layouts and partials, translation catalogs (`locales/<locale>/<namespace>.json`), mail templates (`mail/<template>/<locale>/`) and the app error catalog |
|
|
185
|
-
| `src/
|
|
186
|
+
| `src/shared/validation/` | user | Input rules several apps or modules share (D-0227): reading a list query (`?page`, `?sort`, `?ids`), a reason field. They take the values (query, body), never import app or module code; the rules of one app or module stay in its own `validation/` |
|
|
187
|
+
| `src/shared/browser/` | user | Browser code several apps or modules share (D-0226): `components/` (a design system's UI components), `layouts/`, `composables/`, `styles/` (CSS, tokens) and `lib/` (browser modules that are not Vue: a socket client, formatters); a project with two looks puts one folder per look first (`browser/staff/components/`). Pages import it with a relative path and the dev server serves what they import; server code never imports it. Browser code — this folder and the `views/` of apps and modules — is checked by `tsconfig.vue.json` (vue-tsc, Vite's types), not `tsconfig.json`: a project made before cli 0.4.53 adds `"exclude": ["src/apps/*/views/**", "src/shared/modules/*/views/**", "src/shared/browser/**"]` to `tsconfig.json`, and to `tsconfig.vue.json` the include entries `"src/apps/*/views/**/*.ts"`, `"src/shared/modules/*/views/**/*.ts"`, `"src/shared/browser/**/*.ts"` with `"exclude": ["node_modules", "dist"]`. Code one app or module uses stays in its `views/` |
|
|
188
|
+
| `src/infra/<name>/` | user | Plugin connection and extension code (for example `db/connections.ts`, `auth/extension.ts`, `worker/tasks.ts`, `events/types.ts`, `runtime/application.ts`); migrations and seeds in `db/migrations/<connection>/` and `db/seeds/<connection>/`. The project's wrapper of a plugin (a `defineModule` wrapper that adds the project's declarations, `module/`) and code several apps share that reads a request through a plugin (the viewer from `request.auth` in `auth/`, Inertia props several apps build the same way beside `inertia/shared.ts`) live here too (D-0227); services never take the request |
|
|
186
189
|
| `tests/{unit,integration,support}/` | user | Tests (`*.test.ts`, run by `npm test`: `node --test "tests/**/*.test.ts"`) and their helpers (never `*.test.ts`) |
|
|
187
190
|
| `scripts/` | user | Development tools, run with `node scripts/<name>.ts`, never imported by `src` |
|
|
188
191
|
|
|
189
|
-
The maintained form of these rules is the **Files and folders** integration rule in AGENTS.md (refreshed by `guide --sync`). A plugin manifest cannot write files outside `src/shared/{models,services,modules,views,mail,locales}/` and `src/infra/<name>/` (`INVALID_MANIFEST`). The exception is `src/apps/` for a plugin with `apps` in `dokebi.hosts`. Old paths are reported by doctor as `LEGACY_LAYOUT` (warning; they keep working). That includes a file an older recipe wrote where the layout no longer puts it, such as `src/site-worker.ts`; `details.moveTo` names its place now.
|
|
192
|
+
Nothing else sits right under `src/shared/`: `dokebi check` warns `shared-folder` for any other entry (D-0226, D-0227). The maintained form of these rules is the **Files and folders** integration rule in AGENTS.md (refreshed by `guide --sync`). A plugin manifest cannot write files outside `src/shared/{models,services,modules,views,mail,locales}/` and `src/infra/<name>/` (`INVALID_MANIFEST`). The exception is `src/apps/` for a plugin with `apps` in `dokebi.hosts`. Old paths are reported by doctor as `LEGACY_LAYOUT` (warning; they keep working). That includes a file an older recipe wrote where the layout no longer puts it, such as `src/site-worker.ts`; `details.moveTo` names its place now.
|
|
190
193
|
|
|
191
194
|
## 5. Settings rules
|
|
192
195
|
|
|
@@ -238,7 +241,7 @@ Every command also works in an npm workspace member folder. Packages are found t
|
|
|
238
241
|
- AI entry (D-0065): `ANSWERS_REQUIRED` (exit 2), `ANSWERS_SOURCE_REQUIRED` (applying without `--answers-from user` or `--defaults`), `AI_CHOICE_UNKNOWN`, `AI_CHOICE_FIXED`, `AI_CHOICE_WITHOUT_ANSWER`, `AI_REASON_WITHOUT_CHOICE`, `INVALID_AI_REASON` (D-0095: `--ai-chose`/`--ai-reason` refused), `UNKNOWN_RECIPE`, `INVALID_ANSWER`, `OPTION_ABSENT`, `OPTION_NOT_APPLICABLE` (an answer another answer rules out: `--admin login` with `--db none`), `RECIPE_FILE_CONFLICT` (a file the recipe writes exists with other content; `details.path`, `fix`), `NOT_A_PROJECT`, `PREFLIGHT_FAILED` (details.preflight: `DOCKER_MISSING`, `PORT_IN_USE`), `RECIPE_STEP_FAILED`, `STEP_COMMAND_FAILED`, `NOT_PUBLISHED`, `NO_COMPATIBLE_VERSION`, `UNKNOWN_ADAPTER`, `ADAPTER_TEMPLATE_MISSING`, `DB_PLUGIN_MISSING`, `CONNECTION_MISSING`, `DEV_INFRA_UNSUPPORTED`, `COMPOSE_CONFLICT`, `COMPOSE_PORT_UNKNOWN`, `COMPOSE_INVALID`, `NOT_INSTALLED`, `DOC_MISSING`, `CATALOG_MISSING`, `CATALOG_INVALID`. check (D-0072): `TYPESCRIPT_UNAVAILABLE`, `TSCONFIG_INVALID`. drift (D-0120): `DRIFT_EXPECTED_INVALID`. verify check codes: `DOCTOR_FAILED`, `CHECK_FAILED` (details: `problems`), `TYPECHECK_FAILED`, `BUILD_FAILED`, `ALREADY_RUNNING`, `PORT_IN_USE`, `DB_URL_MISSING`, `NOT_READY`, `URL_UNKNOWN`, `HTTP_FAILED`, `FOREIGN_SERVER` (another server answered), `NOT_STARTED` (the app did not start, so no HTTP), `STOP_FORCED`, `APP_EXITED`, `CHECK_ERROR`, `TEST_FAILED` (details: `failures`, the counts and `exitCode`), `TEST_TIMEOUT` (the tests did not finish within `--test-timeout-ms`). Before any check, verify refuses a folder without `package.json`, `dokebi.yaml` or `.dokebi/state.json` with `NOT_A_PROJECT` (`details.file`, `details.fix`; the state file is the CLI's and belongs in version control, so a copied project needs it). The changing commands (`add`, `upgrade`, `remove`, `migrate`, `app`, `module`, `settings`, `config set`/`unset`/`secret`) and the app, module and settings lists do the same outside a project: `NOT_A_PROJECT` with `details.file` (`.dokebi/state.json`, or `dokebi.yaml` in a folder that has the state) and `details.fix`. For a missing dokebi.yaml the fix is `npx dokebi config init` (D-0163), which answers `CONFIG_EXISTS` when the file is there and `EXAMPLE_MISSING` without dokebi.example.yaml.
|
|
239
242
|
- Commands: `USAGE`, `UNKNOWN_COMMAND`, `PROJECT_EXISTS`, `UNSUPPORTED_PROJECT`, `INVALID_SPEC`, `INVALID_PACKAGE`, `INVALID_MANIFEST`, `INCOMPATIBLE_VERSION`, `MISSING_DEPENDENCY`, `DEPENDENCY_CYCLE`, `DUPLICATE_PLUGIN`, `UNKNOWN_PLUGIN`, `REVERSE_DEPENDENCY`, `REQUIRED_PLUGIN`, `INVALID_PLUGIN_OPTIONS`, `INVALID_SET`, `PATH_MISMATCH` (config set, unset and secret: the command would change an option path it was not asked for — the plugin id `dokebi-logger` reaching `options.logging`, an old or renamed section; refused before anything is written, a warning with `--dry-run`; `details.outside` and `details.paths` name them; `config show` of such a plugin id names the section in `details.outside` and `fix`), `SAMPLE_SECRET` (`config diff --write`: the copy would leave a secret in dokebi.example.yaml; nothing written), `FILE_CONFLICT`, `PATH_CONFLICT`, `PACKAGE_CONFLICT`, `NPM_FAILED`, `REGISTRY_MISMATCH`, `INTERRUPTED` (a Ctrl+C, SIGTERM or SIGHUP before the commit: nothing applied, no lock left; run the command again), `LOCK_FAILED` (.dokebi/lock cannot be created: not writable), `PROJECT_LOCKED` (`details`: `pid`, `running`, `since` and `fix`, as doctor says it), `INVALID_ENV`, `CONCURRENT_CHANGE`, `COMMIT_FAILED`, `UPGRADE_DOWNGRADE`, `UPGRADE_IDENTITY_CHANGED`, `UPGRADE_ENTRY_MOVED`, `UPGRADE_CONFIG_CONFLICT`, `APP_EXISTS`, `APP_IN_USE`, `APPS_PRESENT`, `APP_PLUGIN_MISSING`, `DOMAIN_IN_USE`, `UNKNOWN_APP`, `UNKNOWN_DOMAIN`, `MODULE_EXISTS`, `MODULE_PLUGIN_MISSING`, `UNKNOWN_MODULE`, `HOST_MISSING`, `HOST_CONFLICT`, and for the server commands `ENTRY_MISSING`, `START_CHECK_FAILED`, `ALREADY_RUNNING`, `START_IN_PROGRESS`, `START_FAILED`, `STOP_TIMEOUT`, `STOP_FAILED` (verify could not signal the pid it started, or stop could not signal the app and its log writer could not be asked), `PROCESS_INFO_FAILED`, `NO_LOG`, `UNSUPPORTED_PLATFORM`; D-0154 `RELOAD_UNSUPPORTED`, `RELOAD_RESTART_REQUIRED`, `RELOAD_INVALID`, `RELOAD_FAILED` (`dokebi reload`); D-0155 `INVALID_SETTINGS`, `SETTINGS_EXISTS`, `SETTINGS_SECTION_CONFLICT`, `UNKNOWN_SETTINGS`, `SETTINGS_SCHEMA_FAILED`, `UNDECLARED_SECTION` (`settings` commands; doctor also `SETTINGS_SCHEMA_MISSING` and the warning `SETTINGS_SCHEMA_STALE`).
|
|
240
243
|
- `UNSUPPORTED_PROJECT`: a package.json the CLI cannot install for: npm workspaces of its own, `workspace:` or `link:` specs, URLs. A tarball dependency is fine as an absolute path or a path inside the project (`file:vendor/web-0.4.3.tgz`, as npm writes it when installed from the project; it stays relative, so the project can move). `file:~/…` (npm's form of `npm install ~/x.tgz`) is the home folder for npm, not the project, and is refused, as is an absolute path npm reads the same way (`file:/~/…`, `file://~/…`: not the folder `/~`; `dokebi add` or `upgrade --to` of such a path is `INVALID_SPEC`); a listed tarball the folder lacks (an ignored `vendor/`) is npm's `NPM_FAILED` naming the file, as for an absolute path, and a folder at its path is `UNSUPPORTED_PROJECT` with `details.path`. Outside Windows a backslash in a `file:` tarball path (`file:vendor\x.tgz`) is refused too, with `details.path` and a `fix` that writes it with `/` (npm reads it as part of a file name there and saves the path with `/`, another file; `add` or `upgrade --to` of such a path: `INVALID_SPEC`); on Windows it is a separator, as for npm. `dokebi add ./vendor/web-0.4.3.tgz` and `upgrade --to vendor/web-0.4.3.tgz` write a tarball inside the project relative too; one outside it, reached through a symbolic link that leads out, or in a project folder named `~` (npm would read the home folder), is written absolute. `INVALID_OPTIONS_SCHEMA`: a plugin's options schema cannot be checked — with `details.keyword` and `details.config` it uses an `x-dokebi-*` keyword the @dokebi/config of this CLI does not know (a schema of a newer release: run the @dokebi/cli of the same release as the plugins; nothing is damaged), with `details.validator: true` the validator itself cannot load (restore node_modules), otherwise that plugin's schema is broken (reinstall it).
|
|
241
|
-
- Diagnostics (inspect, doctor): `ENV_DOKEBI_CONFIG_IGNORED` (warning, R4CC-7: a `.env` line sets `DOKEBI_CONFIG`, which the app never gets from there; `path` `.env:<line>`, `hint`), `MIGRATION_REQUIRED`, `CONFIG_CONFLICT`, `INVALID_CORE`, `PACKAGE_VERSION_MISMATCH`, `MISSING_CORE_DEPENDENCY`, `MISSING_PACKAGE_DEPENDENCY`, `MODIFIED_REGISTRATION`, `MODIFIED_TEMPLATE` (warning: only `owner: "cli"` files), `MANIFEST_CHANGED`, `INVALID_PLUGIN_OPTIONS`, `ENTRY_MISSING`, `LEGACY_ADMIN_SECTION` (warning, D-0115: `options.blog-admin` of an older recipe keeps working; the hint says how to rename it with the seed), `LEGACY_LAYOUT`, `TEMPLATE_FIX_MISSING` (warning: a `src/infra/db/adapters/<id>.ts` — or a copy moved or renamed under `src/`, a file that imports the driver and @dokebi/db's `ResourceAdapter` — copied from @dokebi/db's template before a fix the installed template has — the handling of a socket error of a client in use (@dokebi/db's client failure code), `lazy`, `usage`, pg `failed-connect` (a client whose connect fails ends its socket, else a URL without a password kept the process alive), mariadb `url-query` (a URL query such as `?ssl=true` is refused, not dropped) and `ipv6`, pg and mariadb `lost` (a lost connection takes readiness down at once), mysql2 and mariadb `idle` (idle connections end after `idleTimeoutMs`), pg, mysql2 and mariadb `repeats` (errors of many pooled connections at once are logged once per `logRepeatWindowMs`, the rest counted), mysql2 `connect-cause` (a pool wait that ran out while the caller's own connect was pending names it, so a frozen server takes readiness down) and `queue-leave` (a caller that gave up leaves mysql2's queue instead of counting against `maxWaiting`); and, with @dokebi/template-inertia installed, a `vite.config.*` or `vite.ssr.config.*` without `build.emptyOutDir: false` (`keep-chunks`: a rolling deploy needs the previous build's chunks) or, when the installed apps host's template has it, without `vue({ script: { fs } })` (`vue-type-files`: a page whose props type is imported from another file fails `vite build`, since TypeScript 7 gives the Vue compiler no file access), an Inertia app's `views/app.js` or `views/ssr.js` that does not import `virtual:dokebi/module-pages` while a module under `src/` keeps Vue pages in its views folder (`module-pages`, D-0218: a module page answers "Unknown page"; `details.page` names one) and a Vite config without `dokebiInertia()` while an entry imports it (`module-pages-plugin`: the build cannot resolve the import); and a `src/main.ts` that reads `process.env.DOKEBI_CONFIG ??` (`empty-config-env`, `plugin: null`: an empty `DOKEBI_CONFIG` is taken for a path and the app stops with `CONFIG_READ_FAILED`, while every CLI command reads dokebi.yaml then; the generated main.ts uses `||`; doctor only); `details.missing` and `details.template` name them, `hint` names the file and the change; the copy is yours, compare and bring them over), `RELOAD_NOT_WIRED` (warning: `src/main.ts` passes no `configFile` to `new Application` or `ClusterRunner`, so dokebi.yaml is never read again and `dokebi dev` restarts on every change, saying so; or the cluster workers' `src/infra/runtime/application.ts` builds `new Application` without it, so a worker cannot take the reload its primary asks for), `VUE_TYPECHECK_MISSING` (warning: an Inertia app under `src/apps` and a `typecheck` script without `vue-tsc`, from before `app add --inertia` prepared the Vue check; the hint lists the files and devDependencies to add), `DEV_FILES_UNGUARDED` (D-0129: an Inertia app under `src/apps` and an installed @dokebi/template-inertia without the dev file policy, so `dokebi dev` serves every project file such as `dokebi.yaml?raw`; an error when `options.dokebi-template-inertia.devHosts` is set, a warning otherwise; the hint says to upgrade the package and change secrets that were reachable), `MISSING_REQUIRED_PLUGIN`, `STALE_REQUIREMENTS`, `PLUGIN_CHECK` (details `code`, `optionPath`, and the plugin's `hint`), `GUIDE_BLOCK_MODIFIED` (warning: the installed list in AGENTS.md was edited between its markers by hand, D-0072), `GUIDE_PROJECT_BLOCK_INVALID` (warning: the `dokebi:project` markers of AGENTS.md cannot be read, D-0077), `PROJECT_LOCKED`, `RECOVERY_REQUIRED`, `UNSAFE_PATH`, `INVALID_LOGGING_CONFIG` (error: a level value of `options.logging`, or `options.logging` that is not an object), `LOGGING_PLUGIN_UNKNOWN` (warning: a level for a plugin that is not installed), `LOGGING_OPTIONS_UNUSED` (warning, D-0151: keys other than `level` and `plugins` in `options.logging` without the logger plugin; core warns the same at startup; with @dokebi/logger installed its options schema checks them as `INVALID_PLUGIN_OPTIONS`).
|
|
244
|
+
- Diagnostics (inspect, doctor): `ENV_DOKEBI_CONFIG_IGNORED` (warning, R4CC-7: a `.env` line sets `DOKEBI_CONFIG`, which the app never gets from there; `path` `.env:<line>`, `hint`), `MIGRATION_REQUIRED`, `CONFIG_CONFLICT`, `INVALID_CORE`, `PACKAGE_VERSION_MISMATCH`, `MISSING_CORE_DEPENDENCY`, `MISSING_PACKAGE_DEPENDENCY`, `MODIFIED_REGISTRATION`, `MODULE_LIST_MODIFIED` (D-0227: `src/dokebi.modules.generated.ts` differs from the registered modules), `MODULE_LIST_MISSING` (warning, D-0227: a project with `@dokebi/module` has no module list yet; `npx dokebi module sync`), `MODIFIED_TEMPLATE` (warning: only `owner: "cli"` files), `MANIFEST_CHANGED`, `INVALID_PLUGIN_OPTIONS`, `ENTRY_MISSING`, `LEGACY_ADMIN_SECTION` (warning, D-0115: `options.blog-admin` of an older recipe keeps working; the hint says how to rename it with the seed), `LEGACY_LAYOUT`, `TEMPLATE_FIX_MISSING` (warning: a `src/infra/db/adapters/<id>.ts` — or a copy moved or renamed under `src/`, a file that imports the driver and @dokebi/db's `ResourceAdapter` — copied from @dokebi/db's template before a fix the installed template has — the handling of a socket error of a client in use (@dokebi/db's client failure code), `lazy`, `usage`, pg `failed-connect` (a client whose connect fails ends its socket, else a URL without a password kept the process alive), mariadb `url-query` (a URL query such as `?ssl=true` is refused, not dropped) and `ipv6`, pg and mariadb `lost` (a lost connection takes readiness down at once), mysql2 and mariadb `idle` (idle connections end after `idleTimeoutMs`), pg, mysql2 and mariadb `repeats` (errors of many pooled connections at once are logged once per `logRepeatWindowMs`, the rest counted), mysql2 `connect-cause` (a pool wait that ran out while the caller's own connect was pending names it, so a frozen server takes readiness down) and `queue-leave` (a caller that gave up leaves mysql2's queue instead of counting against `maxWaiting`); and, with @dokebi/template-inertia installed, a `vite.config.*` or `vite.ssr.config.*` without `build.emptyOutDir: false` (`keep-chunks`: a rolling deploy needs the previous build's chunks) or, when the installed apps host's template has it, without `vue({ script: { fs } })` (`vue-type-files`: a page whose props type is imported from another file fails `vite build`, since TypeScript 7 gives the Vue compiler no file access), an Inertia app's `views/app.js` or `views/ssr.js` that does not import `virtual:dokebi/module-pages` while a module under `src/` keeps Vue pages in its views folder (`module-pages`, D-0218: a module page answers "Unknown page"; `details.page` names one) and a Vite config without `dokebiInertia()` while an entry imports it (`module-pages-plugin`: the build cannot resolve the import); and a `src/main.ts` that reads `process.env.DOKEBI_CONFIG ??` (`empty-config-env`, `plugin: null`: an empty `DOKEBI_CONFIG` is taken for a path and the app stops with `CONFIG_READ_FAILED`, while every CLI command reads dokebi.yaml then; the generated main.ts uses `||`; doctor only); `details.missing` and `details.template` name them, `hint` names the file and the change; the copy is yours, compare and bring them over), `RELOAD_NOT_WIRED` (warning: `src/main.ts` passes no `configFile` to `new Application` or `ClusterRunner`, so dokebi.yaml is never read again and `dokebi dev` restarts on every change, saying so; or the cluster workers' `src/infra/runtime/application.ts` builds `new Application` without it, so a worker cannot take the reload its primary asks for), `VUE_TYPECHECK_MISSING` (warning: an Inertia app under `src/apps` and a `typecheck` script without `vue-tsc`, from before `app add --inertia` prepared the Vue check; the hint lists the files and devDependencies to add), `DEV_FILES_UNGUARDED` (D-0129: an Inertia app under `src/apps` and an installed @dokebi/template-inertia without the dev file policy, so `dokebi dev` serves every project file such as `dokebi.yaml?raw`; an error when `options.dokebi-template-inertia.devHosts` is set, a warning otherwise; the hint says to upgrade the package and change secrets that were reachable), `MISSING_REQUIRED_PLUGIN`, `STALE_REQUIREMENTS`, `PLUGIN_CHECK` (details `code`, `optionPath`, and the plugin's `hint`), `GUIDE_BLOCK_MODIFIED` (warning: the installed list in AGENTS.md was edited between its markers by hand, D-0072), `GUIDE_PROJECT_BLOCK_INVALID` (warning: the `dokebi:project` markers of AGENTS.md cannot be read, D-0077), `PROJECT_LOCKED`, `RECOVERY_REQUIRED`, `UNSAFE_PATH`, `INVALID_LOGGING_CONFIG` (error: a level value of `options.logging`, or `options.logging` that is not an object), `LOGGING_PLUGIN_UNKNOWN` (warning: a level for a plugin that is not installed), `LOGGING_OPTIONS_UNUSED` (warning, D-0151: keys other than `level` and `plugins` in `options.logging` without the logger plugin; core warns the same at startup; with @dokebi/logger installed its options schema checks them as `INVALID_PLUGIN_OPTIONS`).
|
|
242
245
|
|
|
243
246
|
### Logs (D-0047)
|
|
244
247
|
|
|
@@ -414,7 +417,7 @@ than creating new pools or a service instance on every request. Existing customi
|
|
|
414
417
|
remain user-owned and are not silently migrated or overwritten.
|
|
415
418
|
|
|
416
419
|
Shared translation catalogs belong in `src/shared/locales/<language>/<namespace>.json`.
|
|
417
|
-
Inertia pages belong to the
|
|
420
|
+
Inertia pages belong to the app that renders them, or to the module whose pages they are (`views/<template>/Pages/` of the module, D-0218). Keep project-specific rules in the
|
|
418
421
|
`dokebi:project` block of `AGENTS.md` so future CLI sessions can read them.
|
|
419
422
|
Instructions guide contributors; they do not mechanically enforce every design decision.
|
|
420
423
|
|
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.
|
|
4
|
+
"cli": "0.4.54",
|
|
5
5
|
"core": {
|
|
6
6
|
"package": "@dokebi/core",
|
|
7
7
|
"version": "0.4.7"
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
{
|
|
447
447
|
"id": "dokebi-app",
|
|
448
448
|
"package": "@dokebi/app",
|
|
449
|
-
"version": "0.4.
|
|
449
|
+
"version": "0.4.13",
|
|
450
450
|
"kind": "plugin",
|
|
451
451
|
"summary": "Several apps chosen by request domain (src/apps/<app>) with a template each; installs web, controller and template-ejs with it",
|
|
452
452
|
"description": "Multiple apps per project for Dokebi: pick the app and template by request domain, with EJS and Inertia skeletons.",
|
|
@@ -825,7 +825,7 @@
|
|
|
825
825
|
{
|
|
826
826
|
"id": null,
|
|
827
827
|
"package": "@dokebi/cli",
|
|
828
|
-
"version": "0.4.
|
|
828
|
+
"version": "0.4.54",
|
|
829
829
|
"kind": "cli",
|
|
830
830
|
"summary": "Commands to create a project, browse the plugin catalog, run recipes, install plugins and verify (dokebi)",
|
|
831
831
|
"description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
|
|
@@ -2143,7 +2143,7 @@
|
|
|
2143
2143
|
{
|
|
2144
2144
|
"id": "dokebi-module",
|
|
2145
2145
|
"package": "@dokebi/module",
|
|
2146
|
-
"version": "0.4.
|
|
2146
|
+
"version": "0.4.9",
|
|
2147
2147
|
"kind": "plugin",
|
|
2148
2148
|
"summary": "Modules that hold one feature each (src/shared/modules/<module>); an app attaches them under a prefix",
|
|
2149
2149
|
"description": "Feature modules for Dokebi apps: controllers, models, views and routes in one folder mounted under a prefix.",
|
|
@@ -2691,7 +2691,7 @@
|
|
|
2691
2691
|
{
|
|
2692
2692
|
"id": "dokebi-permissions",
|
|
2693
2693
|
"package": "@dokebi/permissions",
|
|
2694
|
-
"version": "0.1.
|
|
2694
|
+
"version": "0.1.4",
|
|
2695
2695
|
"kind": "plugin",
|
|
2696
2696
|
"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",
|
|
2697
2697
|
"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.",
|
|
@@ -2830,7 +2830,7 @@
|
|
|
2830
2830
|
{
|
|
2831
2831
|
"id": null,
|
|
2832
2832
|
"package": "@dokebi/rich-text",
|
|
2833
|
-
"version": "0.2.
|
|
2833
|
+
"version": "0.2.1",
|
|
2834
2834
|
"kind": "library",
|
|
2835
2835
|
"summary": "Editor documents (Tiptap or ProseMirror JSON) checked whole against a declared schema of nodes, marks, links, image sources, tables, colours and alignment, with coded 422 errors, then safe HTML, plain text and excerpts; editorConfig gives Tiptap its settings from the same schema",
|
|
2836
2836
|
"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; tables, colours and alignment; the editor settings from the same schema.",
|
|
@@ -3451,7 +3451,7 @@
|
|
|
3451
3451
|
{
|
|
3452
3452
|
"id": "dokebi-template-inertia",
|
|
3453
3453
|
"package": "@dokebi/template-inertia",
|
|
3454
|
-
"version": "0.4.
|
|
3454
|
+
"version": "0.4.9",
|
|
3455
3455
|
"kind": "plugin",
|
|
3456
3456
|
"summary": "Inertia (v3) server adapter: Vue 3 views, Vite build files and optional server-side rendering (SSR)",
|
|
3457
3457
|
"description": "Inertia v3 server adapter for Dokebi: page JSON, Vite manifest assets and optional server-side rendering.",
|
package/dist/bin.js
CHANGED
|
@@ -1256,7 +1256,10 @@ async function app(input) {
|
|
|
1256
1256
|
throw new CliError('USAGE', USAGE_LINES);
|
|
1257
1257
|
process.stdout.write(JSON.stringify(machine ? envelope(`app ${action}`, result) : result, null, 2) + '\n');
|
|
1258
1258
|
}
|
|
1259
|
-
/**
|
|
1259
|
+
/**
|
|
1260
|
+
* `dokebi module add|remove|list|sync` (D-0032): feature modules in src/shared/modules/<name>;
|
|
1261
|
+
* `sync` writes the module list src/dokebi.modules.generated.ts (D-0227).
|
|
1262
|
+
*/
|
|
1260
1263
|
async function moduleCommand(input) {
|
|
1261
1264
|
const action = input.shift();
|
|
1262
1265
|
const project = await newProject();
|
|
@@ -1266,6 +1269,17 @@ async function moduleCommand(input) {
|
|
|
1266
1269
|
throw new CliError('USAGE', USAGE_LINES);
|
|
1267
1270
|
result = await project.moduleList(process.cwd());
|
|
1268
1271
|
}
|
|
1272
|
+
else if (action === 'sync') {
|
|
1273
|
+
let dryRun = false;
|
|
1274
|
+
for (const arg of input) {
|
|
1275
|
+
if (arg === '--dry-run' && !dryRun)
|
|
1276
|
+
dryRun = true;
|
|
1277
|
+
else
|
|
1278
|
+
throw new CliError('USAGE', USAGE_LINES);
|
|
1279
|
+
}
|
|
1280
|
+
mutationStarted = true;
|
|
1281
|
+
result = await project.moduleSync(process.cwd(), dryRun);
|
|
1282
|
+
}
|
|
1269
1283
|
else if (action === 'add' || action === 'remove') {
|
|
1270
1284
|
const name = input.shift();
|
|
1271
1285
|
if (!name || name.startsWith('-'))
|
|
@@ -1287,7 +1301,7 @@ async function moduleCommand(input) {
|
|
|
1287
1301
|
: await project.moduleRemove(process.cwd(), name, dryRun);
|
|
1288
1302
|
}
|
|
1289
1303
|
else if (action && !action.startsWith('-'))
|
|
1290
|
-
throw unknownCommand(action, ['add', 'remove', 'list'], 'module ');
|
|
1304
|
+
throw unknownCommand(action, ['add', 'remove', 'list', 'sync'], 'module ');
|
|
1291
1305
|
else
|
|
1292
1306
|
throw new CliError('USAGE', USAGE_LINES);
|
|
1293
1307
|
process.stdout.write(JSON.stringify(machine ? envelope(`module ${action}`, result) : result, null, 2) + '\n');
|
package/dist/capability-guide.js
CHANGED
|
@@ -28,7 +28,7 @@ export const INTEGRATION_RULES = [
|
|
|
28
28
|
'Scope: these are reusable engineering rules, not a product specification. Seal browser transport and Korean/English UI are explicit consumer conventions; other features remain conditional. Examples do not fix domain names, schemas, UI layout, worker count, retention duration, notification recipients or message-history policy for a new product. Apply feature-specific rules only when that feature is requested or installed; do not add uploads, hierarchies, notifications or other product features merely because they appear here. Keep domain entities, user roles, recipient rules and workflows in the project-specific requirements outside this maintained block.',
|
|
29
29
|
'',
|
|
30
30
|
'- Product planning before implementation: treat the result as a real service, not a demo. Map the intended user journeys and distinguish domain concepts before choosing tables, endpoints or screens. Define each domain concept by its purpose, ownership, lifecycle and discovery/editing flow; concepts sharing a persistence mechanism need not share a user flow. For hierarchical features, specify traversal order, sibling order and page boundaries before choosing hierarchy queries. A requested tree listing renders descendants beneath their parent in tree order; a globally time-sorted list with depth badges or parent links is not that tree. Retain parent context when a bounded page continues a branch, and test the actual rendered row order with multiple branches and interleaved creation times. Record acceptance checks for discovery/navigation, creation, editing, cancellation, deletion, permissions, empty/loading/error states and operator recovery. Validate those journeys in the actual UI (see Browser apps and the view: a service people use in a browser has screens); API tests and startup success cannot establish usable product behavior. Resolve material product ambiguity with the user, preserve existing requirements, and keep deployment claims limited to environments actually verified.',
|
|
31
|
-
"- Required browser transport (consumer convention; the core plugin remains optional): install @dokebi/seal in every browser-facing web app whose pages send data, and configure and verify seal-enabled domains. Which hosts: Seal a host whose pages send data (forms, sealedFetch, Inertia visits). A host that only shows public pages (no writes, no signed-in JSON) gains nothing from seal: leave its domain without `seal: true`. Its pages then need no seal files and no 'wasm-unsafe-eval', and may use Inertia SSR. If you do seal such a host, its read-only pages load only the two small modules (about 19 KB), never the wasm. Inertia + Vue is the default view unless the user chose another. Inertia: navigation/forms retain the official sealInertia(http) integration before createInertiaApp (the generated views/app.js imports @dokebi/seal/http when the first page is sealed, then the data-page and every visit, form post and validation error go sealed; a plain JSON body gets 415 SEAL_REQUIRED). The generated vite.config.ts has dokebiInertia() from @dokebi/template-inertia/vite: every import of @dokebi/seal/http in the app's browser code loads the module the app serves (/dokebi/seal/http.mjs), in the build and in dokebi dev, so Vue pages write a plain static import { sealedFetch } from '@dokebi/seal/http' and share the bootstrap's seal; keep that plugin in a vite config of your own (app add warns VITE_PLUGIN_MISSING without it). The plugin also limits what dokebi dev serves to the browser (D-0129): the views folders, node_modules and the files they import; dokebi.yaml, .env, keys and the server code answer 403. Never add server.fs to vite.config (strict: false, a deny list, allow: ['.']) to make a file load: put browser code under views/ or
|
|
31
|
+
"- Required browser transport (consumer convention; the core plugin remains optional): install @dokebi/seal in every browser-facing web app whose pages send data, and configure and verify seal-enabled domains. Which hosts: Seal a host whose pages send data (forms, sealedFetch, Inertia visits). A host that only shows public pages (no writes, no signed-in JSON) gains nothing from seal: leave its domain without `seal: true`. Its pages then need no seal files and no 'wasm-unsafe-eval', and may use Inertia SSR. If you do seal such a host, its read-only pages load only the two small modules (about 19 KB), never the wasm. Inertia + Vue is the default view unless the user chose another. Inertia: navigation/forms retain the official sealInertia(http) integration before createInertiaApp (the generated views/app.js imports @dokebi/seal/http when the first page is sealed, then the data-page and every visit, form post and validation error go sealed; a plain JSON body gets 415 SEAL_REQUIRED). The generated vite.config.ts has dokebiInertia() from @dokebi/template-inertia/vite: every import of @dokebi/seal/http in the app's browser code loads the module the app serves (/dokebi/seal/http.mjs), in the build and in dokebi dev, so Vue pages write a plain static import { sealedFetch } from '@dokebi/seal/http' and share the bootstrap's seal; keep that plugin in a vite config of your own (app add warns VITE_PLUGIN_MISSING without it). The plugin also limits what dokebi dev serves to the browser (D-0129): the views folders, node_modules and the files they import; dokebi.yaml, .env, keys and the server code answer 403. Never add server.fs to vite.config (strict: false, a deny list, allow: ['.']) to make a file load: put browser code under views/ or, when several apps or modules share it, in src/shared/browser/ (a page imports it, so it is served); dokebiInertia({ allow }) is only for files the browser loads by URL without an import (dokebi check warns vite-dev-files). EJS: write <%- data.seal?.head ?? '' %> in the shared layout <head> (the template-ejs layout has it), and in the <head> of every page rendered without that layout (it is empty on a domain without seal); when a layout has its own import map, the seal head comes first, before that map and every module script. It loads the browser module @dokebi/seal/forms (served as /dokebi/seal/forms.mjs), which seals every same-origin <form method=\"post\"> with no per-form code and sends it with the request header x-dokebi-form: 1, so the form keeps its <%- data.csrf.field %> and the handlers, validation and 303/422 form flow stay those of a plain HTML form. Sealed forms are form bodies: set dokebi-web.formBody: true (without it they get 415 FORM_BODY_DISABLED). A form with a chosen file goes as multipart (file bytes are not sealed) and the forms module moves its _csrf field into the x-csrf-token header itself; write no upload-specific CSRF code. To submit from a script call form.requestSubmit() or submitSealedForm(form) from @dokebi/seal/forms, never form.submit(): it fires no submit event and goes out plain (415). Page navigation (GET) stays plain HTML. Mark a form data-seal=\"off\" only for a deliberate exception, never to make a plain form post pass: a sealed domain refuses that unsealed post (415 SEAL_REQUIRED). Never turn sealing off, set seal: false on a form route or drop the layout head to make a plain form work. Both views: use sealedFetch from @dokebi/seal/http for all application-owned HTTP requests, including REST/JSON and multipart uploads. Do not call raw fetch, Axios or Inertia http.getClient().request from application API adapters. Import bootstrap and request helpers from the same module instance, the served /dokebi/seal/http.mjs: EJS pages reach it through the import map of the seal head, Inertia apps through dokebiInertia(), so both import @dokebi/seal/http by name; never load /dokebi/seal/http.mjs by URL next to a bundled copy of @dokebi/seal/http. Preserve generated template selection and hydration contracts. Server rendering on a seal host covers public pages only (D-0195): a route that renders with { public: true } gets a plain, server-rendered first HTML without the visitor's props (auth, csrf and the entry's shared arrive right after through a sealed visit), and every other page of that host stays sealed and is not server rendered. dokebi app add --inertia --ssr --seal makes such an app; mark the routes whose first HTML crawlers must read with { public: true } and head (title, description, canonical, alternates), put only public data in their props, keep values the same for every visitor in publicShared of src/infra/inertia/shared.ts, and draw the layout before the visitor's props arrive. The recipes leave SSR hosts unsealed and say so: ask the user whether those hosts send data, and if they do, seal them and mark their public pages (a read-only public host may stay unsealed with SSR). File multipart bytes and GET queries are outside sealing; verify sealed JSON responses and errors too. sealedFetch does not add CSRF headers automatically: follow the installed @dokebi/csrf guide in one shared adapter, read the current token for each request, keep credentials same-origin, and never disable CSRF to make uploads pass.",
|
|
32
32
|
`- Recipe answers (D-0095): a request often settles some choices (for example PostgreSQL, Docker, EJS) and leaves others open. Choices the request leaves open are still the user's: ask and end your turn, unless the user said to decide them. ${ANSWER_SOURCES} The recipe records who made each choice (answeredBy user, ai, default) and verify's tellUser tells the user; never present a choice you made as the user's answer.`,
|
|
33
33
|
`- Browser apps and the view (D-0098): ${BROWSER_APPS} Outside a recipe, npx dokebi app add records the view with --answers-from user or --ai-chose view --ai-reason view=<why>; an EJS app added without either (also the first app of add @dokebi/app) is reported to the user as not the default view with its chooser unrecorded. Validate the journeys of the screens in the actual UI (Product planning).`,
|
|
34
34
|
'- Processes and shared tools: stop a process by the PID you recorded or with npx dokebi stop, never by a pattern (pkill -f, killall): other apps on the machine run the same command lines (src/main.ts, the cluster worker). Check screens in a browser you start yourself with its own temporary profile (a headless or separate Playwright browser), never in the browser the person is using, through an extension or a computer-use tool: its tabs, cookies and signed-in sessions belong to them. Close only the tabs and contexts you opened; never navigate, reuse or close tabs you did not open. Keep downloaded browsers and package caches outside the project folder.',
|
|
@@ -37,7 +37,7 @@ export const INTEGRATION_RULES = [
|
|
|
37
37
|
'- Background work (D-0141): deliveries (webhooks, mail, notifications), exports, imports, copies, grace periods and cleanups are work items of @dokebi/outbox, not loops you write. Enqueue with outbox.enqueue(tx, { type, owner, destination, payload, dedupeKey, notBefore }) inside the business transaction and register outbox.handle(type, handler, { onDone }) in the setup of the module that owns the work; its runner claims fair batches across owners through one due-time index, retries with backoff, waits out a destination that is down (a breaker per destination, dead only after a horizon of days), keeps dead items for outbox.resend and removes finished rows after a retention. It derives its own small pool of the main connection (pool.max, default 4), so add nothing but run the migration that npx dokebi add @dokebi/outbox writes, keep handlers idempotent with item.key, query in handlers through context.db (the outbox handler pool, never the main pool: an owner whose handlers wait on a locked row then holds at most runner.maxInFlightPerOwner of them while the other owners keep flowing), and put the arrival and drain per second of npx dokebi-outbox stats in the section 6 table of the final report. Never hand-write a claim loop, a retry or dead-letter table or a timer for such work. A destination is one endpoint (one webhook id or URL, one mailbox provider), never a whole host or a shared name such as database: items of one failing endpoint must not pause the others. Database-only cleanup has no destination, and a batch handler records a failing row and skips it rather than failing the whole item. Best-effort signals after a commit (an SSE change notice, a cache invalidation) are not outbox work: send them directly.',
|
|
38
38
|
'- Recipe fit: pick the recipe whose scaffold matches the app (npx dokebi recipe list shows each recipe and its match); when you build on a scaffold made for something else, rename or remove its sample names (tables, option keys, routes, view titles) so none of them remains in the finished app.',
|
|
39
39
|
'- Responsibility boundaries: use Controller -> Service -> Model for application data. Controllers translate HTTP input/output and call services; models own SQL, services provide data and coordinate workflows, and jobs invoke those services. Put app-specific services in src/apps/<app>/services, cross-app services in src/shared/services, and feature-module services in src/shared/modules/<module>/services. Shared services must not import app-specific code. Services accept explicit inputs and return DTOs, never request/reply or template objects; do not expose models or SQL pools through a service for controllers/routes to bypass it. Compose dependencies once during setup. Periodic and background work runs only through the scheduler and job plugins, registered by the module that owns it; never start timers, intervals or background loops in controllers, services or setup code. Keep auth extension wiring separate from reusable member persistence. Audit the final route and registration graph after replacing scaffold flows; remove obsolete unreferenced implementations that duplicate the active behavior, while preserving required engine entries, mail templates and user-owned resources. Split by responsibility, not by arbitrary file counts. When a browser UI is present, keep views/runtime for browser integration and requested reusable editor/upload UI in the template components, and display helpers separate from transport. Use explicit DTO types through services, browser adapters and Vue props; a default any response or any page state defeats SFC checking. Keep readable formatting. Keep original TS/JS/Vue source formatted; minification belongs only to generated build output. Declare a formatter that supports the source formats, include its check in project verification, and inspect the final source rather than claiming readability from build success. Include Vue SFC scripts/templates in type checking; a successful Vite build or server-only tsc is not a Vue type check. dokebi app add --inertia prepares it: npm run typecheck runs tsc and then vue-tsc (typecheck-vue.mjs with tsconfig.vue.json), so keep that step, write pages as <script setup lang="ts">, and type the shared page props in src/infra/inertia/page.d.ts. Preserve the shared error catalog at src/shared/errors.ts.',
|
|
40
|
-
'- Files and folders (maintained layout; refreshed by guide --sync like every rule here): src holds only main.ts and dokebi.generated.ts
|
|
40
|
+
'- Files and folders (maintained layout; refreshed by guide --sync like every rule here): src holds only main.ts and the files the CLI writes at its root: dokebi.generated.ts and dokebi.modules.generated.ts (the registered modules; import registeredModules from it where code needs every module, an app that mounts each one or keys collected from each, and never keep a module list of your own). One app per src/apps/<app>: app.ts, routes.ts (or routes/ for route groups), controllers/, services/, models/, validation/ and views/<template>/ (Inertia pages in views/<template>/Pages, components in components/, browser integration in views/runtime/). Shared code: src/shared/models, src/shared/services, src/shared/views (layouts, partials), src/shared/locales/<locale>/<namespace>.json, src/shared/mail/<template>/<locale>/, application settings in src/shared/settings, input rules several apps or modules share (reading a list query, a reason) in src/shared/validation and the error catalog src/shared/errors.ts. Browser code several apps or modules share (a design system, shared layouts, composables, a socket client) goes in src/shared/browser: components/, layouts/, composables/, styles/ and lib/ (a project with two looks, an operator console and a member site, puts one folder per look first, src/shared/browser/staff/components/); pages import it with a relative path, server code never imports it. Browser code (the views of apps and modules and src/shared/browser) is type-checked by tsconfig.vue.json with vue-tsc, not by tsconfig.json. Code one app or module uses stays in the views/ of that app or module. src/shared holds nothing else (dokebi check warns shared-folder). One feature per module in src/shared/modules/<module> (module.ts, routes.ts and the same controllers/services/models/validation/views folders; create it with npx dokebi module add). Declarations the project adds to every module (its menu entries, its permission keys) are files at the module root named for what they declare (menu.ts, permissions.ts) that module.ts passes on; pages declared but not built yet are routes and stay in routes.ts. A feature several apps show is one module, a login of two apps included; when each app needs route ids of its own, each app mounts a set of its own whose routes carry those ids and call the same controllers. Plugin connection and extension code in src/infra/<name> (src/infra/db/connections.ts, src/infra/auth/extension.ts), including the project wrapper of a plugin (a defineModule wrapper in src/infra/module/) and code several apps share that reads a request through a plugin (the viewer from request.auth in src/infra/auth/, Inertia props several apps build the same way beside src/infra/inertia/shared.ts, a gate of every route of an app, a dokebi-web routeHook each app registers in its setup, in src/infra/web/); services never take the request; your own plugins in src/plugins/<name>. Migrations in src/infra/db/migrations/<connection> and seeds in src/infra/db/seeds/<connection> (npx dokebi-migrate make writes the file). Job handlers and event subscriptions are registered in the setup of the module that owns the feature (src/shared/modules/<module>/module.ts) and call its services; schedules are entries of options.dokebi-scheduler.schedules in dokebi.yaml whose job type such a handler takes; CPU tasks go in src/infra/worker/tasks.ts, event payload types in src/infra/events/types.ts and the cluster worker factory in src/infra/runtime/application.ts. Input validation (route schemas and validators) lives in validation/ of the app or module that owns the route; a pure rule both the server and the pages of that app or module use (a code check, a rich-text schema) stays in that validation/ folder, imports neither Node nor browser APIs, and the pages import it with a relative path (one several apps or modules use goes in src/shared/validation); a DTO type is exported by the service that returns it (cross-app DTOs with their service in src/shared/services). Tests: tests/unit (no external service), tests/integration (a real database, HTTP or broker) and tests/support (helpers and fixtures, never named *.test.ts); npm test runs node --test "tests/**/*.test.ts", which covers both test folders, and tsconfig.json includes tests/**/*.ts. Development tools (imports, measurements, one-off maintenance) go in scripts/ at the project root, run with node scripts/<name>.ts and never imported by src. Name .ts files and folders in kebab-case (Vue components and Inertia pages are PascalCase, as Pages/Posts/Show.vue), and give each file one responsibility.',
|
|
41
41
|
'- Apps split by host (D-0132): with several @dokebi/app apps on different hosts, routes that plugins add answer on every host unless they are bound to apps. Bind each plugin endpoint to its app in dokebi.yaml: dokebi-mcp.app: mcp (the MCP route), dokebi-oauth.app: studio (the authorization server: metadata, authorize with the consent page, token, revoke, register; the issuer origin is a domain of that app) and dokebi-oauth.resources.<id>.app: mcp (the protected resource metadata, on the app of the resource uri host). Every other host then answers the 404 of an unknown route. Put the sign-in page on the issuer app. A route of your own module or plugin on web takes app: <name> or app: [<name>, ...] the same way. Never write an onRequest hook that compares the Host header to hide an endpoint, and never answer 403 on the wrong host. Without @dokebi/app a bound route fails the start (ROUTE_APP_UNAVAILABLE), an unknown app name too (ROUTE_APP_UNKNOWN), and an issuer or resource uri on a domain of another app fails it with INVALID_OPTIONS naming the option to set; health routes stay on every host.',
|
|
42
42
|
'- Module contributions (D-0130): a feature module that offers values to a plugin point (MCP tools, prompts and resources of @dokebi/mcp, mail template folders) declares the points in defineModule({ contributes: [mcpTools] }) and calls module.contribute(point, value) in its own setup, after it builds its services; the contributed objects (an McpTool subclass) take those services in their constructors. Core sets the module up before the plugin that collects the point, so the services exist when the collector reads them, and contributions close when every setup has finished. A module never collects. Never rebuild module services in a separate definePlugin, and never register an app plugin by hand in src/main.ts or src/infra/runtime/application.ts to reach them: describe, the tests and the other entry do not see such a plugin, and doctor and check do not read it. A second module reaches the services through requires: [workspace] and module.get(workspace). Values that no registered plugin collects are dropped with warn POINT_NOT_COLLECTED, npx dokebi check reports module-point-not-installed when the plugin package of a point is not installed, and npx dokebi describe lists each module point and its collector. MCP tool names are unique across modules and plugins (INVALID_TOOL names both owners).',
|
|
43
43
|
"- What `npx dokebi check` enforces from these rules (D-0105), so a broken one fails before you report: background-timer (an error, so verify fails) is a setInterval, a setTimeout/setImmediate that reschedules itself, or a loop that sleeps inside a task started in the background (an immediately invoked async function or a function called without await, such as a polling loop in a module start), in server code under src/ (views and tests are not read): move the work to a @dokebi/job handler registered in the owning module's setup and an entry of options.dokebi-scheduler.schedules; one-shot delays, time limits, awaited sleeps of node:timers/promises and timers of one request or socket are fine (a timer a request stores on this or in an outer variable outlives it and is reported). polling-loop (an error no marker silences) is a loop that sleeps inside a task started in the background, or a timer whose callback does database work: move it to an @dokebi/outbox or @dokebi/job handler. private-pool (an error) is a database pool or client made with the driver outside src/infra/db (new pg.Pool, mysql2 createPool, new MongoClient): take connections from @dokebi/db (connection(main), derive('main', { purpose, overrides: { max } }) for a pool of one kind of work, or another connection in dokebi.yaml) so dokebi.yaml sets their size and waitTimeoutMs and a caller past the wait gets 503 with Retry-After. overload-off (an error) is a route config overload: false: keep the overload protection on every API route (a metrics scrape or status page takes a marker). readiness-off (an error) is a route config readiness: false: an API route keeps refusing with 503 NOT_READY while a required dependency is down (a metrics scrape or status page that must answer then takes a marker). Warnings: in-process-queue (the resolve of a new Promise stored in a collection to call later: a queue of one worker without bound or deadline), fixed-owner-cap (a per-owner count of requests in progress compared with a fixed limit: use the owner share of @dokebi/db, share(main).enter(owner), which refuses only while the pool is full, @dokebi/db AI.md 6.4), wait-count-refusal (a comparison of the callers waiting for a pool connection, such as pool.waitingCount, with a number: refuse by the wait deadline, never by how many wait), responsibility-size (a model of 400+ code lines over 8+ tables or collections, a controller with 20+ route handlers or 300+ code lines, a service whose methods mostly only pass their arguments to a model) and memory-filtered-page (rows a query returned, skipped in code by an input such as filter.status and then cut to a page). A warning is still a broken rule: fix it, or keep it with // dokebi-check: allow <rule> <reason> and say why in your final message. An allow marker on background-timer is only for per-process upkeep of in-memory state (a cache of this worker); a loop that reads or writes the database (claiming, folding, polling a queue table) is never a valid reason: move it to a job or an outbox handler. check lists every marker with a reason under allowed, and verify ok asks your final message to list them with their reasons. With @dokebi/db installed, verify ok lists finalReport: the section 6 table your final message must contain.",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { VirtualSource } from './typescript.js';
|
|
2
2
|
/** The suffix of a virtual source; never a real file and never what an import resolves to. */
|
|
3
3
|
export declare const VIRTUAL_SUFFIX = ".dokebi-check";
|
|
4
|
+
/** The browser code several apps and modules share (D-0226). */
|
|
5
|
+
export declare const SHARED_BROWSER = "src/shared/browser/";
|
|
4
6
|
/**
|
|
5
7
|
* The script of a .vue file as one TypeScript or JavaScript text of the same length: the
|
|
6
8
|
* template, the styles and the tags blanked (newlines kept). Undefined without a script block.
|
|
@@ -11,10 +13,14 @@ export declare function vueScript(text: string): {
|
|
|
11
13
|
} | undefined;
|
|
12
14
|
/** The virtual source of one file (project-relative `path`), or undefined when there is none. */
|
|
13
15
|
export declare function browserSource(root: string, path: string, text: string): VirtualSource | undefined;
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Is `path` (project-relative) browser code check reads: a .vue file, .js/.mjs in views/, .ts/.mts
|
|
18
|
+
* in the views of an app or module, or a module of src/shared/browser/ (never a .d.ts)?
|
|
19
|
+
*/
|
|
15
20
|
export declare function isBrowserPath(path: string): boolean;
|
|
16
21
|
/**
|
|
17
|
-
* The browser code under `directory` (default `src/`) of a project: .vue files
|
|
18
|
-
* under views/ (node_modules, dist, .vite, .git and the
|
|
22
|
+
* The browser code under `directory` (default `src/`) of a project: .vue files, the .js/.mjs
|
|
23
|
+
* under views/ and the modules of src/shared/browser/ (node_modules, dist, .vite, .git and the
|
|
24
|
+
* .tmp scratch folder are not walked).
|
|
19
25
|
*/
|
|
20
26
|
export declare function browserSources(root: string, skip?: (path: string) => boolean, directory?: string): Promise<VirtualSource[]>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Browser code for `dokebi check` (D-0120): the `<script>` and `<script setup>` blocks of the
|
|
2
|
-
// project's .vue files
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// project's .vue files, the .js/.mjs files under a views/ folder, and the .ts/.mts of the views of
|
|
3
|
+
// apps and modules and of src/shared/browser/ (D-0226: browser code, which tsconfig.json leaves to
|
|
4
|
+
// vue-tsc) are not in the tsconfig program, so empty-catch, missing-cause and
|
|
5
|
+
// floating-promise never saw them. Each such file becomes a virtual source next to the original (`<file>.dokebi-check.ts` or
|
|
5
6
|
// `.js`), which typescript.ts serves to tsgo through its virtual file system in a second project:
|
|
6
7
|
// relative imports resolve from the same folder and the checker gives real types. A .vue file
|
|
7
8
|
// keeps its length and its newlines, everything outside the script blocks blanked to spaces, so a
|
|
@@ -15,7 +16,9 @@ import { sources } from './form-rules.js';
|
|
|
15
16
|
export const VIRTUAL_SUFFIX = '.dokebi-check';
|
|
16
17
|
/** Files larger than this are not read (generated bundles), as in form-rules.ts. */
|
|
17
18
|
const MAX_BYTES = 1024 * 1024;
|
|
18
|
-
const BROWSER = /\.(?:vue|js|mjs)$/;
|
|
19
|
+
const BROWSER = /\.(?:vue|js|mjs|ts|mts)$/;
|
|
20
|
+
/** The browser code several apps and modules share (D-0226). */
|
|
21
|
+
export const SHARED_BROWSER = 'src/shared/browser/';
|
|
19
22
|
const SCRIPT = /<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi;
|
|
20
23
|
const LANG = /\blang\s*=\s*(["']?)([a-z]+)\1/i;
|
|
21
24
|
/**
|
|
@@ -57,17 +60,32 @@ export function browserSource(root, path, text) {
|
|
|
57
60
|
text: script.text,
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
const typescript = /\.m?ts$/.test(path);
|
|
64
|
+
return { path, fileName: `${absolute}${VIRTUAL_SUFFIX}.${typescript ? 'ts' : 'js'}`, text };
|
|
61
65
|
}
|
|
62
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Is `path` (project-relative) browser code check reads: a .vue file, .js/.mjs in views/, .ts/.mts
|
|
68
|
+
* in the views of an app or module, or a module of src/shared/browser/ (never a .d.ts)?
|
|
69
|
+
*/
|
|
63
70
|
export function isBrowserPath(path) {
|
|
64
71
|
if (!BROWSER.test(path))
|
|
65
72
|
return false;
|
|
66
|
-
|
|
73
|
+
if (path.endsWith('.vue'))
|
|
74
|
+
return true;
|
|
75
|
+
if (/\.d\.m?ts$/.test(path))
|
|
76
|
+
return false;
|
|
77
|
+
if (path.startsWith(SHARED_BROWSER))
|
|
78
|
+
return true;
|
|
79
|
+
// The views of apps and modules: .js/.mjs anywhere in a views/ folder (D-0120); .ts/.mts there
|
|
80
|
+
// since tsconfig.json leaves them to vue-tsc (D-0226). src/shared/views/ holds EJS (server).
|
|
81
|
+
if (/\.m?js$/.test(path))
|
|
82
|
+
return /(?:^|\/)views\//.test(path);
|
|
83
|
+
return /^src\/(?:apps\/[^/]+|shared\/modules\/[^/]+)\/views\//.test(path);
|
|
67
84
|
}
|
|
68
85
|
/**
|
|
69
|
-
* The browser code under `directory` (default `src/`) of a project: .vue files
|
|
70
|
-
* under views/ (node_modules, dist, .vite, .git and the
|
|
86
|
+
* The browser code under `directory` (default `src/`) of a project: .vue files, the .js/.mjs
|
|
87
|
+
* under views/ and the modules of src/shared/browser/ (node_modules, dist, .vite, .git and the
|
|
88
|
+
* .tmp scratch folder are not walked).
|
|
71
89
|
*/
|
|
72
90
|
export async function browserSources(root, skip = () => false, directory = 'src') {
|
|
73
91
|
const found = [];
|
|
@@ -15,7 +15,7 @@ import { stat } from 'node:fs/promises';
|
|
|
15
15
|
import { join } from 'node:path';
|
|
16
16
|
import { debug, isMissing } from '../diagnostics.js';
|
|
17
17
|
import { CliError } from '../errors.js';
|
|
18
|
-
import { formatterFix, formatterUses,
|
|
18
|
+
import { formatterFix, formatterUses, GENERATED_FILES, migrationsFolder, } from '../formatter-ignore.js';
|
|
19
19
|
const RULE = 'formatter-migrations';
|
|
20
20
|
/** A file or folder that exists under the project. */
|
|
21
21
|
async function present(root, path) {
|
|
@@ -31,19 +31,22 @@ async function present(root, path) {
|
|
|
31
31
|
}
|
|
32
32
|
export async function formatterProblems(root) {
|
|
33
33
|
const problems = [];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
// The registration and the module list (D-0227): the CLI writes both and doctor refuses a copy
|
|
35
|
+
// that differs.
|
|
36
|
+
for (const file of GENERATED_FILES)
|
|
37
|
+
if (await present(root, file))
|
|
38
|
+
for (const use of await formatterUses(root, file)) {
|
|
39
|
+
if (use.covered)
|
|
40
|
+
continue;
|
|
41
|
+
problems.push({
|
|
42
|
+
rule: 'formatter-generated',
|
|
43
|
+
severity: 'warning',
|
|
44
|
+
file: use.config,
|
|
45
|
+
line: 0,
|
|
46
|
+
message: `${use.tool} would format ${file}: the CLI writes it and refuses a project whose copy differs (MODIFIED_REGISTRATION)`,
|
|
47
|
+
fix: formatterFix(use, file),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
47
50
|
const folder = await migrationsFolder(root);
|
|
48
51
|
try {
|
|
49
52
|
if (!(await stat(join(root, folder))).isDirectory())
|