npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mistriwork/mistri

v1.4.2

Published

The App framework: a few lines of TypeScript, a complete App, served from your own database.

Readme

mistri

A few lines of TypeScript. A complete App. — mistriwork.dev

The App framework: navigation, record pages, forms, dashboards, commands, policies, jobs and workflows declared in a typed DSL over a database you already have — SQLite or PostgreSQL — and served from it. Any screen is a TypeScript page beside your declarations: a React component that reads only what it declares and writes only through a command.

npm create mistri                               # a starter App, in a directory of its own
npx @mistriwork/mistri dev --app ./my-app             # serve it with a dev secret and a sign-in per role
npx @mistriwork/mistri check --app ./my-app     # schema types, typecheck and validation

It needs Node 24 or newer. Browsing a database with no App is the database browser's, a package of its own: npx tablewalk <db>. The DSL is imported from @mistriwork/mistri/app, @mistriwork/mistri/commands and the other entry points.

Build an App

App mode uses a version-controlled TypeScript DSL to define navigation, record pages, forms, dashboards, actions and themes over the same database runtime. JSON remains supported as a data-only definition format. Neither requires an App build to run on the supported Node 24 runtime; TypeScript examples also have an explicit typecheck (TypeScript 7 or later, the native compiler), and mistri build is the optional production step that runs it, validates the App and bundles it — see Build and deploy an App. These App features ship in mistri 1.4.2; the status page says what is stable and what comes next. Start with the sample catalog (examples/apps/README.md), written for people and coding agents, then the App DSL reference (the same pages read offline with npx @mistriwork/mistri docs).

The reference ships in the package, so it reads offline: npx @mistriwork/mistri docs lists one-screen topics — what an App serves: its declared resources, and no Workbench (access-model), keeping columns and secrets out of the browser (secrets), relationships, dates-and-types, reload-and-restart, check-codes — and npx @mistriwork/mistri docs <topic> prints one (--brief: its headings and the first sentence under each). schema/app.d.ts carries the DSL's hover docs, and mistri observe --mcp offers the same pages to a coding agent as mistri://docs/topic/<topic> resources.

Apps are internal tools and data apps over a database you already have. An App serves only the resources it declares; the standalone browser (npx tablewalk <db>, no App) is the tool for the tables it does not curate. Think admin consoles, operations desks, review queues, CRM-style workspaces, where the schema is the product model and shipping matters more than bespoke UI. Where a product needs its own design or its own code — a branded public site, a screen no view draws, a route that is not a command — the App sits inside it: a free-form page of the App's own, the handler mounted in your server, the App embedded in your React app (the general path).

What it builds, each shown once on the site:

| | | |---|---| | The DSL | Resources, views, actions, commands and a look, typed against your own schema: the DSL in one App, then the reference | | Eleven looks, fourteen palettes | Workshop (the default, in Safety orange), Lumen, Mono, Sage, Ledger, Atelier, Graphite, Bloom, Gallery, Parlor and Signal, each offering the same fourteen palettes, one structure and type scale, or a look of the App's own: looks | | Building blocks | Cards, galleries, facts and sheets, a property rail, a record's sections as tabs, similar lists, a filter bar or a filter rail, boards and calendars you drag in, lists kept in your order: choose a building block and the component tour | | Your own components | Where no built-in fits, a React module of the App's own as a section, a value renderer, a form's input, a list's rows or a whole room, fed by declared, authorized reads, changing data only through the App's commands and drawn with @mistriwork/mistri/ui in every look: custom components | | An assistant | People ask the App about their records, see answers drawn as its own tables and records, and confirm the changes it proposes, under their own grants; Claude via ANTHROPIC_API_KEY: add an assistant | | The App API | An App's reads and commands to scoped tokens over HTTP — loopback by default, the network when the App declares api.network — and to a coding agent as MCP tools (--app-mcp, or …/$mcp), rate-limited per token, on SQLite and PostgreSQL, tenant and row-policy Apps included: the App API | | Commands | Declared inputs, a typed db, a checked record, refuse and output shapes, lookup and effects: actions & commands | | Sources and services | An API as a connection, a shared cache and webhooks; tenant Apps with invitations, events and public intake: services | | Jobs and workflows | Jobs on events and at times, signed callbacks and durable workflows; flows whose steps are rows that people edit while the App runs: events & jobs | | Shipping | mistri build, mistri deploy to Cloudflare Containers, an App's first page in 314 KB of script with brotli, PostgreSQL pools sized per connection: build and deploy, performance |

Building with a coding agent? Use the agent build guide for a copyable prompt that works from the npm package, the loop and a concrete verification checklist, and npx @mistriwork/mistri agent init to install the agent skill that Claude Code, Codex, Cursor and Copilot load on their own.

An App's addresses read as words, one canonical address per thing. A record is its id under the first view showing its table that the reader is served (/leases/12; a resident's repair /my-requests/12, the office's /repairs/12, and a mailed link is the recipient's own), so following a reference opens the target's own address and Back retraces the walk; a list is its view's key, and what the reader chose follows as parameters: /leases?tab=ending_soon&search=reyes, /listings?bedrooms=2&market_rent=..200000&sort=-market_rent. The New form is /leases/new, a dashboard /today?period=last-30-days; a natural key (Thread's labels, /thread/label/bug) and, on public pages, a slug (Forecourt's vehicles, /forecourt/vehicles/1-2024-toyota-corolla-le) are opt-in. Only a question those cannot say is written as q= its text. The database browser keeps the query language in its links, and those still open inside an App.

A server serving one App serves it at the root, as above. Serve several and each keeps its id (/lintel/leases/12); --mount main=/ makes one of them the main App at the root beside the others, and --base-path /tools serves everything under a reverse proxy's path (https://host/tools/leases/12). mistri check --routes prints the addresses as they will be served, and refuses a main App's route that another App's place would hide.

For independent per-App connections and sign-in on one local listener, mistri suite suite.json provides an initial suite runtime. See Local App suites for configuration and the currently supported subset.

For an opt-in local performance check, run npm run test:load:smoke from a source checkout of the repository (the npm package does not ship the script). The load-testing section describes concurrent HTTP traffic and real browser journeys against a fresh, isolated instance of a test fixture App; existing previews and databases are not load targets.

