Skip to content

Commit 0398f94

Browse files
author
ai-commit
committed
feat(registry): add provider registry and defaults
- Introduce a registry system for AI providers with Factory, Register, Get, Has, Names - Add default provider settings storage and per-provider API key requirement tracking - Centralize provider creation via factories and register defaults for each provider - Add helper methods GetDefaults and RequiresAPIKey to registry - Extend config to support a Providers map with per-provider settings and limits - Add GetProviderSettings on Config to fetch provider settings with defaults (env/flag overrides) - Update provider wiring to use registry-based registration (phind, openai, google, anthropic, deepseek, ollama, openrouter) - BREAKING CHANGE: migrates to registry-based provider loading; config format and wiring changed (Providers map required, direct provider fields deprecated)
1 parent 34e678b commit 0398f94

File tree

31 files changed

+1766
-1018
lines changed

31 files changed

+1766
-1018
lines changed

README.md

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
It supports:
88

9+
- **Phind** (current model is free, enjoy!)
910
- **OpenAI**
1011
- **Google Gemini**
1112
- **Anthropic Claude**
1213
- **DeepSeek**
13-
- **Phind** (current model is free)
1414
- **Ollama** (local AI models)
15+
- **OpenRouter** (access to multiple open-source models)
1516

1617
Boost your commit quality, enforce standards, and save valuable time with AI-Commit, your all-in-one AI assistant for Git workflows.
1718

@@ -66,7 +67,7 @@ sudo mv ai-commit /usr/local/bin/
6667
- **Interactive Commit Splitting (`--interactive-split`)**: Gain granular control over your commits with chunk-based staging and commit message generation for partial commits.
6768
- **Emoji Support (`--emoji`)**: Add a touch of visual flair to your commit history with automatically included emojis based on commit types.
6869
- **Customizable Templates (`--template`)**: Tailor commit messages to your team's style with custom templates, incorporating dynamic values like branch names.
69-
- **Multi-Provider AI Support**: Choose the best AI for each task by switching seamlessly between OpenAI, Google, Anthropic, DeepSeek, and Phind.
70+
- **Multi-Provider AI Support**: Choose the best AI for each task by switching seamlessly between OpenAI, Google, Anthropic, DeepSeek, OpenRouter, and Phind.
7071
- **Configurable and Filterable**: Adapt AI-Commit to your projects with customizable commit types and prompt templates. Filter lock file diffs for cleaner, AI-focused message generation and reviews.
7172
- **Diff View in TUI**: Inspect complete Git diffs within the TUI (`l` key) for thorough pre-commit reviews.
7273
- **Enhanced Splitter UI**: Benefit from improved interactive splitting with chunk selection inversion and clear status updates.
@@ -83,30 +84,51 @@ authorName: "Your Name"
8384
authorEmail: "youremail@example.com"
8485

8586
provider: "phind"
86-
87-
phindApiKey: "" # Phind does not require an API key by default
88-
phindModel: "Phind-70B" # Current Phind model is free
89-
phindBaseURL: "https://https.extension.phind.com/agent/"
90-
91-
openAiApiKey: "sk-YOUR-OPENAI-KEY"
92-
openaiModel: "gpt-4o-latest"
93-
openaiBaseURL: "https://api.openai.com/v1"
94-
95-
googleApiKey: "YOUR-GOOGLE-KEY"
96-
googleModel: "models/google-2.0-flash"
97-
googleBaseURL: "https://generativelanguage.googleapis.com"
98-
99-
anthropicApiKey: "sk-YOUR-ANTHROPIC-KEY"
100-
anthropicModel: "claude-3-5-sonnet-latest"
101-
anthropicBaseURL: "https://api.anthropic.com/v1"
102-
103-
deepseekApiKey: "YOUR-DEEPSEEK-KEY"
104-
deepseekModel: "deepseek-chat"
105-
deepseekBaseURL: "https://api.deepseek.com/v1"
106-
107-
ollamaBaseURL: "http://localhost:11434"
108-
ollamaModel: "llama2"
109-
87+
limits:
88+
diff:
89+
enabled: false
90+
maxChars: 0
91+
prompt:
92+
enabled: false
93+
maxChars: 0
94+
95+
# Preferred provider config.
96+
providers:
97+
phind:
98+
apiKey: "" # Phind does not require an API key by default
99+
model: "Phind-70B"
100+
baseURL: "https://https.extension.phind.com/agent/"
101+
openai:
102+
apiKey: "sk-YOUR-OPENAI-KEY"
103+
model: "gpt-5-nano"
104+
baseURL: "https://api.openai.com/v1"
105+
google:
106+
apiKey: "YOUR-GOOGLE-KEY"
107+
model: "models/gemini-2.5-flash"
108+
baseURL: "https://generativelanguage.googleapis.com"
109+
anthropic:
110+
apiKey: "sk-YOUR-ANTHROPIC-KEY"
111+
model: "claude-sonnet-4-20250514"
112+
baseURL: "https://api.anthropic.com/v1"
113+
deepseek:
114+
apiKey: "YOUR-DEEPSEEK-KEY"
115+
model: "deepseek-chat"
116+
baseURL: "https://api.deepseek.com/v1"
117+
openrouter:
118+
apiKey: "YOUR-OPENROUTER-KEY"
119+
model: "openrouter/auto"
120+
baseURL: "https://openrouter.ai/api/v1"
121+
ollama:
122+
apiKey: "" # Ollama does not require an API key by default
123+
model: "llama3"
124+
baseURL: "http://localhost:11434"
125+
limits:
126+
diff:
127+
enabled: false
128+
maxChars: 0
129+
prompt:
130+
enabled: false
131+
maxChars: 0
110132
semanticRelease: false
111133
interactiveSplit: false
112134
enableEmoji: false
@@ -142,15 +164,10 @@ lockFiles: # Specify lock files to be ignored in diffs for commit messages and r
142164
143165
> **Note**: Command-line flags always take precedence over configuration file values. API keys can be set via environment variables or within `config.yaml`. You can now also customize the `promptTemplate` in this file to adjust the behavior of both commit message generation and code reviews.
144166

