Conversation
Deploying head-start with
|
| Latest commit: |
ebb690d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1232ca60.head-start.pages.dev |
| Branch Preview URL: | https://feat-ai-search.head-start.pages.dev |
anareyna
marked this pull request as draft
May 19, 2026 10:16
anareyna
marked this pull request as ready for review
May 21, 2026 08:25
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an AI Search prototype to Head Start by introducing (1) a post-deploy indexer that uploads site markdown into Cloudflare AI Search (with optional KV hash caching) and (2) a server-side /api/ai-search proxy to query AI Search without exposing the API token.
Changes:
- Add
/api/ai-searchPOST proxy with SSE streaming by default and optional?format=jsonresponse reshaping. - Add
scripts/index-ai-search.ts+ GitHub Actions workflow to crawl the sitemap and (re)index pages in Cloudflare AI Search, optionally skipping unchanged pages via KV. - Add
parseFrontmatter()(with tests) to extract metadata from the markdown frontmatter for AI Search item metadata.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/pages/api/ai-search.ts |
Adds the AI Search query proxy endpoint (streaming + JSON mode). |
src/lib/frontmatter.ts |
Adds parseFrontmatter() to read back fields emitted by buildFrontmatter(). |
src/lib/frontmatter.test.ts |
Adds unit tests covering parseFrontmatter() round-trips/escaping. |
scripts/index-ai-search.ts |
Adds the sitemap crawler + uploader indexer with optional KV hash cache and pruning. |
package.json |
Adds index:ai-search script entry. |
env.d.ts |
Adds typings for new AI Search-related env vars. |
docs/getting-started.md |
Documents setup steps for enabling AI Search and the indexer workflow. |
docs/decision-log/2026-05-20-ai-search-prototype.md |
Records the rationale/architecture for the prototype. |
astro.config.ts |
Declares new server-side secret env schema for the runtime proxy. |
.github/workflows/node-ci.yml |
Adds empty placeholders for new env vars in CI jobs. |
.github/workflows/index-ai-search.yml |
Adds post-deploy indexing workflow triggered by deployment_status. |
.env.example |
Documents new optional env vars for AI Search. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JopMolenaar
force-pushed
the
feat-ai-search
branch
from
June 30, 2026 08:09
8cba6f9 to
35d564a
Compare
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
head-start-worker | ebb690d | Jul 22 2026, 07:50 AM |
JopMolenaar
self-requested a review
July 10, 2026 07:50
JopMolenaar
force-pushed
the
feat-ai-search
branch
from
July 10, 2026 07:54
cd56f4a to
3270a82
Compare
JopMolenaar
added a commit
that referenced
this pull request
Jul 10, 2026
Depends on #379 Adds the "Ask AI" page so people can actually use the AI search we wired up in the previous PR. Type a question, get an answer with sources. <img width="1471" height="991" alt="Screenshot 2026-05-27 at 09 21 26" src="https://github.com/user-attachments/assets/342f03f2-d239-4f43-8fae-7fdcbb40f6ca" /> ## What's added - A new **Ask AI** page at `/[locale]/ask/`. Question box at the top, answer streams in below as it's written, sources show up alongside it. - An **Ask AI** link in the main nav, right next to Search. Same link in the mobile nav. - The answer renders as proper markdown while it's still streaming, so code blocks and lists look right from the first chunk, not just when it finishes. - You can share a question via URL: `/en/ask/?query=...` runs the search on page load, and submitting the form keeps the URL in sync. Good for linking people to "here's the answer I got". ## How to test Check cloudfare preview link https://feat-ai-search-component.head-start.pages.dev/en/ask or 1. Run the app locally (env vars from the [previous PR](ttps://github.com//pull/379) need to be set). 2. Visit `/en/ask/`. Ask something the site would know about. You should see "Thinking…", then the answer appear word by word, with the sources it used. 3. Try a deep link like `/en/ask/?query=How%20do%20I%20add%20a%20new%20locale%3F`. It should run on its own. 4. Check the item is in header nav: "Ask AI" ## Checklist - [x] Self-reviewed - [x] Easy to review (one component, one page, one nav link) - [ ] Notified a reviewer --------- Co-authored-by: Jop Molenaar <jopmolenaar@icloud.com>
JopMolenaar
approved these changes
Jul 15, 2026
feat: ai search query proxy endpoint feat: <ai-search> web component + demo page
…getting started guide
…able, entry entries spelling logic addd
Depends on #379 Adds the "Ask AI" page so people can actually use the AI search we wired up in the previous PR. Type a question, get an answer with sources. <img width="1471" height="991" alt="Screenshot 2026-05-27 at 09 21 26" src="https://github.com/user-attachments/assets/342f03f2-d239-4f43-8fae-7fdcbb40f6ca" /> - A new **Ask AI** page at `/[locale]/ask/`. Question box at the top, answer streams in below as it's written, sources show up alongside it. - An **Ask AI** link in the main nav, right next to Search. Same link in the mobile nav. - The answer renders as proper markdown while it's still streaming, so code blocks and lists look right from the first chunk, not just when it finishes. - You can share a question via URL: `/en/ask/?query=...` runs the search on page load, and submitting the form keeps the URL in sync. Good for linking people to "here's the answer I got". Check cloudfare preview link https://feat-ai-search-component.head-start.pages.dev/en/ask or 1. Run the app locally (env vars from the [previous PR](ttps://github.com//pull/379) need to be set). 2. Visit `/en/ask/`. Ask something the site would know about. You should see "Thinking…", then the answer appear word by word, with the sources it used. 3. Try a deep link like `/en/ask/?query=How%20do%20I%20add%20a%20new%20locale%3F`. It should run on its own. 4. Check the item is in header nav: "Ask AI" - [x] Self-reviewed - [x] Easy to review (one component, one page, one nav link) - [ ] Notified a reviewer --------- Co-authored-by: Jop Molenaar <jopmolenaar@icloud.com>
JopMolenaar
force-pushed
the
feat-ai-search
branch
from
July 22, 2026 07:49
cf81475 to
ebb690d
Compare
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 the indexer and query API for AI search and chat. UI in the next PR.
What's added
scripts/index-ai-search.ts(run vianpm run index:ai-search) walks the sitemap, fetches each page as markdown from the existing/api/content/*.mdendpoint, uploads to Cloudflare AI Search..github/workflows/index-ai-search.ymlruns the indexer automatically after every successful production deploy. No manual work once secrets are set.POST /api/ai-searchproxies the question to Cloudflare AI Search and hides the API token. Streams the answer back by default. Pass?format=jsonfor a single{ answer, sources }object that's easy to read in curl.KV hash cache so re-runs skip pages that haven't changed. Optional. Leave the KV namespace ID empty to fall back to "re-upload everything."
Docs: new "Enable AI Search" section in
docs/getting-started.md.How to test
1. For easy testing use the Cloudflare Playground. No setup. Dashboard → AI → AI Search →
head-start-site→ Playground → Chat tab. Type a question, read the answer. Best way to check if the AI's answers actually make sense.The Playground has two tabs. Use Chat to test what our endpoint does (question in, AI answer out, plus the sources it used). The Search tab returns raw matching content with no AI answer. Useful for debugging retrieval, not what we ship.
2. Curl the JSON mode against a preview deploy (once env vars are added, see below):
Returns:
{ "answer": "To add a new locale, ...", "sources": [ { "url": "...", "title": "Internationalization (i18n)" } ] }The default response (no
?format=json) is a streaming SSE response. That's what the UI will consume in a next PR. Hard to read by eye, so use JSON mode for manual testing.3. Run it locally. Setup in docs/getting-started.md. Reuse the
head-start-siteinstance andAI_SEARCH_HASHESKV namespace already on the Voorhoede CF account (don't create duplicates).What still needs to happen (not code)
GitHub repo secrets for the auto-indexer workflow. Four values listed in the docs.✅Cloudflare Pages env vars (prod + preview) for the live proxy. Three values listed in the docs.✅Until these are done, the auto-indexer and the live preview proxy won't work. Local + Playground work today.
What's NOT in this PR (by design)
Decision log
docs/decision-log/2026-05-20-ai-search-prototype.mdcovers the why.Checklist
docs/getting-started.md)