CLI

Run the package binary through its package name:

code
npx @mordn/chat-widget

With 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:

  1. Implement getChatUserId from a verified server session.
  2. Install the provider, database, and optional storage peer dependencies you use.
  3. Run npx drizzle-kit push for the Drizzle store.
  4. Create a private chat-attachments bucket when using Supabase storage.
  5. Mount <ChatWidget> and import the precompiled stylesheet.

Knowledge commands

Commands load chat-widget.config.{mjs,js,cjs}. Override the path with --config or -c.

CommandPurpose
initScaffold the backend
ingest [urls...]Ingest config sources or ad-hoc URLs
syncRe-ingest configured sources idempotently
statusShow per-source status and chunk counts
listList indexed sources
eval --file evals.jsonRun retrieval evaluation cases
code
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.