145-
API Keys via Environment Variables:
167+
Environment Overrides
146168

147-
- `OPENAI_API_KEY`
148-
- `GOOGLE_API_KEY`
149-
- `ANTHROPIC_API_KEY`
150-
- `DEEPSEEK_API_KEY`
151-
- `PHIND_API_KEY`
152-
153-
---
169+
- `${PROVIDER}_API_KEY` and `${PROVIDER}_BASE_URL`, with `PROVIDER` in uppercase.
170+
Examples: `OPENAI_API_KEY`, `OPENAI_BASE_URL`; `GOOGLE_API_KEY`, `GOOGLE_BASE_URL`; `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`; `DEEPSEEK_API_KEY`, `DEEPSEEK_BASE_URL`; `PHIND_API_KEY`, `PHIND_BASE_URL`; `OLLAMA_BASE_URL`.
154171

155172
## 🚀 Basic Usage
156173

@@ -181,10 +198,13 @@ API Keys via Environment Variables:
181198

182199
**Main Flags**:
183200

184-
* `--provider`: AI provider selection (`openai`, `google`, `anthropic`, `deepseek`, `phind`, `ollama`).
185-
* `--model`: Specific model choice per provider (e.g., `gpt-4`, `models/google-2.0-flash`, `claude-3-5-sonnet-latest`, `deepseek-chat`, `Phind-70B`, `llama2`).
186-
* `--apiKey`, `--googleApiKey`, `--anthropicApiKey`, `--deepseekApiKey`, `--phindApiKey`: API keys for each provider.
187-
* `--openaiBaseURL`, `--googleBaseURL`, `--anthropicBaseURL`, `--deepseekBaseURL`, `--phindBaseURL`, `--ollamaBaseURL`: Base URLs for each provider (Ollama defaults to http://localhost:11434).
201+
* `--provider`: AI provider selection (`openai`, `google`, `anthropic`, `deepseek`, `phind`, `ollama`, `openrouter`, `your_provider`).
202+
* `--model`: Specific model choice for the selected provider (overrides `providers.<name>.model`).
203+
* `--apiKey`: API key for the selected provider (overrides `providers.<name>.apiKey` or env `${PROVIDER}_API_KEY`).
204+
* `--baseURL`: Base URL for the selected provider (overrides `providers.<name>.baseURL` or env `${PROVIDER}_BASE_URL`).
205+
* Limits (config.yaml):
206+
- `limits.diff.enabled` + `limits.diff.maxChars` to summarize/truncate large diffs before sending to AI.
207+
- `limits.prompt.enabled` + `limits.prompt.maxChars` to hard-limit total prompt size.
188208
* `--commit-type`: Force a commit type (e.g., `fix`, `feat`) for non-interactive use or AI guidance.
189209
* `--template`: Custom template for commit messages, wrapping AI output.
190210
* `--prompt` *(Deprecated)*: Use `promptTemplate` in `config.yaml` for persistent prompt customization instead.
@@ -252,6 +272,7 @@ API Keys via Environment Variables:
252272
ai-commit --provider=deepseek --model=deepseek-chat --deepseekApiKey=...
253273
ai-commit --provider=phind --model=Phind-70B # Phind model is currently free; API key is optional
254274
ai-commit --provider=ollama --model=llama2 --ollamaBaseURL=http://localhost:11434 # Use local Ollama instance
275+
ai-commit --provider=openrouter --model=openrouter/auto --openrouterApiKey=...
255276
```
256277

257278
7. **Interactive Split Commit**:

0 commit comments

Comments
 (0)