Four TypeScript example projects ship, from a single-file starter to full-featured Apps:

| Sample | Start here for | | --- | --- | | Tick (examples/apps/tick/README.md) | A five-minute TODO app: one DSL file with inline types, plus a README. Seed with node examples/databases/tick/seed.mjs <db>. | | Lintel (examples/apps/lintel/README.md) | The flagship, property operations in the Lumen look: a staff desk and a resident portal in one App under a row policy, roles that extend roles, a rent ledger posted by a job, a late-fee workflow, repairs whose parts come off a storeroom shelf, a signed payment callback, a public listing with a viewing form, and its own test suite. PostgreSQL or SQLite. | | Ladle (examples/apps/ladle/README.md) | Embedding a mistri App inside a custom React site with free-form pages and shared authentication. | | Foundry (examples/apps/foundry/README.md) | A public editorial catalog and storefront in the Gallery look with signed-out reads, SSR, and custom pages. |

All four use the shared renderer. Seed fresh disposable databases and follow each sample's README. Database setup lives separately under examples/databases/. Review queues, status strips and action when conditions are UI curation; server permissions and command checks enforce access and business rules. Lintel's row policy and authority.lock show both.

Two access models exist, both opt-in and both enforced on the server. A row policy (auth.rows: 'policy' plus --policy <file>) scopes what an authenticated App reads and, on a SQLite or PostgreSQL source, what it may update, insert, delete and undo; see row policies and Undo (App DSL reference). A tenant App (auth.rows: 'tenant' plus --policy <file>) adds native sign-in, verified membership and per-tab tenant selection on one provisioned SQLite file or dedicated PostgreSQL database; see tenant startup (docs/tenant-apps.md) for the supported boundary and what a tenant App still refuses.

Mail, agents and sign-in

An App's mistri.json can name two connections beside its databases:

{
  "connections": [
    { "name": "mail",   "kind": "email", "url": "smtps://smtp.example.com:465",
      "from": "Compass <[email protected]>",
      "auth": { "username": "${SMTP_USER}", "password": "${SMTP_PASSWORD}" } },
    { "name": "agents", "kind": "oauth", "apps": ["compass"], "roles": ["sales"] }
  ]
}

