161 lines
5.3 KiB
Markdown
Raw Normal View History

feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
# Gemini CLI Provider
The Gemini CLI provider allows you to use Google's Gemini models through the Gemini CLI tool, leveraging your existing Gemini subscription and OAuth authentication.
## Why Use Gemini CLI?
The primary benefit of using the `gemini-cli` provider is to leverage your existing Personal Gemini Code Assist license/usage Google offers for free, or Gemini Code Assist Standard/Enterprise subscription you may already have, via OAuth configured through the Gemini CLI. This is ideal for users who:
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
- Have an active Gemini Code Assist license (including those using the free tier offere by Google)
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
- Want to use OAuth authentication instead of managing API keys
- Have already configured authentication via `gemini` OAuth login
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
## Installation
The provider is already included in Task Master. However, you need to install the Gemini CLI tool:
```bash
# Install gemini CLI globally
npm install -g @google/gemini-cli
```
## Authentication
### Primary Method: CLI Authentication (Recommended)
The Gemini CLI provider is designed to use your pre-configured OAuth authentication:
```bash
# Launch Gemini CLI and go through the authentication procedure
gemini
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
```
For OAuth use, select `Login with Google` - This will open a browser window for OAuth authentication. Once authenticated, Task Master will automatically use these credentials when you select the `gemini-cli` provider and models.
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
### Alternative Method: API Key
While the primary use case is OAuth authentication, you can also use an API key if needed:
```bash
export GEMINI_API_KEY="your-gemini-api-key"
```
**Note:** If you want to use API keys, consider using the standard `google` provider instead, as `gemini-cli` is specifically designed for OAuth/subscription users.
More details on authentication steps and options can be found in the [gemini-cli GitHub README](https://github.com/google-gemini/gemini-cli).
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
## Configuration
Use the `task-master init` command to run through the guided initialization:
```bash
task-master init
```
**OR**
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
Configure `gemini-cli` as a provider using the Task Master models command:
```bash
# Set gemini-cli as your main provider with gemini-2.5-pro
task-master models --set-main gemini-2.5-pro --gemini-cli
# Or use the faster gemini-2.5-flash model
task-master models --set-main gemini-2.5-flash --gemini-cli
```
You can also manually edit your `.taskmaster/config.json`:
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
```json
{
"models": {
"main": {
"provider": "gemini-cli",
"modelId": "gemini-2.5-pro",
"maxTokens": 65536,
"temperature": 0.2
},
"research": {
"provider": "gemini-cli",
"modelId": "gemini-2.5-pro",
"maxTokens": 65536,
"temperature": 0.1
},
"fallback": {
"provider": "gemini-cli",
"modelId": "gemini-2.5-flash",
"maxTokens": 65536,
"temperature": 0.2
}
},
"global": {
"logLevel": "info",
"debug": false,
"defaultNumTasks": 10,
"defaultSubtasks": 5,
"defaultPriority": "medium",
"projectName": "Taskmaster",
"ollamaBaseURL": "http://localhost:11434/api",
"bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com",
"responseLanguage": "English",
"defaultTag": "master",
"azureOpenaiBaseURL": "https://your-endpoint.openai.azure.com/"
},
"claudeCode": {}
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
}
```
### Available Models
The gemini-cli provider supports only two models:
- `gemini-2.5-pro` - High performance model (1M token context window, 65,536 max output tokens)
- `gemini-2.5-flash` - Fast, efficient model (1M token context window, 65,536 max output tokens)
## Usage Examples
### Basic Usage
Once gemini-cli is installed and authenticated, and Task Master simply use Task Master as normal:
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
```bash
# The provider will automatically use your OAuth credentials
task-master parse-prd my-prd.txt
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
```
## Troubleshooting
### "Authentication failed" Error
If you get an authentication error:
1. **Primary solution**: Run `gemini` to authenticate with your Google account - use `/auth` slash command in **gemini-cli** to change authentication method if desired.
2. **Check authentication status**: Run `gemini` and use `/about` to verify your Auth Method and GCP Project if applicable.
3. **If using API key** (not recommended): Ensure `GEMINI_API_KEY` env variable is set correctly, see the gemini-cli README.md for more info.
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
### "Model not found" Error
The gemini-cli provider only supports two models:
- `gemini-2.5-pro`
- `gemini-2.5-flash`
If you need other Gemini models, use the standard `google` provider with an API key instead.
### Gemini CLI Not Found
If you get a "gemini: command not found" error:
```bash
# Install the Gemini CLI globally
npm install -g @google/gemini-cli
# Verify installation
gemini --version
```
## Important Notes
- **OAuth vs API Key**: This provider is specifically designed for users who want to use OAuth authentication via gemini-cli. If you prefer using API keys, consider using the standard `google` provider instead.
feat: Add gemini-cli provider integration for Task Master (#897) * 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.
2025-07-02 13:46:19 -06:00
- **Limited Model Support**: Only `gemini-2.5-pro` and `gemini-2.5-flash` are available through gemini-cli.
- **Subscription Benefits**: Using OAuth authentication allows you to leverage any subscription benefits associated with your Google account.
- The provider uses the `ai-sdk-provider-gemini-cli` npm package internally.
- Supports all standard Task Master features: text generation, streaming, and structured object generation.