feat: add provider abstraction for review backends

This commit is contained in:
2026-06-12 19:23:45 +01:00
parent 1b8edb7eba
commit 732d6edd38
22 changed files with 1432 additions and 882 deletions
+22 -17
View File
@@ -425,33 +425,35 @@ Rules:
## 12. OpenAI Integration
Use OpenAI as a second-opinion provider only.
Use OpenAI as a second-opinion provider only. The integration lives behind the provider abstraction layer:
```text
Provider: OpenAI
API: Responses API
Model: configurable
Temperature: low
Output: structured text
src/providers/factory.js — createChatProvider(config) validates and returns configured provider
src/providers/openai.js — openaiProvider.send(input, config) thin adapter
src/openai/client.js — createOpenAIClient(config) low-level client
src/openai/responses.js — sendOpenAIResponse(client, params) API call wrapper
```
Environment variables:
### Provider Selection
Configured via `CHATGPT_MCP_PROVIDER` env var (defaults to `"openai"`):
```env
OPENAI_API_KEY=
CHATGPT_MCP_PROVIDER=openai # current default; accepts any string but factory validates at runtime
```
The factory whitelists `"openai"`. Any unrecognized value throws at provider creation time (not config load time). Null/NaN/falsy values default to `"openai"` for safe fallback.
### OpenAI-specific Environment Variables
```env
OPENAI_API_KEY= # required — no default, throws if missing
OPENAI_MODEL=gpt-5.1
OPENAI_TEMPERATURE=0.2
OPENAI_MAX_OUTPUT_TOKENS=2000
```
The OpenAI integration should be isolated behind:
```text
src/openai/client.js
src/openai/responses.js
```
This makes it easier to add other providers later, including Ollama.
The provider pattern makes it straightforward to add other providers (Ollama, Anthropic) — implement the `send(input, config)` interface and register it in the factory's whitelist.
---
@@ -805,7 +807,10 @@ Later:
- Add Gitea pull request workflow.
- Add safe project summary generation.
- Add optional OpenHands integration.
- Add provider abstraction for OpenAI/Ollama/local models.
- Implement Ollama provider (factory already supports it).
- Implement Anthropic provider.
- Add streaming responses support.
- Add cost tracking per tool call.
---