Skip to content

refactor: consolidate provider architecture and shared search logic#9

Merged
emilsvennesson merged 2 commits intomainfrom
refactor/provider-folders-shared-dispatch
Apr 4, 2026
Merged

refactor: consolidate provider architecture and shared search logic#9
emilsvennesson merged 2 commits intomainfrom
refactor/provider-folders-shared-dispatch

Conversation

@emilsvennesson
Copy link
Copy Markdown
Owner

Summary

  • Reorganize providers into folder-based modules (anthropic/, openai/, copilot/) and add shared provider utilities for OpenAI-compatible client/response handling and error formatting.
  • Centralize provider detection/metadata in a registry and replace branching dispatch in src/index.ts with a provider adapter map.
  • Refactor config/provider resolution to reuse shared scanning logic, split constants by ownership (provider-local vs shared), and remove the old global src/constants.ts.
  • Shift import sorting responsibility to Oxfmt by adding .oxfmtrc.json and disabling sort-imports in Oxlint.

Validation

  • bun run format
  • bun run check
  • bun run build

Copilot AI review requested due to automatic review settings April 4, 2026 21:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) and src/providers/index.ts (adapter-based dispatch), and rewires src/index.ts to use them.
  • Refactors provider scanning/resolution in src/config.ts and removes the legacy global src/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.

@emilsvennesson emilsvennesson merged commit 85d7e3c into main Apr 4, 2026
1 check passed
@emilsvennesson emilsvennesson deleted the refactor/provider-folders-shared-dispatch branch April 4, 2026 21:22
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.

2 participants