feat: add a visitor chat stage to sanity-kb-setup - #13
Merged
Merged
Conversation
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.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 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. Comment |
Stated, not enacted: this review is posted as a comment and approves nothing. Reviewed |
anshroboto
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdis 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.mdandconnect-agents.mdnow point at it. Version goes to 1.3.0.