Skip to content

feat: add a visitor chat stage to sanity-kb-setup - #13

Merged
chiburoboto merged 7 commits into
mainfrom
skill/sanity-kb-setup-ask-box
Sep 21, 2026
Merged

chiburoboto merged 7 commits into
mainfrom
skill/sanity-kb-setup-ask-box

Conversation

@chiburoboto

Copy link
Copy Markdown
Contributor

Adds stage 7 to sanity-kb-setup: once the Knowledge Base is Clean, the skill offers to add a visitor chat to the user's site, either a chatbot or an FAQ ask box, answering from the Knowledge Base.

The new references/visitor-chat.md is guidance, not code. It tells the agent what to check before building, what to walk the user through in their own stack, and how to test that answers come from the Knowledge Base rather than the model's own knowledge.

SKILL.md and connect-agents.md now point at it. Version goes to 1.3.0.

Add stage 7, references/ask-box.md. After stage 6, or once the Knowledge
Base is Clean, the skill asks the user whether visitors should be able to
ask their own questions on the FAQ page. On a yes it adds a server route
that answers from the Knowledge Base over MCP through AI Gateway, and an
ask item styled as the site's last FAQ item, built with useCompletion.

The offer is skipped while conflicts are kept on purpose, since visitors
would get the planted wrong answers. Code is taken from the Fernhouse
demo and uses the non-deprecated AI SDK 7 streaming helpers.
The ask box no longer assumes Vercel AI Gateway. A new 'Choose the
model' section puts the provider in lib/ask-model.ts, uses the one the
project already has or asks, and gives the package, key variable and
factory line for AI Gateway, Anthropic, OpenAI, Google, Mistral,
OpenRouter and any OpenAI-compatible gateway. Every line typechecks
against the current packages.

Pin baseURL for providers that read a *_BASE_URL variable. A coding
agent's session can set ANTHROPIC_BASE_URL, and a dev server started
from it would send the site's key to the wrong address.

The route now awaits request.json() and returns a separate plain-text
error for bad JSON, a missing question and a bad length. Test step 2
checks answer details against the entries instead of a log the route
doesn't write.
…tions in the client

Each exit in the ask box route now returns Response.json({ error }, { status })
directly. The fail() helper and the hand-built new Response are gone.
useCompletion puts the raw error body in error.message, so the component
parses it and shows the error field instead of raw JSON.

The component now checks the same 3 to 300 character limits as the
route, so an empty or whitespace-only question never reaches the
server. The route keeps its own checks for direct callers.
The skill no longer prescribes how the ask box looks or where it sits:
no FAQ-item markup, row heights, placeholder copy, icon toggle, support
line or open animation. Stage 7 now asks the user where it goes and how
it should look, and says to match the components already on that page.

What stays is what decides whether answers are right and safe: the route,
the model, the limits, the streamed rendering, the error field, keeping
hidden content out of the tab order, and the tests.
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0946144a-5970-4e90-b3dd-253591c9c318


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread skills/sanity-kb-setup/references/visitor-chat.md Outdated
@diffy-eve

diffy-eve Bot commented Sep 21, 2026

Copy link
Copy Markdown
Risk Auto-approval Confidence
0/100 · Low No, a human needs to read it 95%

Why not approved: the blast radius is unknown, which is the case we know least about

Stated, not enacted: this review is posted as a comment and approves nothing.

Reviewed 98d95db — 3 findings (0 open, 3 resolved)

Comment thread skills/sanity-kb-setup/references/visitor-chat.md Outdated
Comment thread skills/sanity-kb-setup/references/visitor-chat.md Outdated
@chiburoboto
chiburoboto merged commit 94b7f02 into main Sep 21, 2026
3 checks passed
@chiburoboto
chiburoboto deleted the skill/sanity-kb-setup-ask-box branch September 21, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants