Krispy AI
reference

CLI reference

the `krispy` commands and the env vars that configure them.

krispy CLI

the self-host CLI. it manages your bot's knowledge base (system prompt) by POSTing to the edge Worker's /api/tenant/config route โ€” no hand-written wrangler kv calls. single-file core, no arg-parser dependency.

commands

commandwhat it does
krispy initguided first-run wizard โ€” Telegram โ†’ train โ†’ embed โ†’ next steps. persists each step via POST /api/tenant/config.
krispy set-kbase <file>write <file>'s contents as the bot's system prompt (POST /api/tenant/config).
krispy logo <file>remove a logo's background locally (no cloud) โ†’ print a paste-ready theme.avatar data URI.
krispy kb-suggestionslist the pending relearning suggestions โ€” the approval inbox (GET /api/tenant/kb-suggestions).
krispy kb-approve <id>approve a suggestion into kbSources + bump kbVersion (POST /api/tenant/kb-approve).
krispy kb-dismiss <id>drop a suggestion, no KB change (POST /api/tenant/kb-dismiss).
krispy devrun the edge Worker locally โ€” a thin wrapper over wrangler dev in services/edge.

the kb-* commands take an optional --site <id> flag (โ†’ ?s= / siteId) to scope a single site; omit it for the tenant's default site.

running krispy with no command (or an unknown one) prints usage.

krispy init

the terminal-native counterpart to the Cloud dashboard onboarding. four steps, each persisted as it completes; re-run any time โ€” the Worker merges, so it never clobbers fields you've already set.

  1. connect Telegram โ€” BotFather guide โ†’ paste the bot token, validated live via Telegram's getMe (green โœ“ @yourbot or red retry) โ†’ supergroup-with-Topics + add-the-bot-as-admin guide โ†’ chat id. persists botToken + chatId.
  2. train your bot โ€” a knowledge-base file, a starter template, or skip. persists systemPrompt.
  3. embed the widget โ€” prints the copy-paste <script> snippet with your data-api + data-tenant baked in.
  4. next steps โ€” run/deploy commands and how to test the loop.

init needs a real terminal (TTY); in CI or piped input it exits with guidance instead of hanging. it's the only command with dependencies (@clack/prompts, picocolors), lazy-loaded so the core stays lean.

the self-host counterpart to Krispy Cloud's AI logo background-removal โ€” fully local, no cloud call and no API key. it removes the background with a corner chroma-key (samples the four corners; if they agree on one background color, flood-fills that region to transparent) and prints a ready-to-paste data:image/png;base64,โ€ฆ URI on stdout:

krispy logo ./logo.png | pbcopy

paste the result as theme.avatar in your tenant config (the dashboard, or a POST /api/tenant/config body) โ€” the widget renders it in both the header and the launcher badge, and the edge write-path already accepts data:image/(png|webp|jpeg) avatars up to 48KB. accepts .png/.jpg/.jpeg/.webp/.svg and downscales to 144px (~5โ€“30KB). an already-transparent image (SVG / transparent PNG) passes through untouched, and a photographic / busy background it can't cleanly key is kept as-is โ€” removal never mangles a logo.

corner chroma-key is the documented floor: it excels at logos on a flat background. the upgrade path is local ONNX segmentation (modnet) if arbitrary backgrounds ever justify a large model download. logo depends on sharp, lazy-loaded so the CLI core stays dependency-free at import.

krispy kb-suggestions / kb-approve / kb-dismiss

the self-host counterpart to Krispy Cloud's /knowledge approval inbox, over the same secret-authed routes. when a handed-off session hands back to the AI and a human answered something the bot couldn't, the edge proposes a Qโ†’A suggestion. nothing reaches the bot's knowledge until you approve it โ€” human-in-the-loop by design, so a visitor can't poison the KB.

krispy kb-suggestions          # list pending suggestions (id + Q + A)
krispy kb-approve sug_abc123   # append it to kbSources (+ bump kbVersion), drop it
krispy kb-dismiss  sug_abc123  # drop it, no KB change

each command scopes to the tenant's default site; pass --site <id> (โ†’ ?s= / siteId) to target a specific site. all three require TENANT_SYNC_SECRET; kb-approve on an unknown id prints a clear error and exits non-zero.

env / config

vardefaultmeaning
KRISPY_APIhttp://localhost:8787your edge Worker base URL
KRISPY_TENANTselftenant id
TENANT_SYNC_SECRETโ€”must match the Worker's TENANT_SYNC_SECRET; sent as x-tenant-sync-secret. set-kbase/init fail with a clear message if it's missing.

run from the repo (no publish needed)

KRISPY_API=https://krispy-edge.YOU.workers.dev \
TENANT_SYNC_SECRET=... \
  bun packages/cli/src/index.ts set-kbase ./kbase.md

On this page