Skip to content

feat: add Moonshot AI, Z.AI, MiniMax, and OpenRouter providers#15

Open
AhmedOsman101 wants to merge 9 commits intomainfrom
feat/new-providers
Open

feat: add Moonshot AI, Z.AI, MiniMax, and OpenRouter providers#15
AhmedOsman101 wants to merge 9 commits intomainfrom
feat/new-providers

Conversation

@AhmedOsman101
Copy link
Copy Markdown
Owner

Summary

  • Add support for four new AI providers: Moonshot AI (Kimi), Z.AI (GLM), MiniMax, and OpenRouter
  • DeepSeek integration confirmed (already existed, audit completed)
  • Add verbose debug logging via DEBUG=1 environment variable
  • Fix config migration infinite loop bug
  • Refactor Ollama/OpenRouter to use provider.model instead of separate config sections

New Providers

Provider Package Default Model Env Var
Moonshot AI @ai-sdk/moonshotai kimi-k2.5 MOONSHOTAI_API_KEY
Z.AI @ai-sdk/openai (adapter) glm-4.5-flash ZAI_API_KEY
MiniMax vercel-minimax-ai-provider MiniMax-M2.5 MINIMAX_API_KEY
OpenRouter @openrouter/ai-sdk-provider openai/gpt-4.1-mini OPENROUTER_API_KEY

Debug Logging

Set DEBUG=1 before running to enable verbose debug output with timestamps.

Test Plan

  • Type-check passes
  • Format check passes
  • Verified OpenRouter works with user config

- Add moonshotService.ts (Kimi models via @ai-sdk/moonshotai)
- Add zaiService.ts (GLM models via @ai-sdk/openai with Z.AI base URL)
- Add minimaxService.ts (MiniMax-M2.x via vercel-minimax-ai-provider)
- Add openrouterService.ts (meta-provider via @openrouter/ai-sdk-provider)
- Extend ProviderType union with moonshotai, zai, minimax, openrouter
- Extend ApiService union with MoonshotAI, Zai, MiniMax, OpenRouter
- Add OpenRouterConfig type and openrouter section to Config type
- Update DEFAULT_CONFIG with openrouter section and new provider defaults
- Update providerRegistry.ts with all four new providers
- Add OpenRouter special-case dispatch in aiService.ts
- Update configValidationService.ts SUPPORTED_PROVIDERS and schema
- Update configService.ts migrateConfig (modelMap + prefix detection)
- Add validateApiKey cases for new providers in configService.ts
- Add validateOpenRouterApiKey (sk-or-v1- prefix check) to keyValidationService.ts
- Update config.schema.json with new provider enums and openrouter section
- Update CHANGELOG.md with all new provider details
The openrouter config section is optional for users - it should only
be required when using the openrouter provider, not for all users.
Kept openrouter as required in TypeScript Config type since DEFAULT_CONFIG
always includes it and all service code expects it.
Root cause: load() was calling migrateConfig() then recursively calling
load() again, creating an infinite loop. The fix converts the parsed
config directly to Config type instead of re-loading from disk.
- logDebug checks DEBUG_ENABLED (cached at module load, no env lookup per call)
- Added logDebug calls to all major async operations:
  - aiService: generateCommitMessage, generateAndApplyMessage
  - All provider services: moonshot, zai, minimax, openrouter
  - gitService: initialize, getDiff, getChangedFiles
  - promptService: generatePrompt
  - gitBlameAnalyzer: analyzeChanges
- Format: [timestamp] [functionName] EVENT details
- Timestamp format: 2026-03-11@02:00AM
Ollama and OpenRouter now read model from provider.model instead of
ollama.model / openrouter.model. Only baseUrl stays in its own section.
- OpenRouter and Ollama now throw clear error if provider.model is missing
- Optional baseUrl falls back to DEFAULT_CONFIG values instead of hardcoded
- Added debug logging to OllamaService
- Updated config types to allow optional baseUrl
- Modified config service to handle optional values
- Adjusted Ollama/OpenRouter services to use default baseUrl if not provided
- Updated AGENTS.md header
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.

1 participant