Appearance
Running & Deploying the Docs
This page is the full, copy-paste walkthrough for running this docs site on your machine and putting it online. Run every command from the repo root (Kairo/), not from inside docs-site/.
Two ways to run locally (pick the right one)
| You want to… | Use | Chat works? |
|---|---|---|
| Write/preview pages fast (hot reload) | npm run docs:dev | ❌ No |
| Test the AI chat too | wrangler pages dev (below) | ✅ Yes |
The AI chat needs the Cloudflare Function in functions/api/chat.ts. npm run docs:dev is just VitePress — it never serves /api/chat, so the chat button will fail there. That's expected, not a bug.
Preview content only (no chat)
bash
npm run docs:devOpens a hot-reloading dev server (the URL is printed, usually http://localhost:5173). Edit any .md file and it updates instantly. Best for writing.
Run locally with the AI chat
You need a Gemini API key (get one free).
Create a file named
.dev.varsin the repo root (same folder aspackage.json). One line — quotes optional:GEMINI_API_KEY=AIzaSy...your-keyIt's already gitignored, so it won't be committed.
Build the static site (Wrangler serves the built output, not live source):
bashnpm run docs:buildServe it with Cloudflare's local runtime, which runs the Function:
bashnpx wrangler pages dev docs-site/.vitepress/distFirst run may prompt to install
wrangler— accept. It auto-loads.dev.varsand auto-detects thefunctions/folder.Open the printed URL — usually
http://localhost:8788(the8788one, not thedocs:devport). Click the chat button and ask something.
Chat says "function not running" / 404?
You're viewing the docs:dev server. Chat only works under wrangler pages dev. Re-run steps 2–3 and open the :8788 URL.
Changed a page and don't see it under Wrangler?
Wrangler serves a build, not live source. Re-run npm run docs:build after edits. (For fast content iteration, use docs:dev instead and just don't test chat there.)
First-time deploy to Cloudflare Pages
Do this once. After it's set up, deploys are automatic (next section).
Push your latest work so the remote is current:
bashgit add -A git commit -m "docs: update" git pushGo to dash.cloudflare.com and sign in (free account is fine).
Left sidebar → Workers & Pages → Create → Pages tab → Connect to Git.
Authorize Cloudflare for GitHub, then select the
SeiynJie/Kairorepo → Begin setup.On the build-config screen set:
- Production branch:
main - Framework preset:
None(VitePress isn't in the preset list — leave it None) - Build command:
npm run docs:build - Build output directory:
docs-site/.vitepress/dist
- Production branch:
Expand Environment variables (advanced) → Add variable:
- Name:
GEMINI_API_KEY - Value: your key → click Encrypt (stores it as a secret).
- Name:
Click Save and Deploy. Wait ~1–2 min.
You get a live URL like
https://kairo-xyz.pages.dev. Open it — docs load, and chat works because the repo-rootfunctions/folder deploys automatically alongside the site.
Forgot the env var?
Chat will just say "AI chat isn't configured yet." Add it later under the project's Settings → Variables and Secrets, then redeploy.
Ongoing deploys (automatic)
Every push to main triggers a rebuild + redeploy. Your PC can be off — the site stays online.
bash
git add -A
git commit -m "docs: update <page>"
git push # Cloudflare rebuilds automaticallyWatch build logs under Workers & Pages → your project → Deployments. A red build is almost always a dead internal link (npm run docs:build fails loudly on those — catch it locally first).
Lock it down
The *.pages.dev URL is public to anyone who has it. To restrict the site to only your GitHub account, see Access Control.