Skip to content

feat: add DocsGPT semantic search with backwards-compatible fallback#18

Open
critesjosh wants to merge 1 commit intomainfrom
feat/docsgpt-semantic-search
Open

feat: add DocsGPT semantic search with backwards-compatible fallback#18
critesjosh wants to merge 1 commit intomainfrom
feat/docsgpt-semantic-search

Conversation

@critesjosh
Copy link
Copy Markdown
Collaborator

Summary

  • Adds DocsGPT as an optional semantic search backend for aztec_search_docs and aztec_lookup_error, activated when API_KEY is set
  • Preserves full backwards compatibility: schema always advertises section/maxResults, and DocsGPT errors gracefully fall back to ripgrep over local docs
  • aztec_lookup_error gains a semantic fallback that searches documentation when the static error catalog has no matches

Review feedback addressed

  • [P1] Schema regression: section and maxResults are always present in the advertised schema regardless of DocsGPT config. maxResults maps to chunks in semantic mode (chunks ?? maxResults ?? 5). Schema descriptions clarify that section applies to local fallback only.
  • [P2] No fallback on DocsGPT failure: DocsGPT errors now fall through to ripgrep search instead of returning failure immediately. If local docs are cloned, the search still works; if not, the user gets the standard "run aztec_sync_repos" message.

Test plan

  • tsc --noEmit passes
  • vitest run tests/tools/search.test.ts — 19 tests pass, including:
    • Semantic results returned from DocsGPT client
    • chunks parameter respected
    • maxResults used as fallback for chunks in semantic mode
    • chunks takes precedence over maxResults when both provided
    • DocsGPT error falls back to ripgrep when local docs exist
    • DocsGPT error returns not-cloned message when no local docs
  • vitest run tests/utils/error-lookup.test.ts — 15 tests pass

🤖 Generated with Claude Code

Integrate DocsGPT as an optional semantic search backend for documentation
queries and error lookup fallback, activated when API_KEY is set. Preserves
the existing ripgrep-based search as a fallback when DocsGPT is unavailable
or unconfigured, ensuring no public-contract regression for existing callers.

- Add DocsGPT HTTP client (src/backends/docsgpt-client.ts)
- aztec_search_docs uses semantic search when API_KEY is configured,
  falls back to ripgrep on DocsGPT errors if local docs are cloned
- aztec_lookup_error falls back to semantic doc search when static
  catalog produces no matches
- Schema always advertises section/maxResults for backwards compat;
  descriptions clarify semantic-mode behavior
- maxResults maps to chunks in semantic mode (chunks ?? maxResults ?? 5)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant