* feat: Add gemini-cli provider integration for Task Master
This commit adds comprehensive support for the Gemini CLI provider, enabling users
to leverage Google's Gemini models through OAuth authentication via the gemini CLI
tool. This integration provides a seamless experience for users who prefer using
their existing Google account authentication rather than managing API keys.
## Implementation Details
### Provider Class (`src/ai-providers/gemini-cli.js`)
- Created GeminiCliProvider extending BaseAIProvider
- Implements dual authentication support:
- Primary: OAuth authentication via `gemini auth login` (authType: 'oauth-personal')
- Secondary: API key authentication for compatibility (authType: 'api-key')
- Uses the npm package `ai-sdk-provider-gemini-cli` (v0.0.3) for SDK integration
- Properly handles authentication validation without console output
### Model Configuration (`scripts/modules/supported-models.json`)
- Added two Gemini models with accurate specifications:
- gemini-2.5-pro: 72% SWE score, 65,536 max output tokens
- gemini-2.5-flash: 71% SWE score, 65,536 max output tokens
- Both models support main, fallback, and research roles
- Configured with zero cost (free tier)
### System Integration
- Registered provider in PROVIDERS map (`scripts/modules/ai-services-unified.js`)
- Added to OPTIONAL_AUTH_PROVIDERS set for flexible authentication
- Added GEMINI_CLI constant to provider constants (`src/constants/providers.js`)
- Exported GeminiCliProvider from index (`src/ai-providers/index.js`)
### Command Line Support (`scripts/modules/commands.js`)
- Added --gemini-cli flag to models command for provider hint
- Integrated into model selection logic (setModel function)
- Updated error messages to include gemini-cli in provider list
- Removed unrelated azure/vertex changes to maintain PR focus
### Documentation (`docs/providers/gemini-cli.md`)
- Comprehensive provider documentation emphasizing OAuth-first approach
- Clear explanation of why users would choose gemini-cli over standard google provider
- Detailed installation, authentication, and configuration instructions
- Troubleshooting section with common issues and solutions
### Testing (`tests/unit/ai-providers/gemini-cli.test.js`)
- Complete test suite with 12 tests covering all functionality
- Tests for both OAuth and API key authentication paths
- Error handling and edge case coverage
- Updated mocks in ai-services-unified.test.js for integration testing
## Key Design Decisions
1. **OAuth-First Design**: The provider assumes users want to leverage their existing
`gemini auth login` credentials, making this the default authentication method.
2. **Authentication Type Mapping**: Discovered through testing that the SDK expects:
- 'oauth-personal' for OAuth/CLI authentication (not 'gemini-cli' or 'oauth')
- 'api-key' for API key authentication (not 'gemini-api-key')
3. **Silent Operation**: Removed console.log statements from validateAuth to match
the pattern used by other providers like claude-code.
4. **Limited Model Support**: Only gemini-2.5-pro and gemini-2.5-flash are available
through the CLI, as confirmed by the package author.
## Usage
```bash
# Install gemini CLI globally
npm install -g @google/gemini-cli
# Authenticate with Google account
gemini auth login
# Configure Task Master to use gemini-cli
task-master models --set-main gemini-2.5-pro --gemini-cli
# Use Task Master normally
task-master new "Create a REST API endpoint"
```
## Dependencies
- Added `ai-sdk-provider-gemini-cli@^0.0.3` to package.json
- This package wraps the Google Gemini CLI Core functionality for Vercel AI SDK
## Testing
All tests pass (613 total), including the new gemini-cli provider tests.
Code has been formatted with biome to maintain consistency.
This implementation provides a clean, well-tested integration that follows Task Master's
existing patterns while offering users a convenient way to use Gemini models with their
existing Google authentication.
* feat: implement lazy loading for gemini-cli provider
- Move ai-sdk-provider-gemini-cli to optionalDependencies
- Implement dynamic import with loadGeminiCliModule() function
- Make getClient() async to support lazy loading
- Update base-provider to handle async getClient() calls
- Update tests to handle async getClient() method
This allows the application to start without the gemini-cli package
installed, only loading it when actually needed.
* feat(gemini-cli): replace regex-based JSON extraction with jsonc-parser
- Add jsonc-parser dependency for robust JSON parsing
- Replace simple regex approach with progressive parsing strategy:
1. Direct parsing after cleanup
2. Smart boundary detection with single-pass analysis
3. Limited fallback for edge cases
- Optimize performance with early termination and strategic sampling
- Add comprehensive tests for variable declarations, trailing commas,
escaped quotes, nested objects, and performance edge cases
- Improve reliability for complex JSON structures that Gemini commonly produces
- Fix code formatting with biome
This addresses JSON parsing failures in generateObject operations while
maintaining backward compatibility and significantly improving performance
for large responses.
* fix: update package-lock.json and fix formatting for CI/CD
- Add jsonc-parser to package-lock.json for proper npm ci compatibility
- Fix biome formatting issues in gemini-cli provider and tests
- Ensure all CI/CD checks pass
* feat(gemini-cli): implement comprehensive JSON output reliability system
- Add automatic JSON request detection via content analysis patterns
- Implement task-specific prompt simplification for improved AI compliance
- Add strict JSON enforcement through enhanced system prompts
- Implement response interception with intelligent JSON extraction fallback
- Add comprehensive test coverage for all new JSON handling methods
- Move debug logging to appropriate level for clean user experience
This multi-layered approach addresses gemini-cli's conversational response
tendencies, ensuring reliable structured JSON output for task expansion
operations. Achieves 100% success rate in end-to-end testing while
maintaining full backward compatibility with existing functionality.
Technical implementation includes:
• JSON detection via user message content analysis
• Expand-task prompt simplification with cleaner instructions
• System prompt enhancement with strict JSON enforcement
• Response processing with jsonc-parser-based extraction
• Comprehensive unit test coverage for edge cases
• Debug-level logging to prevent user interface clutter
Resolves: gemini-cli JSON formatting inconsistencies
Tested: All 46 test suites pass, formatting verified
* chore: add changeset for gemini-cli provider implementation
Adds minor version bump for comprehensive gemini-cli provider with:
- Lazy loading and optional dependency management
- Advanced JSON parsing with jsonc-parser
- Multi-layer reliability system for structured output
- Complete test coverage and CI/CD compliance
* refactor: consolidate optional auth provider logic
- Add gemini-cli to existing providersWithoutApiKeys array in config-manager
- Export providersWithoutApiKeys for reuse across modules
- Remove duplicate OPTIONAL_AUTH_PROVIDERS Set from ai-services-unified
- Update ai-services-unified to import and use centralized array
- Fix Jest mock to include new providersWithoutApiKeys export
This eliminates code duplication and provides a single source of truth
for which providers support optional authentication, addressing PR
reviewer feedback about existing similar functionality in src/constants.
Implements Claude Code as a new AI provider that uses the Claude Code CLI
without requiring API keys. This enables users to leverage Claude models
through their local Claude Code installation.
Key changes:
- Add complete AI SDK v1 implementation for Claude Code provider
- Custom SDK with streaming/non-streaming support
- Session management for conversation continuity
- JSON extraction for object generation mode
- Support for advanced settings (maxTurns, allowedTools, etc.)
- Integrate Claude Code into Task Master's provider system
- Update ai-services-unified.js to handle keyless authentication
- Add provider to supported-models.json with opus/sonnet models
- Ensure correct maxTokens values are applied (opus: 32000, sonnet: 64000)
- Fix maxTokens configuration issue
- Add max_tokens property to getAvailableModels() output
- Update setModel() to properly handle claude-code models
- Create update-config-tokens.js utility for init process
- Add comprehensive documentation
- User guide with configuration examples
- Advanced settings explanation and future integration options
The implementation maintains full backward compatibility with existing
providers while adding seamless Claude Code support to all Task Master
commands.
* fix: claude-4 not having the right max_tokens
* feat: add bedrock support
* chore: fix package-lock.json
* fix: rename baseUrl to baseURL
* feat: add azure support
* fix: final touches of azure integration
* feat: add google vertex provider
* chore: fix tests and refactor task-manager.test.js
* chore: move task 92 to 94
Problem:
- Task Master model configuration wasn't properly checking for API keys in the project's .env file when running through MCP
- The isApiKeySet function was only checking session.env and process.env but not inspecting the .env file directly
- This caused incorrect API key status reporting in MCP tools even when keys were properly set in .env
Solution:
- Modified resolveEnvVariable function in utils.js to properly read from .env file at projectRoot
- Updated isApiKeySet to correctly pass projectRoot to resolveEnvVariable
- Enhanced the key detection logic to have consistent behavior between CLI and MCP contexts
- Maintains the correct precedence: session.env → .env file → process.env
Testing:
- Verified working correctly with both MCP and CLI tools
- API keys properly detected in .env file in both contexts
- Deleted .cursor/mcp.json to confirm introspection of .env as fallback works
Adds the ability for users to specify custom model IDs for Ollama and OpenRouter providers, bypassing the internal supported model list.
- Introduces --ollama and --openrouter flags for the 'task-master models --set-<role>' command.
- Updates the interactive 'task-master models --setup' to include options for entering custom Ollama/OpenRouter IDs.
- Implements live validation against the OpenRouter API when a custom OpenRouter ID is provided.
- Refines the model setting logic to prioritize explicit provider flags/choices.
- Adds warnings when custom models are set.
- Updates the changeset file.
- Add OpenAI provider implementation using @ai-sdk/openai.\n- Update `models` command/tool to display API key status for configured providers.\n- Implement model-specific `maxTokens` override logic in `config-manager.js` using `supported-models.json`.\n- Improve AI error message parsing in `ai-services-unified.js` for better clarity.
- Fixed MCP server initialization warnings by refactoring config-manager.js to handle missing project roots silently during startup
- Added project root tracking (loadedConfigRoot) to improve config caching and prevent unnecessary reloads
- Modified _loadAndValidateConfig to return defaults without warnings when no explicitRoot provided
- Improved getConfig to only update cache when loading config with a specific project root
- Ensured warning messages still appear when explicitly specified roots have missing/invalid configs
- Prevented console output during MCP startup that was causing JSON parsing errors
- Verified parse_prd and other MCP tools still work correctly with the new config loading approach.
- Replaces test perplexity api key in mcp.json and rolls it. It's invalid now.
This commit implements several related improvements to the models command and configuration system:
- Added MCP support for the models command:
- Created new direct function implementation in models.js
- Registered modelsDirect in task-master-core.js for proper export
- Added models tool registration in tools/index.js
- Ensured project name replacement when copying .taskmasterconfig in init.js
- Improved .taskmasterconfig copying during project initialization:
- Added copyTemplateFile() call in createProjectStructure()
- Ensured project name is properly replaced in the config
- Restructured tool registration in logical workflow groups:
- Organized registration into 6 functional categories
- Improved command ordering to follow typical workflow
- Added clear group comments for maintainability
- Enhanced documentation in cursor rules:
- Updated dev_workflow.mdc with clearer config management instructions
- Added comprehensive models command reference to taskmaster.mdc
- Clarified CLI vs MCP usage patterns and options
- Added warning against manual .taskmasterconfig editing