refactor: consolidate provider architecture and shared search logic#9
Merged
emilsvennesson merged 2 commits intomainfrom Apr 4, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the provider implementation to a folder-based architecture (Anthropic/OpenAI/Copilot), introduces shared utilities for OpenAI-compatible providers, and centralizes provider detection/metadata so the plugin entry point can dispatch via a provider adapter map instead of branching logic.
Changes:
- Consolidates shared search request/response helpers and OpenAI-compatible response parsing into
src/providers/shared/*. - Introduces
src/providers/registry.ts(provider rules + detection) andsrc/providers/index.ts(adapter-based dispatch), and rewiressrc/index.tsto use them. - Refactors provider scanning/resolution in
src/config.tsand removes the legacy globalsrc/constants.ts; updates formatting tooling to let Oxfmt own import sorting.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/providers/shared/search.ts | Adds shared search constants + helpers (input building, structured response). |
| src/providers/shared/openai-compatible.ts | Adds shared OpenAI/Copilot client creation and response text/hit extraction utilities. |
| src/providers/shared/errors.ts | Adds shared fallback error formatting for providers. |
| src/providers/registry.ts | Centralizes provider metadata and detection (npm package + provider ID hints). |
| src/providers/openai/index.ts | Rehomes OpenAI provider implementation to folder module using shared helpers. |
| src/providers/openai.ts | Removes legacy OpenAI provider implementation file. |
| src/providers/index.ts | Adds provider adapter map for unified dispatch + error formatting. |
| src/providers/copilot/index.ts | Rehomes Copilot provider implementation to folder module using shared helpers. |
| src/providers/copilot/constants.ts | Adds Copilot-specific constants scoped to Copilot provider module. |
| src/providers/copilot/auth.ts | Updates Copilot auth helper to import provider-local constants. |
| src/providers/copilot.ts | Removes legacy Copilot provider implementation file. |
| src/providers/anthropic/index.ts | Updates Anthropic provider to use shared search helpers and shared error formatting. |
| src/providers/shared/errors.ts | Introduces shared error helper used across providers. |
| src/index.ts | Replaces branching provider dispatch/detection with registry + adapter dispatch; keeps model resolution logic but simplifies priority handling. |
| src/constants.ts | Removes legacy global constants module (constants now owned by shared/provider modules). |
| src/config.ts | Refactors provider scanning/resolution to reuse shared detection + scanning helpers and to support new registry approach. |
| AGENTS.md | Updates repo structure documentation to match the new provider module layout. |
| .oxlintrc.json | Disables sort-imports in oxlint (import sorting delegated to formatter). |
| .oxfmtrc.json | Adds Oxfmt import grouping config for consistent import ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
anthropic/,openai/,copilot/) and add shared provider utilities for OpenAI-compatible client/response handling and error formatting.src/index.tswith a provider adapter map.src/constants.ts..oxfmtrc.jsonand disablingsort-importsin Oxlint.Validation
bun run formatbun run checkbun run build