Skip to content

feat: advanced search#76

Merged
Kinfe123 merged 3 commits intomainfrom
feat/advanced-search-provider
Apr 9, 2026
Merged

feat: advanced search#76
Kinfe123 merged 3 commits intomainfrom
feat/advanced-search-provider

Conversation

@Kinfe123
Copy link
Copy Markdown
Contributor

@Kinfe123 Kinfe123 commented Apr 9, 2026

closes #25


Summary by cubic

Adds a provider-agnostic advanced search with a shared adapter pipeline across the UI and MCP, plus a new Next API entry and a CLI to sync external indexes. Env-driven setup lets projects switch between built-in search, Typesense (keyword or hybrid via Ollama), Algolia, MCP, or a custom adapter.

  • New Features

    • Search adapters: simple (built-in), typesense (keyword or hybrid via Ollama), algolia, mcp, custom
    • Shared pipeline for UI and MCP search; Astro, SvelteKit, Nuxt, and TanStack Start now use performDocsSearch
    • New exports: performDocsSearch, buildDocsSearchDocuments, resolveSearchRequestConfig, and adapter factories
    • defineDocs() now accepts search; examples/docs use env-driven setup
    • Next: new @farming-labs/next/api with createDocsAPI and createDocsMCPAPI; generated routes forward search and ai
    • CLI: docs search sync to push content to Typesense or Algolia (reads .env), with --typesense/--algolia flags
  • Migration

    • Next: switch imports to @farming-labs/next/api; pass search and ai to createDocsAPI/createDocsMCPAPI
    • Add search to docs.config.ts (or keep defaults for built-in search)
    • For external providers, set env vars (e.g. TYPESENSE_* or ALGOLIA_*), then run pnpm exec docs search sync if pre-indexing is desired

Written for commit 0516c1d. Summary will update on new commits.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment Apr 9, 2026 0:37am

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 9, 2026

Open in StackBlitz

@farming-labs/astro

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro@76

@farming-labs/astro-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro-theme@76

@farming-labs/docs

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/docs@76

@farming-labs/theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/theme@76

@farming-labs/next

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/next@76

@farming-labs/nuxt

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt@76

@farming-labs/nuxt-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt-theme@76

@farming-labs/svelte

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte@76

@farming-labs/svelte-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte-theme@76

@farming-labs/tanstack-start

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/tanstack-start@76

commit: 0516c1d

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 55 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="README.md">

<violation number="1" location="README.md:130">
P2: Replace the machine-local absolute path with a repository-relative link so the README link works for all users.</violation>
</file>

<file name="packages/docs/src/cli/config.ts">

<violation number="1" location="packages/docs/src/cli/config.ts:26">
P2: `readStringProperty` uses an unescaped, unbounded dynamic regex key, which can match the wrong property name.</violation>
</file>

<file name="packages/docs/src/search.ts">

<violation number="1" location="packages/docs/src/search.ts:38">
P2: Image markdown is not stripped correctly because the link regex runs first. For `![alt](url)`, the link regex matches the inner `[alt](url)`, producing `!alt` instead of `alt`. Swap these two lines so the image regex runs before the link regex.</violation>
</file>

<file name="packages/docs/src/mcp.ts">

<violation number="1" location="packages/docs/src/mcp.ts:738">
P2: Preserve `chunking` (and any other relevant search options) when converting a self-referential MCP search config to the simple provider. Otherwise user-defined chunking is ignored for the search tool.</violation>
</file>

<file name="packages/fumadocs/src/docs-command-search.tsx">

<violation number="1" location="packages/fumadocs/src/docs-command-search.tsx:36">
P2: `stripSearchPreview` strips normal links before images, which leaves a leading `!` for image markdown (e.g. `![alt](url)` becomes `!alt`). Strip images first (or exclude `!`-prefixed links) so previews are cleaned correctly.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/docs/src/search.ts">

<violation number="1" location="packages/docs/src/search.ts:324">
P1: Record-size trimming can still exceed the byte cap because it measures raw content bytes, not JSON-encoded bytes.</violation>

<violation number="2" location="packages/docs/src/search.ts:842">
P2: Algolia indexing now omits `locale`/`framework`/`version`/`tags`, causing metadata regression versus other adapters and previous behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

const baseRecord = { ...record, content: "" };
const fixedBytes = sizeOf(baseRecord);
const remainingBytes = Math.max(ALGOLIA_MAX_RECORD_BYTES - fixedBytes - 32, 0);
record.content = trimTextToBytes(document.content, remainingBytes);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Record-size trimming can still exceed the byte cap because it measures raw content bytes, not JSON-encoded bytes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/docs/src/search.ts, line 324:

<comment>Record-size trimming can still exceed the byte cap because it measures raw content bytes, not JSON-encoded bytes.</comment>

<file context>
@@ -274,6 +275,57 @@ function cleanSearchResultText(value?: string): string | undefined {
+  const baseRecord = { ...record, content: "" };
+  const fixedBytes = sizeOf(baseRecord);
+  const remainingBytes = Math.max(ALGOLIA_MAX_RECORD_BYTES - fixedBytes - 32, 0);
+  record.content = trimTextToBytes(document.content, remainingBytes);
+
+  return record;
</file context>
Fix with Cubic

body: JSON.stringify({
requests: context.documents.map((document) => ({
action: "addObject",
body: buildAlgoliaRecord(document),
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Algolia indexing now omits locale/framework/version/tags, causing metadata regression versus other adapters and previous behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/docs/src/search.ts, line 842:

<comment>Algolia indexing now omits `locale`/`framework`/`version`/`tags`, causing metadata regression versus other adapters and previous behavior.</comment>

<file context>
@@ -787,20 +839,7 @@ export function createAlgoliaSearchAdapter(config: AlgoliaDocsSearchConfig): Doc
-                version: document.version,
-                tags: document.tags,
-              },
+              body: buildAlgoliaRecord(document),
             })),
           }),
</file context>
Fix with Cubic

@Kinfe123 Kinfe123 merged commit a137452 into main Apr 9, 2026
9 checks passed
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.

advanced search's with providers agnostic interface

1 participant