CLI
Run the package binary through its package name:
npx @mordn/chat-widgetWith no command, or with init, the wizard detects src/app versus app and
creates the catch-all route, auth stub, Drizzle config, and environment template.
Existing files require confirmation before overwrite.
Scaffold checklist
After generation:
- Implement
getChatUserIdfrom a verified server session. - Install the provider, database, and optional storage peer dependencies you use.
- Run
npx drizzle-kit pushfor the Drizzle store. - Create a private
chat-attachmentsbucket when using Supabase storage. - Mount
<ChatWidget>and import the precompiled stylesheet.
Knowledge commands
Commands load chat-widget.config.{mjs,js,cjs}. Override the path with
--config or -c.
| Command | Purpose |
|---|---|
init | Scaffold the backend |
ingest [urls...] | Ingest config sources or ad-hoc URLs |
sync | Re-ingest configured sources idempotently |
status | Show per-source status and chunk counts |
list | List indexed sources |
eval --file evals.json | Run retrieval evaluation cases |
npx @mordn/chat-widget ingest https://docs.example.com/guide
npx @mordn/chat-widget ingest --llms https://docs.example.com/llms.txt
npx @mordn/chat-widget status -c ./chat-widget.config.mjs
npx @mordn/chat-widget eval --file evals.json
npx @mordn/chat-widget eval -f evals.json --json--llms is repeatable. Direct .md and .mdx URLs use heading-aware Markdown
ingestion. eval exits nonzero when any retrieval case fails, so it can gate CI;
--json emits machine-readable output.
Ingestion is an admin operation
The CLI uses a write-capable knowledge store. Do not run it through the end-user chat request path and never derive namespaces from untrusted request input.
See Knowledge / RAG for configuration and source types.