一键导入
add-provider
Guided checklist for adding a new AI provider to gitai's AIService
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guided checklist for adding a new AI provider to gitai's AIService
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Rank the functions/modules changed this session by test-worthiness and output TEST / integration-only / SKIP per symbol. Uses graphify blast-radius when graphify-out/ exists, a static rubric otherwise. Use when you changed several units and are unsure which deserve a unit test, or before writing tests for a batch of new code.
Use when performing code review, writing or refactoring code, or discussing architecture; complements clean-code and does not replace project linter/formatter.
Use when publishing a new version of gitai to npm — cutting a release, bumping the version, shipping to the registry — or when a release was cut but the new version never reached npm, or a user reports the CLI still showing an old version.
Use when asked to generate, build, prepare, optimize or assemble a /goal command for autonomous or overnight execution — triggers: "montar goal", "gerar goal autônomo", "preparar task overnight", "goal para sessão autônoma", "otimizar goal", "goal builder".
Smoke test end-to-end do gitai CLI em repo temporário
Create, update, and manage GitHub issues using MCP tools. Use this skill when users want to create bug reports, feature requests, or task issues, update existing issues, add labels/assignees/milestones, set issue fields (dates, priority, custom fields), set issue types, manage issue workflows, link issues, add dependencies, or track blocked-by/blocking relationships. Triggers on requests like "create an issue", "file a bug", "request a feature", "update issue X", "set the priority", "set the start date", "link issues", "add dependency", "blocked by", "blocking", or any GitHub issue management task.
| name | add-provider |
| description | Guided checklist for adding a new AI provider to gitai's AIService |
| user-invocable | false |
This skill guides you through adding a new AI provider (like OpenAI, Groq, Anthropic) to gitai's AIService abstraction layer.
npm install <provider-sdk-package>
Examples:
npm install openainpm install groq-sdknpm install @anthropic-ai/sdkUpdate package.json to lock the version.
src/services/ai.tsAdd the import at the top with the other SDK imports (lines 1–3):
import NewProvider from 'new-provider-sdk';
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts lines 1–3
AIServiceAdd a private property to the class (lines 18–22):
private newProvider?: NewProvider;
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts lines 20–22
Example:
private openai?: OpenAI;
private groq?: Groq;
private anthropic?: Anthropic;
private newProvider?: NewProvider; // Add here
initializeClient() SwitchIn AIService.initializeClient() (lines 29–43), add a new case:
case 'new-provider':
this.newProvider = new NewProvider({ apiKey: this.config.apiKey });
break;
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts lines 30–43
Pattern to follow:
'openai', 'groq', 'anthropic')new ProviderClass({ apiKey: this.config.apiKey })break; to avoid fallthroughIf the provider has reasoning/o1-style models, update isReasoningModel() (lines 14–16):
export function isReasoningModel(model: string): boolean {
return ['o1', 'o3', 'gpt-5', 'deepseek-reasoner'].some((prefix) => model.startsWith(prefix));
// Add provider's reasoning prefixes if applicable
}
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts lines 14–16
Note: Reasoning models often have different API signatures; see Step 7 for handling.
callApi() MethodIn the private callApi() method (lines 207–268), add a new branch:
} else if (this.config.provider === 'new-provider' && this.newProvider) {
logger.ai(`Provider: new-provider - Model: ${this.config.model}`);
const completion = await this.newProvider.chat.completions.create({
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: userPrompt },
],
model: this.config.model,
temperature: 0.5,
max_tokens: 500,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
});
return completion.choices[0].message.content?.trim() || '';
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts lines 208–265
Key points:
logger.ai() (imported from ../utils/logger.js) for provider/model loggingProvider: <key> - Model: ${this.config.model}max_tokens, newer reasoning models use max_completion_tokens)If the provider supports reasoning models, check isReasoningModel() before the standard call:
} else if (this.config.provider === 'new-provider' && this.newProvider) {
logger.ai(`Provider: new-provider - Model: ${this.config.model}`);
if (isReasoningModel(this.config.model)) {
// Special API (e.g., Responses API)
const response = await this.newProvider.responses.create({
model: this.config.model,
instructions: systemPrompt,
input: userPrompt,
max_output_tokens: 500,
});
return response.output_text?.trim() || '';
}
// Standard chat API
const completion = await this.newProvider.chat.completions.create({
// ... standard parameters
});
return completion.choices[0].message.content?.trim() || '';
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts lines 211–219 (OpenAI reasoning model example)
In src/utils/config.ts, ensure the AppConfig interface includes PROVIDER (line 9–13).
No changes needed if PROVIDER field already exists. The field is a simple string that matches your case 'new-provider': key.
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/utils/config.ts lines 8–13
In src/utils/setup.ts, update the PROVIDER prompt choices (lines 72–80):
{
type: 'list',
name: 'PROVIDER',
message: 'Which AI Provider do you want to use?',
choices: [
{ name: 'OpenAI', value: 'openai' },
{ name: 'Anthropic', value: 'anthropic' },
{ name: 'Groq', value: 'groq' },
{ name: 'New Provider', value: 'new-provider' }, // Add here
],
default: 'openai',
when: () => !currentConfig.PROVIDER
},
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/utils/setup.ts lines 71–81
Also update the MODEL default prompt (lines 91–101) to include a sensible default model for the new provider:
{
type: 'input',
name: 'MODEL',
message: 'Model ID (e.g., gpt-5.2, claude-3-5-sonnet, llama-3.3-70b-versatile):',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
default: (answers: any) => {
const provider = answers.PROVIDER || currentConfig.PROVIDER;
if (provider === 'openai') return 'gpt-5.2';
if (provider === 'anthropic') return 'claude-3-5-sonnet-20240620';
if (provider === 'groq') return 'llama-3.3-70b-versatile';
if (provider === 'new-provider') return 'new-provider-model-id'; // Add here
return 'gpt-5.2';
},
when: () => !currentConfig.MODEL
}
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/src/utils/setup.ts lines 91–103
In /Users/leandrosilvaferreira/Projetos/gitai-js/CLAUDE.md, update the "Conventions" section to document the new provider:
## Conventions
...
- **Novos provedores de IA** entram no `switch` de `AIService.initializeClient()` + tratamento por-provedor do request (modelos novos da OpenAI usam `max_completion_tokens` em vez de `max_tokens`; novo-provedor usa [inserir parâmetros específicos]).
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/CLAUDE.md (Conventions section)
Run the project's canonical verification commands:
npx tsc --noEmit
npm run lint
npm run format
Reference: /Users/leandrosilvaferreira/Projetos/gitai-js/CLAUDE.md (Canonical commands section)
Fix any TypeScript errors (type mismatches, missing properties) and lint violations before moving to testing.
If the project has integration tests, add a test that:
AIService with the new provider configgenerateCommitMessage() with a mock diffExample pattern (where test framework is used):
test('generateCommitMessage with new-provider', async () => {
const service = new AIService({
provider: 'new-provider',
model: 'new-provider-model-id',
apiKey: 'test-key',
language: 'en',
});
const message = await service.generateCommitMessage(
'feat: test feature\n\nSample diff',
[],
'TypeScript',
'test commit'
);
expect(message).toBeTruthy();
});
Run the setup wizard:
npm run dev
Select the new provider from the list.
Provide a valid API key.
Test by running gitai on a real repository with uncommitted changes.
Verify the commit message is generated and properly formatted.
| Issue | Solution |
|---|---|
| Provider not showing in setup wizard | Check the choices array in setup.ts; ensure value matches the case key in initializeClient() |
TypeScript errors on this.newProvider | Ensure the property is declared in lines 18–22 of AIService |
| API call returns empty string | Check response structure; provider SDKs vary (e.g., message.content[0].text vs choices[0].message.content) |
| Reasoning models fail | Verify isReasoningModel() condition and use the correct API endpoint (e.g., Responses API for o1/o3) |
| Tests fail due to API key | Use mock/stub for provider SDK in tests; do not use real API keys |
| Lint fails | Run npm run format to auto-fix style issues; check ESLint output for type errors |
Before marking the task complete:
npm install)src/services/ai.ts (lines 1–3)AIService (lines 18–22)initializeClient() switch (lines 29–43)callApi() method handles new provider (lines 207–268)isReasoningModel() (lines 14–16)npx tsc --noEmit passesnpm run lint passesnpm run format applied (if needed)/Users/leandrosilvaferreira/Projetos/gitai-js/src/services/ai.ts/Users/leandrosilvaferreira/Projetos/gitai-js/src/utils/config.ts/Users/leandrosilvaferreira/Projetos/gitai-js/src/utils/setup.ts/Users/leandrosilvaferreira/Projetos/gitai-js/CLAUDE.md/Users/leandrosilvaferreira/Projetos/gitai-js/src/utils/logger.ts