mail is the one email service a server sends through — notifications marked email: true, a status check's step-up code, sign-up verification and reset links — over smtps://, smtp:// with STARTTLS, or log: (write each message instead of sending it, for development). A notice's email is queued with its write and sent after the commit, with retries; a failed send never fails the write (mistri docs email). agents is an OAuth 2.1 authorization server for the App API: an MCP client registers itself, the person signs in to the App and picks which of their roles it may act with (at most roles; in a tenant App, which of their tenants too, the token that one membership's), and the client gets an hour's API token and a rotating refresh token, the grant ending after 30 days or when the person disconnects it from their profile (the App API).

An App can sign people in itself: "auth": { "providers": ["email"] } in its manifest brings in Better Auth — email and password, GitHub, Google or any OpenID Connect or SAML 2.0 provider (Entra ID, Okta, ADFS, Keycloak…) with roles from its claims, invite-only, open or just-in-time sign-up, roles with their own write scope — with sessions in a SQLite file of mistri's own and the secrets in the environment. mistri docs sign-in has the block and mistri docs identity-providers the providers; it is an optional dependency, installed by default and loaded only by Apps that declare auth.

Options

mistri --app <dir>            serve an App: its pages, commands and jobs (below)
mistri check [--app <dir>]    types, typecheck and validation of an App (below)
mistri build [--app <dir>]    make an App ready for production (below)
mistri deploy [init cloudflare|status|verify|rollback|logs]
                              check, migrate, deploy and verify an App on Cloudflare Containers (below)
mistri new [<name>] [<dir>]   a starter App with its own SQLite database: a task
                              list in one app.ts, a schema and rows, for mistri dev
mistri new --brief <BRIEF.md> [<dir>]
                              an App drafted from an approved brief: its schema, database, roles,
                              commands and look (the mistri skill's step 0)
mistri new --template intake [<name>] [<dir>]
                              a public multi-step intake: the stock form over one table,
                              no page or CSS of its own
mistri new --api <name> [<dir>]
                              an App that is only an API: a resource, a command,
                              its event, tokens and MCP; no pages
mistri suite <suite.json>     serve a local suite with per-App configuration
mistri virtual <service.ts>   run a typed virtual HTTP service for tests
mistri flags --help           explicit flag control-store provisioning
mistri experiments --help     explicit experiment evidence-store provisioning
mistri analytics --help       behavior-analytics store provisioning and funnels
mistri shot [--app <dir>]     an App's pages as PNG files, to look at (below)
mistri grade [--app <dir>]    an App's pages measured against the rubric (below)
mistri theme show <look|.>    a theme's every color, recipe, type and shape (below)
mistri schema --brief         the schema as one line per table, for an agent's context
mistri explain <code>         what a check code means, with its fix (below)
mistri messages extract [--app <dir>] [--locale <tag>]
                              an App's words for a translator: a catalog's missing
                              keys appended as comments, or its literal captions
mistri migrate <command>      change the schema with versioned SQL files (below)
mistri seed [--app <dir>]     believable rows in an App's writable database (below)
mistri dev [--app <dir>]        serve an App with a dev secret and a sign-in per role (below)
mistri test init [--app <dir>]
                              a starter suite: a journey per role, a permissions matrix (below)
mistri flows start <resource>
                              start a resource's flows on records already there (below)
mistri jobs run <name>        run one of an App's jobs at times now, once (below)
mistri audit reads            who read an audited resource's rows, as JSON lines (below)
mistri decide eval <name>     measure a decision on settled records, and pin its model (below)
mistri tenant init|grant|brand
                              a tenant App's first boot: its realms, tenants, first operators and branding (below)
mistri tenant clone|import|clock
                              a tenant App's sandboxes: clone, import plan, dev clock (below)
mistri docs [topic]           the App reference, offline (below)
mistri agent init             put the agent skill where coding agents read it (below)
mistri acp [--app <dir>] [--config <file>]
                              run Mistri as an Agent Client Protocol (ACP v1) agent over stdio
mistri mcp config|inspect     emit safe MCP client config or inspect a Streamable HTTP MCP server
mistri upgrade [--app <dir>] [--check]
                              rewrite an App's source to the names this mistri reads (below)
mistri compare-openapi <previous.json> <current.json>
                              compare two exported App API documents (below)
mistri api client <spec.json> --out <client.ts> [--hooks <hooks.ts>]
                              a typed fetch client and optional TanStack Query hooks (below)
mistri api init --app <dir> [--config <file>] [--commands <file>] [--role <role>...] [--no-writes] [--public-spec] [--explorer]
                              print an explicit expose(...) api declaration from an App (below)
mistri api-token --help       local token-store maintenance; no server
mistri mail-dns [<config>]    the SPF, DKIM and DMARC records tenant mail is sent under
mistri doctor [--config <file>]
                              pre-flight runtime, security, pool sizing, and Valkey/PostgreSQL checks (below)
mistri policy explain [--app <dir|file>]
                              explain why a role can or cannot read/write a resource, column, or command (below)
mistri diff <previous-app> <current-app>
                              compare two App manifests for breaking vs additive changes (below)
  -d, --db <target>           the App's database: a SQLite path or a URL (or set DATABASE_URL,
                              used when no config names connections)
  -p, --port <n>              default 4111
      --schema <name>         Postgres only; repeatable. Defaults to all user schemas.
      --read-pool <n>         PostgreSQL connections that may read at once, per
                              database (default 4; an App's at least 10 and its writers, at most 64); a connection's
                              "pool": { "read": n } wins. Or set
                              MISTRI_READ_POOL
      --write-pool <n>        connections an App may write through at once,
                              per PostgreSQL database (default twice the cores, 4 to 16; at most 64; the database browser always writes
                              through one); a connection's "pool": { "write":
                              n } wins. Or set MISTRI_WRITE_POOL
      --lock-timeout <s>      seconds a write waits for a row or table another
                              transaction holds before it is refused (default
                              5, 0.1 to 30). Or set MISTRI_LOCK_TIMEOUT
      --pooler <mode>         session (default: direct, or a pooler that keeps
                              a client on one server connection) or transaction
                              (PgBouncer in transaction mode, RDS Proxy): the
                              read-only guard and statement cap are then set
                              per transaction. Or set MISTRI_POOLER
      --drain-delay <s>       seconds /readyz answers 503 before the listener
                              closes on SIGTERM, so a balancer that probes
                              takes this instance out first (default 0, up to
                              120). Or set MISTRI_DRAIN_DELAY
      --shutdown-grace <s>    seconds a response still unfinished after the
                              drain may keep the process before it is cut
                              (default 10, 1 to 300); hold both inside the
                              platform's stop timeout. Or set
                              MISTRI_SHUTDOWN_GRACE
      --workers <n|auto>      processes serving the one port (default auto:
                              one per core the container is given, its CPU
                              quota and 256 MiB of its memory limit each, at
                              most 64); a session's requests stay on one. More
                              requests at once, not a faster page. PostgreSQL
                              only: a SQLite start is one process unless asked.
                              1 turns it off; mistri dev is always one. Or set
                              MISTRI_WORKERS
      --replicas <n>          expected instance count behind a load balancer
                              (default 1, 1 to 1000). When > 1, startup refuses
                              SQLite stores, missing MISTRI_FORM_KEY on public
                              command pages, and missing Valkey "cache" service.
                              Or set MISTRI_REPLICAS
      --host <addr>           interface to bind (default 127.0.0.1)
      --allowed-host <name>   also answer for this Host header; repeatable
      --trust-proxy <address|CIDR>
                              a proxy whose X-Forwarded-For the public forms'
                              rate limit may believe (172.17.0.1, or a range
                              like fd00::/8); repeatable or comma-separated, or
                              set MISTRI_TRUST_PROXY. Loopback is always trusted.
                              Client address only, never identity
      --trust-proxy-hops <n>  behind a managed front end with no address to name
                              (Cloud Run, a cloud load balancer): how many
                              proxies append to X-Forwarded-For; the client is
                              the address n places from the right. Or set
                              MISTRI_TRUST_PROXY_HOPS
      --trust-proxy-cloudflare
                              read CF-Connecting-IP as the client; only when the
                              server is reachable through Cloudflare alone; not
                              with --trust-proxy-hops. Or set
                              MISTRI_TRUST_PROXY_CLOUDFLARE=1
      --insecure-http-sign-in
                              serve sign-in at an http address beyond this
                              machine, which is otherwise refused; prefer
                              MISTRI_PUBLIC_URL set to a TLS proxy's https
                              address. Or set MISTRI_INSECURE_HTTP_SIGN_IN=1
      --auth-proxy-header <name>
                              behind a proxy that signs people in: the header
                              it sets with the user (X-Forwarded-User). Requests
                              from beyond loopback must carry it; it is
                              believed only from loopback and --auth-proxy-from
                              peers. Every write is journaled with it
      --auth-proxy-from <address|CIDR>
                              a peer, beside loopback, whose
                              --auth-proxy-header value is believed: the
                              proxy's own address (10.0.0.7). A separate list
                              from --trust-proxy; repeatable or
                              comma-separated, or set MISTRI_AUTH_PROXY_FROM
      --config <path>         read connections from this file, and the
                              cache, search, webhook, email (smtps://,
                              smtp:// or log:) and OAuth services beside
                              them; the paths in it are relative to its folder
      --no-config             ignore any config file
      --no-live               turn live sync off, even for an App that asks
                              for it (live: true): its open pages then
                              refresh on focus and after their own saves.
                              Nothing is written to the change store and
                              /api/live answers 204
      --db-latency <ms>       development only: every database round trip
                              waits this long before it is sent (a pipelined
                              batch pays once), to feel a remote database on
                              this machine; 20 is a typical cloud distance. Or
                              set MISTRI_DEV_DB_LATENCY. Refused under
                              NODE_ENV=production and when serving a build
      --as-of <date>          development and tests only: App logic's clock
                              starts at this moment and moves on in real time
                              (2026-01-05 is midnight in the App's zone), so
                              seed data dated for one day reads as it did.
                              Sign-in, sessions and receipts keep the real
                              clock. Or set MISTRI_AS_OF. Refused under
                              NODE_ENV=production and when serving a build
      --app <dir>             serve an app: a directory whose app.ts (or
                              app.mjs / app.json) declares its resources,
                              views, navigation and pages. Repeatable; with
                              more than one, every app names its connection.
                              A config file can say the same with
                              "apps": [dir | { "dir", "env" }, …]; "env" lists
                              the variables the App's definition may read, and
                              it reads no others. A save reloads the App; a
                              change to its grants, sources or sign-in needs a
                              restart (mistri docs reload-and-restart).
                              --app names the App on every command that takes one
                              (check, build, shot, grade, dev, test init, flows,
                              jobs, audit, decide, tenant, deploy init, migrate
                              files);
                              left out, the App is the current directory when it
                              holds an app.ts (or app.mjs / app.json). seed,
                              migrate, messages extract and theme show read it
                              left out as no App. A directory typed where a
                              database or route goes is refused.
                              One App is served at the root (/leases/12);
                              several each under its id (/lintel/leases/12)
      --mount <app>=<path>    where an App is served, over that default: /
                              makes it the main App at the root, /billing
                              puts it there. Repeatable, one per App. Or
                              "mount": { "<app>": "/" } in the config
      --base-path <path>      the path a reverse proxy serves this server
                              under, like /tools: every address, asset, API
                              call, cookie and link carries it. Or "basePath"
                              in the config, or set MISTRI_BASE_PATH
      --app-entry <file>      with one --app: the manifest to read, when it is
                              not the directory's own app.ts. The directory
                              stays the App's root: components, pages/,
                              features/ and authority.lock
      --commands <file>       the server-only default defineCommands registry of
                              one explicit --app, when it is not the
                              commands.ts beside its manifest (read without
                              the flag); authenticated access and a migrated
                              writable SQLite or PostgreSQL command source
                              required. Restart the server to reload commands.
      --jobs <file>           load a server-only default defineJobs module with
                              one --app and its commands: jobs that run a
                              command, as a declared principal, when a
                              committed event says so or at the times they
                              say (every). Stores provisioned once from
                              @mistriwork/mistri/maintenance; restart to reload.
      --policy <file>         load a server-only row or tenant policy for one authenticated,
                              named-source --app whose auth.rows is "policy" or "tenant".
                              Tenant Apps require one existing provisioned SQLite or
                              PostgreSQL source.
                              Row policies support reads and
                              explicit commands and scoped creation/updates with Undo.
                              Delete/restore requires an explicit deleted-record policy.
                              App and policy changes require a restart.
      --from-openapi <spec>   draft an HTTP connection's description from an
                              OpenAPI 3.0 or 3.1 JSON spec (a file or URL),
                              print it, and exit; guesses and skipped
                              operations go to stderr
      --openapi <spec>        serve an API straight from its OpenAPI spec (a
                              file or URL): the description is drafted in
                              memory and the base URL is the spec's server
      --api-url <url>         with --openapi: the API's base URL, when the
                              spec's servers do not give a usable one
      --api-token-env <name>  with --openapi: send $name as a bearer token
      --scaffold-app <dir>    draft an App project for the active connection
                              in helper-built TypeScript — list views, display
                              rules, an Overview, record pages, schema types,
                              tsconfig.json, an .oxfmtrc.json, a mistri.json
                              naming a SQLite file by a path from the App, and
                              (outside a checkout) package.json with format
                              scripts — that passes mistri
                              check as written, and exit. A start to curate.
                              With --config naming several connections, one
                              App with a source per connection; a PostgreSQL
                              one holding several schemas is a source
                              per schema on that one connection.
      --name <name>           with --scaffold-app: the App's name, instead of
                              one read off the database file's
      mistri check             with --app: validate the app against its
                              connection, print every problem, and exit
                              non-zero if any. For CI. An app with an
                              authority.lock also fails when what it
                              grants differs from the lock.
      --write-authority       with mistri check: write each app's
                              authority.lock (what it grants, one fact per
                              line, and each command's contract) to commit
                              beside it. The server refuses to start an app
                              whose authority differs from its lock, and a
                              reload that changes it.
      --bump <command>        with mistri check: move the command's contract
                              to its next version in authority.lock, when it
                              changed and the App API, a job or kept
                              receipts depend on it
      --reindex [resource]    with --app and a search provider plugged in
                              (a search pack): read every searched resource (or
                              the one named) from the database into its search
                              index, then exit
      --demo                  build a throwaway sample database and open it
      --open                  open a browser once the server is up
      --dev                   serve the dev observer at /_mistri/observe
                              (loopback only, in memory, credentials masked)
                              and, with an App, the theme bench at /_theme
      --mcp                   the database browser's MCP server: refused,
                              naming npx tablewalk --mcp (an App's MCP is
                              --app-mcp)
      --export <fmt>          print the schema as md, mermaid, json, brief or types
                              (a .d.ts of this connection's names for the app
                              DSL), then exit; openapi exports one App's API
                              document (JSON), openapi-yaml exports it as YAML,
                              enabling no API routes;
                              asyncapi its AsyncAPI 3 document (feed events,
                              webhooks, and inbound endpoints with --jobs)
      --app-mcp               speak one authenticated App's API as MCP tools on
                              stdio, instead of serving HTTP: its
                              reads, and with --commands the targeted commands
                              it exposes. The token comes from
                              MISTRI_API_TOKEN, never the command line;
                              reads integers from the App's api block; SQLite or
                              PostgreSQL; a tenant or row-policy App under its
                              --policy
  -h, --help                  print the short help and stop; --help all, this
  -v, --version               print the version and stop

mistri compare-openapi <previous.json> <current.json>
                              compare two exported App API documents; JSON
                              report, no server or database. Exit 0: version
                              requirement met; 1: unmet or version decreased;
                              2: invalid input. Not a general compatibility proof.
                              Requires no-follow/nonblocking file-open support;
                              Windows comparison is not supported yet.

mistri api client <spec.json> --out <client.ts> [--hooks <hooks.ts>]
                              a typed fetch client from an exported App API
                              document (and with --hooks, typed TanStack Query
                              hooks): one TypeScript file with no imports,
                              the same bytes for the same document; no server
                              or database. Exit 1: no --out, or a file that is
                              not an App API document.

mistri api init --app <dir> [--config <file>] [--commands <file>] [--policy <file>] [--role <role>...] [--no-writes] [--public-spec] [--explorer]
                              inspect an App and its database schema and print
                              a ready-to-paste TypeScript api declaration using
                              expose(...); no server.

mistri doctor [--config <file>] [--workers <n>] [--pg-max-connections <n>] [--live] [--json]
                              audit Node runtime, security secrets, PostgreSQL
                              pool sizing, and optional live Valkey checks.
                              Exit 0: healthy; 1: failures; 2: bad args.

mistri policy explain [--app <dir|file>] [--config <file>] [--db <url>] [--role <role>] [--table <table>]
                [--column <col>] [--command <name>] [--json]
                              explain offline why a role can or cannot
                              read/write a resource or column, or run a command.
                              Exit 0: allowed or summary; 1: denied; 2: error.

mistri diff <previous-app> <current-app> [--fail-on-breaking] [--json]
                              compare two App manifests or directories
                              and report breaking vs additive changes. Exit 0: ok;
                              1: breaking with --fail-on-breaking; 2: bad input.

mistri check [--app <dir>] [--app-entry <file>]
                [<db> | --db <target> | --config <path>]
                [--commands <file>] [--jobs <file>] [--policy <file>] [--bump <command>]
                [--routes [--mount <app>=<path>] [--base-path <path>]]
                [--design] [--fix] [--defaults] [--fail-on-design-warning] [--max-warnings <n>] [--warnings]
                [--no-index-check] [--no-query-check]
                [--pending [--pending-on <url>] [--migrations <dir>] [--history-table <name>]]
                [--schema-file [<schema.sql>] [--dev-url <url>]]
                [--deploy [--target <cloudflare|cloudrun|ecs>] [--replicas <n>] [--workers <n|auto>] [--connection-limit <n>] [--cpus <n>] [--strict-migrations]] [--json | --brief]
                              the authoring loop in one command: regenerate the
                              App's mistri-schema.d.ts when the database
                              has changed, its mistri-commands.d.ts from
                              its commands module and its mistri-components.d.ts
                              (a props type for each custom component, from its
                              declaration), typecheck it (file:line, the
                              mismatch, a hint) and validate it. Every
                              step runs; the errors print first, and warnings are advisory (unless --fail-on-design-warning or --max-warnings is exceeded) and print as one line a kind unless --warnings lists them in full. On PostgreSQL an indexes step names each read the App declares that no index leads (index-missing), with the CREATE INDEX that adds it; --no-index-check skips it. A queries step has the database EXPLAIN each read the App's pages would make (lists, related and grouped lists, timelines, breakdowns, figures, rollups, and the App's own list tabs, dashboard figures in each window, and segments), one a statement and never run (a READ ONLY transaction on PostgreSQL); a read it refuses is a query-invalid error naming the page:section, list, dashboard or segment, and --no-query-check skips it. --routes also
                              prints every address the App answers to, as the
                              --mount and --base-path given would serve it, and
                              fails on a route another App's place would hide;
                              --design warns where a page, form or the shell
                              will come out basic, with the fix (mistri
                              docs design), and with --fix deletes the rules a
                              restated warning names; --fix also writes into
                              an App theme's source each color or chart order
                              its failures say passes; --defaults prints what
                              each column is drawn by and each page's layout;
                              --pending judges
                              the App against a scratch copy of the database
                              with the pending migrations applied (SQLite: a
                              copy of the file; PostgreSQL: CREATE DATABASE
                              … TEMPLATE); --pending-on <url> applies them
                              to the scratch database that URL names instead
                              (a branch of the real one; no CREATEDB needed);
                              --schema-file [<schema.sql>] checks with no database
                              to reach: the file is run on a scratch database
                              (SQLite; PostgreSQL on --dev-url's server);
                              --deploy judges whether the App
                              survives a replaced container (no SQLite
                              source, auth.store or analytics.store,
                              BETTER_AUTH_SECRET / MISTRI_AUDIT_KEY /
                              MISTRI_SECRETS_KEY / MISTRI_CACHE_KEY set,
                              https MISTRI_PUBLIC_URL, service ${NAME} refs
                              present; --target <cloudflare|cloudrun|ecs>
                              adds host proxy-trust and shutdown-budget
                              checks; --replicas <n> and --workers <n|auto>
                              warn of per-process rate limits and, with
                              --connection-limit <n>, refuse pools that sum
                              past it, counting the hosts the App serves with;
                              --cpus <n> sizes pool defaults for the
                              deployment's cores, not this machine's); it also
                              warns of migrations that break the running code
                              (--strict-migrations fails on them);
                              --json prints one JSON document of
                              every finding (code, file, line, path, fix) for
                              an agent, or --brief one line per problem
                              (code file:line message — fix: …). Exit 1 could not check, 2 schema
                              types, 3 typecheck, 4 validation, 5 components,
                              6 a pending migration failed on the copy, 7 --deploy refused,
                              8 a store the App uses is not in its database
                              (store-pending: its fix is the migrate up --app
                              that makes it; validation still runs)
                              (mistri docs check-codes)

mistri schema --brief [<db> | --db <target> | --config <path>]
                              the schema as one line per table (columns with
                              short types, vocabularies, foreign keys), for an
                              agent's context; the same as --export brief
mistri explain <check-code>
                              one screen on a code check prints: what it
                              means and the fix, from the check-codes page;
                              an unknown code lists the nearest

mistri migrate new <name> [--repeatable | --number <n>]
mistri migrate status | up | validate | baseline | repair
mistri migrate diff <name> | check | squash
                [--app <dir>] [<db> | --db <target> | --config <path>]
                [--connection <name>] [--schema <name>] [--migrations <dir>]
                [--history-table <name>] [--dry-run] [--tool flyway]
                [--schema-file <path>] [--dev-url <url>] [--json]
                [--commands <file>] [--jobs <file>] [--policy <file>]
                              versioned SQL files in Flyway's format, forward
                              only: V3__add_payoff_quote.sql once, in its own
                              transaction (a failure is recorded as failed);
                              R__views.sql again when it changes. up
                              applies what is pending. With --app, status
                              prints the App's bootstrap plan and changes
                              nothing, and up carries it out: migrations,
                              the stores the App uses (with the --commands,
                              --jobs and --policy it takes), a postgres://
                              auth.store, seed (reported, never run), then
                              check (with --policy for an App with row
                              policies; without it, up says the check was
                              skipped). up --dry-run prints the plan, --json
                              prints it as data. status shows applied,
                              pending, drift made outside migrations and
                              types older than the database; validate fails
                              on any of those; baseline records an existing
                              database as version 0 and writes
                              baseline.schema.json; repair fixes the history.
                              Without --app, up, baseline and repair need
                              "writable": true on a connection a config names.
                              A lock keeps two deploys apart. Exit 1 could
                              not run, 2 files and history disagree (with
                              --app, validate: a phase pending), 3 a
                              migration failed, 4 applied but the App no
                              longer checks, 5 a store or the sign-in store
                              failed or is still absent.
                              diff writes the next V file from schema.sql
                              (beside the migrations): what they still lack,
                              for review; check exits 2 when the migrations
                              do not build schema.sql; squash folds the V
                              files into V1__baseline.sql. Atlas community,
                              pinned by sha256, fetched once into
                              .mistri/bin (MISTRI_ATLAS: your own)

mistri migrate stores status | up
                [--suite <suite.json>] [--app <dir> [--jobs <file>] [--policy <file>]]
                [<db> | --db <target> | --config <path>] [--connection <name>]
The layouts mistri keeps in a database of its own (auth, tokens, history,
inbox, command journal and sequences, tenant stores, flags, experiments, analytics,
the assistant's conversations)
move forward only here: serving never migrates, and refuses a store behind
its layout with this command in the message. status prints one line per
store; up applies each pending step in its own transaction (PostgreSQL: under
an advisory lock) and is safe to run twice. --suite adds the suite's identity,
grant, preference, flag and experiment stores and each App's connections.
With --app, up also creates every store the App uses: the inbox its notify
rules write, the record history it shows, the command journal and event
store its commands need, their effects' store; --jobs <file> adds the jobs
module's stores and delivery destinations. The one step before it serves.
A tenant App's stores are bound to its policy: with --policy <file>, up
also makes the tenant store and the journals the policy declares.
--app may name a build (mistri build): its own bundled commands and jobs
are read, and a --jobs or --commands must name the build's own.
Exit codes: 1 could not run, 2 a store refused, 3 a step failed.

mistri migrate files status | up | sweep [--app <dir>]
                [<db> | --db <target> | --config <path>] [--connection <name>]
                [--policy <file>] [--dry-run]
An App's files move to where each resource's storage says: up copies each
database-kept file to the bucket and then empties its content, or back; a
file is read from wherever its row says throughout, so up can stop and run
again anywhere. sweep deletes the bucket's objects no row names (a deleted
record's, an upload whose row was refused) that are older than an hour. status
counts both sides; --dry-run says what up or sweep would do. A tenant App
names its --policy. Credentials come from MISTRI_S3_ACCESS_KEY_ID and
MISTRI_S3_SECRET_ACCESS_KEY, else from an ECS task role or (with
MISTRI_S3_INSTANCE_ROLE=1) an EC2 instance role; a server whose App names a
bucket does not start without them. Served with --jobs, an App is swept daily by the
server itself (a tenant App tenant by tenant); otherwise run sweep daily
from cron.
Exit codes: 1 could not run, 3 some files did not move.

mistri migrate backstop status | new --app <dir> --policy <file> [--runtime <role>]
                [--connection <name>] [--config <path>]
A tenant App's row-security backstop on PostgreSQL 15 or later
(docs/postgresql.md), read from the App instead of written by hand: the
runtime role, what it may touch, and the one policy, mistri_tenant, on each
tenant table's ownership column. status says what the database lacks of it
or holds beside it: a policy missing, changed or extra, row security off or
forced, a grant gone or one the plan does not make (exit 2); new writes the next V file, tenant_backstop,
idempotent SQL that migrate up applies as the owner. The role is made
NOLOGIN: its login and password are the operator's step, never in the file.
--runtime names the role; a connection that declares the backstop gives it
by its url's user. mistri check judges the same, as its backstop step, for
a connection that declares it.
Exit codes: 1 could not run, 2 the database differs from the plan.

mistri flows start <resource> [--app <dir>] --jobs <file>
                [--where <query>] [--flow <id>] [--tenant <id> --policy <file>]
                [--dry-run] [<db> | --db <target> | --config <path>]
Start a resource's created flows on the records already there, as though
each had just been created: one keyed dispatch per record, in the App's job
store, which the server started with --jobs runs. Each flow's condition
still decides. --where narrows the records (the query language over their
own columns), --flow to one flow; a tenant App runs one --tenant at a time,
whose owner column its --policy names. Running it again starts nothing new.
Exit codes: 1 could not run.

mistri audit reads [--app <dir>] [--resource <name>] [--record <id>] [--actor <who>]
                [--tenant <id>] [--since <instant | 30m | 24h | 7d>] [--until <instant | age>]
                [--before <row id> | --after <row id>] [--limit <n> | --all] [<db> | --db <target> | --config <path>]
Prints the reads recorded for the App's resources with audit: { reads: true },
newest first (or oldest first when --after is set), one JSON object a line: id,
when, the actor, the roles it read under and, on a tenant App, its membership,
the tenant, the resource, the route (page, api, mcp, assistant, export, picker,
custom-page, related, link, or command with the command's id) and the one record
read or the query with the count and ids it returned; never a field's value.
Each flag narrows: --record by the record's key, --actor an account id,
service:<principal>, support:<operator>, api-token:<id>, link:<id> or
assistant:<account>, --since and --until an ISO instant or an age, --before a
row id to page older rows, --after a row id to resume newer rows in ascending
order, --limit at most n rows (default 1000) or --all for every matching row.
Read from the database, no server started; the store is made by mistri migrate
stores up, never here.
Exit codes: 1 could not run.

mistri secrets rotate [--app <dir>] [--dry-run] [--store <path|url>]
                      [--provider <name>...] [--operator <name>] [--json]
                      [<db> | --db <target> | --config <path>]
Re-seals stored integration secrets and delegated OIDC user tokens opened by a
retired key in MISTRI_SECRETS_KEY_PREVIOUS under the current primary
MISTRI_SECRETS_KEY, leaving already-current rows untouched. --dry-run checks
without writing, --store names the auth store, --provider names an OIDC
provider id (repeatable), --operator stamps saved_by, and --json prints counts.
Exit codes: 0 rotated cleanly, 1 unreadable rows or error, 2 bad usage.

mistri jobs run <name> [--app <dir>] --jobs <file> [--wait <seconds>]
                [--policy <file> [--tenant <id>]] [<db> | --db <target> | --config <path>]
Enqueues one run of the job in the App's job store, marked manual beside
the slots the schedule enqueues, for the server started with --jobs to run
as the job's principal, journaled as a slot's run is; waits --wait seconds
(default 60; 0 returns at once) and says how it ended. A job at times runs
one at a time: a manual run waits while the schedule's run of the job holds
its lease. A name that is not one of the App's jobs at times is refused with
the names that are. A job store with no run of a job yet starts at its next
slot: a first start never runs a missed one. On a tenant App, --policy names
its policy, as its server's start does: a job per tenant runs for the tenant
--tenant names, or once for each tenant active now, one run at a time; a
job on the platform runs once and takes no --tenant.
Exit codes: 1 could not run, 2 still waiting when --wait ran out, 3 the run
did not succeed.

mistri decide eval <decision> [--app <dir>] --jobs <file> [--provider jev|anthropic]
                [--limit <n>] [--truth "<query>"] [--max-cost <dollars>] [--max-error <share>]
                [--dry-run] [--yes] [--pin] [--json <file>] [--policy <file>] [<db> | --db <target> | --config <path>]
Asks a provider about records whose answer people settled (--truth narrows
them; default every record with the field set, at most --limit, 500) and
reports accuracy, Brier, calibration error, a reliability table and what the
declared thresholds would have applied, suggested and left. The records are
read as the decision reads them, put back as they were before the answer was
settled where the App keeps their history. It prints the count and a price
that errs high first, and asks nothing without --yes or above --max-cost
(default $5); --dry-run prints what one record would send. It writes nothing to
the database and never applies; --pin writes the model version into
decisions.lock, which is what lets a decision apply, only when the share it
would apply was wrong at most --max-error of the time (default 0.02).
Exit codes: 1 could not run, 2 not spent (no --yes, or over --max-cost),
3 --pin asked and not earned. A row-policy App names its policy with
--policy, and the records are read as its service reads them when served.

mistri tenant init [<tenant>...] [--app <dir>] --policy <file>
mistri tenant grant <email> --roles <role,...> [--tenant <id>] [--name <name>] [--days <n>] [--store <path|url>]
                [--app <dir>] --policy <file> [--operator <name>] [<db> | --db <target> | --config <path>]
mistri tenant grant --account <email>... [--tenant <id>...] --roles <role,...> [--days <n>] [--store <path|url>] [--app <dir>] --policy <file>
mistri tenant grant --from <file.csv> [--days <n>] [--store <path|url>] [--app <dir>] --policy <file>
mistri tenant brand <tenant> [--name <name>] [--preset <theme>] [--file <branding.json>]
                [--app <dir>] --policy <file> [--operator <name>] [<db> | --db <target> | --config <path>]
A tenant App's first boot, after `mistri migrate stores up --policy`, from
a shell or a deployment's one-off job. init opens the platform realm (when the App declares one) and puts each named
tenant, active; one already there is left as it is, so it runs again after a
stop part-way. grant grants <email> a membership of the platform realm, or
with --tenant of that tenant, with that realm's --roles, for --days (default
180, at most 366). An address with no account gets one in the App's auth
store, its password read from MISTRI_ACCOUNT_PASSWORD, never the command
line: --store when given, else the store the App names, else mistri dev's once dev has started the
App there, else a plain start's; grant says which. Several at once: repeat --account and --tenant (each account in each tenant), or
--from names a CSV with the header account,tenant,role (an empty tenant is the
platform realm; several roles are written a|b). Every row is checked first, so a
wrong one is listed with the others and none is applied; then each tenant is
granted in one transaction, and an account that already holds a membership there
is left as it is, so the run can be repeated. A running server reads grants from
the store as it serves: it is not restarted. brand saves a tenant's
branding, checked as a tenant admin's save is against the App's branding:
--file names the whole value (JSON), else the saved one is kept, and
--name and --preset are laid over either; the stored logo is kept. A
server sharing the cache connection reads it on its next page, one with
its own cache within five minutes. Exit codes: 1 could not run.

mistri tenant clone <source> <sandbox> [--app <dir>] --policy <file> [--samples]
mistri tenant import <sandbox> [--app <dir>] --policy <file>
mistri tenant clock <sandbox> [--app <dir>] --policy <file> --ahead <duration> [--rate <n>]
                [--operator <name>] [--commands <file>] [--jobs <file>] [<db> | --db <target> | --config <path>]
A tenant App's sandboxes: a copy of a tenant to try changes in. clone makes
a new sandbox tenant from a copy of the source's rows of every resource the
App marks clone: 'config' (and 'sample' with --samples), its ids rewritten so
the copy names only its own rows. import prints what importing the sandbox
into its source would change and what conflicts; the source's owner approves
it in Manage tenants. clock sets a sandbox's dev clock, --ahead of real time
and --rate times as fast, which its machine timers fall due on; a live tenant
has none. --operator names who ran it on the receipt (default: your login).
Exit codes: 1 could not run.

mistri tenant init [<tenant>...] [--app <dir>] --policy <file> --suite <suite.json> [--subdomain <label>]
mistri tenant host list [<tenant>] [--app <dir>] --policy <file>
mistri tenant host add <tenant> (--subdomain <label> --suite <suite.json> | --host <hostname>) [--primary]
                [--app <dir>] --policy <file> [--operator <name>]
mistri tenant host add <tenant> --custom <hostname> --suite <suite.json> [--app <dir>] --policy <file>
mistri tenant host verify <tenant> <host> --suite <suite.json> [--app <dir>] --policy <file>
mistri tenant host remove <host> [--suite <suite.json>] [--app <dir>] --policy <file>
mistri tenant host primary <tenant> <host> [--app <dir>] --policy <file>
A tenant's addresses, for a suite whose config sets `tenantDomain` or `customDomains`. With
--suite, init gives each new tenant a subdomain under the suite's
tenantDomain in the step that makes it (--subdomain chooses the label, for
one tenant; else its id). host add gives a tenant a subdomain or a whole
hostname the operator vouches for, remove takes one away, primary picks the
host its links are written with. A label that is reserved (www, api, app,
admin, mail, auth, static, assets, status, docs, the suite's own) or taken is
refused. host add --custom adds a domain the tenant owns, pending until its
CNAME and its TXT `_mistri-verify.<host>` record (list prints both) are
found; host verify checks them over DNS-over-HTTPS, as the tenant's Settings
> Domains does, and a verified domain goes live once its certificate is.
remove with --suite releases a custom domain's certificate. Each change
writes a receipt; a running suite reads it within 30 seconds. Exit codes: 1
could not run.
      --migrations <dir>      with migrate: where the files are (default
                              migrations/ in the App, or the connection's
                              "migrations": { "dir": … })
      --history-table <name>  with migrate: the history table (default
                              __mistri_schema_history, Flyway's layout;
                              flyway_schema_history to take over from Flyway)
      --connection <name>     with migrate: which configured connection
      --dry-run               with migrate up, baseline or repair: print what
                              would run and change nothing
      --tool flyway           with migrate: run it with an installed Flyway
                              (PATH or MISTRI_FLYWAY), same files and history
      --schema-file <path>    with migrate diff, check or squash: the schema
                              you want (default schema.sql beside the
                              migrations directory)
      --dev-url <url>         with migrate diff, check or squash on
                              PostgreSQL: where two scratch databases are made
                              and dropped (default the connection's server)
      --repeatable            with migrate new: an R__ file
      --number <n>            with migrate new: the V file's version as
                              written (0042), refused when a file has it

mistri shot [--app <dir>] [<route>…] [<db> | --db <target> | --config <path>]
                [--theme <id|all>] [--palette <id>]
                [--compare <look>] [--recipes <part>] [--dark | --light] [--phone | --desk | --both]
                [--click <name>] [--type <field> <text>] [--press <key>] [--wait-for <text>] [--matrix]
                [--width <px>] [--full] [--scale <1-3>] [--as <role|email> [--tenant <id>] [--store <dir>]]
                [--live] [--out <dir>] [--text]
                              serve the App on a free port with a temporary
                              config directory (and a throwaway copy of local
                              SQLite files unless --live) and write a PNG of
                              each route (with none, every view and page it
                              declares); prints each file's path. Needs
                              Playwright's Chromium. Exit 1 could not shoot,
                              2 a page threw
      --theme <id|all>        with shot or grade: a built-in look (workshop,
                              lumen, mono, sage, ledger, atelier, graphite,
                              bloom, gallery, parlor, signal) or one of the App's own themes instead of
                              the one it wears; with shot, all: every look,
                              then the App's. The menu stands where that
                              theme suggests (shell.placement) unless the
                              App's ui.shell says, which a note says
      --palette <id>          with shot or grade: one of that theme's palettes
      --compare <look>        with shot: the App's theme (or --theme) beside
                              that look, one picture of the two,
                              <page>-<mode>.png, the look left
      --recipes <part>        with shot: one page in each value of that recipe
                              part, one contact sheet,
                              <part>-<page>-<mode>.png; a note
                              names values that draw the page nearly alike
      --dark, --light         with shot: the scheme a reader picked, worn as if
                              chosen in the page's menu (without either, the
                              machine's, light)
      --click <name>          with shot: before the picture, press the button,
                              link, tab, menu item or option with that
                              accessible name, else the visible text;
                              css:<selector> names an element by selector
      --type <field> <text>   with shot: type into the box with that label or
                              placeholder (css:<selector> likewise)
      --press <key>           with shot: press a key (Enter, Escape, ArrowDown)
      --wait-for <text>       with shot: wait until that text is visible. The
                              four run in the order given, on every route; the
                              page is settled before the first and after each,
                              and a step that matches nothing in 15 seconds is
                              refused with the step and the address
      --matrix                with shot: every built-in look and the App's own,
                              light and dark, at a desk and on a phone, for the routes, as
                              <page>-<look>-<mode>-<size>.png
                              and an index.html; takes no --theme, --palette,
                              --dark, --light or size flag
      --phone, --desk, --both with shot: 390 wide, 1280 (default), or both
      --width <px>            with shot: the window's width instead (320 to
                              2560), with --desk or --phone
      --full                  with shot: the whole page, not the window
      --scale <1-3>           with shot: device pixels per CSS pixel (default 1;
                              2 is sharp); the page lays out the same
      --as <role>             with shot or grade: signed in as the earliest
                              account of that role in the App's local store,
                              in a copy of it, else a fresh one (no rows)
      --as <email>            with shot or grade: signed in as that account,
                              already made (mistri dev or a local start),
                              with the password in MISTRI_AS_PASSWORD; its
                              store is copied, never written
      --as <role>:<email>     with shot or grade: a new account of that role
                              with that address, verified, in the run's own
                              store: the household a row policy finds by
                              email (not admin; not a tenant App)
      --tenant <id>           with shot --as on a tenant App: the tenant the
                              role is held in, a temporary membership in the
                              App's tenant store (journaled), revoked when the
                              shot ends; a platform role needs none
      --store <dir>           with --as: read the accounts from this folder instead
                              of <app>/.mistri/ and a plain start's. It is shaped
                              as an App's .mistri/ (its config/ holds the auth
                              store): a copy of one, or another checkout's. The
                              only store read; never written
      --out <dir>             with shot: where every file goes, from the current
                              directory (default mistri-shots/<app> in the