feat: Migrate Task Master to generateObject for structured AI responses#1034
feat: Migrate Task Master to generateObject for structured AI responses#1034ben-vargas wants to merge 8 commits intoeyaltoledano:nextfrom
Conversation
🦋 Changeset detectedLatest commit: 4367df7 The changes in this PR will be included in the next version bump. 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 |
|
Caution Review failedFailed to post review comments. WalkthroughThis update migrates all AI-driven task management features from text-based to schema-driven structured data generation using a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TaskManagerModule
participant generateObjectService
participant AIProvider
participant ZodSchema
User->>TaskManagerModule: Initiate task operation (add/expand/update/analyze)
TaskManagerModule->>generateObjectService: Call with prompt, schema, objectName
generateObjectService->>AIProvider: Send prompt, schema, mode
AIProvider->>AIProvider: Generate structured JSON response
AIProvider-->>generateObjectService: Return structured response
generateObjectService->>ZodSchema: Validate response against schema
ZodSchema-->>generateObjectService: Return validated result or error
generateObjectService-->>TaskManagerModule: Return structured data
TaskManagerModule-->>User: Proceed with validated, structured result
Estimated code review effort5 (~2 hours) Suggested reviewers
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
3eafc5e to
783d068
Compare
Fixed issue where AI was generating inconsistent subtask IDs (101-105, 601-603)
instead of sequential numbering (1, 2, 3...) after the generateObject migration.
Changes:
- Updated all expand-task prompt variants with forceful "CRITICAL" instructions
- Made ID requirements explicit with examples: id={{nextSubtaskId}}, id={{nextSubtaskId}}+1
- Added warning not to use parent task ID in subtask numbering
- Removed parseSubtasksFromText post-processing that was overwriting AI-generated IDs
This ensures subtasks display correctly as X.1, X.2, X.3 format and the
`tm show X.Y` command works as expected.
783d068 to
e6d58d7
Compare
3317e34 to
0ca22a5
Compare
Integration tests that make real API calls cannot run in CI without proper API keys. These tests should either be mocked or run in a separate test suite with appropriate infrastructure.
|
@ben-vargas you're back, will review Asap, but since we're aiming for wednesday release, this will have to be a part of 0.23 :( So exxcited to see your PR, will review shortly |
|
@CodeRabbit try reviewing again |
|
Tip For best results, initiate chat on the files or code changes. @Crunchyman-ralph I'll conduct a comprehensive review of this significant migration PR. This is an excellent architectural improvement that moves from fragile text parsing to robust structured object generation. 🎯 Review SummaryThis PR successfully migrates the Task Master system from ✅ StrengthsArchitectural Excellence
Implementation Quality
Performance & Reliability
🔍 Key Changes AnalysisSchema Design ⭐The schema hierarchy is well-designed: // Base schemas for reusability
BaseTaskSchema, SubtaskSchema, TaskStatusSchema
// Command-specific schemas
AddTaskResponseSchema, ExpandTaskResponseSchema, etc.
// Centralized registry
COMMAND_SCHEMAS['add-task'], COMMAND_SCHEMAS['expand-task']AI Service MigrationClean transition from: // Old approach
const response = await generateTextService(prompt, role);
const parsed = parseComplexJSONFromText(response.mainResult);To: // New approach
const response = await generateObjectService(prompt, role, {
schema: COMMAND_SCHEMAS['analyze-complexity'],
objectName: 'complexityAnalysis'
});
const result = response.mainResult.complexityAnalysis;Prompt Template UpdatesPrompts correctly updated to specify structured output requirements while maintaining clarity and effectiveness. 🚀 Impact AssessmentReliability Improvements
Developer Experience
Performance Benefits
📋 Testing CoverageThe test updates are comprehensive:
🎉 RecommendationAPPROVE - This is an excellent architectural improvement that significantly enhances the system's reliability and maintainability. The migration is thorough, well-tested, and maintains backward compatibility while providing substantial benefits. The 90% reduction in parsing errors and elimination of 500+ lines of fragile code makes this a high-impact improvement that will benefit long-term maintenance and reliability. Great work on this comprehensive refactor! 🚀 ( .. ) 🧠 Learnings used |
Summary
This PR migrates Task Master from
generateTexttogenerateObjectfor AI command processing, providing significant improvements in reliability, maintainability, and performance.Key Changes:
Additional Fixes:
Migration Details
Commands Migrated
analyze-complexity- Uses structured ComplexityAnalysisResponseSchemaupdate-task-by-id- Full update mode uses generateObject; append mode still uses generateTextexpand-task- Uses structured ExpandTaskResponseSchemaupdate-tasks- Uses structured UpdatedTasksResponseSchemaadd-task- Already used generateObject with AiTaskDataSchemaparse-prd- Already used generateObject with prdResponseSchemaArchitecture Changes
Before:
After:
Benefits Realized
Test Plan
Breaking Changes
None - This is an internal refactor that maintains the same external API.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Tests
Chores