-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Subtask generation fails on gemini-2.5-pro #852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Subtask generation fails on gemini-2.5-pro #852
Conversation
🦋 Changeset detectedLatest commit: 5647b43 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a changeset using npm run changeset
so that we can see your fix in upcoming releases and credit!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* fix: clarify details format in task expansion prompt * chore: add changeset
* feat: implement centralized path management system with initTaskMaster This commit introduces a comprehensive refactoring of the TaskMaster CLI's path handling system, consolidating all path resolution logic into a centralized initTaskMaster function and TaskMaster class. This architectural change eliminates circular dependencies and provides consistent path management across all CLI commands. Key changes: • **Created new TaskMaster class and initTaskMaster factory function** in src/task-master.js - Centralized path resolution with boolean override logic (string = explicit path, true = required search, false/undefined = optional) - Built-in error handling with automatic process.exit() for missing required paths - Immutable path objects with getter methods for safe access • **Replaced findProjectRoot() calls throughout CLI** in scripts/modules/commands.js - Updated all 25+ CLI commands to use initTaskMaster() instead of scattered path handling - Eliminated hundreds of lines of redundant path resolution and error handling code - Consistent project root validation and path discovery across all commands • **Added comprehensive test suite** in tests/unit/task-master.test.js - 22 test cases covering project root detection, path resolution, override validation, and edge cases - Tests use temporary directories with proper cleanup and mock process.exit/console.error - Validates both successful scenarios and error conditions with proper exit codes * bring Usage for Parse PRD back, and revamp initTaskMaster to throw errors not error/exit. * fix(claude-code): recover from CLI JSON truncation bug (#913) (#920) Gracefully handle SyntaxError thrown by @anthropic-ai/claude-code when the CLI truncates large JSON outputs (4–16 kB cut-offs).\n\nKey points:\n• Detect JSON parse error + existing buffered text in both doGenerate() and doStream() code paths.\n• Convert the failure into a recoverable 'truncated' finish state and push a provider-warning.\n• Allows Task Master to continue parsing long PRDs / expand-task operations instead of crashing.\n\nA patch changeset (.changeset/claude-code-json-truncation.md) is included for the next release.\n\nRef: #913 * docs: fix gemini-cli authentication documentation (#923) Remove erroneous 'gemini auth login' command references and replace with correct 'gemini' command authentication flow. Update documentation to reflect proper OAuth setup process via the gemini CLI interactive interface. * fix: .gitignore missing trailing newline during project initialization (#855) * Support for Additional Anthropic Models on Bedrock (#870) * Add additional Anthropic Models for Bedrock * Update Models Docs from `scripts/modules/supported-models.json` * feat(models): add additional Bedrock supported models * docs: Auto-update and format models.md * fix: Ensure projectRoot is a string (potential WSL fix) (#892) * ensure projectRoot is a string * add changeset * Fix/spelling mistakes (#876) * docs: Auto-update and format models.md * fix: correct typos in documentation for parse-prd and taskmaster commands - Updated the `parse-prd` documentation to fix the spelling of "multiple." - Clarified the description of the `id` parameter in the `taskmaster` documentation to ensure proper syntax and readability. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix `rules` command to use reliable project root detection like other commands (#908) * update/fix projectRoot call for consistency * internal naming consistency * add changeset * fix: Subtask generation fails on gemini-2.5-pro (#852) * fix: clarify details format in task expansion prompt * chore: add changeset * fix: use tag-specific complexity reports (#857) * fix(expand-task): Use tag-specific complexity reports - Add getTagAwareFilePath utility function to resolve tag-specific file paths - Update expandTask to use tag-aware complexity report paths - Fix issue where expand-task always used default complexity report - Add comprehensive tests for getTagAwareFilePath utility - Ensure proper handling of file extensions and directory structures Fixes #850: Expanding tasks not using tag-specific complexity reports The expandTask function now correctly uses complexity reports specific to the current tag context (e.g., task-complexity-report_feature-branch.json) instead of always using the default task-complexity-report.json file. This enables proper task expansion behavior when working with multiple tag contexts, ensuring complexity analysis is tag-specific and accurate. * chore: Add changeset for tag-specific complexity reports fix * test(expand-task): Add tests for tag-specific complexity report integration - Introduced a new test suite for verifying the integration of tag-specific complexity reports in the expandTask function. - Added a test case to ensure the correct complexity report is used when available for a specific tag. - Mocked file system interactions to simulate the presence of tag-specific complexity reports. This enhances the test coverage for task expansion behavior, ensuring it accurately reflects the complexity analysis based on the current tag context. * refactor(task-manager): unify and simplify tag-aware file path logic and tests - Reformatted imports and cleaned up comments in test files for readability - Centralized mocks: moved getTagAwareFilePath & slugifyTagForFilePath mocks to setup.js for consistency and maintainability - Simplified utils/getTagAwareFilePath: replaced manual parsing with path.parse() & path.format(); improved extension handling - Enhanced test mocks for path.parse, path.format & reset path.join in beforeEach to avoid interference - All tests now pass consistently; no change in functionality * fix: prevent tag corruption in bulk updates (#856) * fix(task-manager): prevent tag corruption in bulk updates and add tag preservation test - Fix writeJSON call in scripts/modules/task-manager/update-tasks.js (line 469) to include projectRoot and tag parameters. - Ensure tagged task lists maintain data integrity during bulk updates, preventing task disappearance in tagged contexts. - Update MCP tools to properly pass tag context through the call chain. - Introduce a comprehensive test case to verify that all tags are preserved when updating tasks, covering both master and feature-branch scenarios. Addresses an issue where bulk updates could corrupt tasks.json in tagged task list structures, reinforcing task management robustness. * style(tests): format task data in update-tasks test * fix: Critical writeJSON Context Fixes - Prevent Tag Corruption (#910) * feat(tasks): Fix critical tag corruption bug in task management - Fixed missing context parameters in writeJSON calls across add-task, remove-task, and add-subtask functions - Added projectRoot and tag parameters to prevent data corruption in multi-tag environments - Re-enabled generateTaskFiles calls to ensure markdown files are updated after operations - Enhanced add_subtask MCP tool with tag parameter support - Refactored addSubtaskDirect function to properly pass context to core logic - Streamlined codebase by removing deprecated functionality This resolves the critical bug where task operations in one tag context would corrupt or delete tasks from other tags in tasks.json. * feat(task-manager): Enhance addSubtask with current tag support - Added `getCurrentTag` utility to retrieve the current tag context for task operations. - Updated `addSubtask` to use the current tag when reading and writing tasks, ensuring proper context handling. - Refactored tests to accommodate changes in the `addSubtask` function, ensuring accurate mock implementations and expectations. - Cleaned up test cases for better readability and maintainability. This improves task management by preventing tag-related data corruption and enhances the overall functionality of the task manager. * feat(remove-task): Add tag support for task removal and enhance error handling - Introduced `tag` parameter in `removeTaskDirect` to specify context for task operations, improving multi-tag support. - Updated logging to include tag context in messages for better traceability. - Refactored task removal logic to streamline the process and improve error reporting. - Added comprehensive unit tests to validate tag handling and ensure robust error management. This enhancement prevents task data corruption across different tags and improves the overall reliability of the task management system. * feat(add-task): Add projectRoot and tag parameters to addTask tests - Updated `addTask` unit tests to include `projectRoot` and `tag` parameters for better context handling. - Enhanced test cases to ensure accurate expectations and improve overall test coverage. This change aligns with recent enhancements in task management, ensuring consistency across task operations. * feat(set-task-status): Add tag parameter support and enhance task status handling - Introduced `tag` parameter in `setTaskStatusDirect` and related functions to improve context management in multi-tag environments. - Updated `writeJSON` calls to ensure task data integrity across different tags. - Enhanced unit tests to validate tag preservation during task status updates, ensuring robust functionality. This change aligns with recent improvements in task management, preventing data corruption and enhancing overall reliability. * feat(tag-management): Enhance writeJSON calls to preserve tag context - Updated `writeJSON` calls in `createTag`, `deleteTag`, `renameTag`, `copyTag`, and `enhanceTagsWithMetadata` to include `projectRoot` for better context management and to prevent tag corruption. - Added comprehensive unit tests for tag management functions to ensure data integrity and proper tag handling during operations. This change improves the reliability of tag management by ensuring that operations do not corrupt existing tags and maintains the overall structure of the task data. * feat(expand-task): Update writeJSON to include projectRoot and tag context - Modified `writeJSON` call in `expandTaskDirect` to pass `projectRoot` and `tag` parameters, ensuring proper context management when saving tasks.json. - This change aligns with recent enhancements in task management, preventing potential data corruption and improving overall reliability. * feat(fix-dependencies): Add projectRoot and tag parameters for enhanced context management - Updated `fixDependenciesDirect` and `registerFixDependenciesTool` to include `projectRoot` and `tag` parameters, improving context handling during dependency fixes. - Introduced a new unit test for `fixDependenciesCommand` to ensure proper preservation of projectRoot and tag data in JSON outputs. This change enhances the reliability of dependency management by ensuring that context is maintained across operations, preventing potential data issues. * fix(context): propagate projectRoot and tag through dependency, expansion, status-update and tag-management commands to prevent cross-tag data corruption * test(fix-dependencies): Enhance unit tests for fixDependenciesCommand - Refactored tests to use unstable mocks for utils, ui, and task-manager modules, improving isolation and reliability. - Added checks for process.exit to ensure proper handling of invalid data scenarios. - Updated test cases to verify writeJSON calls with projectRoot and tag parameters, ensuring accurate context preservation during dependency fixes. This change strengthens the test suite for dependency management, ensuring robust functionality and preventing potential data issues. * chore(plan): remove outdated fix plan for `writeJSON` context parameters * 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. * docs: Auto-update and format models.md * Feat: Added automatic determination of task number based on complexity (#884) - Added 'defaultNumTasks: 10' to default config, now used in 'parse-prd' - Adjusted 'parse-prd' and 'expand-task' to: - Accept a 'numTasks' value of 0 - Updated tool and command descriptions - Updated prompts to 'an appropriate number of' when value is 0 - Updated 'README-task-master.md' and 'command-reference.md' docs - Added more tests for: 'parse-prd', 'expand-task' and 'config-manager' Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> * feat: Support custom response language (#510) * feat: Support custom response language * fix: Add default values for response language in config-manager.js * chore: Update configuration file and add default response language settings * feat: Support MCP/CLI custom response language * chore: Update test comments to English for consistency * docs: Auto-update and format models.md * chore: fix format --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> * Feat: Implemented advanced settings for Claude Code AI provider (#872) * Feat: Implemented advanced settings for Claude Code AI provider - Added new 'claudeCode' property to default config - Added getters and validation functions to 'config-manager.js' - Added new 'isEmpty' utility to 'utils.js' - Added new constants file 'commands.js' for AI_COMMAND_NAMES - Updated Claude Code AI provider to use new config functions - Updated 'claude-code-usage.md' documentation - Added 'config-manager.test.js' tests to cover new settings * chore: run format --------- Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> * fix: issues with release (#915) Fix remove-task bug with mcp Fix response-language using old config file .taskmaster * fix(claude-code): recover from CLI JSON truncation bug (#913) (#920) Gracefully handle SyntaxError thrown by @anthropic-ai/claude-code when the CLI truncates large JSON outputs (4–16 kB cut-offs).\n\nKey points:\n• Detect JSON parse error + existing buffered text in both doGenerate() and doStream() code paths.\n• Convert the failure into a recoverable 'truncated' finish state and push a provider-warning.\n• Allows Task Master to continue parsing long PRDs / expand-task operations instead of crashing.\n\nA patch changeset (.changeset/claude-code-json-truncation.md) is included for the next release.\n\nRef: #913 * docs: fix gemini-cli authentication documentation (#923) Remove erroneous 'gemini auth login' command references and replace with correct 'gemini' command authentication flow. Update documentation to reflect proper OAuth setup process via the gemini CLI interactive interface. * chore: run format * fix: add initTaskMaster to new commands Fixes CI and broken commands * chore: format --------- Co-authored-by: Chris Covington <chris.covington@hey.com> Co-authored-by: Ben Vargas <ben@vargas.com> Co-authored-by: Joe Danziger <joe@ticc.net> Co-authored-by: Nicholas Spalding <nishedcob@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Ofer Shaal <oshaal@phase2technology.com> Co-authored-by: Shandy Hermawan <hrm.shandy05@gmail.com> Co-authored-by: Parthy <52548018+mm-parthy@users.noreply.github.com> Co-authored-by: Geoff Hammond <geoff@geoffhammond.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> Co-authored-by: shenysun <40556411+shenysun@users.noreply.github.com>
Description
This PR fixes a critical issue where subtask generation fails on gemini-2.5-pro unless explicitly prompted to
return 'details' field as a string not an object
Type of Change
Testing
Changeset