diff --git a/.taskmaster/config.json b/.taskmaster/config.json index a61d10d5..442dfc1c 100644 --- a/.taskmaster/config.json +++ b/.taskmaster/config.json @@ -1,33 +1,33 @@ { - "models": { - "main": { - "provider": "anthropic", - "modelId": "claude-sonnet-4-20250514", - "maxTokens": 50000, - "temperature": 0.2 - }, - "research": { - "provider": "perplexity", - "modelId": "sonar-pro", - "maxTokens": 8700, - "temperature": 0.1 - }, - "fallback": { - "provider": "anthropic", - "modelId": "claude-3-7-sonnet-20250219", - "maxTokens": 128000, - "temperature": 0.2 - } - }, - "global": { - "logLevel": "info", - "debug": false, - "defaultSubtasks": 5, - "defaultPriority": "medium", - "projectName": "Taskmaster", - "ollamaBaseURL": "http://localhost:11434/api", - "bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com", - "userId": "1234567890", - "azureBaseURL": "https://your-endpoint.azure.com/" - } -} + "models": { + "main": { + "provider": "anthropic", + "modelId": "claude-sonnet-4-20250514", + "maxTokens": 50000, + "temperature": 0.2 + }, + "research": { + "provider": "perplexity", + "modelId": "sonar-pro", + "maxTokens": 8700, + "temperature": 0.1 + }, + "fallback": { + "provider": "anthropic", + "modelId": "claude-3-7-sonnet-20250219", + "maxTokens": 128000, + "temperature": 0.2 + } + }, + "global": { + "logLevel": "info", + "debug": false, + "defaultSubtasks": 5, + "defaultPriority": "medium", + "projectName": "Taskmaster", + "ollamaBaseURL": "http://localhost:11434/api", + "bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com", + "userId": "1234567890", + "azureBaseURL": "https://your-endpoint.azure.com/" + } +} \ No newline at end of file diff --git a/.taskmaster/tasks/task_096.txt b/.taskmaster/tasks/task_096.txt new file mode 100644 index 00000000..3468bfa5 --- /dev/null +++ b/.taskmaster/tasks/task_096.txt @@ -0,0 +1,37 @@ +# Task ID: 96 +# Title: Create Export Command for On-Demand Task File and PDF Generation +# Status: pending +# Dependencies: 2, 4, 95 +# Priority: medium +# Description: Develop an 'export' CLI command that generates task files and comprehensive PDF exports on-demand, replacing automatic file generation and providing users with flexible export options. +# Details: +Implement a new 'export' command in the CLI that supports two primary modes: (1) generating individual task files on-demand (superseding the current automatic generation system), and (2) producing a comprehensive PDF export. The PDF should include: a first page with the output of 'tm list --with-subtasks', followed by individual pages for each task (using 'tm show ') and each subtask (using 'tm show '). Integrate PDF generation using a robust library (e.g., pdfkit, Puppeteer, or jsPDF) to ensure high-quality output and proper pagination. Refactor or disable any existing automatic file generation logic to avoid performance overhead. Ensure the command supports flexible output paths and options for exporting only files, only PDF, or both. Update documentation and help output to reflect the new export capabilities. Consider concurrency and error handling for large projects. Ensure the export process is efficient and does not block the main CLI thread unnecessarily. + +# Test Strategy: +1. Run the 'export' command with various options and verify that task files are generated only on-demand, not automatically. 2. Generate a PDF export and confirm that the first page contains the correct 'tm list --with-subtasks' output, and that each subsequent page accurately reflects the output of 'tm show ' and 'tm show ' for all tasks and subtasks. 3. Test exporting in projects with large numbers of tasks and subtasks to ensure performance and correctness. 4. Attempt exports with invalid paths or missing data to verify robust error handling. 5. Confirm that no automatic file generation occurs during normal task operations. 6. Review CLI help output and documentation for accuracy regarding the new export functionality. + +# Subtasks: +## 1. Remove Automatic Task File Generation from Task Operations [pending] +### Dependencies: None +### Description: Eliminate all calls to generateTaskFiles() from task operations such as add-task, remove-task, set-status, and similar commands to prevent unnecessary performance overhead. +### Details: +Audit the codebase for any automatic invocations of generateTaskFiles() and remove or refactor them to ensure task files are not generated automatically during task operations. + +## 2. Implement Export Command Infrastructure with On-Demand Task File Generation [pending] +### Dependencies: 96.1 +### Description: Develop the CLI 'export' command infrastructure, enabling users to generate task files on-demand by invoking the preserved generateTaskFiles function only when requested. +### Details: +Create the export command with options for output paths and modes (files, PDF, or both). Ensure generateTaskFiles is only called within this command and not elsewhere. + +## 3. Implement Comprehensive PDF Export Functionality [pending] +### Dependencies: 96.2 +### Description: Add PDF export capability to the export command, generating a structured PDF with a first page listing all tasks and subtasks, followed by individual pages for each task and subtask, using a robust PDF library. +### Details: +Integrate a PDF generation library (e.g., pdfkit, Puppeteer, or jsPDF). Ensure the PDF includes the output of 'tm list --with-subtasks' on the first page, and uses 'tm show ' and 'tm show ' for subsequent pages. Handle pagination, concurrency, and error handling for large projects. + +## 4. Update Documentation, Tests, and CLI Help for Export Workflow [pending] +### Dependencies: 96.2, 96.3 +### Description: Revise all relevant documentation, automated tests, and CLI help output to reflect the new export-based workflow and available options. +### Details: +Update user guides, README files, and CLI help text. Add or modify tests to cover the new export command and its options. Ensure all documentation accurately describes the new workflow and usage. + diff --git a/.taskmaster/tasks/tasks.json b/.taskmaster/tasks/tasks.json index 9e62ad65..5e8c2d97 100644 --- a/.taskmaster/tasks/tasks.json +++ b/.taskmaster/tasks/tasks.json @@ -17,9 +17,7 @@ "title": "Develop Command Line Interface Foundation", "description": "Create the basic CLI structure using Commander.js with command parsing and help documentation.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "priority": "high", "details": "Implement the CLI foundation including:\n- Set up Commander.js for command parsing\n- Create help documentation for all commands\n- Implement colorized console output for better readability\n- Add logging system with configurable levels\n- Handle global options (--help, --version, --file, --quiet, --debug, --json)", "testStrategy": "Test each command with various parameters to ensure proper parsing. Verify help documentation is comprehensive and accurate. Test logging at different verbosity levels.", @@ -30,9 +28,7 @@ "title": "Implement Basic Task Operations", "description": "Create core functionality for managing tasks including listing, creating, updating, and deleting tasks.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "priority": "high", "details": "Implement the following task operations:\n- List tasks with filtering options\n- Create new tasks with required fields\n- Update existing task properties\n- Delete tasks\n- Change task status (pending/done/deferred)\n- Handle dependencies between tasks\n- Manage task priorities", "testStrategy": "Test each operation with valid and invalid inputs. Verify that dependencies are properly tracked and that status changes are reflected correctly in the tasks.json file.", @@ -43,10 +39,7 @@ "title": "Create Task File Generation System", "description": "Implement the system for generating individual task files from the tasks.json data structure.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "priority": "medium", "details": "Build the task file generation system including:\n- Create task file templates\n- Implement generation of task files from tasks.json\n- Add bi-directional synchronization between task files and tasks.json\n- Implement proper file naming and organization\n- Handle updates to task files reflecting back to tasks.json", "testStrategy": "Generate task files from sample tasks.json data and verify the content matches the expected format. Test synchronization by modifying task files and ensuring changes are reflected in tasks.json.", @@ -64,9 +57,7 @@ "title": "Implement Task File Generation Logic", "description": "Develop the core functionality to generate individual task files from the tasks.json data structure. This includes reading the tasks.json file, iterating through each task, applying the template to each task's data, and writing the resulting content to appropriately named files in the tasks directory. Ensure proper error handling for file operations and data validation.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Successfully reads tasks from tasks.json\n- Correctly applies template to each task's data\n- Generates files with proper naming convention (e.g., task_001.txt)\n- Creates the tasks directory if it doesn't exist\n- Handles errors gracefully (file not found, permission issues, etc.)\n- Validates task data before generation to prevent errors\n- Logs generation process with appropriate verbosity levels" }, { @@ -74,9 +65,7 @@ "title": "Implement File Naming and Organization System", "description": "Create a consistent system for naming and organizing task files. Implement a function that generates standardized filenames based on task IDs (e.g., task_001.txt for task ID 1). Design the directory structure for storing task files according to the PRD specification. Ensure the system handles task ID formatting consistently and prevents filename collisions.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Generates consistent filenames based on task IDs with proper zero-padding\n- Creates and maintains the correct directory structure as specified in the PRD\n- Handles special characters or edge cases in task IDs appropriately\n- Prevents filename collisions between different tasks\n- Provides utility functions for converting between task IDs and filenames\n- Maintains backward compatibility if the naming scheme needs to evolve" }, { @@ -84,11 +73,7 @@ "title": "Implement Task File to JSON Synchronization", "description": "Develop functionality to read modified task files and update the corresponding entries in tasks.json. This includes parsing the task file format, extracting structured data, validating the changes, and updating the tasks.json file accordingly. Ensure the system can handle concurrent modifications and resolve conflicts appropriately.", "status": "done", - "dependencies": [ - 1, - 3, - 2 - ], + "dependencies": [1, 3, 2], "acceptanceCriteria": "- Successfully parses task files to extract structured data\n- Validates parsed data against the task model schema\n- Updates tasks.json with changes from task files\n- Handles conflicts when the same task is modified in both places\n- Preserves task relationships and dependencies during synchronization\n- Provides clear error messages for parsing or validation failures\n- Updates the \"updatedAt\" timestamp in tasks.json metadata" }, { @@ -96,12 +81,7 @@ "title": "Implement Change Detection and Update Handling", "description": "Create a system to detect changes in task files and tasks.json, and handle updates bidirectionally. This includes implementing file watching or comparison mechanisms, determining which version is newer, and applying changes in the appropriate direction. Ensure the system handles edge cases like deleted files, new tasks, and conflicting changes.", "status": "done", - "dependencies": [ - 1, - 3, - 4, - 2 - ], + "dependencies": [1, 3, 4, 2], "acceptanceCriteria": "- Detects changes in both task files and tasks.json\n- Determines which version is newer based on modification timestamps or content\n- Applies changes in the appropriate direction (file to JSON or JSON to file)\n- Handles edge cases like deleted files, new tasks, and renamed tasks\n- Provides options for manual conflict resolution when necessary\n- Maintains data integrity during the synchronization process\n- Includes a command to force synchronization in either direction\n- Logs all synchronization activities for troubleshooting\n\nEach of these subtasks addresses a specific component of the task file generation system, following a logical progression from template design to bidirectional synchronization. The dependencies ensure that prerequisites are completed before dependent work begins, and the acceptance criteria provide clear guidelines for verifying each subtask's completion.", "details": "\n\n\n{\n \"id\": 5,\n \"title\": \"Implement Change Detection and Update Handling\",\n \"description\": \"Create a system to detect changes in task files and tasks.json, and handle updates bidirectionally. This includes implementing file watching or comparison mechanisms, determining which version is newer, and applying changes in the appropriate direction. Ensure the system handles edge cases like deleted files, new tasks, and conflicting changes.\",\n \"status\": \"done\",\n \"dependencies\": [\n 1,\n 3,\n 4,\n 2\n ],\n \"acceptanceCriteria\": \"- Detects changes in both task files and tasks.json\\n- Determines which version is newer based on modification timestamps or content\\n- Applies changes in the appropriate direction (file to JSON or JSON to file)\\n- Handles edge cases like deleted files, new tasks, and renamed tasks\\n- Provides options for manual conflict resolution when necessary\\n- Maintains data integrity during the synchronization process\\n- Includes a command to force synchronization in either direction\\n- Logs all synchronization activities for troubleshooting\\n\\nEach of these subtasks addresses a specific component of the task file generation system, following a logical progression from template design to bidirectional synchronization. The dependencies ensure that prerequisites are completed before dependent work begins, and the acceptance criteria provide clear guidelines for verifying each subtask's completion.\",\n \"details\": \"[2025-05-01 21:59:07] Adding another note via MCP test.\"\n}\n" } @@ -112,9 +92,7 @@ "title": "Integrate Anthropic Claude API", "description": "Set up the integration with Claude API for AI-powered task generation and expansion.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "priority": "high", "details": "Implement Claude API integration including:\n- API authentication using environment variables\n- Create prompt templates for various operations\n- Implement response handling and parsing\n- Add error management with retries and exponential backoff\n- Implement token usage tracking\n- Create configurable model parameters", "testStrategy": "Test API connectivity with sample prompts. Verify authentication works correctly with different API keys. Test error handling by simulating API failures.", @@ -132,9 +110,7 @@ "title": "Develop Prompt Template System", "description": "Create a flexible prompt template system for Claude API interactions. Implement a PromptTemplate class that can handle variable substitution, system and user messages, and proper formatting according to Claude's requirements. Include templates for different operations (task generation, task expansion, etc.) with appropriate instructions and constraints for each use case.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- PromptTemplate class supports variable substitution\n- System and user message separation is properly implemented\n- Templates exist for all required operations (task generation, expansion, etc.)\n- Templates include appropriate constraints and formatting instructions\n- Template system is unit tested with various inputs" }, { @@ -142,10 +118,7 @@ "title": "Implement Response Handling and Parsing", "description": "Create a response handling system that processes Claude API responses. Implement JSON parsing for structured outputs, error detection in responses, and extraction of relevant information. Build utility functions to transform Claude's responses into the application's data structures. Include validation to ensure responses meet expected formats.", "status": "done", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "acceptanceCriteria": "- Response parsing functions handle both JSON and text formats\n- Error detection identifies malformed or unexpected responses\n- Utility functions transform responses into task data structures\n- Validation ensures responses meet expected schemas\n- Edge cases like empty or partial responses are handled gracefully" }, { @@ -153,10 +126,7 @@ "title": "Build Error Management with Retry Logic", "description": "Implement a robust error handling system for Claude API interactions. Create middleware that catches API errors, network issues, and timeout problems. Implement exponential backoff retry logic that increases wait time between retries. Add configurable retry limits and timeout settings. Include detailed logging for troubleshooting API issues.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- All API errors are caught and handled appropriately\n- Exponential backoff retry logic is implemented\n- Retry limits and timeouts are configurable\n- Detailed error logging provides actionable information\n- System degrades gracefully when API is unavailable\n- Unit tests verify retry behavior with mocked API failures" }, { @@ -164,10 +134,7 @@ "title": "Implement Token Usage Tracking", "description": "Create a token tracking system to monitor Claude API usage. Implement functions to count tokens in prompts and responses. Build a logging system that records token usage per operation. Add reporting capabilities to show token usage trends and costs. Implement configurable limits to prevent unexpected API costs.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- Token counting functions accurately estimate usage\n- Usage logging records tokens per operation type\n- Reporting functions show usage statistics and estimated costs\n- Configurable limits can prevent excessive API usage\n- Warning system alerts when approaching usage thresholds\n- Token tracking data is persisted between application runs" }, { @@ -175,10 +142,7 @@ "title": "Create Model Parameter Configuration System", "description": "Implement a flexible system for configuring Claude model parameters. Create a configuration module that manages model selection, temperature, top_p, max_tokens, and other parameters. Build functions to customize parameters based on operation type. Add validation to ensure parameters are within acceptable ranges. Include preset configurations for different use cases (creative, precise, etc.).", "status": "done", - "dependencies": [ - 1, - 5 - ], + "dependencies": [1, 5], "acceptanceCriteria": "- Configuration module manages all Claude model parameters\n- Parameter customization functions exist for different operations\n- Validation ensures parameters are within acceptable ranges\n- Preset configurations exist for different use cases\n- Parameters can be overridden at runtime when needed\n- Documentation explains parameter effects and recommended values\n- Unit tests verify parameter validation and configuration loading" } ] @@ -188,10 +152,7 @@ "title": "Build PRD Parsing System", "description": "Create the system for parsing Product Requirements Documents into structured task lists.", "status": "done", - "dependencies": [ - 1, - 5 - ], + "dependencies": [1, 5], "priority": "high", "details": "Implement PRD parsing functionality including:\n- PRD file reading from specified path\n- Prompt engineering for effective PRD parsing\n- Convert PRD content to task structure via Claude API\n- Implement intelligent dependency inference\n- Add priority assignment logic\n- Handle large PRDs by chunking if necessary", "testStrategy": "Test with sample PRDs of varying complexity. Verify that generated tasks accurately reflect the requirements in the PRD. Check that dependencies and priorities are logically assigned.", @@ -217,9 +178,7 @@ "title": "Implement PRD to Task Conversion System", "description": "Develop the core functionality that sends PRD content to Claude API and converts the response into the task data structure. This includes sending the engineered prompts with PRD content to Claude, parsing the structured response, and transforming it into valid task objects that conform to the task model. Implement validation to ensure the generated tasks meet all requirements.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Successfully sends PRD content to Claude API with appropriate prompts\n- Parses Claude's response into structured task objects\n- Validates generated tasks against the task model schema\n- Handles API errors and response parsing failures gracefully\n- Generates unique and sequential task IDs" }, { @@ -227,10 +186,7 @@ "title": "Build Intelligent Dependency Inference System", "description": "Create an algorithm that analyzes the generated tasks and infers logical dependencies between them. The system should identify which tasks must be completed before others based on the content and context of each task. Implement both explicit dependency detection (from Claude's output) and implicit dependency inference (based on task relationships and logical ordering).", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- Correctly identifies explicit dependencies mentioned in task descriptions\n- Infers implicit dependencies based on task context and relationships\n- Prevents circular dependencies in the task graph\n- Provides confidence scores for inferred dependencies\n- Allows for manual override/adjustment of detected dependencies" }, { @@ -238,10 +194,7 @@ "title": "Implement Priority Assignment Logic", "description": "Develop a system that assigns appropriate priorities (high, medium, low) to tasks based on their content, dependencies, and position in the PRD. Create algorithms that analyze task descriptions, identify critical path tasks, and consider factors like technical risk and business value. Implement both automated priority assignment and manual override capabilities.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- Assigns priorities based on multiple factors (dependencies, critical path, risk)\n- Identifies foundation/infrastructure tasks as high priority\n- Balances priorities across the project (not everything is high priority)\n- Provides justification for priority assignments\n- Allows for manual adjustment of priorities" }, { @@ -249,11 +202,7 @@ "title": "Implement PRD Chunking for Large Documents", "description": "Create a system that can handle large PRDs by breaking them into manageable chunks for processing. Implement intelligent document segmentation that preserves context across chunks, tracks section relationships, and maintains coherence in the generated tasks. Develop a mechanism to reassemble and deduplicate tasks generated from different chunks into a unified task list.", "status": "done", - "dependencies": [ - 1, - 5, - 3 - ], + "dependencies": [1, 5, 3], "acceptanceCriteria": "- Successfully processes PRDs larger than Claude's context window\n- Intelligently splits documents at logical boundaries (sections, chapters)\n- Preserves context when processing individual chunks\n- Reassembles tasks from multiple chunks into a coherent task list\n- Detects and resolves duplicate or overlapping tasks\n- Maintains correct dependency relationships across chunks" } ] @@ -263,10 +212,7 @@ "title": "Implement Task Expansion with Claude", "description": "Create functionality to expand tasks into subtasks using Claude's AI capabilities.", "status": "done", - "dependencies": [ - 3, - 5 - ], + "dependencies": [3, 5], "priority": "medium", "details": "Build task expansion functionality including:\n- Create subtask generation prompts\n- Implement workflow for expanding a task into subtasks\n- Add context-aware expansion capabilities\n- Implement parent-child relationship management\n- Allow specification of number of subtasks to generate\n- Provide mechanism to regenerate unsatisfactory subtasks", "testStrategy": "Test expanding various types of tasks into subtasks. Verify that subtasks are properly linked to parent tasks. Check that context is properly incorporated into generated subtasks.", @@ -284,9 +230,7 @@ "title": "Develop Task Expansion Workflow and UI", "description": "Implement the command-line interface and workflow for expanding tasks into subtasks. Create a new command that allows users to select a task, specify the number of subtasks, and add optional context. Design the interaction flow to handle the API request, process the response, and update the tasks.json file with the newly generated subtasks.", "status": "done", - "dependencies": [ - 5 - ], + "dependencies": [5], "acceptanceCriteria": "- Command `node scripts/dev.js expand --id= --count=` is implemented\n- Optional parameters for additional context (`--context=\"...\"`) are supported\n- User is shown progress indicators during API calls\n- Generated subtasks are displayed for review before saving\n- Command handles errors gracefully with helpful error messages\n- Help documentation for the expand command is comprehensive" }, { @@ -294,9 +238,7 @@ "title": "Implement Context-Aware Expansion Capabilities", "description": "Enhance the task expansion functionality to incorporate project context when generating subtasks. Develop a system to gather relevant information from the project, such as related tasks, dependencies, and previously completed work. Implement logic to include this context in the Claude prompts to improve the relevance and quality of generated subtasks.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- System automatically gathers context from related tasks and dependencies\n- Project metadata is incorporated into expansion prompts\n- Implementation details from dependent tasks are included in context\n- Context gathering is configurable (amount and type of context)\n- Generated subtasks show awareness of existing project structure and patterns\n- Context gathering has reasonable performance even with large task collections" }, { @@ -304,9 +246,7 @@ "title": "Build Parent-Child Relationship Management", "description": "Implement the data structure and operations for managing parent-child relationships between tasks and subtasks. Create functions to establish these relationships in the tasks.json file, update the task model to support subtask arrays, and develop utilities to navigate, filter, and display task hierarchies. Ensure all basic task operations (update, delete, etc.) properly handle subtask relationships.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Task model is updated to include subtasks array\n- Subtasks have proper ID format (parent.sequence)\n- Parent tasks track their subtasks with proper references\n- Task listing command shows hierarchical structure\n- Completing all subtasks automatically updates parent task status\n- Deleting a parent task properly handles orphaned subtasks\n- Task file generation includes subtask information" }, { @@ -314,11 +254,7 @@ "title": "Implement Subtask Regeneration Mechanism", "description": "Create functionality that allows users to regenerate unsatisfactory subtasks. Implement a command that can target specific subtasks for regeneration, preserve satisfactory subtasks, and incorporate feedback to improve the new generation. Design the system to maintain proper parent-child relationships and task IDs during regeneration.", "status": "done", - "dependencies": [ - 1, - 2, - 4 - ], + "dependencies": [1, 2, 4], "acceptanceCriteria": "- Command `node scripts/dev.js regenerate --id=` is implemented\n- Option to regenerate all subtasks for a parent (`--all`)\n- Feedback parameter allows user to guide regeneration (`--feedback=\"...\"`)\n- Original subtask details are preserved in prompt context\n- Regenerated subtasks maintain proper ID sequence\n- Task relationships remain intact after regeneration\n- Command provides clear before/after comparison of subtasks" } ] @@ -328,11 +264,7 @@ "title": "Develop Implementation Drift Handling", "description": "Create system to handle changes in implementation that affect future tasks.", "status": "done", - "dependencies": [ - 3, - 5, - 7 - ], + "dependencies": [3, 5, 7], "priority": "medium", "details": "Implement drift handling including:\n- Add capability to update future tasks based on completed work\n- Implement task rewriting based on new context\n- Create dependency chain updates when tasks change\n- Preserve completed work while updating future tasks\n- Add command to analyze and suggest updates to future tasks", "testStrategy": "Simulate implementation changes and test the system's ability to update future tasks appropriately. Verify that completed tasks remain unchanged while pending tasks are updated correctly.", @@ -366,9 +298,7 @@ "title": "Implement Completed Work Preservation", "description": "Develop a mechanism to ensure that updates to future tasks don't affect completed work. This includes creating a versioning system for tasks, tracking task history, and implementing safeguards to prevent modifications to completed tasks. The system should maintain a record of task changes while ensuring that completed work remains stable.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Implementation of task versioning to track changes\n- Safeguards that prevent modifications to tasks marked as \"done\"\n- System to store and retrieve task history\n- Clear visual indicators in the CLI for tasks that have been modified\n- Ability to view the original version of a modified task\n- Unit tests for completed work preservation" }, { @@ -376,9 +306,7 @@ "title": "Create Update Analysis and Suggestion Command", "description": "Implement a CLI command that analyzes the current state of tasks, identifies potential drift between completed and pending tasks, and suggests updates. This command should provide a comprehensive report of potential inconsistencies and offer recommendations for task updates without automatically applying them. It should include options to apply all suggested changes, select specific changes to apply, or ignore suggestions.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- New CLI command \"analyze-drift\" implemented\n- Comprehensive analysis of potential implementation drift\n- Detailed report of suggested task updates\n- Interactive mode to select which suggestions to apply\n- Batch mode to apply all suggested changes\n- Option to export suggestions to a file for review\n- Documentation of the command usage and options\n- Integration tests that verify the end-to-end workflow" } ] @@ -388,9 +316,7 @@ "title": "Integrate Perplexity API", "description": "Add integration with Perplexity API for research-backed task generation.", "status": "done", - "dependencies": [ - 5 - ], + "dependencies": [5], "priority": "low", "details": "Implement Perplexity integration including:\n- API authentication via OpenAI client\n- Create research-oriented prompt templates\n- Implement response handling for Perplexity\n- Add fallback to Claude when Perplexity is unavailable\n- Implement response quality comparison logic\n- Add configuration for model selection", "testStrategy": "Test connectivity to Perplexity API. Verify research-oriented prompts return useful information. Test fallback mechanism by simulating Perplexity API unavailability.", @@ -442,10 +368,7 @@ "title": "Create Research-Backed Subtask Generation", "description": "Enhance subtask generation with research capabilities from Perplexity API.", "status": "done", - "dependencies": [ - 7, - 9 - ], + "dependencies": [7, 9], "priority": "low", "details": "Implement research-backed generation including:\n- Create specialized research prompts for different domains\n- Implement context enrichment from research results\n- Add domain-specific knowledge incorporation\n- Create more detailed subtask generation with best practices\n- Include references to relevant libraries and tools", "testStrategy": "Compare subtasks generated with and without research backing. Verify that research-backed subtasks include more specific technical details and best practices.", @@ -471,9 +394,7 @@ "title": "Develop Context Enrichment Pipeline", "description": "Create a pipeline that processes research results and enriches the task context with relevant information. This should include filtering irrelevant information, organizing research findings by category (tools, libraries, best practices, etc.), and formatting the enriched context for use in subtask generation. Implement a scoring mechanism to prioritize the most relevant research findings.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- Context enrichment function that takes raw research results and task details as input\n- Filtering system to remove irrelevant or low-quality information\n- Categorization of research findings into distinct sections (tools, libraries, patterns, etc.)\n- Relevance scoring algorithm to prioritize the most important findings\n- Formatted output that can be directly used in subtask generation prompts\n- Tests comparing enriched context quality against baseline" }, { @@ -481,9 +402,7 @@ "title": "Implement Domain-Specific Knowledge Incorporation", "description": "Develop a system to incorporate domain-specific knowledge into the subtask generation process. This should include identifying key domain concepts, technical requirements, and industry standards from the research results. Create a knowledge base structure that organizes domain information and can be referenced during subtask generation.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Domain knowledge extraction function that identifies key technical concepts\n- Knowledge base structure for organizing domain-specific information\n- Integration with the subtask generation prompt to incorporate relevant domain knowledge\n- Support for technical terminology and concept explanation in generated subtasks\n- Mechanism to link domain concepts to specific implementation recommendations\n- Tests verifying improved technical accuracy in generated subtasks" }, { @@ -491,10 +410,7 @@ "title": "Enhance Subtask Generation with Technical Details", "description": "Extend the existing subtask generation functionality to incorporate research findings and produce more technically detailed subtasks. This includes modifying the Claude prompt templates to leverage the enriched context, implementing specific sections for technical approach, implementation notes, and potential challenges. Ensure generated subtasks include concrete technical details rather than generic steps.", "status": "done", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "acceptanceCriteria": "- Enhanced prompt templates for Claude that incorporate research-backed context\n- Generated subtasks include specific technical approaches and implementation details\n- Each subtask contains references to relevant tools, libraries, or frameworks\n- Implementation notes section with code patterns or architectural recommendations\n- Potential challenges and mitigation strategies are included where appropriate\n- Comparative tests showing improvement over baseline subtask generation" }, { @@ -502,10 +418,7 @@ "title": "Implement Reference and Resource Inclusion", "description": "Create a system to include references to relevant libraries, tools, documentation, and other resources in generated subtasks. This should extract specific references from research results, validate their relevance, and format them as actionable links or citations within subtasks. Implement a verification step to ensure referenced resources are current and applicable.", "status": "done", - "dependencies": [ - 3, - 5 - ], + "dependencies": [3, 5], "acceptanceCriteria": "- Reference extraction function that identifies tools, libraries, and resources from research\n- Validation mechanism to verify reference relevance and currency\n- Formatting system for including references in subtask descriptions\n- Support for different reference types (GitHub repos, documentation, articles, etc.)\n- Optional version specification for referenced libraries and tools\n- Tests verifying that included references are relevant and accessible" } ] @@ -515,9 +428,7 @@ "title": "Implement Batch Operations", "description": "Add functionality for performing operations on multiple tasks simultaneously.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "priority": "medium", "details": "Create batch operations including:\n- Implement multi-task status updates\n- Add bulk subtask generation\n- Create task filtering and querying capabilities\n- Implement advanced dependency management\n- Add batch prioritization\n- Create commands for operating on filtered task sets", "testStrategy": "Test batch operations with various filters and operations. Verify that operations are applied correctly to all matching tasks. Test with large task sets to ensure performance.", @@ -527,9 +438,7 @@ "title": "Implement Multi-Task Status Update Functionality", "description": "Create a command-line interface command that allows users to update the status of multiple tasks simultaneously. Implement the backend logic to process batch status changes, validate the requested changes, and update the tasks.json file accordingly. The implementation should include options for filtering tasks by various criteria (ID ranges, status, priority, etc.) and applying status changes to the filtered set.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Command accepts parameters for filtering tasks (e.g., `--status=pending`, `--priority=high`, `--id=1,2,3-5`)\n- Command accepts a parameter for the new status value (e.g., `--new-status=done`)\n- All matching tasks are updated in the tasks.json file\n- Command provides a summary of changes made (e.g., \"Updated 5 tasks from 'pending' to 'done'\")\n- Command handles errors gracefully (e.g., invalid status values, no matching tasks)\n- Changes are persisted correctly to tasks.json" }, { @@ -537,10 +446,7 @@ "title": "Develop Bulk Subtask Generation System", "description": "Create functionality to generate multiple subtasks across several parent tasks at once. This should include a command-line interface that accepts filtering parameters to select parent tasks and either a template for subtasks or an AI-assisted generation option. The system should validate parent tasks, generate appropriate subtasks with proper ID assignments, and update the tasks.json file.", "status": "done", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "acceptanceCriteria": "- Command accepts parameters for filtering parent tasks\n- Command supports template-based subtask generation with variable substitution\n- Command supports AI-assisted subtask generation using Claude API\n- Generated subtasks have proper IDs following the parent.sequence format (e.g., 1.1, 1.2)\n- Subtasks inherit appropriate properties from parent tasks (e.g., dependencies)\n- Generated subtasks are added to the tasks.json file\n- Task files are regenerated to include the new subtasks\n- Command provides a summary of subtasks created" }, { @@ -556,9 +462,7 @@ "title": "Create Advanced Dependency Management System", "description": "Implement batch operations for managing dependencies between tasks. This includes commands for adding, removing, and updating dependencies across multiple tasks simultaneously. The system should validate dependency changes to prevent circular dependencies, update the tasks.json file, and regenerate task files to reflect the changes.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Command for adding dependencies to multiple tasks at once\n- Command for removing dependencies from multiple tasks\n- Command for replacing dependencies across multiple tasks\n- Validation to prevent circular dependencies\n- Validation to ensure referenced tasks exist\n- Automatic update of affected task files\n- Summary report of dependency changes made\n- Error handling for invalid dependency operations" }, { @@ -566,9 +470,7 @@ "title": "Implement Batch Task Prioritization and Command System", "description": "Create a system for batch prioritization of tasks and a command framework for operating on filtered task sets. This includes commands for changing priorities of multiple tasks at once and a generic command execution system that can apply custom operations to filtered task sets. The implementation should include a plugin architecture that allows for extending the system with new batch operations.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Command for changing priorities of multiple tasks at once\n- Support for relative priority changes (e.g., increase/decrease priority)\n- Generic command execution framework that works with the filtering system\n- Plugin architecture for registering new batch operations\n- At least three example plugins (e.g., batch tagging, batch assignment, batch export)\n- Command for executing arbitrary operations on filtered task sets\n- Documentation for creating new batch operation plugins\n- Performance testing with large task sets (100+ tasks)" } ] @@ -578,12 +480,7 @@ "title": "Develop Project Initialization System", "description": "Create functionality for initializing new projects with task structure and configuration.", "status": "done", - "dependencies": [ - 1, - 3, - 4, - 6 - ], + "dependencies": [1, 3, 4, 6], "priority": "medium", "details": "Implement project initialization including:\n- Create project templating system\n- Implement interactive setup wizard\n- Add environment configuration generation\n- Create initial directory structure\n- Generate example tasks.json\n- Set up default configuration", "testStrategy": "Test project initialization in empty directories. Verify that all required files and directories are created correctly. Test the interactive setup with various inputs.", @@ -593,9 +490,7 @@ "title": "Create Project Template Structure", "description": "Design and implement a flexible project template system that will serve as the foundation for new project initialization. This should include creating a base directory structure, template files (e.g., default tasks.json, .env.example), and a configuration file to define customizable aspects of the template.", "status": "done", - "dependencies": [ - 4 - ], + "dependencies": [4], "acceptanceCriteria": "- A `templates` directory is created with at least one default project template" }, { @@ -603,9 +498,7 @@ "title": "Implement Interactive Setup Wizard", "description": "Develop an interactive command-line wizard using a library like Inquirer.js to guide users through the project initialization process. The wizard should prompt for project name, description, initial task structure, and other configurable options defined in the template configuration.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Interactive wizard prompts for essential project information" }, { @@ -613,9 +506,7 @@ "title": "Generate Environment Configuration", "description": "Create functionality to generate environment-specific configuration files based on user input and template defaults. This includes creating a .env file with necessary API keys and configuration values, and updating the tasks.json file with project-specific metadata.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- .env file is generated with placeholders for required API keys" }, { @@ -623,9 +514,7 @@ "title": "Implement Directory Structure Creation", "description": "Develop the logic to create the initial directory structure for new projects based on the selected template and user inputs. This should include creating necessary subdirectories (e.g., tasks/, scripts/, .cursor/rules/) and copying template files to appropriate locations.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Directory structure is created according to the template specification" }, { @@ -633,9 +522,7 @@ "title": "Generate Example Tasks.json", "description": "Create functionality to generate an initial tasks.json file with example tasks based on the project template and user inputs from the setup wizard. This should include creating a set of starter tasks that demonstrate the task structure and provide a starting point for the project.", "status": "done", - "dependencies": [ - 6 - ], + "dependencies": [6], "acceptanceCriteria": "- An initial tasks.json file is generated with at least 3 example tasks" }, { @@ -653,10 +540,7 @@ "title": "Create Cursor Rules Implementation", "description": "Develop the Cursor AI integration rules and documentation.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "priority": "medium", "details": "Implement Cursor rules including:\n- Create dev_workflow.mdc documentation\n- Implement cursor_rules.mdc\n- Add self_improve.mdc\n- Design rule integration documentation\n- Set up .cursor directory structure\n- Document how Cursor AI should interact with the system", "testStrategy": "Review rules documentation for clarity and completeness. Test with Cursor AI to verify the rules are properly interpreted and followed.", @@ -674,9 +558,7 @@ "title": "Create dev_workflow.mdc Documentation", "description": "Develop the dev_workflow.mdc file that documents the development workflow for Cursor AI. This file should outline how Cursor AI should assist with task discovery, implementation, and verification within the project. Include specific examples of commands and interactions that demonstrate the optimal workflow.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- dev_workflow.mdc file created in .cursor/rules directory\n- Document clearly explains the development workflow with Cursor AI\n- Workflow documentation includes task discovery process\n- Implementation guidance for Cursor AI is detailed\n- Verification procedures are documented\n- Examples of typical interactions are provided" }, { @@ -684,9 +566,7 @@ "title": "Implement cursor_rules.mdc", "description": "Create the cursor_rules.mdc file that defines specific rules and guidelines for how Cursor AI should interact with the codebase. This should include code style preferences, architectural patterns to follow, documentation requirements, and any project-specific conventions that Cursor AI should adhere to when generating or modifying code.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- cursor_rules.mdc file created in .cursor/rules directory\n- Rules document clearly defines code style guidelines\n- Architectural patterns and principles are specified\n- Documentation requirements for generated code are outlined\n- Project-specific naming conventions are documented\n- Rules for handling dependencies and imports are defined\n- Guidelines for test implementation are included" }, { @@ -694,11 +574,7 @@ "title": "Add self_improve.mdc Documentation", "description": "Develop the self_improve.mdc file that instructs Cursor AI on how to continuously improve its assistance capabilities within the project context. This document should outline how Cursor AI should learn from feedback, adapt to project evolution, and enhance its understanding of the codebase over time.", "status": "done", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "acceptanceCriteria": "- self_improve.mdc file created in .cursor/rules directory\n- Document outlines feedback incorporation mechanisms\n- Guidelines for adapting to project evolution are included\n- Instructions for enhancing codebase understanding over time\n- Strategies for improving code suggestions based on past interactions\n- Methods for refining prompt responses based on user feedback\n- Approach for maintaining consistency with evolving project patterns" }, { @@ -706,12 +582,7 @@ "title": "Create Cursor AI Integration Documentation", "description": "Develop comprehensive documentation on how Cursor AI integrates with the task management system. This should include detailed instructions on how Cursor AI should interpret tasks.json, individual task files, and how it should assist with implementation. Document the specific commands and workflows that Cursor AI should understand and support.", "status": "done", - "dependencies": [ - 1, - 2, - 3, - 4 - ], + "dependencies": [1, 2, 3, 4], "acceptanceCriteria": "- Integration documentation created and stored in an appropriate location\n- Documentation explains how Cursor AI should interpret tasks.json structure\n- Guidelines for Cursor AI to understand task dependencies and priorities\n- Instructions for Cursor AI to assist with task implementation\n- Documentation of specific commands Cursor AI should recognize\n- Examples of effective prompts for working with the task system\n- Troubleshooting section for common Cursor AI integration issues\n- Documentation references all created rule files and explains their purpose" } ] @@ -721,9 +592,7 @@ "title": "Develop Agent Workflow Guidelines", "description": "Create comprehensive guidelines for how AI agents should interact with the task system.", "status": "done", - "dependencies": [ - 13 - ], + "dependencies": [13], "priority": "medium", "details": "Create agent workflow guidelines including:\n- Document task discovery workflow\n- Create task selection guidelines\n- Implement implementation guidance\n- Add verification procedures\n- Define how agents should prioritize work\n- Create guidelines for handling dependencies", "testStrategy": "Review guidelines with actual AI agents to verify they can follow the procedures. Test various scenarios to ensure the guidelines cover all common workflows.", @@ -741,9 +610,7 @@ "title": "Implement Task Selection Algorithm", "description": "Develop an algorithm for AI agents to select the most appropriate task to work on based on priority, dependencies, and current project status. This should include logic for evaluating task urgency, managing blocked tasks, and optimizing workflow efficiency. Implement the algorithm in JavaScript and integrate it with the existing task management system.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- JavaScript module implementing the task selection algorithm" }, { @@ -751,9 +618,7 @@ "title": "Create Implementation Guidance Generator", "description": "Develop a system that generates detailed implementation guidance for AI agents based on task descriptions and project context. This should leverage the Anthropic Claude API to create step-by-step instructions, suggest relevant libraries or tools, and provide code snippets or pseudocode where appropriate. Implement caching to reduce API calls and improve performance.", "status": "done", - "dependencies": [ - 5 - ], + "dependencies": [5], "acceptanceCriteria": "- Node.js module for generating implementation guidance using Claude API" }, { @@ -761,10 +626,7 @@ "title": "Develop Verification Procedure Framework", "description": "Create a flexible framework for defining and executing verification procedures for completed tasks. This should include a DSL (Domain Specific Language) for specifying acceptance criteria, automated test generation where possible, and integration with popular testing frameworks. Implement hooks for both automated and manual verification steps.", "status": "done", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "acceptanceCriteria": "- JavaScript module implementing the verification procedure framework" }, { @@ -772,11 +634,7 @@ "title": "Implement Dynamic Task Prioritization System", "description": "Develop a system that dynamically adjusts task priorities based on project progress, dependencies, and external factors. This should include an algorithm for recalculating priorities, a mechanism for propagating priority changes through dependency chains, and an API for external systems to influence priorities. Implement this as a background process that periodically updates the tasks.json file.", "status": "done", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "acceptanceCriteria": "- Node.js module implementing the dynamic prioritization system" } ] @@ -786,9 +644,7 @@ "title": "Optimize Agent Integration with Cursor and dev.js Commands", "description": "Document and enhance existing agent interaction patterns through Cursor rules and dev.js commands.", "status": "done", - "dependencies": [ - 14 - ], + "dependencies": [14], "priority": "medium", "details": "Optimize agent integration including:\n- Document and improve existing agent interaction patterns in Cursor rules\n- Enhance integration between Cursor agent capabilities and dev.js commands\n- Improve agent workflow documentation in cursor rules (dev_workflow.mdc, cursor_rules.mdc)\n- Add missing agent-specific features to existing commands\n- Leverage existing infrastructure rather than building a separate system", "testStrategy": "Test the enhanced commands with AI agents to verify they can correctly interpret and use them. Verify that agents can effectively interact with the task system using the documented patterns in Cursor rules.", @@ -814,9 +670,7 @@ "title": "Optimize Command Responses for Agent Consumption", "description": "Refine the output format of existing commands to ensure they are easily parseable by AI agents. Focus on consistent, structured outputs that agents can reliably interpret without requiring a separate parsing system.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- Command outputs optimized for agent consumption" }, { @@ -824,10 +678,7 @@ "title": "Improve Agent Workflow Documentation in Cursor Rules", "description": "Enhance the agent workflow documentation in dev_workflow.mdc and cursor_rules.mdc to provide clear guidance on how agents should interact with the task system. Include example interactions and best practices for agents.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- Enhanced agent workflow documentation in Cursor rules" }, { @@ -835,9 +686,7 @@ "title": "Add Agent-Specific Features to Existing Commands", "description": "Identify and implement any missing agent-specific features in the existing command system. This may include additional flags, parameters, or output formats that are particularly useful for agent interactions.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- Agent-specific features added to existing commands" }, { @@ -845,10 +694,7 @@ "title": "Create Agent Usage Examples and Patterns", "description": "Develop a set of example interactions and usage patterns that demonstrate how agents should effectively use the task system. Include these examples in the documentation to guide future agent implementations.", "status": "done", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "acceptanceCriteria": "- Comprehensive set of agent usage examples and patterns" } ] @@ -858,9 +704,7 @@ "title": "Create Configuration Management System", "description": "Implement robust configuration handling with environment variables and .env files.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "priority": "high", "details": "Build configuration management including:\n- Environment variable handling\n- .env file support\n- Configuration validation\n- Sensible defaults with overrides\n- Create .env.example template\n- Add configuration documentation\n- Implement secure handling of API keys", "testStrategy": "Test configuration loading from various sources (environment variables, .env files). Verify that validation correctly identifies invalid configurations. Test that defaults are applied when values are missing.", @@ -878,9 +722,7 @@ "title": "Implement .env File Support", "description": "Add support for loading configuration from .env files using dotenv or a similar library. Implement file detection, parsing, and merging with existing environment variables. Handle multiple environments (.env.development, .env.production, etc.) and implement proper error handling for file reading issues.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Integration with dotenv or equivalent library\n- Support for multiple environment-specific .env files (.env.development, .env.production)\n- Proper error handling for missing or malformed .env files\n- Priority order established (process.env overrides .env values)\n- Unit tests verifying .env file loading and overriding behavior" }, { @@ -888,10 +730,7 @@ "title": "Implement Configuration Validation", "description": "Create a validation system for configuration values using a schema validation library like Joi, Zod, or Ajv. Define schemas for all configuration categories (API keys, file paths, feature flags, etc.). Implement validation that runs at startup and provides clear error messages for invalid configurations.", "status": "done", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "acceptanceCriteria": "- Schema validation implemented for all configuration values\n- Type checking and format validation for different value types\n- Comprehensive error messages that clearly identify validation failures\n- Support for custom validation rules for complex configuration requirements\n- Unit tests covering validation of valid and invalid configurations" }, { @@ -899,11 +738,7 @@ "title": "Create Configuration Defaults and Override System", "description": "Implement a system of sensible defaults for all configuration values with the ability to override them via environment variables or .env files. Create a unified configuration object that combines defaults, .env values, and environment variables with proper precedence. Implement a caching mechanism to avoid repeated environment lookups.", "status": "done", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "acceptanceCriteria": "- Default configuration values defined for all settings\n- Clear override precedence (env vars > .env files > defaults)\n- Configuration object accessible throughout the application\n- Caching mechanism to improve performance\n- Unit tests verifying override behavior works correctly" }, { @@ -911,12 +746,7 @@ "title": "Create .env.example Template", "description": "Generate a comprehensive .env.example file that documents all supported environment variables, their purpose, format, and default values. Include comments explaining the purpose of each variable and provide examples. Ensure sensitive values are not included but have clear placeholders.", "status": "done", - "dependencies": [ - 1, - 2, - 3, - 4 - ], + "dependencies": [1, 2, 3, 4], "acceptanceCriteria": "- Complete .env.example file with all supported variables\n- Detailed comments explaining each variable's purpose and format\n- Clear placeholders for sensitive values (API_KEY=your-api-key-here)\n- Categorization of variables by function (API, logging, features, etc.)\n- Documentation on how to use the .env.example file" }, { @@ -924,12 +754,7 @@ "title": "Implement Secure API Key Handling", "description": "Create a secure mechanism for handling sensitive configuration values like API keys. Implement masking of sensitive values in logs and error messages. Add validation for API key formats and implement a mechanism to detect and warn about insecure storage of API keys (e.g., committed to git). Add support for key rotation and refresh.", "status": "done", - "dependencies": [ - 1, - 2, - 3, - 4 - ], + "dependencies": [1, 2, 3, 4], "acceptanceCriteria": "- Secure storage of API keys and sensitive configuration\n- Masking of sensitive values in logs and error messages\n- Validation of API key formats (length, character set, etc.)\n- Warning system for potentially insecure configuration practices\n- Support for key rotation without application restart\n- Unit tests verifying secure handling of sensitive configuration\n\nThese subtasks provide a comprehensive approach to implementing the configuration management system with a focus on security, validation, and developer experience. The tasks are sequenced to build upon each other logically, starting with basic environment variable support and progressing to more advanced features like secure API key handling." } ] @@ -939,9 +764,7 @@ "title": "Implement Comprehensive Logging System", "description": "Create a flexible logging system with configurable levels and output formats.", "status": "done", - "dependencies": [ - 16 - ], + "dependencies": [16], "priority": "medium", "details": "Implement logging system including:\n- Multiple log levels (debug, info, warn, error)\n- Configurable output destinations\n- Command execution logging\n- API interaction logging\n- Error tracking\n- Performance metrics\n- Log file rotation", "testStrategy": "Test logging at different verbosity levels. Verify that logs contain appropriate information for debugging. Test log file rotation with large volumes of logs.", @@ -959,9 +782,7 @@ "title": "Implement Configurable Output Destinations", "description": "Extend the logging framework to support multiple output destinations simultaneously. Implement adapters for console output, file output, and potentially other destinations (like remote logging services). Create a configuration system that allows specifying which log levels go to which destinations. Ensure thread-safe writing to prevent log corruption.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Abstract destination interface that can be implemented by different output types\n- Console output adapter with color-coding based on log level\n- File output adapter with proper file handling and path configuration\n- Configuration options to route specific log levels to specific destinations\n- Ability to add custom output destinations through the adapter pattern\n- Tests verifying logs are correctly routed to configured destinations" }, { @@ -969,10 +790,7 @@ "title": "Implement Command and API Interaction Logging", "description": "Create specialized logging functionality for command execution and API interactions. For commands, log the command name, arguments, options, and execution status. For API interactions, log request details (URL, method, headers), response status, and timing information. Implement sanitization to prevent logging sensitive data like API keys or passwords.", "status": "done", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "acceptanceCriteria": "- Command logger that captures command execution details\n- API logger that records request/response details with timing information\n- Data sanitization to mask sensitive information in logs\n- Configuration options to control verbosity of command and API logs\n- Integration with existing command execution flow\n- Tests verifying proper logging of commands and API calls" }, { @@ -980,9 +798,7 @@ "title": "Implement Error Tracking and Performance Metrics", "description": "Enhance the logging system to provide detailed error tracking and performance metrics. For errors, capture stack traces, error codes, and contextual information. For performance metrics, implement timing utilities to measure execution duration of key operations. Create a consistent format for these specialized log types to enable easier analysis.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Error logging with full stack trace capture and error context\n- Performance timer utility for measuring operation duration\n- Standard format for error and performance log entries\n- Ability to track related errors through correlation IDs\n- Configuration options for performance logging thresholds\n- Unit tests for error tracking and performance measurement" }, { @@ -990,9 +806,7 @@ "title": "Implement Log File Rotation and Management", "description": "Create a log file management system that handles rotation based on file size or time intervals. Implement compression of rotated logs, automatic cleanup of old logs, and configurable retention policies. Ensure that log rotation happens without disrupting the application and that no log messages are lost during rotation.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- Log rotation based on configurable file size or time interval\n- Compressed archive creation for rotated logs\n- Configurable retention policy for log archives\n- Zero message loss during rotation operations\n- Proper file locking to prevent corruption during rotation\n- Configuration options for rotation settings\n- Tests verifying rotation functionality with large log volumes\n- Documentation for log file location and naming conventions" } ] @@ -1002,17 +816,7 @@ "title": "Create Comprehensive User Documentation", "description": "Develop complete user documentation including README, examples, and troubleshooting guides.", "status": "done", - "dependencies": [ - 1, - 3, - 4, - 5, - 6, - 7, - 11, - 12, - 16 - ], + "dependencies": [1, 3, 4, 5, 6, 7, 11, 12, 16], "priority": "medium", "details": "Create user documentation including:\n- Detailed README with installation and usage instructions\n- Command reference documentation\n- Configuration guide\n- Example workflows\n- Troubleshooting guides\n- API integration documentation\n- Best practices\n- Advanced usage scenarios", "testStrategy": "Review documentation for clarity and completeness. Have users unfamiliar with the system attempt to follow the documentation and note any confusion or issues.", @@ -1022,9 +826,7 @@ "title": "Create Detailed README with Installation and Usage Instructions", "description": "Develop a comprehensive README.md file that serves as the primary documentation entry point. Include project overview, installation steps for different environments, basic usage examples, and links to other documentation sections. Structure the README with clear headings, code blocks for commands, and screenshots where helpful.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- README includes project overview, features list, and system requirements\n- Installation instructions cover all supported platforms with step-by-step commands\n- Basic usage examples demonstrate core functionality with command syntax\n- Configuration section explains environment variables and .env file usage\n- Documentation includes badges for version, license, and build status\n- All sections are properly formatted with Markdown for readability" }, { @@ -1032,9 +834,7 @@ "title": "Develop Command Reference Documentation", "description": "Create detailed documentation for all CLI commands, their options, arguments, and examples. Organize commands by functionality category, include syntax diagrams, and provide real-world examples for each command. Document all global options and environment variables that affect command behavior.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- All commands are documented with syntax, options, and arguments\n- Each command includes at least 2 practical usage examples\n- Commands are organized into logical categories (task management, AI integration, etc.)\n- Global options are documented with their effects on command execution\n- Exit codes and error messages are documented for troubleshooting\n- Documentation includes command output examples" }, { @@ -1050,10 +850,7 @@ "title": "Develop Example Workflows and Use Cases", "description": "Create detailed documentation of common workflows and use cases, showing how to use the tool effectively for different scenarios. Include step-by-step guides with command sequences, expected outputs, and explanations. Cover basic to advanced workflows, including PRD parsing, task expansion, and implementation drift handling.", "status": "done", - "dependencies": [ - 3, - 6 - ], + "dependencies": [3, 6], "acceptanceCriteria": "- At least 5 complete workflow examples from initialization to completion\n- Each workflow includes all commands in sequence with expected outputs\n- Screenshots or terminal recordings illustrate the workflows\n- Explanation of decision points and alternatives within workflows\n- Advanced use cases demonstrate integration with development processes\n- Examples show how to handle common edge cases and errors" }, { @@ -1061,11 +858,7 @@ "title": "Create Troubleshooting Guide and FAQ", "description": "Develop a comprehensive troubleshooting guide that addresses common issues, error messages, and their solutions. Include a FAQ section covering common questions about usage, configuration, and best practices. Document known limitations and workarounds for edge cases.", "status": "done", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "acceptanceCriteria": "- All error messages are documented with causes and solutions\n- Common issues are organized by category (installation, configuration, execution)\n- FAQ covers at least 15 common questions with detailed answers\n- Troubleshooting decision trees help users diagnose complex issues\n- Known limitations and edge cases are clearly documented\n- Recovery procedures for data corruption or API failures are included" }, { @@ -1073,9 +866,7 @@ "title": "Develop API Integration and Extension Documentation", "description": "Create technical documentation for API integrations (Claude, Perplexity) and extension points. Include details on prompt templates, response handling, token optimization, and custom integrations. Document the internal architecture to help developers extend the tool with new features or integrations.", "status": "done", - "dependencies": [ - 5 - ], + "dependencies": [5], "acceptanceCriteria": "- Detailed documentation of all API integrations with authentication requirements\n- Prompt templates are documented with variables and expected responses\n- Token usage optimization strategies are explained\n- Extension points are documented with examples\n- Internal architecture diagrams show component relationships\n- Custom integration guide includes step-by-step instructions and code examples" } ] @@ -1085,14 +876,7 @@ "title": "Implement Error Handling and Recovery", "description": "Create robust error handling throughout the system with helpful error messages and recovery options.", "status": "done", - "dependencies": [ - 1, - 3, - 5, - 9, - 16, - 17 - ], + "dependencies": [1, 3, 5, 9, 16, 17], "priority": "high", "details": "Implement error handling including:\n- Consistent error message format\n- Helpful error messages with recovery suggestions\n- API error handling with retries\n- File system error recovery\n- Data validation errors with specific feedback\n- Command syntax error guidance\n- System state recovery after failures", "testStrategy": "Deliberately trigger various error conditions and verify that the system handles them gracefully. Check that error messages are helpful and provide clear guidance on how to resolve issues.", @@ -1118,9 +902,7 @@ "title": "Develop File System Error Recovery Mechanisms", "description": "Implement error handling and recovery mechanisms for file system operations, focusing on tasks.json and individual task files. This should include handling of file not found errors, permission issues, and data corruption scenarios. Implement automatic backups and recovery procedures to ensure data integrity.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- File system operations are wrapped with comprehensive error handling" }, { @@ -1128,10 +910,7 @@ "title": "Enhance Data Validation with Detailed Error Feedback", "description": "Improve the existing data validation system to provide more specific and actionable error messages. Implement detailed validation checks for all user inputs and task data, with clear error messages that pinpoint the exact issue and how to resolve it. This should cover task creation, updates, and any data imported from external sources.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- Enhanced validation checks are implemented for all task properties and user inputs" }, { @@ -1139,9 +918,7 @@ "title": "Implement Command Syntax Error Handling and Guidance", "description": "Enhance the CLI to provide more helpful error messages and guidance when users input invalid commands or options. Implement a \"did you mean?\" feature for close matches to valid commands, and provide context-sensitive help for command syntax errors. This should integrate with the existing Commander.js setup.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- Invalid commands trigger helpful error messages with suggestions for valid alternatives" }, { @@ -1149,10 +926,7 @@ "title": "Develop System State Recovery After Critical Failures", "description": "Implement a system state recovery mechanism to handle critical failures that could leave the task management system in an inconsistent state. This should include creating periodic snapshots of the system state, implementing a recovery procedure to restore from these snapshots, and providing tools for manual intervention if automatic recovery fails.", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "acceptanceCriteria": "- Periodic snapshots of the tasks.json and related state are automatically created" } ] @@ -1162,11 +936,7 @@ "title": "Create Token Usage Tracking and Cost Management", "description": "Implement system for tracking API token usage and managing costs.", "status": "done", - "dependencies": [ - 5, - 9, - 17 - ], + "dependencies": [5, 9, 17], "priority": "medium", "details": "Implement token tracking including:\n- Track token usage for all API calls\n- Implement configurable usage limits\n- Add reporting on token consumption\n- Create cost estimation features\n- Implement caching to reduce API calls\n- Add token optimization for prompts\n- Create usage alerts when approaching limits", "testStrategy": "Track token usage across various operations and verify accuracy. Test that limits properly prevent excessive usage. Verify that caching reduces token consumption for repeated operations.", @@ -1176,9 +946,7 @@ "title": "Implement Token Usage Tracking for API Calls", "description": "Create a middleware or wrapper function that intercepts all API calls to OpenAI, Anthropic, and Perplexity. This function should count the number of tokens used in both the request and response, storing this information in a persistent data store (e.g., SQLite database). Implement a caching mechanism to reduce redundant API calls and token usage.", "status": "done", - "dependencies": [ - 5 - ], + "dependencies": [5], "acceptanceCriteria": "- Token usage is accurately tracked for all API calls" }, { @@ -1194,10 +962,7 @@ "title": "Implement Token Usage Reporting and Cost Estimation", "description": "Develop a reporting module that generates detailed token usage reports. Include breakdowns by API, user, and time period. Implement cost estimation features by integrating current pricing information for each API. Create both command-line and programmatic interfaces for generating reports and estimates.", "status": "done", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "acceptanceCriteria": "- CLI command for generating usage reports with various filters" }, { @@ -1213,10 +978,7 @@ "title": "Develop Token Usage Alert System", "description": "Create an alert system that monitors token usage in real-time and sends notifications when usage approaches or exceeds defined thresholds. Implement multiple notification channels (e.g., email, Slack, system logs) and allow for customizable alert rules. Integrate this system with the existing logging and reporting modules.", "status": "done", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "acceptanceCriteria": "- Real-time monitoring of token usage against configured limits" } ] @@ -1226,11 +988,7 @@ "title": "Refactor dev.js into Modular Components", "description": "Restructure the monolithic dev.js file into separate modular components to improve code maintainability, readability, and testability while preserving all existing functionality.", "status": "done", - "dependencies": [ - 3, - 16, - 17 - ], + "dependencies": [3, 16, 17], "priority": "high", "details": "This task involves breaking down the current dev.js file into logical modules with clear responsibilities:\n\n1. Create the following module files:\n - commands.js: Handle all CLI command definitions and execution logic\n - ai-services.js: Encapsulate all AI service interactions (OpenAI, etc.)\n - task-manager.js: Manage task operations (create, read, update, delete)\n - ui.js: Handle all console output formatting, colors, and user interaction\n - utils.js: Contain helper functions, utilities, and shared code\n\n2. Refactor dev.js to serve as the entry point that:\n - Imports and initializes all modules\n - Handles command-line argument parsing\n - Sets up the execution environment\n - Orchestrates the flow between modules\n\n3. Ensure proper dependency injection between modules to avoid circular dependencies\n\n4. Maintain consistent error handling across modules\n\n5. Update import/export statements throughout the codebase\n\n6. Document each module with clear JSDoc comments explaining purpose and usage\n\n7. Ensure configuration and logging systems are properly integrated into each module\n\nThe refactoring should not change any existing functionality - this is purely a code organization task.", "testStrategy": "Testing should verify that functionality remains identical after refactoring:\n\n1. Automated Testing:\n - Create unit tests for each new module to verify individual functionality\n - Implement integration tests that verify modules work together correctly\n - Test each command to ensure it works exactly as before\n\n2. Manual Testing:\n - Execute all existing CLI commands and verify outputs match pre-refactoring behavior\n - Test edge cases like error handling and invalid inputs\n - Verify that configuration options still work as expected\n\n3. Code Quality Verification:\n - Run linting tools to ensure code quality standards are maintained\n - Check for any circular dependencies between modules\n - Verify that each module has a single, clear responsibility\n\n4. Performance Testing:\n - Compare execution time before and after refactoring to ensure no performance regression\n\n5. Documentation Check:\n - Verify that each module has proper documentation\n - Ensure README is updated if necessary to reflect architectural changes", @@ -1248,9 +1006,7 @@ "title": "Create Core Module Structure and Entry Point Refactoring", "description": "Create the skeleton structure for all module files (commands.js, ai-services.js, task-manager.js, ui.js, utils.js) with proper export statements. Refactor dev.js to serve as the entry point that imports and orchestrates these modules. Implement the basic initialization flow and command-line argument parsing in the new structure.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- All module files created with appropriate JSDoc headers explaining purpose" }, { @@ -1258,9 +1014,7 @@ "title": "Implement Core Module Functionality with Dependency Injection", "description": "Migrate the core functionality from dev.js into the appropriate modules following the mapping document. Implement proper dependency injection to avoid circular dependencies. Ensure each module has a clear API and properly encapsulates its internal state. Focus on the critical path functionality first.", "status": "done", - "dependencies": [ - 2 - ], + "dependencies": [2], "acceptanceCriteria": "- All core functionality migrated to appropriate modules" }, { @@ -1268,9 +1022,7 @@ "title": "Implement Error Handling and Complete Module Migration", "description": "Establish a consistent error handling pattern across all modules. Complete the migration of remaining functionality from dev.js to the appropriate modules. Ensure all edge cases, error scenarios, and helper functions are properly moved and integrated. Update all import/export statements throughout the codebase to reference the new module structure.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "acceptanceCriteria": "- Consistent error handling pattern implemented across all modules" }, { @@ -1278,9 +1030,7 @@ "title": "Test, Document, and Finalize Modular Structure", "description": "Perform comprehensive testing of the refactored codebase to ensure all functionality works as expected. Add detailed JSDoc comments to all modules, functions, and significant code blocks. Create or update developer documentation explaining the new modular structure, module responsibilities, and how they interact. Perform a final code review to ensure code quality, consistency, and adherence to best practices.", "status": "done", - "dependencies": [ - "21.4" - ], + "dependencies": ["21.4"], "acceptanceCriteria": "- All existing functionality works exactly as before" } ] @@ -1290,9 +1040,7 @@ "title": "Create Comprehensive Test Suite for Task Master CLI", "description": "Develop a complete testing infrastructure for the Task Master CLI that includes unit, integration, and end-to-end tests to verify all core functionality and error handling.", "status": "done", - "dependencies": [ - 21 - ], + "dependencies": [21], "priority": "high", "details": "Implement a comprehensive test suite using Jest as the testing framework. The test suite should be organized into three main categories:\n\n1. Unit Tests:\n - Create tests for all utility functions and core logic components\n - Test task creation, parsing, and manipulation functions\n - Test data storage and retrieval functions\n - Test formatting and display functions\n\n2. Integration Tests:\n - Test all CLI commands (create, expand, update, list, etc.)\n - Verify command options and parameters work correctly\n - Test interactions between different components\n - Test configuration loading and application settings\n\n3. End-to-End Tests:\n - Test complete workflows (e.g., creating a task, expanding it, updating status)\n - Test error scenarios and recovery\n - Test edge cases like handling large numbers of tasks\n\nImplement proper mocking for:\n- Claude API interactions (using Jest mock functions)\n- File system operations (using mock-fs or similar)\n- User input/output (using mock stdin/stdout)\n\nEnsure tests cover both successful operations and error handling paths. Set up continuous integration to run tests automatically. Create fixtures for common test data and scenarios. Include test coverage reporting to identify untested code paths.", "testStrategy": "Verification will involve:\n\n1. Code Review:\n - Verify test organization follows the unit/integration/end-to-end structure\n - Check that all major functions have corresponding tests\n - Verify mocks are properly implemented for external dependencies\n\n2. Test Coverage Analysis:\n - Run test coverage tools to ensure at least 80% code coverage\n - Verify critical paths have 100% coverage\n - Identify any untested code paths\n\n3. Test Quality Verification:\n - Manually review test cases to ensure they test meaningful behavior\n - Verify both positive and negative test cases exist\n - Check that tests are deterministic and don't have false positives/negatives\n\n4. CI Integration:\n - Verify tests run successfully in the CI environment\n - Ensure tests run in a reasonable amount of time\n - Check that test failures provide clear, actionable information\n\nThe task will be considered complete when all tests pass consistently, coverage meets targets, and the test suite can detect intentionally introduced bugs.", @@ -1310,9 +1058,7 @@ "title": "Implement Unit Tests for Core Components", "description": "Create a comprehensive set of unit tests for all utility functions, core logic components, and individual modules of the Task Master CLI. This includes tests for task creation, parsing, manipulation, data storage, retrieval, and formatting functions. Ensure all edge cases and error scenarios are covered.", "status": "done", - "dependencies": [ - 1 - ], + "dependencies": [1], "acceptanceCriteria": "- Unit tests are implemented for all utility functions in the project" }, { @@ -1320,10 +1066,7 @@ "title": "Develop Integration and End-to-End Tests", "description": "Create integration tests that verify the correct interaction between different components of the CLI, including command execution, option parsing, and data flow. Implement end-to-end tests that simulate complete user workflows, such as creating a task, expanding it, and updating its status. Include tests for error scenarios, recovery processes, and handling large numbers of tasks.", "status": "deferred", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "acceptanceCriteria": "- Integration tests cover all CLI commands (create, expand, update, list, etc.)" } ] @@ -1333,9 +1076,7 @@ "title": "Complete MCP Server Implementation for Task Master using FastMCP", "description": "Finalize the MCP server functionality for Task Master by leveraging FastMCP's capabilities, transitioning from CLI-based execution to direct function imports, and optimizing performance, authentication, and context management. Ensure the server integrates seamlessly with Cursor via `mcp.json` and supports proper tool registration, efficient context handling, and transport type handling (focusing on stdio). Additionally, ensure the server can be instantiated properly when installed via `npx` or `npm i -g`. Evaluate and address gaps in the current implementation, including function imports, context management, caching, tool registration, and adherence to FastMCP best practices.", "status": "done", - "dependencies": [ - 22 - ], + "dependencies": [22], "priority": "medium", "details": "This task involves completing the Model Context Protocol (MCP) server implementation for Task Master using FastMCP. Key updates include:\n\n1. Transition from CLI-based execution (currently using `child_process.spawnSync`) to direct Task Master function imports for improved performance and reliability.\n2. Implement caching mechanisms for frequently accessed contexts to enhance performance, leveraging FastMCP's efficient transport mechanisms (e.g., stdio).\n3. Refactor context management to align with best practices for handling large context windows, metadata, and tagging.\n4. Refactor tool registration in `tools/index.js` to include clear descriptions and parameter definitions, leveraging FastMCP's decorator-based patterns for better integration.\n5. Enhance transport type handling to ensure proper stdio communication and compatibility with FastMCP.\n6. Ensure the MCP server can be instantiated and run correctly when installed globally via `npx` or `npm i -g`.\n7. Integrate the ModelContextProtocol SDK directly to streamline resource and tool registration, ensuring compatibility with FastMCP's transport mechanisms.\n8. Identify and address missing components or functionalities to meet FastMCP best practices, such as robust error handling, monitoring endpoints, and concurrency support.\n9. Update documentation to include examples of using the MCP server with FastMCP, detailed setup instructions, and client integration guides.\n10. Organize direct function implementations in a modular structure within the mcp-server/src/core/direct-functions/ directory for improved maintainability and organization.\n11. Follow consistent naming conventions: file names use kebab-case (like-this.js), direct functions use camelCase with Direct suffix (functionNameDirect), tool registration functions use camelCase with Tool suffix (registerToolNameTool), and MCP tool names exposed to clients use snake_case (tool_name).\n\nThe implementation must ensure compatibility with existing MCP clients and follow RESTful API design principles, while supporting concurrent requests and maintaining robust error handling.", "testStrategy": "Testing for the MCP server implementation will follow a comprehensive approach based on our established testing guidelines:\n\n## Test Organization\n\n1. **Unit Tests** (`tests/unit/mcp-server/`):\n - Test individual MCP server components in isolation\n - Mock all external dependencies including FastMCP SDK\n - Test each tool implementation separately\n - Test each direct function implementation in the direct-functions directory\n - Verify direct function imports work correctly\n - Test context management and caching mechanisms\n - Example files: `context-manager.test.js`, `tool-registration.test.js`, `direct-functions/list-tasks.test.js`\n\n2. **Integration Tests** (`tests/integration/mcp-server/`):\n - Test interactions between MCP server components\n - Verify proper tool registration with FastMCP\n - Test context flow between components\n - Validate error handling across module boundaries\n - Test the integration between direct functions and their corresponding MCP tools\n - Example files: `server-tool-integration.test.js`, `context-flow.test.js`\n\n3. **End-to-End Tests** (`tests/e2e/mcp-server/`):\n - Test complete MCP server workflows\n - Verify server instantiation via different methods (direct, npx, global install)\n - Test actual stdio communication with mock clients\n - Example files: `server-startup.e2e.test.js`, `client-communication.e2e.test.js`\n\n4. **Test Fixtures** (`tests/fixtures/mcp-server/`):\n - Sample context data\n - Mock tool definitions\n - Sample MCP requests and responses\n\n## Testing Approach\n\n### Module Mocking Strategy\n```javascript\n// Mock the FastMCP SDK\njest.mock('@model-context-protocol/sdk', () => ({\n MCPServer: jest.fn().mockImplementation(() => ({\n registerTool: jest.fn(),\n registerResource: jest.fn(),\n start: jest.fn().mockResolvedValue(undefined),\n stop: jest.fn().mockResolvedValue(undefined)\n })),\n MCPError: jest.fn().mockImplementation(function(message, code) {\n this.message = message;\n this.code = code;\n })\n}));\n\n// Import modules after mocks\nimport { MCPServer, MCPError } from '@model-context-protocol/sdk';\nimport { initMCPServer } from '../../scripts/mcp-server.js';\n```\n\n### Direct Function Testing\n- Test each direct function in isolation\n- Verify proper error handling and return formats\n- Test with various input parameters and edge cases\n- Verify integration with the task-master-core.js export hub\n\n### Context Management Testing\n- Test context creation, retrieval, and manipulation\n- Verify caching mechanisms work correctly\n- Test context windowing and metadata handling\n- Validate context persistence across server restarts\n\n### Direct Function Import Testing\n- Verify Task Master functions are imported correctly\n- Test performance improvements compared to CLI execution\n- Validate error handling with direct imports\n\n### Tool Registration Testing\n- Verify tools are registered with proper descriptions and parameters\n- Test decorator-based registration patterns\n- Validate tool execution with different input types\n\n### Error Handling Testing\n- Test all error paths with appropriate MCPError types\n- Verify error propagation to clients\n- Test recovery from various error conditions\n\n### Performance Testing\n- Benchmark response times with and without caching\n- Test memory usage under load\n- Verify concurrent request handling\n\n## Test Quality Guidelines\n\n- Follow TDD approach when possible\n- Maintain test independence and isolation\n- Use descriptive test names explaining expected behavior\n- Aim for 80%+ code coverage, with critical paths at 100%\n- Follow the mock-first-then-import pattern for all Jest mocks\n- Avoid testing implementation details that might change\n- Ensure tests don't depend on execution order\n\n## Specific Test Cases\n\n1. **Server Initialization**\n - Test server creation with various configuration options\n - Verify proper tool and resource registration\n - Test server startup and shutdown procedures\n\n2. **Context Operations**\n - Test context creation, retrieval, update, and deletion\n - Verify context windowing and truncation\n - Test context metadata and tagging\n\n3. **Tool Execution**\n - Test each tool with various input parameters\n - Verify proper error handling for invalid inputs\n - Test tool execution performance\n\n4. **MCP.json Integration**\n - Test creation and updating of .cursor/mcp.json\n - Verify proper server registration in mcp.json\n - Test handling of existing mcp.json files\n\n5. **Transport Handling**\n - Test stdio communication\n - Verify proper message formatting\n - Test error handling in transport layer\n\n6. **Direct Function Structure**\n - Test the modular organization of direct functions\n - Verify proper import/export through task-master-core.js\n - Test utility functions in the utils directory\n\nAll tests will be automated and integrated into the CI/CD pipeline to ensure consistent quality.", @@ -1353,9 +1094,7 @@ "id": 2, "title": "Implement Context Management System", "description": "Develop a robust context management system that can efficiently store, retrieve, and manipulate context data according to the MCP specification.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implementation steps:\n1. Design and implement data structures for context storage\n2. Create methods for context creation, retrieval, updating, and deletion\n3. Implement context windowing and truncation algorithms for handling size limits\n4. Add support for context metadata and tagging\n5. Create utilities for context serialization and deserialization\n6. Implement efficient indexing for quick context lookups\n7. Add support for context versioning and history\n8. Develop mechanisms for context persistence (in-memory, disk-based, or database)\n\nTesting approach:\n- Unit tests for all context operations (CRUD)\n- Performance tests for context retrieval with various sizes\n- Test context windowing and truncation with edge cases\n- Verify metadata handling and tagging functionality\n- Test persistence mechanisms with simulated failures", "status": "done", "parentTaskId": 23 @@ -1364,10 +1103,7 @@ "id": 3, "title": "Implement MCP Endpoints and API Handlers", "description": "Develop the complete API handlers for all required MCP endpoints, ensuring they follow the protocol specification and integrate with the context management system.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Implementation steps:\n1. Implement the `/context` endpoint for:\n - GET: retrieving existing context\n - POST: creating new context\n - PUT: updating existing context\n - DELETE: removing context\n2. Implement the `/models` endpoint to list available models\n3. Develop the `/execute` endpoint for performing operations with context\n4. Create request validators for each endpoint\n5. Implement response formatters according to MCP specifications\n6. Add detailed error handling for each endpoint\n7. Set up proper HTTP status codes for different scenarios\n8. Implement pagination for endpoints that return lists\n\nTesting approach:\n- Unit tests for each endpoint handler\n- Integration tests with mock context data\n- Test various request formats and edge cases\n- Verify response formats match MCP specifications\n- Test error handling with invalid inputs\n- Benchmark endpoint performance", "status": "done", "parentTaskId": 23 @@ -1376,11 +1112,7 @@ "id": 6, "title": "Refactor MCP Server to Leverage ModelContextProtocol SDK", "description": "Integrate the ModelContextProtocol SDK directly into the MCP server implementation to streamline tool registration and resource handling.", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "details": "Implementation steps:\n1. Replace manual tool registration with ModelContextProtocol SDK methods.\n2. Use SDK utilities to simplify resource and template management.\n3. Ensure compatibility with FastMCP's transport mechanisms.\n4. Update server initialization to include SDK-based configurations.\n\nTesting approach:\n- Verify SDK integration with all MCP endpoints.\n- Test resource and template registration using SDK methods.\n- Validate compatibility with existing MCP clients.\n- Benchmark performance improvements from SDK integration.\n\n\nThe subtask is being cancelled because FastMCP already serves as a higher-level abstraction over the Model Context Protocol SDK. Direct integration with the MCP SDK would be redundant and potentially counterproductive since:\n\n1. FastMCP already encapsulates the necessary SDK functionality for tool registration and resource handling\n2. The existing FastMCP abstractions provide a more streamlined developer experience\n3. Adding another layer of SDK integration would increase complexity without clear benefits\n4. The transport mechanisms in FastMCP are already optimized for the current architecture\n\nInstead, we should focus on extending and enhancing the existing FastMCP abstractions where needed, rather than attempting to bypass them with direct SDK integration.\n", "status": "done", "parentTaskId": 23 @@ -1389,9 +1121,7 @@ "id": 8, "title": "Implement Direct Function Imports and Replace CLI-based Execution", "description": "Refactor the MCP server implementation to use direct Task Master function imports instead of the current CLI-based execution using child_process.spawnSync. This will improve performance, reliability, and enable better error handling.", - "dependencies": [ - "23.13" - ], + "dependencies": ["23.13"], "details": "\n\n\n```\n# Refactoring Strategy for Direct Function Imports\n\n## Core Approach\n1. Create a clear separation between data retrieval/processing and presentation logic\n2. Modify function signatures to accept `outputFormat` parameter ('cli'|'json', default: 'cli')\n3. Implement early returns for JSON format to bypass CLI-specific code\n\n## Implementation Details for `listTasks`\n```javascript\nfunction listTasks(tasksPath, statusFilter, withSubtasks = false, outputFormat = 'cli') {\n try {\n // Existing data retrieval logic\n const filteredTasks = /* ... */;\n \n // Early return for JSON format\n if (outputFormat === 'json') return filteredTasks;\n \n // Existing CLI output logic\n } catch (error) {\n if (outputFormat === 'json') {\n throw {\n code: 'TASK_LIST_ERROR',\n message: error.message,\n details: error.stack\n };\n } else {\n console.error(error);\n process.exit(1);\n }\n }\n}\n```\n\n## Testing Strategy\n- Create integration tests in `tests/integration/mcp-server/`\n- Use FastMCP InMemoryTransport for direct client-server testing\n- Test both JSON and CLI output formats\n- Verify structure consistency with schema validation\n\n## Additional Considerations\n- Update JSDoc comments to document new parameters and return types\n- Ensure backward compatibility with default CLI behavior\n- Add JSON schema validation for consistent output structure\n- Apply similar pattern to other core functions (expandTask, updateTaskById, etc.)\n\n## Error Handling Improvements\n- Standardize error format for JSON returns:\n```javascript\n{\n code: 'ERROR_CODE',\n message: 'Human-readable message',\n details: {}, // Additional context when available\n stack: process.env.NODE_ENV === 'development' ? error.stack : undefined\n}\n```\n- Enrich JSON errors with error codes and debug info\n- Ensure validation failures return proper objects in JSON mode\n```\n", "status": "done", "parentTaskId": 23 @@ -1400,9 +1130,7 @@ "id": 9, "title": "Implement Context Management and Caching Mechanisms", "description": "Enhance the MCP server with proper context management and caching to improve performance and user experience, especially for frequently accessed data and contexts.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "1. Implement a context manager class that leverages FastMCP's Context object\n2. Add caching for frequently accessed task data with configurable TTL settings\n3. Implement context tagging for better organization of context data\n4. Add methods to efficiently handle large context windows\n5. Create helper functions for storing and retrieving context data\n6. Implement cache invalidation strategies for task updates\n7. Add cache statistics for monitoring performance\n8. Create unit tests for context management and caching functionality", "status": "done", "parentTaskId": 23 @@ -1411,10 +1139,7 @@ "id": 10, "title": "Enhance Tool Registration and Resource Management", "description": "Refactor tool registration to follow FastMCP best practices, using decorators and improving the overall structure. Implement proper resource management for task templates and other shared resources.", - "dependencies": [ - 1, - "23.8" - ], + "dependencies": [1, "23.8"], "details": "1. Update registerTaskMasterTools function to use FastMCP's decorator pattern\n2. Implement @mcp.tool() decorators for all existing tools\n3. Add proper type annotations and documentation for all tools\n4. Create resource handlers for task templates using @mcp.resource()\n5. Implement resource templates for common task patterns\n6. Update the server initialization to properly register all tools and resources\n7. Add validation for tool inputs using FastMCP's built-in validation\n8. Create comprehensive tests for tool registration and resource access\n\n\nHere is additional information to enhance the subtask regarding resources and resource templates in FastMCP:\n\nResources in FastMCP are used to expose static or dynamic data to LLM clients. For the Task Master MCP server, we should implement resources to provide:\n\n1. Task templates: Predefined task structures that can be used as starting points\n2. Workflow definitions: Reusable workflow patterns for common task sequences\n3. User preferences: Stored user settings for task management\n4. Project metadata: Information about active projects and their attributes\n\nResource implementation should follow this structure:\n\n```python\n@mcp.resource(\"tasks://templates/{template_id}\")\ndef get_task_template(template_id: str) -> dict:\n # Fetch and return the specified task template\n ...\n\n@mcp.resource(\"workflows://definitions/{workflow_id}\")\ndef get_workflow_definition(workflow_id: str) -> dict:\n # Fetch and return the specified workflow definition\n ...\n\n@mcp.resource(\"users://{user_id}/preferences\")\ndef get_user_preferences(user_id: str) -> dict:\n # Fetch and return user preferences\n ...\n\n@mcp.resource(\"projects://metadata\")\ndef get_project_metadata() -> List[dict]:\n # Fetch and return metadata for all active projects\n ...\n```\n\nResource templates in FastMCP allow for dynamic generation of resources based on patterns. For Task Master, we can implement:\n\n1. Dynamic task creation templates\n2. Customizable workflow templates\n3. User-specific resource views\n\nExample implementation:\n\n```python\n@mcp.resource(\"tasks://create/{task_type}\")\ndef get_task_creation_template(task_type: str) -> dict:\n # Generate and return a task creation template based on task_type\n ...\n\n@mcp.resource(\"workflows://custom/{user_id}/{workflow_name}\")\ndef get_custom_workflow_template(user_id: str, workflow_name: str) -> dict:\n # Generate and return a custom workflow template for the user\n ...\n\n@mcp.resource(\"users://{user_id}/dashboard\")\ndef get_user_dashboard(user_id: str) -> dict:\n # Generate and return a personalized dashboard view for the user\n ...\n```\n\nBest practices for integrating resources with Task Master functionality:\n\n1. Use resources to provide context and data for tools\n2. Implement caching for frequently accessed resources\n3. Ensure proper error handling and not-found cases for all resources\n4. Use resource templates to generate dynamic, personalized views of data\n5. Implement access control to ensure users only access authorized resources\n\nBy properly implementing these resources and resource templates, we can provide rich, contextual data to LLM clients, enhancing the Task Master's capabilities and user experience.\n", "status": "done", "parentTaskId": 23 @@ -1425,10 +1150,7 @@ "description": "Implement robust error handling using FastMCP's MCPError, including custom error types for different categories and standardized error responses.", "details": "1. Create custom error types extending MCPError for different categories (validation, auth, etc.)\\n2. Implement standardized error responses following MCP protocol\\n3. Add error handling middleware for all MCP endpoints\\n4. Ensure proper error propagation from tools to client\\n5. Add debug mode with detailed error information\\n6. Document error types and handling patterns", "status": "done", - "dependencies": [ - "23.1", - "23.3" - ], + "dependencies": ["23.1", "23.3"], "parentTaskId": 23 }, { @@ -1437,10 +1159,7 @@ "description": "Implement a comprehensive logging system for the MCP server with different log levels, structured logging format, and request/response tracking.", "details": "1. Design structured log format for consistent parsing\\n2. Implement different log levels (debug, info, warn, error)\\n3. Add request/response logging middleware\\n4. Implement correlation IDs for request tracking\\n5. Add performance metrics logging\\n6. Configure log output destinations (console, file)\\n7. Document logging patterns and usage", "status": "done", - "dependencies": [ - "23.1", - "23.3" - ], + "dependencies": ["23.1", "23.3"], "parentTaskId": 23 }, { @@ -1449,10 +1168,7 @@ "description": "Implement a comprehensive testing framework for the MCP server, including unit tests, integration tests, and end-to-end tests.", "details": "1. Set up Jest testing framework with proper configuration\\n2. Create MCPTestClient for testing FastMCP server interaction\\n3. Implement unit tests for individual tool functions\\n4. Create integration tests for end-to-end request/response cycles\\n5. Set up test fixtures and mock data\\n6. Implement test coverage reporting\\n7. Document testing guidelines and examples", "status": "done", - "dependencies": [ - "23.1", - "23.3" - ], + "dependencies": ["23.1", "23.3"], "parentTaskId": 23 }, { @@ -1461,10 +1177,7 @@ "description": "Implement functionality to create or update .cursor/mcp.json during project initialization, handling cases where: 1) If there's no mcp.json, create it with the appropriate configuration; 2) If there is an mcp.json, intelligently append to it without syntax errors like trailing commas", "details": "1. Create functionality to detect if .cursor/mcp.json exists in the project\\n2. Implement logic to create a new mcp.json file with proper structure if it doesn't exist\\n3. Add functionality to read and parse existing mcp.json if it exists\\n4. Create method to add a new taskmaster-ai server entry to the mcpServers object\\n5. Implement intelligent JSON merging that avoids trailing commas and syntax errors\\n6. Ensure proper formatting and indentation in the generated/updated JSON\\n7. Add validation to verify the updated configuration is valid JSON\\n8. Include this functionality in the init workflow\\n9. Add error handling for file system operations and JSON parsing\\n10. Document the mcp.json structure and integration process", "status": "done", - "dependencies": [ - "23.1", - "23.3" - ], + "dependencies": ["23.1", "23.3"], "parentTaskId": 23 }, { @@ -1473,11 +1186,7 @@ "description": "Add Server-Sent Events (SSE) capabilities to the MCP server to enable real-time updates and streaming of task execution progress, logs, and status changes to clients", "details": "1. Research and implement SSE protocol for the MCP server\\n2. Create dedicated SSE endpoints for event streaming\\n3. Implement event emitter pattern for internal event management\\n4. Add support for different event types (task status, logs, errors)\\n5. Implement client connection management with proper keep-alive handling\\n6. Add filtering capabilities to allow subscribing to specific event types\\n7. Create in-memory event buffer for clients reconnecting\\n8. Document SSE endpoint usage and client implementation examples\\n9. Add robust error handling for dropped connections\\n10. Implement rate limiting and backpressure mechanisms\\n11. Add authentication for SSE connections", "status": "done", - "dependencies": [ - "23.1", - "23.3", - "23.11" - ], + "dependencies": ["23.1", "23.3", "23.11"], "parentTaskId": 23 }, { @@ -1630,9 +1339,7 @@ "description": "Move existing direct function implementations from task-master-core.js to individual files in the new directory structure.", "details": "1. Identify all existing direct functions in task-master-core.js\n2. Create individual files for each function in mcp-server/src/core/direct-functions/\n3. Move the implementation to the new files, ensuring consistent error handling\n4. Update imports/exports in task-master-core.js\n5. Create unit tests for each individual function file\n6. Update documentation to reflect the new structure\n7. Ensure all MCP tools reference the functions through task-master-core.js\n8. Verify backward compatibility with existing code", "status": "done", - "dependencies": [ - "23.31" - ], + "dependencies": ["23.31"], "parentTaskId": 23 }, { @@ -1695,9 +1402,7 @@ "description": "Create MCP tool implementation for the add-dependency command", "details": "", "status": "done", - "dependencies": [ - "23.31" - ], + "dependencies": ["23.31"], "parentTaskId": 23 }, { @@ -1706,9 +1411,7 @@ "description": "Create MCP tool implementation for the remove-dependency command", "details": "", "status": "done", - "dependencies": [ - "23.31" - ], + "dependencies": ["23.31"], "parentTaskId": 23 }, { @@ -1717,11 +1420,7 @@ "description": "Create MCP tool implementation for the validate-dependencies command", "details": "", "status": "done", - "dependencies": [ - "23.31", - "23.39", - "23.40" - ], + "dependencies": ["23.31", "23.39", "23.40"], "parentTaskId": 23 }, { @@ -1730,10 +1429,7 @@ "description": "Create MCP tool implementation for the fix-dependencies command", "details": "", "status": "done", - "dependencies": [ - "23.31", - "23.41" - ], + "dependencies": ["23.31", "23.41"], "parentTaskId": 23 }, { @@ -1742,9 +1438,7 @@ "description": "Create MCP tool implementation for the complexity-report command", "details": "", "status": "done", - "dependencies": [ - "23.31" - ], + "dependencies": ["23.31"], "parentTaskId": 23 }, { @@ -1781,9 +1475,7 @@ "title": "Implement AI-Powered Test Generation Command", "description": "Create a new 'generate-test' command in Task Master that leverages AI to automatically produce Jest test files for tasks based on their descriptions and subtasks, utilizing Claude API for AI integration.", "status": "pending", - "dependencies": [ - 22 - ], + "dependencies": [22], "priority": "high", "details": "Implement a new command in the Task Master CLI that generates comprehensive Jest test files for tasks. The command should be callable as 'task-master generate-test --id=1' and should:\n\n1. Accept a task ID parameter to identify which task to generate tests for\n2. Retrieve the task and its subtasks from the task store\n3. Analyze the task description, details, and subtasks to understand implementation requirements\n4. Construct an appropriate prompt for the AI service using Claude API\n5. Process the AI response to create a well-formatted test file named 'task_XXX.test.ts' where XXX is the zero-padded task ID\n6. Include appropriate test cases that cover the main functionality described in the task\n7. Generate mocks for external dependencies identified in the task description\n8. Create assertions that validate the expected behavior\n9. Handle both parent tasks and subtasks appropriately (for subtasks, name the file 'task_XXX_YYY.test.ts' where YYY is the subtask ID)\n10. Include error handling for API failures, invalid task IDs, etc.\n11. Add appropriate documentation for the command in the help system\n\nThe implementation should utilize the Claude API for AI service integration and maintain consistency with the current command structure and error handling patterns. Consider using TypeScript for better type safety and integration with the Claude API.", "testStrategy": "Testing for this feature should include:\n\n1. Unit tests for the command handler function to verify it correctly processes arguments and options\n2. Mock tests for the Claude API integration to ensure proper prompt construction and response handling\n3. Integration tests that verify the end-to-end flow using a mock Claude API response\n4. Tests for error conditions including:\n - Invalid task IDs\n - Network failures when contacting the AI service\n - Malformed AI responses\n - File system permission issues\n5. Verification that generated test files follow Jest conventions and can be executed\n6. Tests for both parent task and subtask handling\n7. Manual verification of the quality of generated tests by running them against actual task implementations\n\nCreate a test fixture with sample tasks of varying complexity to evaluate the test generation capabilities across different scenarios. The tests should verify that the command outputs appropriate success/error messages to the console and creates files in the expected location with proper content structure.", @@ -1801,9 +1493,7 @@ "id": 2, "title": "Implement AI prompt construction and FastMCP integration", "description": "Develop the logic to analyze tasks, construct appropriate AI prompts, and interact with the AI service using FastMCP to generate test content.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implementation steps:\n1. Create a utility function to analyze task descriptions and subtasks for test requirements\n2. Implement a prompt builder that formats task information into an effective AI prompt\n3. Use FastMCP to send the prompt and receive the response\n4. Process the FastMCP response to extract the generated test code\n5. Implement error handling for FastMCP failures, rate limits, and malformed responses\n6. Add appropriate logging for the FastMCP interaction process\n\nTesting approach:\n- Test prompt construction with various task types\n- Test FastMCP integration with mocked responses\n- Test error handling for FastMCP failures\n- Test response processing with sample FastMCP outputs\n\n## AI Integration Implementation\n\n### AI Service Integration\n- Use the unified AI service layer, not FastMCP directly\n- Implement with `generateObjectService` from '../ai-services-unified.js'\n- Define Zod schema for structured test generation output:\n - testContent: Complete Jest test file content\n - fileName: Suggested filename for the test file\n - mockRequirements: External dependencies that need mocking\n\n### Prompt Construction\n- Create system prompt defining AI's role as test generator\n- Build user prompt with task context (ID, title, description, details)\n- Include test strategy and subtasks context in the prompt\n- Follow patterns from add-task.js for prompt structure\n\n### Task Analysis\n- Retrieve task data using `findTaskById()` from utils.js\n- Build context by analyzing task description, details, and testStrategy\n- Examine project structure for import patterns\n- Parse specific testing requirements from task.testStrategy field\n\n### File System Operations\n- Determine output path in same directory as tasks.json\n- Generate standardized filename based on task ID\n- Use fs.writeFileSync for writing test content to file\n\n### Error Handling & UI\n- Implement try/catch blocks for AI service calls\n- Display user-friendly error messages with chalk\n- Use loading indicators during AI processing\n- Support both research and main AI models\n\n### Telemetry\n- Pass through telemetryData from AI service response\n- Display AI usage summary for CLI output\n\n### Required Dependencies\n- generateObjectService from ai-services-unified.js\n- UI components (loading indicators, display functions)\n- Zod for schema validation\n- Chalk for formatted console output\n", "status": "pending", "parentTaskId": 24 @@ -1812,9 +1502,7 @@ "id": 3, "title": "Implement test file generation and output", "description": "Create functionality to format AI-generated tests into proper Jest test files and save them to the appropriate location.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implementation steps:\n1. Create a utility to format the FastMCP response into a well-structured Jest test file\n2. Implement naming logic for test files (task_XXX.test.ts for parent tasks, task_XXX_YYY.test.ts for subtasks)\n3. Add logic to determine the appropriate file path for saving the test\n4. Implement file system operations to write the test file\n5. Add validation to ensure the generated test follows Jest conventions\n6. Implement formatting of the test file for consistency with project coding standards\n7. Add user feedback about successful test generation and file location\n8. Implement handling for both parent tasks and subtasks\n\nTesting approach:\n- Test file naming logic for various task/subtask combinations\n- Test file content formatting with sample FastMCP outputs\n- Test file system operations with mocked fs module\n- Test the complete flow from command input to file output\n- Verify generated tests can be executed by Jest\n\n## Detailed Implementation Guidelines\n\n### File Naming Convention Implementation\n```javascript\nfunction generateTestFileName(taskId, isSubtask = false) {\n if (isSubtask) {\n // For subtasks like \"24.1\", generate \"task_024_001.test.js\"\n const [parentId, subtaskId] = taskId.split('.');\n return `task_${parentId.padStart(3, '0')}_${subtaskId.padStart(3, '0')}.test.js`;\n } else {\n // For parent tasks like \"24\", generate \"task_024.test.js\"\n return `task_${taskId.toString().padStart(3, '0')}.test.js`;\n }\n}\n```\n\n### File Location Strategy\n- Place generated test files in the `tasks/` directory alongside task files\n- This ensures co-location with task documentation and simplifies implementation\n\n### File Content Structure Template\n```javascript\n/**\n * Test file for Task ${taskId}: ${taskTitle}\n * Generated automatically by Task Master\n */\n\nimport { jest } from '@jest/globals';\n// Additional imports based on task requirements\n\ndescribe('Task ${taskId}: ${taskTitle}', () => {\n beforeEach(() => {\n // Setup code\n });\n\n afterEach(() => {\n // Cleanup code\n });\n\n test('should ${testDescription}', () => {\n // Test implementation\n });\n});\n```\n\n### Code Formatting Standards\n- Follow project's .prettierrc configuration:\n - Tab width: 2 spaces (useTabs: true)\n - Print width: 80 characters\n - Semicolons: Required (semi: true)\n - Quotes: Single quotes (singleQuote: true)\n - Trailing commas: None (trailingComma: \"none\")\n - Bracket spacing: True\n - Arrow parens: Always\n\n### File System Operations Implementation\n```javascript\nimport fs from 'fs';\nimport path from 'path';\n\n// Determine output path\nconst tasksDir = path.dirname(tasksPath); // Same directory as tasks.json\nconst fileName = generateTestFileName(task.id, isSubtask);\nconst filePath = path.join(tasksDir, fileName);\n\n// Ensure directory exists\nif (!fs.existsSync(tasksDir)) {\n fs.mkdirSync(tasksDir, { recursive: true });\n}\n\n// Write test file with proper error handling\ntry {\n fs.writeFileSync(filePath, formattedTestContent, 'utf8');\n} catch (error) {\n throw new Error(`Failed to write test file: ${error.message}`);\n}\n```\n\n### Error Handling for File Operations\n```javascript\ntry {\n // File writing operation\n fs.writeFileSync(filePath, testContent, 'utf8');\n} catch (error) {\n if (error.code === 'ENOENT') {\n throw new Error(`Directory does not exist: ${path.dirname(filePath)}`);\n } else if (error.code === 'EACCES') {\n throw new Error(`Permission denied writing to: ${filePath}`);\n } else if (error.code === 'ENOSPC') {\n throw new Error('Insufficient disk space to write test file');\n } else {\n throw new Error(`Failed to write test file: ${error.message}`);\n }\n}\n```\n\n### User Feedback Implementation\n```javascript\n// Success feedback\nconsole.log(chalk.green('✅ Test file generated successfully:'));\nconsole.log(chalk.cyan(` File: ${fileName}`));\nconsole.log(chalk.cyan(` Location: ${filePath}`));\nconsole.log(chalk.gray(` Size: ${testContent.length} characters`));\n\n// Additional info\nif (mockRequirements && mockRequirements.length > 0) {\n console.log(chalk.yellow(` Mocks needed: ${mockRequirements.join(', ')}`));\n}\n```\n\n### Content Validation Requirements\n1. Jest Syntax Validation:\n - Ensure proper describe/test structure\n - Validate import statements\n - Check for balanced brackets and parentheses\n\n2. Code Quality Checks:\n - Verify no syntax errors\n - Ensure proper indentation\n - Check for required imports\n\n3. Test Completeness:\n - At least one test case\n - Proper test descriptions\n - Appropriate assertions\n\n### Required Dependencies\n```javascript\nimport fs from 'fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport { log } from '../utils.js';\n```\n\n### Integration with Existing Patterns\nFollow the pattern from `generate-task-files.js`:\n1. Read task data using existing utilities\n2. Process content with proper formatting\n3. Write files with error handling\n4. Provide feedback to user\n5. Return success data for MCP integration\n\n\n## Corrected Implementation Approach\n\n### Updated File Location Strategy\n\n**CORRECTION**: Tests should go in `/tests/` directory, not `/tasks/` directory.\n\nBased on Jest configuration analysis:\n- Jest is configured with `roots: ['/tests']`\n- Test pattern: `**/?(*.)+(spec|test).js`\n- Current test structure has `/tests/unit/`, `/tests/integration/`, etc.\n\n### Recommended Directory Structure:\n```\ntests/\n├── unit/ # Manual unit tests\n├── integration/ # Manual integration tests \n├── generated/ # AI-generated tests\n│ ├── tasks/ # Generated task tests\n│ │ ├── task_024.test.js\n│ │ └── task_024_001.test.js\n│ └── README.md # Explains generated tests\n└── fixtures/ # Test fixtures\n```\n\n### Updated File Path Logic:\n```javascript\n// Determine output path - place in tests/generated/tasks/\nconst projectRoot = findProjectRoot() || '.';\nconst testsDir = path.join(projectRoot, 'tests', 'generated', 'tasks');\nconst fileName = generateTestFileName(task.id, isSubtask);\nconst filePath = path.join(testsDir, fileName);\n\n// Ensure directory structure exists\nif (!fs.existsSync(testsDir)) {\n fs.mkdirSync(testsDir, { recursive: true });\n}\n```\n\n### Testing Framework Configuration\n\nThe generate-test command should read the configured testing framework from `.taskmasterconfig`:\n\n```javascript\n// Read testing framework from config\nconst config = getConfig(projectRoot);\nconst testingFramework = config.testingFramework || 'jest'; // Default to Jest\n\n// Generate different templates based on framework\nswitch (testingFramework) {\n case 'jest':\n return generateJestTest(task, context);\n case 'mocha':\n return generateMochaTest(task, context);\n case 'vitest':\n return generateVitestTest(task, context);\n default:\n throw new Error(`Unsupported testing framework: ${testingFramework}`);\n}\n```\n\n### Framework-Specific Templates\n\n**Jest Template** (current):\n```javascript\n/**\n * Test file for Task ${taskId}: ${taskTitle}\n * Generated automatically by Task Master\n */\n\nimport { jest } from '@jest/globals';\n// Task-specific imports\n\ndescribe('Task ${taskId}: ${taskTitle}', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n test('should ${testDescription}', () => {\n // Test implementation\n });\n});\n```\n\n**Mocha Template**:\n```javascript\n/**\n * Test file for Task ${taskId}: ${taskTitle}\n * Generated automatically by Task Master\n */\n\nimport { expect } from 'chai';\nimport sinon from 'sinon';\n// Task-specific imports\n\ndescribe('Task ${taskId}: ${taskTitle}', () => {\n beforeEach(() => {\n sinon.restore();\n });\n\n it('should ${testDescription}', () => {\n // Test implementation\n });\n});\n```\n\n**Vitest Template**:\n```javascript\n/**\n * Test file for Task ${taskId}: ${taskTitle}\n * Generated automatically by Task Master\n */\n\nimport { describe, test, expect, vi, beforeEach } from 'vitest';\n// Task-specific imports\n\ndescribe('Task ${taskId}: ${taskTitle}', () => {\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n test('should ${testDescription}', () => {\n // Test implementation\n });\n});\n```\n\n### AI Prompt Enhancement for Mocking\n\nTo address the mocking challenge, enhance the AI prompt with project context:\n\n```javascript\nconst systemPrompt = `You are an expert at generating comprehensive test files. When generating tests, pay special attention to mocking external dependencies correctly.\n\nCRITICAL MOCKING GUIDELINES:\n1. Analyze the task requirements to identify external dependencies (APIs, databases, file system, etc.)\n2. Mock external dependencies at the module level, not inline\n3. Use the testing framework's mocking utilities (jest.mock(), sinon.stub(), vi.mock())\n4. Create realistic mock data that matches the expected API responses\n5. Test both success and error scenarios for mocked dependencies\n6. Ensure mocks are cleared between tests to prevent test pollution\n\nTesting Framework: ${testingFramework}\nProject Structure: ${projectStructureContext}\n`;\n```\n\n### Integration with Future Features\n\nThis primitive command design enables:\n1. **Automatic test generation**: `task-master add-task --with-test`\n2. **Batch test generation**: `task-master generate-tests --all`\n3. **Framework-agnostic**: Support multiple testing frameworks\n4. **Smart mocking**: LLM analyzes dependencies and generates appropriate mocks\n\n### Updated Implementation Requirements:\n\n1. **Read testing framework** from `.taskmasterconfig`\n2. **Create tests directory structure** if it doesn't exist\n3. **Generate framework-specific templates** based on configuration\n4. **Enhanced AI prompts** with mocking best practices\n5. **Project structure analysis** for better import resolution\n6. **Mock dependency detection** from task requirements\n", "status": "pending", "parentTaskId": 24 @@ -1825,9 +1513,7 @@ "description": "Create MCP server tool support for the generate-test command to enable integration with Claude Code and other MCP clients.", "details": "Implementation steps:\n1. Create direct function wrapper in mcp-server/src/core/direct-functions/\n2. Create MCP tool registration in mcp-server/src/tools/\n3. Add tool to the main tools index\n4. Implement proper parameter validation and error handling\n5. Ensure telemetry data is properly passed through\n6. Add tool to MCP server registration\n\nThe MCP tool should support the same parameters as the CLI command:\n- id: Task ID to generate tests for\n- file: Path to tasks.json file\n- research: Whether to use research model\n- prompt: Additional context for test generation\n\nFollow the existing pattern from other MCP tools like add-task.js and expand-task.js.", "status": "pending", - "dependencies": [ - 3 - ], + "dependencies": [3], "parentTaskId": 24 }, { @@ -1836,9 +1522,7 @@ "description": "Enhance the init.js process to let users choose their preferred testing framework (Jest, Mocha, Vitest, etc.) and store this choice in .taskmasterconfig for use by the generate-test command.", "details": "Implementation requirements:\n\n1. **Add Testing Framework Prompt to init.js**:\n - Add interactive prompt asking users to choose testing framework\n - Support Jest (default), Mocha + Chai, Vitest, Ava, Jasmine\n - Include brief descriptions of each framework\n - Allow --testing-framework flag for non-interactive mode\n\n2. **Update .taskmasterconfig Template**:\n - Add testingFramework field to configuration file\n - Include default dependencies for each framework\n - Store framework-specific configuration options\n\n3. **Framework-Specific Setup**:\n - Generate appropriate config files (jest.config.js, vitest.config.ts, etc.)\n - Add framework dependencies to package.json suggestions\n - Create sample test file for the chosen framework\n\n4. **Integration Points**:\n - Ensure generate-test command reads testingFramework from config\n - Add validation to prevent conflicts between framework choices\n - Support switching frameworks later via models command or separate config command\n\nThis makes the generate-test command truly framework-agnostic and sets up the foundation for --with-test flags in other commands.\n\n# Implementation Plan for Testing Framework Integration\n\n## Code Structure\n\n### 1. Update init.js\n- Add testing framework prompt after addAliases prompt\n- Implement framework selection with descriptions\n- Support non-interactive mode with --testing-framework flag\n- Create setupTestingFramework() function to handle framework-specific setup\n\n### 2. Create New Module Files\n- Create `scripts/modules/testing-frameworks.js` for framework templates and setup\n- Add sample test generators for each supported framework\n- Implement config file generation for each framework\n\n### 3. Update Configuration Templates\n- Modify `assets/.taskmasterconfig` to include testing fields:\n ```json\n \"testingFramework\": \"{{testingFramework}}\",\n \"testingConfig\": {\n \"framework\": \"{{testingFramework}}\",\n \"setupFiles\": [],\n \"testDirectory\": \"tests\",\n \"testPattern\": \"**/*.test.js\",\n \"coverage\": {\n \"enabled\": false,\n \"threshold\": 80\n }\n }\n ```\n\n### 4. Create Framework-Specific Templates\n- `assets/jest.config.template.js`\n- `assets/vitest.config.template.ts`\n- `assets/.mocharc.template.json`\n- `assets/ava.config.template.js`\n- `assets/jasmine.json.template`\n\n### 5. Update commands.js\n- Add `--testing-framework ` option to init command\n- Add validation for supported frameworks\n\n## Error Handling\n- Validate selected framework against supported list\n- Handle existing config files gracefully with warning/overwrite prompt\n- Provide recovery options if framework setup fails\n- Add conflict detection for multiple testing frameworks\n\n## Integration Points\n- Ensure generate-test command reads testingFramework from config\n- Prepare for future --with-test flag in other commands\n- Support framework switching via config command\n\n## Testing Requirements\n- Unit tests for framework selection logic\n- Integration tests for config file generation\n- Validation tests for each supported framework\n", "status": "pending", - "dependencies": [ - 3 - ], + "dependencies": [3], "parentTaskId": 24 } ] @@ -1848,9 +1532,7 @@ "title": "Implement 'add-subtask' Command for Task Hierarchy Management", "description": "Create a command-line interface command that allows users to manually add subtasks to existing tasks, establishing a parent-child relationship between tasks.", "status": "done", - "dependencies": [ - 3 - ], + "dependencies": [3], "priority": "medium", "details": "Implement the 'add-subtask' command that enables users to create hierarchical relationships between tasks. The command should:\n\n1. Accept parameters for the parent task ID and either the details for a new subtask or the ID of an existing task to convert to a subtask\n2. Validate that the parent task exists before proceeding\n3. If creating a new subtask, collect all necessary task information (title, description, due date, etc.)\n4. If converting an existing task, ensure it's not already a subtask of another task\n5. Update the data model to support parent-child relationships between tasks\n6. Modify the task storage mechanism to persist these relationships\n7. Ensure that when a parent task is marked complete, there's appropriate handling of subtasks (prompt user or provide options)\n8. Update the task listing functionality to display subtasks with appropriate indentation or visual hierarchy\n9. Implement proper error handling for cases like circular dependencies (a task cannot be a subtask of its own subtask)\n10. Document the command syntax and options in the help system", "testStrategy": "Testing should verify both the functionality and edge cases of the subtask implementation:\n\n1. Unit tests:\n - Test adding a new subtask to an existing task\n - Test converting an existing task to a subtask\n - Test validation logic for parent task existence\n - Test prevention of circular dependencies\n - Test error handling for invalid inputs\n\n2. Integration tests:\n - Verify subtask relationships are correctly persisted to storage\n - Verify subtasks appear correctly in task listings\n - Test the complete workflow from adding a subtask to viewing it in listings\n\n3. Edge cases:\n - Attempt to add a subtask to a non-existent parent\n - Attempt to make a task a subtask of itself\n - Attempt to create circular dependencies (A → B → A)\n - Test with a deep hierarchy of subtasks (A → B → C → D)\n - Test handling of subtasks when parent tasks are deleted\n - Verify behavior when marking parent tasks as complete\n\n4. Manual testing:\n - Verify command usability and clarity of error messages\n - Test the command with various parameter combinations", @@ -1868,9 +1550,7 @@ "id": 2, "title": "Implement Core addSubtask Function in task-manager.js", "description": "Create the core function that handles adding subtasks to parent tasks", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "1. Create a new addSubtask function in scripts/modules/task-manager.js\n2. Implement logic to validate that the parent task exists\n3. Add functionality to handle both creating new subtasks and converting existing tasks\n4. For new subtasks: collect task information and create a new task with parentId set\n5. For existing tasks: validate it's not already a subtask and update its parentId\n6. Add validation to prevent circular dependencies (a task cannot be a subtask of its own subtask)\n7. Update the parent task's subtasks array\n8. Ensure proper error handling with descriptive error messages\n9. Export the function for use by the command handler\n10. Write unit tests to verify all scenarios (new subtask, converting task, error cases)", "status": "done", "parentTaskId": 25 @@ -1879,9 +1559,7 @@ "id": 3, "title": "Implement add-subtask Command in commands.js", "description": "Create the command-line interface for the add-subtask functionality", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "1. Add a new command registration in scripts/modules/commands.js following existing patterns\n2. Define command syntax: 'add-subtask [--task-id= | --title=]'\n3. Implement command handler that calls the addSubtask function from task-manager.js\n4. Add interactive prompts to collect required information when not provided as arguments\n5. Implement validation for command arguments\n6. Add appropriate success and error messages\n7. Document the command syntax and options in the help system\n8. Test the command with various input combinations\n9. Ensure the command follows the same patterns as other commands like add-dependency", "status": "done", "parentTaskId": 25 @@ -1890,10 +1568,7 @@ "id": 4, "title": "Create Unit Test for add-subtask", "description": "Develop comprehensive unit tests for the add-subtask functionality", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "1. Create a test file in tests/unit/ directory for the add-subtask functionality\n2. Write tests for the addSubtask function in task-manager.js\n3. Test all key scenarios: adding new subtasks, converting existing tasks to subtasks\n4. Test error cases: non-existent parent task, circular dependencies, invalid input\n5. Use Jest mocks to isolate the function from file system operations\n6. Test the command handler in isolation using mock functions\n7. Ensure test coverage for all branches and edge cases\n8. Document the testing approach for future reference", "status": "done", "parentTaskId": 25 @@ -1902,10 +1577,7 @@ "id": 5, "title": "Implement remove-subtask Command", "description": "Create functionality to remove a subtask from its parent, following the same approach as add-subtask", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "1. Create a removeSubtask function in scripts/modules/task-manager.js\n2. Implement logic to validate the subtask exists and is actually a subtask\n3. Add options to either delete the subtask completely or convert it to a standalone task\n4. Update the parent task's subtasks array to remove the reference\n5. If converting to standalone task, clear the parentId reference\n6. Implement the remove-subtask command in scripts/modules/commands.js following patterns from add-subtask\n7. Add appropriate validation and error messages\n8. Document the command in the help system\n9. Export the function in task-manager.js\n10. Ensure proper error handling for all scenarios", "status": "done", "parentTaskId": 25 @@ -1917,11 +1589,7 @@ "title": "Implement Context Foundation for AI Operations", "description": "Implement the foundation for context integration in Task Master, enabling AI operations to leverage file-based context, cursor rules, and basic code context to improve generated outputs.", "status": "pending", - "dependencies": [ - 5, - 6, - 7 - ], + "dependencies": [5, 6, 7], "priority": "high", "details": "Create a Phase 1 foundation for context integration in Task Master that provides immediate practical value:\n\n1. Add `--context-file` Flag to AI Commands:\n - Add a consistent `--context-file <file>` option to all AI-related commands (expand, update, add-task, etc.)\n - Implement file reading functionality that loads content from the specified file\n - Add content integration into Claude API prompts with appropriate formatting\n - Handle error conditions such as file not found gracefully\n - Update help documentation to explain the new option\n\n2. Implement Cursor Rules Integration for Context:\n - Create a `--context-rules <rules>` option for all AI commands\n - Implement functionality to extract content from specified .cursor/rules/*.mdc files\n - Support comma-separated lists of rule names and \"all\" option\n - Add validation and error handling for non-existent rules\n - Include helpful examples in command help output\n\n3. Implement Basic Context File Extraction Utility:\n - Create utility functions in utils.js for reading context from files\n - Add proper error handling and logging\n - Implement content validation to ensure reasonable size limits\n - Add content truncation if files exceed token limits\n - Create helper functions for formatting context additions properly\n\n4. Update Command Handler Logic:\n - Modify command handlers to support the new context options\n - Update prompt construction to incorporate context content\n - Ensure backwards compatibility with existing commands\n - Add logging for context inclusion to aid troubleshooting\n\nThe focus of this phase is to provide immediate value with straightforward implementations that enable users to include relevant context in their AI operations.", "testStrategy": "Testing should verify that the context foundation works as expected and adds value:\n\n1. Functional Tests:\n - Verify `--context-file` flag correctly reads and includes content from specified files\n - Test that `--context-rules` correctly extracts and formats content from cursor rules\n - Test with both existing and non-existent files/rules to verify error handling\n - Verify content truncation works appropriately for large files\n\n2. Integration Tests:\n - Test each AI-related command with context options\n - Verify context is properly included in API calls to Claude\n - Test combinations of multiple context options\n - Verify help documentation includes the new options\n\n3. Usability Testing:\n - Create test scenarios that show clear improvement in AI output quality with context\n - Compare outputs with and without context to measure impact\n - Document examples of effective context usage for the user documentation\n\n4. Error Handling:\n - Test invalid file paths and rule names\n - Test oversized context files\n - Verify appropriate error messages guide users to correct usage\n\nThe testing focus should be on proving immediate value to users while ensuring robust error handling.", @@ -1969,9 +1637,7 @@ "title": "Implement Context Enhancements for AI Operations", "description": "Enhance the basic context integration with more sophisticated code context extraction, task history awareness, and PRD integration to provide richer context for AI operations.", "status": "pending", - "dependencies": [ - 26 - ], + "dependencies": [26], "priority": "high", "details": "Building upon the foundational context implementation in Task #26, implement Phase 2 context enhancements:\n\n1. Add Code Context Extraction Feature:\n - Create a `--context-code <pattern>` option for all AI commands\n - Implement glob-based file matching to extract code from specified patterns\n - Create intelligent code parsing to extract most relevant sections (function signatures, classes, exports)\n - Implement token usage optimization by selecting key structural elements\n - Add formatting for code context with proper file paths and syntax indicators\n\n2. Implement Task History Context:\n - Add a `--context-tasks <ids>` option for AI commands\n - Support comma-separated task IDs and a \"similar\" option to find related tasks\n - Create functions to extract context from specified tasks or find similar tasks\n - Implement formatting for task context with clear section markers\n - Add validation and error handling for non-existent task IDs\n\n3. Add PRD Context Integration:\n - Create a `--context-prd <file>` option for AI commands\n - Implement PRD text extraction and intelligent summarization\n - Add formatting for PRD context with appropriate section markers\n - Integrate with the existing PRD parsing functionality from Task #6\n\n4. Improve Context Formatting and Integration:\n - Create a standardized context formatting system\n - Implement type-based sectioning for different context sources\n - Add token estimation for different context types to manage total prompt size\n - Enhance prompt templates to better integrate various context types\n\nThese enhancements will provide significantly richer context for AI operations, resulting in more accurate and relevant outputs while remaining practical to implement.", "testStrategy": "Testing should verify the enhanced context functionality:\n\n1. Code Context Testing:\n - Verify pattern matching works for different glob patterns\n - Test code extraction with various file types and sizes\n - Verify intelligent parsing correctly identifies important code elements\n - Test token optimization by comparing full file extraction vs. optimized extraction\n - Check code formatting in prompts sent to Claude API\n\n2. Task History Testing:\n - Test with different combinations of task IDs\n - Verify \"similar\" option correctly identifies relevant tasks\n - Test with non-existent task IDs to ensure proper error handling\n - Verify formatting and integration in prompts\n\n3. PRD Context Testing:\n - Test with various PRD files of different sizes\n - Verify summarization functions correctly when PRDs are too large\n - Test integration with prompts and formatting\n\n4. Performance Testing:\n - Measure the impact of context enrichment on command execution time\n - Test with large code bases to ensure reasonable performance\n - Verify token counting and optimization functions work as expected\n\n5. Quality Assessment:\n - Compare AI outputs with Phase 1 vs. Phase 2 context to measure improvements\n - Create test cases that specifically benefit from code context\n - Create test cases that benefit from task history context\n\nFocus testing on practical use cases that demonstrate clear improvements in AI-generated outputs.", @@ -2019,10 +1685,7 @@ "title": "Implement Advanced ContextManager System", "description": "Create a comprehensive ContextManager class to unify context handling with advanced features like context optimization, prioritization, and intelligent context selection.", "status": "pending", - "dependencies": [ - 26, - 27 - ], + "dependencies": [26, 27], "priority": "high", "details": "Building on Phase 1 and Phase 2 context implementations, develop Phase 3 advanced context management:\n\n1. Implement the ContextManager Class:\n - Create a unified `ContextManager` class that encapsulates all context functionality\n - Implement methods for gathering context from all supported sources\n - Create a configurable context priority system to favor more relevant context types\n - Add token management to ensure context fits within API limits\n - Implement caching for frequently used context to improve performance\n\n2. Create Context Optimization Pipeline:\n - Develop intelligent context optimization algorithms\n - Implement type-based truncation strategies (code vs. text)\n - Create relevance scoring to prioritize most useful context portions\n - Add token budget allocation that divides available tokens among context types\n - Implement dynamic optimization based on operation type\n\n3. Add Command Interface Enhancements:\n - Create the `--context-all` flag to include all available context\n - Add the `--context-max-tokens <tokens>` option to control token allocation\n - Implement unified context options across all AI commands\n - Add intelligent default values for different command types\n\n4. Integrate with AI Services:\n - Update the AI service integration to use the ContextManager\n - Create specialized context assembly for different AI operations\n - Add post-processing to capture new context from AI responses\n - Implement adaptive context selection based on operation success\n\n5. Add Performance Monitoring:\n - Create context usage statistics tracking\n - Implement logging for context selection decisions\n - Add warnings for context token limits\n - Create troubleshooting utilities for context-related issues\n\nThe ContextManager system should provide a powerful but easy-to-use interface for both users and developers, maintaining backward compatibility with earlier phases while adding substantial new capabilities.", "testStrategy": "Testing should verify both the functionality and performance of the advanced context management:\n\n1. Unit Testing:\n - Test all ContextManager class methods with various inputs\n - Verify optimization algorithms maintain critical information\n - Test caching mechanisms for correctness and efficiency\n - Verify token allocation and budgeting functions\n - Test each context source integration separately\n\n2. Integration Testing:\n - Verify ContextManager integration with AI services\n - Test with all AI-related commands\n - Verify backward compatibility with existing context options\n - Test context prioritization across multiple context types\n - Verify logging and error handling\n\n3. Performance Testing:\n - Benchmark context gathering and optimization times\n - Test with large and complex context sources\n - Measure impact of caching on repeated operations\n - Verify memory usage remains acceptable\n - Test with token limits of different sizes\n\n4. Quality Assessment:\n - Compare AI outputs using Phase 3 vs. earlier context handling\n - Measure improvements in context relevance and quality\n - Test complex scenarios requiring multiple context types\n - Quantify the impact on token efficiency\n\n5. User Experience Testing:\n - Verify CLI options are intuitive and well-documented\n - Test error messages are helpful for troubleshooting\n - Ensure log output provides useful insights\n - Test all convenience options like `--context-all`\n\nCreate automated test suites for regression testing of the complete context system.", @@ -2254,9 +1917,7 @@ "id": 2, "title": "Implement updateTask command in commands.js", "description": "Create a new command called 'updateTask' in commands.js that leverages the updateTaskById function to update a specific task by ID.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implementation steps:\n1. Create a new command object for 'updateTask' in commands.js following the Command pattern\n2. Define command parameters including a required taskId parameter\n3. Support all options from the existing update command:\n - Research flag for Perplexity integration\n - Formatting and refinement options\n - Task context options\n4. Implement the command handler function that calls the updateTaskById function from task-manager.js\n5. Add appropriate error handling to catch and display user-friendly error messages\n6. Ensure the command follows the same pattern as other commands in the codebase\n7. Implement proper validation of input parameters\n8. Format and return appropriate success/failure messages to the user\n\nTesting approach:\n- Unit test the command handler with various input combinations\n- Test error handling scenarios\n- Verify command options are correctly passed to the updateTaskById function", "status": "done", "parentTaskId": 34 @@ -2265,10 +1926,7 @@ "id": 3, "title": "Add comprehensive error handling and validation", "description": "Implement robust error handling and validation for the updateTask command to ensure proper user feedback and system stability.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Implementation steps:\n1. Create custom error types for different failure scenarios (TaskNotFoundError, ValidationError, etc.)\n2. Implement input validation for the taskId parameter and all options\n3. Add proper error handling for AI service failures with appropriate fallback mechanisms\n4. Implement concurrency handling to prevent conflicts when multiple updates occur simultaneously\n5. Add comprehensive logging for debugging and auditing purposes\n6. Ensure all error messages are user-friendly and actionable\n7. Implement proper HTTP status codes for API responses if applicable\n8. Add validation to ensure the task exists before attempting updates\n\nTesting approach:\n- Test various error scenarios including invalid inputs, non-existent tasks, and API failures\n- Verify error messages are clear and helpful\n- Test concurrency scenarios with multiple simultaneous updates\n- Verify logging captures appropriate information for troubleshooting", "status": "done", "parentTaskId": 34 @@ -2277,11 +1935,7 @@ "id": 4, "title": "Write comprehensive tests for updateTask command", "description": "Create a comprehensive test suite for the updateTask command to ensure it works correctly in all scenarios and maintains backward compatibility.", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "details": "Implementation steps:\n1. Create unit tests for the updateTaskById function in task-manager.js\n - Test finding and updating tasks with various IDs\n - Test preservation of completed subtasks\n - Test different update options combinations\n - Test error handling for non-existent tasks\n2. Create unit tests for the updateTask command in commands.js\n - Test command parameter parsing\n - Test option handling\n - Test error scenarios and messages\n3. Create integration tests that verify the end-to-end flow\n - Test the command with actual AI service integration\n - Test with mock AI responses for predictable testing\n4. Implement test fixtures and mocks for consistent testing\n5. Add performance tests to ensure the command is efficient\n6. Test edge cases such as empty tasks, tasks with many subtasks, etc.\n\nTesting approach:\n- Use Jest or similar testing framework\n- Implement mocks for external dependencies like AI services\n- Create test fixtures for consistent test data\n- Use snapshot testing for command output verification", "status": "done", "parentTaskId": 34 @@ -2290,9 +1944,7 @@ "id": 5, "title": "Update CLI documentation and help text", "description": "Update the CLI help documentation to include the new updateTask command and ensure users understand its purpose and options.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implementation steps:\n1. Add comprehensive help text for the updateTask command including:\n - Command description\n - Required and optional parameters\n - Examples of usage\n - Description of all supported options\n2. Update the main CLI help documentation to include the new command\n3. Add the command to any relevant command groups or categories\n4. Create usage examples that demonstrate common scenarios\n5. Update README.md and other documentation files to include information about the new command\n6. Add inline code comments explaining the implementation details\n7. Update any API documentation if applicable\n8. Create or update user guides with the new functionality\n\nTesting approach:\n- Verify help text is displayed correctly when running `--help`\n- Review documentation for clarity and completeness\n- Have team members review the documentation for usability\n- Test examples to ensure they work as documented", "status": "done", "parentTaskId": 34 @@ -2362,9 +2014,7 @@ "id": 2, "title": "Update Source Code License Headers and Package Metadata", "description": "Add appropriate dual license headers to all source code files and update package metadata to reflect the new licensing structure.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implementation steps:\n1. Create a template for the new license header that references the dual license structure (BSL 1.1 / Apache 2.0).\n2. Systematically update all source code files to include the new license header, replacing any existing MIT headers.\n3. Update the license field in package.json to \"BSL 1.1 / Apache 2.0\".\n4. Update any other metadata files (composer.json, setup.py, etc.) that contain license information.\n5. Verify that any build scripts or tools that reference licensing information are updated.\n\nTesting approach:\n- Write a script to verify that all source files contain the new license header\n- Validate package.json and other metadata files have the correct license field\n- Ensure any build processes that depend on license information still function correctly\n- Run a sample build to confirm license information is properly included in any generated artifacts", "status": "done", "parentTaskId": 39 @@ -2373,10 +2023,7 @@ "id": 3, "title": "Update Documentation and Create License Explanation", "description": "Update project documentation to clearly explain the dual license structure and create comprehensive licensing guidance.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Implementation steps:\n1. Update the README.md with a clear, concise explanation of the licensing terms:\n - Summary of what users can and cannot do with the code\n - Who holds commercial rights (Ralph & Eyal)\n - How to obtain commercial use permission\n - Links to the full license texts\n2. Create a dedicated LICENSING.md or similar document with detailed explanations of:\n - The rationale behind the dual licensing approach\n - Detailed examples of what constitutes commercial vs. non-commercial use\n - FAQs addressing common licensing questions\n3. Update any other documentation references to licensing throughout the project.\n4. Create visual aids (if appropriate) to help users understand the licensing structure.\n5. Ensure all documentation links to licensing information are updated.\n\nTesting approach:\n- Have non-technical stakeholders review the documentation for clarity and understanding\n- Verify all links to license files work correctly\n- Ensure the explanation is comprehensive but concise enough for users to understand quickly\n- Check that the documentation correctly addresses the most common use cases and questions", "status": "done", "parentTaskId": 39 @@ -2405,9 +2052,7 @@ "id": 2, "title": "Generate Implementation Plan with AI", "description": "Use an AI model (Claude or Perplexity) to generate an implementation plan based on the retrieved task content. The plan should outline the steps required to complete the task.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implement logic to switch between Claude and Perplexity APIs. Handle API authentication and rate limiting. Prompt the AI model with the task content and request a detailed implementation plan.", "status": "pending" }, @@ -2415,10 +2060,7 @@ "id": 3, "title": "Format Plan in XML", "description": "Format the generated implementation plan within XML tags. Each step in the plan should be represented as an XML element with appropriate attributes.", - "dependencies": [ - 2, - "40.2" - ], + "dependencies": [2, "40.2"], "details": "Define the XML schema for the implementation plan. Implement a function to convert the AI-generated plan into the defined XML format. Ensure proper XML syntax and validation.", "status": "pending" }, @@ -2426,9 +2068,7 @@ "id": 4, "title": "Error Handling and Output", "description": "Implement error handling for all steps, including API failures and XML formatting errors. Output the formatted XML plan to the console or a file.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Add try-except blocks to handle potential exceptions. Log errors for debugging. Provide informative error messages to the user. Output the XML plan in a user-friendly format.", "status": "pending" } @@ -2456,9 +2096,7 @@ "id": 2, "title": "Graph Layout Algorithms", "description": "Develop or integrate algorithms to compute optimal node and edge placement for clear and readable graph layouts in a terminal environment.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Consider topological sorting, hierarchical, and force-directed layouts suitable for ASCII/Unicode rendering.\n<info added on 2025-05-23T21:02:49.434Z>\nCreate a new diagram-generator.js module in the scripts/modules/ directory following Task Master's module architecture pattern. The module should include:\n\n1. Core functions for generating Mermaid diagrams:\n - generateDependencyGraph(tasks, options) - creates flowchart showing task dependencies\n - generateSubtaskDiagram(task, options) - creates hierarchy diagram for subtasks\n - generateProjectFlow(tasks, options) - creates overall project workflow\n - generateGanttChart(tasks, options) - creates timeline visualization\n\n2. Integration with existing Task Master data structures:\n - Use the same task object format from task-manager.js\n - Leverage dependency analysis from dependency-manager.js\n - Support complexity scores from analyze-complexity functionality\n - Handle both main tasks and subtasks with proper ID notation (parentId.subtaskId)\n\n3. Layout algorithm considerations for Mermaid:\n - Topological sorting for dependency flows\n - Hierarchical layouts for subtask trees\n - Circular dependency detection and highlighting\n - Terminal width-aware formatting for ASCII fallback\n\n4. Export functions following the existing module pattern at the bottom of the file\n</info added on 2025-05-23T21:02:49.434Z>", "status": "pending" }, @@ -2466,9 +2104,7 @@ "id": 3, "title": "ASCII/Unicode Rendering Engine", "description": "Implement rendering logic to display the dependency graph using ASCII and Unicode characters in the terminal.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Support for various node and edge styles, and ensure compatibility with different terminal types.\n<info added on 2025-05-23T21:03:10.001Z>\nExtend ui.js with diagram display functions that integrate with Task Master's existing UI patterns:\n\n1. Implement core diagram display functions:\n - displayTaskDiagram(tasksPath, diagramType, options) as the main entry point\n - displayMermaidCode(mermaidCode, title) for formatted code output with boxen\n - displayDiagramLegend() to explain symbols and colors\n\n2. Ensure UI consistency by:\n - Using established chalk color schemes (blue/green/yellow/red)\n - Applying boxen for consistent component formatting\n - Following existing display function patterns (displayTaskById, displayComplexityReport)\n - Utilizing cli-table3 for any diagram metadata tables\n\n3. Address terminal rendering challenges:\n - Implement ASCII/Unicode fallback when Mermaid rendering isn't available\n - Respect terminal width constraints using process.stdout.columns\n - Integrate with loading indicators via startLoadingIndicator/stopLoadingIndicator\n\n4. Update task file generation to include Mermaid diagram sections in individual task files\n\n5. Support both CLI and MCP output formats through the outputFormat parameter\n</info added on 2025-05-23T21:03:10.001Z>", "status": "pending" }, @@ -2476,9 +2112,7 @@ "id": 4, "title": "Color Coding Support", "description": "Add color coding to nodes and edges to visually distinguish types, statuses, or other attributes in the graph.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Use ANSI escape codes for color; provide options for colorblind-friendly palettes.\n<info added on 2025-05-23T21:03:35.762Z>\nIntegrate color coding with Task Master's existing status system:\n\n1. Extend getStatusWithColor() in ui.js to support diagram contexts:\n - Add 'diagram' parameter to determine rendering context\n - Modify color intensity for better visibility in graph elements\n\n2. Implement Task Master's established color scheme using ANSI codes:\n - Green (\\x1b[32m) for 'done'/'completed' tasks\n - Yellow (\\x1b[33m) for 'pending' tasks\n - Orange (\\x1b[38;5;208m) for 'in-progress' tasks\n - Red (\\x1b[31m) for 'blocked' tasks\n - Gray (\\x1b[90m) for 'deferred'/'cancelled' tasks\n - Magenta (\\x1b[35m) for 'review' tasks\n\n3. Create diagram-specific color functions:\n - getDependencyLineColor(fromTaskStatus, toTaskStatus) - color dependency arrows based on relationship status\n - getNodeBorderColor(task) - style node borders using priority/complexity indicators\n - getSubtaskGroupColor(parentTask) - visually group related subtasks\n\n4. Integrate complexity visualization:\n - Use getComplexityWithColor() for node background or border thickness\n - Map complexity scores to visual weight in the graph\n\n5. Ensure accessibility:\n - Add text-based indicators (symbols like ✓, ⚠, ⏳) alongside colors\n - Implement colorblind-friendly palettes as user-selectable option\n - Include shape variations for different statuses\n\n6. Follow existing ANSI patterns:\n - Maintain consistency with terminal UI color usage\n - Reuse color constants from the codebase\n\n7. Support graceful degradation:\n - Check terminal capabilities using existing detection\n - Provide monochrome fallbacks with distinctive patterns\n - Use bold/underline as alternatives when colors unavailable\n</info added on 2025-05-23T21:03:35.762Z>", "status": "pending" }, @@ -2486,9 +2120,7 @@ "id": 5, "title": "Circular Dependency Detection", "description": "Implement algorithms to detect and highlight circular dependencies within the graph.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Clearly mark cycles in the rendered output and provide warnings or errors as appropriate.\n<info added on 2025-05-23T21:04:20.125Z>\nIntegrate with Task Master's existing circular dependency detection:\n\n1. Import the dependency detection logic from dependency-manager.js module\n2. Utilize the findCycles function from utils.js or dependency-manager.js\n3. Extend validateDependenciesCommand functionality to highlight cycles in diagrams\n\nVisual representation in Mermaid diagrams:\n- Apply red/bold styling to nodes involved in dependency cycles\n- Add warning annotations to cyclic edges\n- Implement cycle path highlighting with distinctive line styles\n\nIntegration with validation workflow:\n- Execute dependency validation before diagram generation\n- Display cycle warnings consistent with existing CLI error messaging\n- Utilize chalk.red and boxen for error highlighting following established patterns\n\nAdd diagram legend entries that explain cycle notation and warnings\n\nEnsure detection of cycles in both:\n- Main task dependencies\n- Subtask dependencies within parent tasks\n\nFollow Task Master's error handling patterns for graceful cycle reporting and user notification\n</info added on 2025-05-23T21:04:20.125Z>", "status": "pending" }, @@ -2496,10 +2128,7 @@ "id": 6, "title": "Filtering and Search Functionality", "description": "Enable users to filter nodes and edges by criteria such as name, type, or dependency depth.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Support command-line flags for filtering and interactive search if feasible.\n<info added on 2025-05-23T21:04:57.811Z>\nImplement MCP tool integration for task dependency visualization:\n\n1. Create task_diagram.js in mcp-server/src/tools/ following existing tool patterns\n2. Implement taskDiagramDirect.js in mcp-server/src/core/direct-functions/\n3. Use Zod schema for parameter validation:\n - diagramType (dependencies, subtasks, flow, gantt)\n - taskId (optional string)\n - format (mermaid, text, json)\n - includeComplexity (boolean)\n\n4. Structure response data with:\n - mermaidCode for client-side rendering\n - metadata (nodeCount, edgeCount, cycleWarnings)\n - support for both task-specific and project-wide diagrams\n\n5. Integrate with session management and project root handling\n6. Implement error handling using handleApiResult pattern\n7. Register the tool in tools/index.js\n\nMaintain compatibility with existing command-line flags for filtering and interactive search.\n</info added on 2025-05-23T21:04:57.811Z>", "status": "pending" }, @@ -2507,10 +2136,7 @@ "id": 7, "title": "Accessibility Features", "description": "Ensure the tool is accessible, including support for screen readers, high-contrast modes, and keyboard navigation.", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Provide alternative text output and ensure color is not the sole means of conveying information.\n<info added on 2025-05-23T21:05:54.584Z>\n# Accessibility and Export Integration\n\n## Accessibility Features\n- Provide alternative text output for visual elements\n- Ensure color is not the sole means of conveying information\n- Support keyboard navigation through the dependency graph\n- Add screen reader compatible node descriptions\n\n## Export Integration\n- Extend generateTaskFiles function in task-manager.js to include Mermaid diagram sections\n- Add Mermaid code blocks to task markdown files under ## Diagrams header\n- Follow existing task file generation patterns and markdown structure\n- Support multiple diagram types per task file:\n * Task dependencies (prerequisite relationships)\n * Subtask hierarchy visualization\n * Task flow context in project workflow\n- Integrate with existing fs module file writing operations\n- Add diagram export options to the generate command in commands.js\n- Support SVG and PNG export using Mermaid CLI when available\n- Implement error handling for diagram generation failures\n- Reference exported diagrams in task markdown with proper paths\n- Update CLI generate command with options like --include-diagrams\n</info added on 2025-05-23T21:05:54.584Z>", "status": "pending" }, @@ -2518,13 +2144,7 @@ "id": 8, "title": "Performance Optimization", "description": "Profile and optimize the tool for large graphs to ensure responsive rendering and low memory usage.", - "dependencies": [ - 2, - 3, - 4, - 5, - 6 - ], + "dependencies": [2, 3, 4, 5, 6], "details": "Implement lazy loading, efficient data structures, and parallel processing where appropriate.\n<info added on 2025-05-23T21:06:14.533Z>\n# Mermaid Library Integration and Terminal-Specific Handling\n\n## Package Dependencies\n- Add mermaid package as an optional dependency in package.json for generating raw Mermaid diagram code\n- Consider mermaid-cli for SVG/PNG conversion capabilities\n- Evaluate terminal-image or similar libraries for terminals with image support\n- Explore ascii-art-ansi or box-drawing character libraries for text-only terminals\n\n## Terminal Capability Detection\n- Leverage existing terminal detection from ui.js to assess rendering capabilities\n- Implement detection for:\n - iTerm2 and other terminals with image protocol support\n - Terminals with Unicode/extended character support\n - Basic terminals requiring pure ASCII output\n\n## Rendering Strategy with Fallbacks\n1. Primary: Generate raw Mermaid code for user copy/paste\n2. Secondary: Render simplified ASCII tree/flow representation using box characters\n3. Tertiary: Present dependencies in tabular format for minimal terminals\n\n## Implementation Approach\n- Use dynamic imports for optional rendering libraries to maintain lightweight core\n- Implement graceful degradation when optional packages aren't available\n- Follow Task Master's philosophy of minimal dependencies\n- Ensure performance optimization through lazy loading where appropriate\n- Design modular rendering components that can be swapped based on terminal capabilities\n</info added on 2025-05-23T21:06:14.533Z>", "status": "pending" }, @@ -2532,16 +2152,7 @@ "id": 9, "title": "Documentation", "description": "Write comprehensive user and developer documentation covering installation, usage, configuration, and extension.", - "dependencies": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], + "dependencies": [1, 2, 3, 4, 5, 6, 7, 8], "details": "Include examples, troubleshooting, and contribution guidelines.", "status": "pending" }, @@ -2549,17 +2160,7 @@ "id": 10, "title": "Testing and Validation", "description": "Develop automated tests for all major features, including CLI parsing, layout correctness, rendering, color coding, filtering, and cycle detection.", - "dependencies": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9 - ], + "dependencies": [1, 2, 3, 4, 5, 6, 7, 8, 9], "details": "Include unit, integration, and regression tests; validate accessibility and performance claims.\n<info added on 2025-05-23T21:08:36.329Z>\n# Documentation Tasks for Visual Task Dependency Graph\n\n## User Documentation\n1. Update README.md with diagram command documentation following existing command reference format\n2. Add examples to CLI command help text in commands.js matching patterns from other commands\n3. Create docs/diagrams.md with detailed usage guide including:\n - Command examples for each diagram type\n - Mermaid code samples and output\n - Terminal compatibility notes\n - Integration with task workflow examples\n - Troubleshooting section for common diagram rendering issues\n - Accessibility features and terminal fallback options\n\n## Developer Documentation\n1. Update MCP tool documentation to include the new task_diagram tool\n2. Add JSDoc comments to all new functions following existing code standards\n3. Create contributor documentation for extending diagram types\n4. Update API documentation for any new MCP interface endpoints\n\n## Integration Documentation\n1. Document integration with existing commands (analyze-complexity, generate, etc.)\n2. Provide examples showing how diagrams complement other Task Master features\n</info added on 2025-05-23T21:08:36.329Z>", "status": "pending" } @@ -2649,9 +2250,7 @@ "id": 2, "title": "Implement webhook authentication and security measures", "description": "Develop security mechanisms for webhook verification and payload signing", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implement signature verification using HMAC, rate limiting to prevent abuse, IP whitelisting options, and webhook secret management. Create a secure token system for webhook verification and implement TLS for all webhook communications.", "status": "pending" }, @@ -2667,10 +2266,7 @@ "id": 4, "title": "Build event processing and queuing system", "description": "Implement a robust system for processing and queuing events before webhook delivery", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "details": "Create an event queue using a message broker (like RabbitMQ or Kafka) to handle high volumes of events. Implement event deduplication, prioritization, and persistence to ensure reliable delivery even during system failures.", "status": "pending" }, @@ -2678,10 +2274,7 @@ "id": 5, "title": "Develop webhook delivery and retry mechanism", "description": "Create a reliable system for webhook delivery with retry logic and failure handling", - "dependencies": [ - 2, - 4 - ], + "dependencies": [2, 4], "details": "Implement exponential backoff retry logic, configurable retry attempts, and dead letter queues for failed deliveries. Add monitoring for webhook delivery success rates and performance metrics. Include timeout handling for unresponsive webhook endpoints.", "status": "pending" }, @@ -2689,9 +2282,7 @@ "id": 6, "title": "Implement comprehensive error handling and logging", "description": "Create robust error handling, logging, and monitoring for the webhook system", - "dependencies": [ - 5 - ], + "dependencies": [5], "details": "Develop detailed error logging for webhook failures, including response codes, error messages, and timing information. Implement alerting for critical failures and create a dashboard for monitoring system health. Add debugging tools for webhook delivery issues.", "status": "pending" }, @@ -2699,11 +2290,7 @@ "id": 7, "title": "Create webhook testing and simulation tools", "description": "Develop tools for testing webhook integrations and simulating event triggers", - "dependencies": [ - 3, - 5, - 6 - ], + "dependencies": [3, 5, 6], "details": "Build a webhook testing console that allows manual triggering of events, viewing delivery history, and replaying failed webhooks. Create a webhook simulator for developers to test their endpoint implementations without generating real system events.", "status": "pending" } @@ -2731,9 +2318,7 @@ "id": 2, "title": "Implement GitHub URL parsing and validation", "description": "Create a module to parse and validate GitHub issue URLs, extracting repository owner, repository name, and issue number.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Handle various GitHub URL formats (e.g., github.com/owner/repo/issues/123, github.com/owner/repo/pull/123). Implement validation to ensure the URL points to a valid issue or pull request. Return structured data with owner, repo, and issue number for valid URLs.", "status": "pending" }, @@ -2741,10 +2326,7 @@ "id": 3, "title": "Develop GitHub API client for issue fetching", "description": "Create a service to authenticate with GitHub and fetch issue details using the GitHub REST API.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Implement authentication using GitHub Personal Access Tokens or OAuth. Handle API responses, including error cases (rate limiting, authentication failures, not found). Extract relevant issue data: title, description, labels, assignees, and comments.", "status": "pending" }, @@ -2752,9 +2334,7 @@ "id": 4, "title": "Create task formatter for GitHub issues", "description": "Develop a formatter to convert GitHub issue data into the application's task format.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Map GitHub issue fields to task fields (title, description, etc.). Convert GitHub markdown to the application's supported format. Handle special GitHub features like issue references and user mentions. Generate appropriate tags based on GitHub labels.", "status": "pending" }, @@ -2762,9 +2342,7 @@ "id": 5, "title": "Implement end-to-end import flow with UI", "description": "Create the user interface and workflow for importing GitHub issues, including progress indicators and error handling.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Design and implement UI for URL input and import confirmation. Show loading states during API calls. Display meaningful error messages for various failure scenarios. Allow users to review and modify imported task details before saving. Add automated tests for the entire import flow.", "status": "pending" }, @@ -2780,9 +2358,7 @@ "id": 7, "title": "Add bidirectional integration with export feature", "description": "Ensure imported tasks work seamlessly with the GitHub export feature and maintain consistent link management.", - "dependencies": [ - 6 - ], + "dependencies": [6], "details": "Verify that tasks imported from GitHub can be properly exported back to GitHub. Implement checks to prevent duplicate exports of imported issues. Add metadata flags to identify imported tasks and their source repositories. Test round-trip workflows (import → modify → export) to ensure data integrity.", "status": "pending" }, @@ -2798,10 +2374,7 @@ "id": 9, "title": "Extend GitHub URL parsing for Issues and Discussions", "description": "Enhance URL parsing to support both GitHub Issues and Discussions with automatic type detection.", - "dependencies": [ - 2, - 8 - ], + "dependencies": [2, 8], "details": "Extend existing URL parser to handle GitHub Discussions URLs. Implement automatic detection of content type (issue vs discussion). Update validation logic for both content types. Ensure consistent data extraction for owner, repo, and content ID regardless of type.", "status": "pending" }, @@ -2809,10 +2382,7 @@ "id": 10, "title": "Implement comprehensive GitHub API client", "description": "Create enhanced GitHub API client supporting both Issues and Discussions APIs with complete content fetching.", - "dependencies": [ - 3, - 9 - ], + "dependencies": [3, 9], "details": "Extend existing API client to support GitHub Discussions API. Implement complete content fetching including all comments and replies. Add support for GITHUB_API_KEY environment variable. Handle threaded discussions and comment hierarchies. Implement robust error handling and rate limiting for both API types.", "status": "pending" }, @@ -2820,9 +2390,7 @@ "id": 11, "title": "Integrate ContextGatherer for LLM-powered analysis", "description": "Integrate with existing ContextGatherer.js to enable LLM-powered analysis of GitHub content.", - "dependencies": [ - 10 - ], + "dependencies": [10], "details": "Adapt ContextGatherer.js to work with GitHub content as input source. Create GitHub-specific context gathering strategies. Implement content preprocessing for optimal LLM analysis. Add project component identification for GitHub discussions. Create prompts for task generation from GitHub content.", "status": "pending" }, @@ -2830,9 +2398,7 @@ "id": 12, "title": "Implement LLM-powered task generation", "description": "Create the core LLM integration that analyzes GitHub content and generates comprehensive tasks with subtasks.", - "dependencies": [ - 11 - ], + "dependencies": [11], "details": "Design LLM prompts for task generation from GitHub content. Implement automatic subtask creation from complex discussions. Add priority and dependency inference based on content analysis. Create test strategy generation from technical discussions. Implement quality validation for LLM-generated content. Add fallback mechanisms for LLM failures.", "status": "pending" }, @@ -2840,10 +2406,7 @@ "id": 13, "title": "Enhance metadata system for rich import context", "description": "Extend the metadata schema to store comprehensive import context and enable advanced features.", - "dependencies": [ - 6, - 12 - ], + "dependencies": [6, 12], "details": "Extend existing metadata schema with import-specific fields. Add source platform, import timestamp, and LLM model tracking. Implement content hash storage for change detection. Store participant information and discussion context. Add support for custom metadata per platform type. Ensure backward compatibility with existing export feature metadata.", "status": "pending" }, @@ -2851,11 +2414,7 @@ "id": 14, "title": "Implement import_task command interface", "description": "Create the user-facing command interface for the new import_task system with GitHub support.", - "dependencies": [ - 8, - 12, - 13 - ], + "dependencies": [8, 12, 13], "details": "Implement the main import_task command with GitHub subcommand. Add command-line argument parsing and validation. Create progress indicators for LLM processing. Implement user review and confirmation workflow. Add verbose output options for debugging. Create help documentation and usage examples.", "status": "pending" }, @@ -2863,9 +2422,7 @@ "id": 15, "title": "Add comprehensive testing and validation", "description": "Implement comprehensive testing suite covering all aspects of the LLM-powered import system.", - "dependencies": [ - 14 - ], + "dependencies": [14], "details": "Create unit tests for all new components. Implement integration tests with real GitHub content. Add LLM response validation and quality tests. Create performance tests for large discussions. Implement end-to-end workflow testing. Add mock data for consistent testing. Test bidirectional compatibility with export feature.", "status": "pending" } @@ -2893,9 +2450,7 @@ "id": 2, "title": "Implement AI integration for ICE scoring", "description": "Develop the AI component that will analyze tasks and generate ICE scores", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create prompts for the AI to evaluate Impact, Confidence, and Ease. Implement error handling for AI responses. Add caching to prevent redundant AI calls. Ensure the AI provides justification for each score component. Test with various task types to ensure consistent scoring.", "status": "pending" }, @@ -2903,9 +2458,7 @@ "id": 3, "title": "Create report file generator", "description": "Build functionality to generate a structured report file with ICE analysis results", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Design the report file format (JSON, CSV, or Markdown). Implement sorting of tasks by ICE score. Include task details, individual I/C/E scores, and final ICE score in the report. Add timestamp and project metadata. Create a function to save the report to the specified location.", "status": "pending" }, @@ -2913,9 +2466,7 @@ "id": 4, "title": "Implement CLI rendering for ICE analysis", "description": "Develop the command-line interface for displaying ICE analysis results", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Design a tabular format for displaying ICE scores in the terminal. Use color coding to highlight high/medium/low priority tasks. Implement filtering options (by score range, task type, etc.). Add sorting capabilities. Create a summary view that shows top N tasks by ICE score.", "status": "pending" }, @@ -2923,10 +2474,7 @@ "id": 5, "title": "Integrate with existing complexity reports", "description": "Connect the ICE analysis functionality with the existing complexity reporting system", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Modify the existing complexity report to include ICE scores. Ensure consistent formatting between complexity and ICE reports. Add cross-referencing between reports. Update the command-line help documentation. Test the integrated system with various project sizes and configurations.", "status": "pending" } @@ -2954,9 +2502,7 @@ "id": 2, "title": "Implement State Management for Task Expansion", "description": "Develop the state management logic to handle expanded task states, subtask creation, and context additions.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create state handlers for expanded/collapsed states, subtask array management, and context data. Implement proper validation for user inputs and error handling. Ensure state persistence across user sessions and synchronization with backend services.", "status": "pending" }, @@ -2964,9 +2510,7 @@ "id": 3, "title": "Build Context Addition Functionality", "description": "Create the functionality that allows users to add additional context to tasks and subtasks.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implement context input fields with support for rich text, attachments, links, and references to other tasks. Add auto-save functionality for context changes and version history if applicable. Include context suggestion features based on task content.", "status": "pending" }, @@ -2974,9 +2518,7 @@ "id": 4, "title": "Develop Task Management Controls", "description": "Implement controls for managing tasks within the expanded card view, including prioritization, scheduling, and assignment.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Create UI controls for task prioritization (drag-and-drop ranking), deadline setting with calendar integration, assignee selection with user search, and status updates. Implement notification triggers for task changes and deadline reminders.", "status": "pending" }, @@ -2984,10 +2526,7 @@ "id": 5, "title": "Integrate with Existing Task Systems", "description": "Ensure the enhanced actions card workflow integrates seamlessly with existing task management functionality.", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Connect the new UI components to existing backend APIs. Update data models if necessary to support new features. Ensure compatibility with existing task filters, search, and reporting features. Implement data migration plan for existing tasks if needed.", "status": "pending" }, @@ -2995,9 +2534,7 @@ "id": 6, "title": "Test and Optimize User Experience", "description": "Conduct thorough testing of the enhanced workflow and optimize based on user feedback and performance metrics.", - "dependencies": [ - 5 - ], + "dependencies": [5], "details": "Perform usability testing with representative users. Collect metrics on task completion time, error rates, and user satisfaction. Optimize performance for large task lists and complex subtask hierarchies. Implement A/B testing for alternative UI approaches if needed.", "status": "pending" } @@ -3025,9 +2562,7 @@ "id": 2, "title": "Extract prompts into individual files", "description": "Identify all hardcoded prompts in the codebase and extract them into individual files in the prompts directory", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Search through the codebase for all hardcoded prompt strings. For each prompt, create a new file in the appropriate subdirectory with a descriptive name (e.g., 'taskBreakdownPrompt.js'). Format each file to export the prompt string as a constant. Add JSDoc comments to document the purpose and expected usage of each prompt.", "status": "pending" }, @@ -3035,10 +2570,7 @@ "id": 3, "title": "Update functions to import prompts", "description": "Modify all functions that use hardcoded prompts to import them from the centralized structure", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "For each function that previously used a hardcoded prompt, add an import statement to pull in the prompt from the centralized structure. Test each function after modification to ensure it still works correctly. Update any tests that might be affected by the refactoring. Create a pull request with the changes and document the new prompt structure in the project documentation.", "status": "pending" } @@ -3066,9 +2598,7 @@ "id": 2, "title": "Implement best practice verification", "description": "Build verification checks against established coding standards and best practices", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create a framework to compare code against established best practices for the specific language/framework. Include checks for naming conventions, function length, complexity metrics, comment coverage, and other industry-standard quality indicators.", "status": "pending" }, @@ -3076,10 +2606,7 @@ "id": 3, "title": "Develop AI integration for code analysis", "description": "Integrate AI capabilities to enhance code analysis and provide intelligent recommendations", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Connect to AI services (like OpenAI) to analyze code beyond rule-based checks. Configure the AI to understand context, project-specific patterns, and provide nuanced analysis that rule-based systems might miss.", "status": "pending" }, @@ -3087,10 +2614,7 @@ "id": 4, "title": "Create recommendation generation system", "description": "Build a system to generate actionable improvement recommendations based on analysis results", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "Develop algorithms to transform analysis results into specific, actionable recommendations. Include priority levels, effort estimates, and potential impact assessments for each recommendation.", "status": "pending" }, @@ -3098,9 +2622,7 @@ "id": 5, "title": "Implement task creation functionality", "description": "Add capability to automatically create tasks from code quality recommendations", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Build functionality to convert recommendations into tasks in the project management system. Include appropriate metadata, assignee suggestions based on code ownership, and integration with existing workflow systems.", "status": "pending" }, @@ -3108,10 +2630,7 @@ "id": 6, "title": "Create comprehensive reporting interface", "description": "Develop a user interface to display analysis results and recommendations", - "dependencies": [ - 4, - 5 - ], + "dependencies": [4, 5], "details": "Build a dashboard showing code quality metrics, identified patterns, recommendations, and created tasks. Include filtering options, trend analysis over time, and the ability to drill down into specific issues with code snippets and explanations.", "status": "pending" } @@ -3140,9 +2659,7 @@ "id": 2, "title": "Develop coverage report parser and adapter system", "description": "Create a framework-agnostic system that can parse coverage reports from various testing tools and convert them to the standardized task-based format in tests.json.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "1. Research and document output formats for major coverage tools (Istanbul/nyc, Jest, Pytest, JaCoCo).\n2. Design a normalized intermediate coverage format that any test tool can map to.\n3. Implement adapter classes for each major testing framework that convert their reports to the intermediate format.\n4. Create a parser registry that can automatically detect and use the appropriate parser based on input format.\n5. Develop a mapping algorithm that associates coverage data with specific tasks based on file paths and code blocks.\n6. Implement file path normalization to handle different operating systems and environments.\n7. Add error handling for malformed or incomplete coverage reports.\n8. Create unit tests for each adapter using sample coverage reports.\n9. Implement a command-line interface for manual parsing and testing.\n10. Document the extension points for adding custom coverage tool adapters.", "status": "pending", "parentTaskId": 50 @@ -3151,10 +2668,7 @@ "id": 3, "title": "Build coverage tracking and update generator", "description": "Create a system that processes code coverage reports, maps them to tasks, and updates the tests.json file to maintain accurate coverage tracking over time.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "1. Implement a coverage processor that takes parsed coverage data and maps it to task IDs.\n2. Create algorithms to calculate aggregate coverage metrics at the task and subtask levels.\n3. Develop a change detection system that identifies when tests or code have changed and require updates.\n4. Implement incremental update logic to avoid reprocessing unchanged tests.\n5. Create a task-code association system that maps specific code blocks to tasks for granular tracking.\n6. Add historical tracking to monitor coverage trends over time.\n7. Implement hooks for CI/CD integration to automatically update coverage after test runs.\n8. Create a conflict resolution strategy for when multiple tests cover the same code areas.\n9. Add performance optimizations for large codebases and test suites.\n10. Develop unit tests that verify correct aggregation and mapping of coverage data.\n11. Document the update workflow with sequence diagrams and examples.", "status": "pending", "parentTaskId": 50 @@ -3163,11 +2677,7 @@ "id": 4, "title": "Implement CLI commands for coverage operations", "description": "Create a set of command-line interface tools that allow developers to view, analyze, and manage test coverage at the task level.", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "details": "1. Design a cohesive CLI command structure with subcommands for different coverage operations.\n2. Implement 'coverage show' command to display test coverage for a specific task/subtask.\n3. Create 'coverage gaps' command to identify untested code related to a particular task.\n4. Develop 'coverage history' command to show how coverage has changed over time.\n5. Implement 'coverage generate' command that uses LLMs to suggest tests for uncovered code.\n6. Add filtering options to focus on specific test types or coverage thresholds.\n7. Create formatted output options (JSON, CSV, markdown tables) for integration with other tools.\n8. Implement colorized terminal output for better readability of coverage reports.\n9. Add batch processing capabilities for running operations across multiple tasks.\n10. Create comprehensive help documentation and examples for each command.\n11. Develop unit and integration tests for CLI commands.\n12. Document command usage patterns and example workflows.", "status": "pending", "parentTaskId": 50 @@ -3176,12 +2686,7 @@ "id": 5, "title": "Develop AI-powered test generation system", "description": "Create an intelligent system that uses LLMs to generate targeted tests for uncovered code sections within tasks, integrating with the existing task management workflow.", - "dependencies": [ - 1, - 2, - 3, - 4 - ], + "dependencies": [1, 2, 3, 4], "details": "1. Design prompt templates for different test types (unit, integration, E2E) that incorporate task descriptions and code context.\n2. Implement code analysis to extract relevant context from uncovered code sections.\n3. Create a test generation pipeline that combines task metadata, code context, and coverage gaps.\n4. Develop strategies for maintaining test context across task changes and updates.\n5. Implement test quality evaluation to ensure generated tests are meaningful and effective.\n6. Create a feedback mechanism to improve prompts based on acceptance or rejection of generated tests.\n7. Add support for different testing frameworks and languages through templating.\n8. Implement caching to avoid regenerating similar tests.\n9. Create a workflow that integrates with the task management system to suggest tests alongside implementation requirements.\n10. Develop specialized generation modes for edge cases, regression tests, and performance tests.\n11. Add configuration options for controlling test generation style and coverage goals.\n12. Create comprehensive documentation on how to use and extend the test generation system.\n13. Implement evaluation metrics to track the effectiveness of AI-generated tests.", "status": "pending", "parentTaskId": 50 @@ -3220,9 +2725,7 @@ "id": 3, "title": "Build Explore Command CLI Interface", "description": "Implement the Commander.js command structure for the 'explore' command with all required options and parameters to launch the interactive REPL.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implementation details:\n1. Create a new command file `commands/explore.js`\n2. Set up the Commander.js command structure with the following options:\n - `--tasks` or `-t` option for task/subtask IDs (comma-separated)\n - `--files` or `-f` option for file paths (comma-separated)\n - `--session` or `-s` option to resume a previous session\n - `--context` or `-c` option for custom initial context\n3. Implement command validation logic for parameters\n4. Create entry point that launches the interactive REPL\n5. Integrate context initialization from command line parameters\n6. Register the command in the main CLI application\n7. Add help text and usage examples\n8. Implement parameter parsing for task IDs and file paths\n\nTesting approach:\n- Test command registration and option parsing\n- Verify command validation logic works correctly\n- Test with various combinations of options\n- Ensure proper error messages for invalid inputs\n- Test parameter parsing for complex task ID formats\n<info added on 2025-05-23T21:09:08.478Z>\nImplementation details:\n1. Create a new module `repl/research-chat.js` for the interactive research experience\n2. Implement REPL-style chat interface using inquirer with:\n - Persistent conversation history management\n - Context-aware prompting system\n - Command parsing for special instructions\n3. Implement REPL commands:\n - `/save` - Save conversation to file\n - `/task` - Associate with or load context from a task\n - `/help` - Show available commands and usage\n - `/exit` - End the research session\n - `/copy` - Copy last response to clipboard\n - `/summary` - Generate summary of conversation\n - `/detail` - Adjust research depth level\n4. Create context initialization system:\n - Task/subtask context loading\n - File content integration\n - System prompt configuration\n5. Integrate with ai-services-unified.js research mode\n6. Implement conversation state management:\n - Track message history\n - Maintain context window\n - Handle context pruning for long conversations\n7. Design consistent UI patterns using ui.js library\n8. Add entry point in main CLI application\n\nTesting approach:\n- Test REPL command parsing and execution\n- Verify context initialization with various inputs\n- Test conversation state management\n- Ensure proper error handling and recovery\n- Validate UI consistency across different terminal environments\n</info added on 2025-05-23T21:09:08.478Z>", "status": "pending", "parentTaskId": 51 @@ -3231,9 +2734,7 @@ "id": 4, "title": "Implement Chat Formatting and Display System", "description": "Create functionality to format and display conversational research interactions in the terminal with streaming responses and markdown support.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Implementation details:\n1. Create a new module `utils/chatFormatter.js` for REPL interface formatting\n2. Implement terminal output formatting for conversational display:\n - Color-coded messages distinguishing user inputs and AI responses\n - Proper text wrapping and indentation for readability\n - Support for markdown rendering in terminal\n - Visual indicators for system messages and status updates\n3. Implement streaming/progressive display of AI responses:\n - Character-by-character or chunk-by-chunk display\n - Cursor animations during response generation\n - Ability to interrupt long responses\n4. Design chat history visualization:\n - Scrollable history with clear message boundaries\n - Timestamp display options\n - Session identification\n5. Create specialized formatters for different content types:\n - Code blocks with syntax highlighting\n - Bulleted and numbered lists\n - Tables and structured data\n - Citations and references\n6. Implement export functionality:\n - Save conversations to markdown or text files\n - Export individual responses\n - Copy responses to clipboard\n7. Adapt existing ui.js patterns for conversational context:\n - Maintain consistent styling while supporting chat flow\n - Handle multi-turn context appropriately\n\nTesting approach:\n- Test streaming display with various response lengths and speeds\n- Verify markdown rendering accuracy for complex formatting\n- Test history navigation and scrolling functionality\n- Verify export features create properly formatted files\n- Test display on various terminal sizes and configurations\n- Verify handling of special characters and unicode\n<info added on 2025-05-23T21:10:00.181Z>\nImplementation details:\n1. Create a new module `utils/chatFormatter.js` for REPL interface formatting\n2. Implement terminal output formatting for conversational display:\n - Color-coded messages distinguishing user inputs and AI responses\n - Proper text wrapping and indentation for readability\n - Support for markdown rendering in terminal\n - Visual indicators for system messages and status updates\n3. Implement streaming/progressive display of AI responses:\n - Character-by-character or chunk-by-chunk display\n - Cursor animations during response generation\n - Ability to interrupt long responses\n4. Design chat history visualization:\n - Scrollable history with clear message boundaries\n - Timestamp display options\n - Session identification\n5. Create specialized formatters for different content types:\n - Code blocks with syntax highlighting\n - Bulleted and numbered lists\n - Tables and structured data\n - Citations and references\n6. Implement export functionality:\n - Save conversations to markdown or text files\n - Export individual responses\n - Copy responses to clipboard\n7. Adapt existing ui.js patterns for conversational context:\n - Maintain consistent styling while supporting chat flow\n - Handle multi-turn context appropriately\n\nTesting approach:\n- Test streaming display with various response lengths and speeds\n- Verify markdown rendering accuracy for complex formatting\n- Test history navigation and scrolling functionality\n- Verify export features create properly formatted files\n- Test display on various terminal sizes and configurations\n- Verify handling of special characters and unicode\n</info added on 2025-05-23T21:10:00.181Z>", "status": "pending", "parentTaskId": 51 @@ -3242,10 +2743,7 @@ "id": 5, "title": "Implement Caching and Results Management System", "description": "Create a persistent caching system for research results and implement functionality to manage, retrieve, and reference previous research.", - "dependencies": [ - 1, - 4 - ], + "dependencies": [1, 4], "details": "Implementation details:\n1. Create a research results database using a simple JSON file or SQLite:\n - Store queries, timestamps, and results\n - Index by query and related task IDs\n2. Implement cache retrieval and validation:\n - Check for cached results before making API calls\n - Validate cache freshness with configurable TTL\n3. Add commands to manage research history:\n - List recent research queries\n - Retrieve past research by ID or search term\n - Clear cache or delete specific entries\n4. Create functionality to associate research results with tasks:\n - Add metadata linking research to specific tasks\n - Implement command to show all research related to a task\n5. Add configuration options for cache behavior in user settings\n6. Implement export/import functionality for research data\n\nTesting approach:\n- Test cache storage and retrieval with various queries\n- Verify cache invalidation works correctly\n- Test history management commands\n- Verify task association functionality\n- Test with large cache sizes to ensure performance\n<info added on 2025-05-23T21:10:28.544Z>\nImplementation details:\n1. Create a session management system for the REPL experience:\n - Generate and track unique session IDs\n - Store conversation history with timestamps\n - Maintain context and state between interactions\n2. Implement session persistence:\n - Save sessions to disk automatically\n - Load previous sessions on startup\n - Handle graceful recovery from crashes\n3. Build session browser and selector:\n - List available sessions with preview\n - Filter sessions by date, topic, or content\n - Enable quick switching between sessions\n4. Implement conversation state serialization:\n - Capture full conversation context\n - Preserve user preferences per session\n - Handle state migration during updates\n5. Add session sharing capabilities:\n - Export sessions to portable formats\n - Import sessions from files\n - Generate shareable links (if applicable)\n6. Create session management commands:\n - Create new sessions\n - Clone existing sessions\n - Archive or delete old sessions\n\nTesting approach:\n- Verify session persistence across application restarts\n- Test session recovery from simulated crashes\n- Validate state serialization with complex conversations\n- Ensure session switching maintains proper context\n- Test session import/export functionality\n- Verify performance with large conversation histories\n</info added on 2025-05-23T21:10:28.544Z>", "status": "cancelled", "parentTaskId": 51 @@ -3254,9 +2752,7 @@ "id": 6, "title": "Implement Project Context Generation", "description": "Create functionality to generate and include project-level context such as file trees, repository structure, and codebase insights for more informed research.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implementation details:\n1. Create a new module `utils/projectContextGenerator.js` for project-level context extraction\n2. Implement file tree generation functionality:\n - Scan project directory structure recursively\n - Filter out irrelevant files (node_modules, .git, etc.)\n - Format file tree for AI consumption\n - Include file counts and structure statistics\n3. Add code analysis capabilities:\n - Extract key imports and dependencies\n - Identify main modules and their relationships\n - Generate high-level architecture overview\n4. Implement context summarization:\n - Create concise project overview\n - Identify key technologies and patterns\n - Summarize project purpose and structure\n5. Add caching for expensive operations:\n - Cache file tree with invalidation on changes\n - Store analysis results with TTL\n6. Create integration with research REPL:\n - Add project context to system prompts\n - Support `/project` command to refresh context\n - Allow selective inclusion of project components\n\nTesting approach:\n- Test file tree generation with various project structures\n- Verify filtering logic works correctly\n- Test context summarization quality\n- Measure performance impact of context generation\n- Verify caching mechanism effectiveness", "status": "pending", "parentTaskId": 51 @@ -3265,9 +2761,7 @@ "id": 7, "title": "Create REPL Command System", "description": "Implement a flexible command system for the explore REPL that allows users to control the conversation flow, manage sessions, and access additional functionality.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Implementation details:\n1. Create a new module `repl/commands.js` for REPL command handling\n2. Implement a command parser that:\n - Detects commands starting with `/`\n - Parses arguments and options\n - Handles quoted strings and special characters\n3. Create a command registry system:\n - Register command handlers with descriptions\n - Support command aliases\n - Enable command discovery and help\n4. Implement core commands:\n - `/save [filename]` - Save conversation\n - `/task <taskId>` - Load task context\n - `/file <path>` - Include file content\n - `/help [command]` - Show help\n - `/exit` - End session\n - `/copy [n]` - Copy nth response\n - `/summary` - Generate conversation summary\n - `/detail <level>` - Set detail level\n - `/clear` - Clear conversation\n - `/project` - Refresh project context\n - `/session <id|new>` - Switch/create session\n - `/context` - Show current context information\n5. Add command completion and suggestions\n6. Implement error handling for invalid commands\n7. Create a help system with examples\n\nTesting approach:\n- Test command parsing with various inputs\n- Verify command execution and error handling\n- Test command completion functionality\n- Verify help system provides useful information\n- Test with complex command sequences", "status": "pending", "parentTaskId": 51 @@ -3276,10 +2770,7 @@ "id": 8, "title": "Integrate with AI Services Unified", "description": "Integrate the explore REPL with the existing ai-services-unified.js to leverage the unified AI service architecture with research mode.", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Implementation details:\n1. Update `repl/research-chat.js` to integrate with ai-services-unified.js\n2. Configure research mode in AI service:\n - Set appropriate system prompts for exploration and research\n - Configure temperature and other parameters\n - Enable streaming responses\n3. Implement context management:\n - Format conversation history for AI context\n - Include task and project context\n - Handle context window limitations\n4. Add support for different exploration styles:\n - Exploratory research with broader context\n - Focused research with specific questions\n - Comparative analysis between concepts\n - Code exploration and analysis\n5. Implement response handling:\n - Process streaming chunks\n - Format and display responses\n - Handle errors and retries\n6. Add configuration options for AI service selection\n7. Implement fallback mechanisms for service unavailability\n\nTesting approach:\n- Test integration with mocked AI services\n- Verify context formatting and management\n- Test streaming response handling\n- Verify error handling and recovery\n- Test with various exploration styles and queries", "status": "pending", "parentTaskId": 51 @@ -3288,10 +2779,7 @@ "id": 9, "title": "Implement Session Management System", "description": "Create a comprehensive session management system for the explore REPL that handles session persistence, recovery, and switching between multiple exploration sessions.", - "dependencies": [ - 4, - 7 - ], + "dependencies": [4, 7], "details": "Implementation details:\n1. Create a session management system for the explore REPL:\n - Generate and track unique session IDs\n - Store conversation history with timestamps\n - Maintain context and state between interactions\n2. Implement session persistence:\n - Save sessions to disk automatically\n - Load previous sessions on startup\n - Handle graceful recovery from crashes\n3. Build session browser and selector:\n - List available sessions with preview\n - Filter sessions by date, topic, or content\n - Enable quick switching between sessions\n4. Implement conversation state serialization:\n - Capture full conversation context\n - Preserve user preferences per session\n - Handle state migration during updates\n5. Add session sharing capabilities:\n - Export sessions to portable formats\n - Import sessions from files\n - Generate shareable session summaries\n6. Create session management commands:\n - Create new sessions\n - Clone existing sessions\n - Archive or delete old sessions\n7. Integrate with command line --session parameter\n\nTesting approach:\n- Verify session persistence across application restarts\n- Test session recovery from simulated crashes\n- Validate state serialization with complex conversations\n- Ensure session switching maintains proper context\n- Test session import/export functionality\n- Verify performance with large conversation histories", "status": "pending", "parentTaskId": 51 @@ -3320,9 +2808,7 @@ "id": 2, "title": "Implement AI integration for task suggestions", "description": "Develop the core functionality to generate task suggestions using AI based on existing tasks", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create an AI prompt template that effectively communicates the existing task context and request for suggestions. Implement error handling for API failures, rate limiting, and malformed responses. Include parameters for controlling suggestion quantity and specificity.", "status": "pending" }, @@ -3330,9 +2816,7 @@ "id": 3, "title": "Build interactive CLI interface for suggestions", "description": "Create the command-line interface for requesting and displaying task suggestions", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Design a user-friendly CLI command structure with appropriate flags for customization. Implement progress indicators during AI processing and format the output of suggestions in a clear, readable format. Include help text and examples in the command documentation.", "status": "pending" }, @@ -3340,9 +2824,7 @@ "id": 4, "title": "Implement suggestion selection and task creation", "description": "Allow users to interactively select suggestions to convert into actual tasks", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Create an interactive selection interface where users can review suggestions, select which ones to create as tasks, and optionally modify them before creation. Implement batch creation capabilities and validation to ensure new tasks meet system requirements.", "status": "pending" }, @@ -3350,10 +2832,7 @@ "id": 5, "title": "Add configuration options and flag handling", "description": "Implement various configuration options and command flags for customizing suggestion behavior", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Create a comprehensive set of command flags for controlling suggestion quantity, specificity, format, and other parameters. Implement persistent configuration options that users can set as defaults. Document all available options and provide examples of common usage patterns.", "status": "pending" } @@ -3381,9 +2860,7 @@ "id": 2, "title": "Build context gathering mechanism", "description": "Develop a system to collect relevant context from parent task and existing subtasks", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create functions to extract information from the parent task including title, description, and metadata. Also gather information about any existing subtasks to provide context for AI suggestions. Format this data appropriately for the AI prompt.", "status": "pending" }, @@ -3391,9 +2868,7 @@ "id": 3, "title": "Develop AI suggestion logic for subtasks", "description": "Create the core AI integration to generate relevant subtask suggestions", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implement the AI prompt engineering and response handling for subtask generation. Ensure the AI provides structured output with appropriate fields for subtasks. Include error handling for API failures and malformed responses.", "status": "pending" }, @@ -3401,9 +2876,7 @@ "id": 4, "title": "Create interactive CLI interface", "description": "Build a user-friendly command-line interface for the subtask suggestion feature", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Develop CLI commands and options for requesting subtask suggestions. Include interactive elements for selecting, modifying, or rejecting suggested subtasks. Ensure clear user feedback throughout the process.", "status": "pending" }, @@ -3411,9 +2884,7 @@ "id": 5, "title": "Implement subtask linking functionality", "description": "Create system to properly link suggested subtasks to their parent task", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Develop the database operations to save accepted subtasks and link them to the parent task. Include functionality for setting dependencies between subtasks. Ensure proper transaction handling to maintain data integrity.", "status": "pending" }, @@ -3421,9 +2892,7 @@ "id": 6, "title": "Perform comprehensive testing", "description": "Test the subtask suggestion feature across various scenarios", - "dependencies": [ - 5 - ], + "dependencies": [5], "details": "Create unit tests for each component. Develop integration tests for the full feature workflow. Test edge cases including invalid inputs, API failures, and unusual task structures. Document test results and fix any identified issues.", "status": "pending" } @@ -3461,9 +2930,7 @@ "id": 2, "title": "Design positional argument specification format", "description": "Create a specification for how positional arguments will be defined in command definitions, including their order, required/optional status, and type validation.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Define a clear syntax for specifying positional arguments in command definitions. Consider how to handle mixed positional and named arguments, default values, and type constraints. Document the specification with examples for different command types.", "status": "pending" }, @@ -3471,10 +2938,7 @@ "id": 3, "title": "Implement core positional argument parsing logic", "description": "Modify the argument parser to recognize and process positional arguments according to the specification, while maintaining compatibility with existing named arguments.", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Update the parser to identify arguments without flags as positional, map them to the correct parameter based on order, and apply appropriate validation. Ensure the implementation handles missing required positional arguments and provides helpful error messages.", "status": "pending" }, @@ -3482,9 +2946,7 @@ "id": 4, "title": "Handle edge cases and error conditions", "description": "Implement robust handling for edge cases such as too many/few arguments, type mismatches, and ambiguous situations between positional and named arguments.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Create comprehensive error handling for scenarios like: providing both positional and named version of the same argument, incorrect argument types, missing required positional arguments, and excess positional arguments. Ensure error messages are clear and actionable for users.", "status": "pending" }, @@ -3492,11 +2954,7 @@ "id": 5, "title": "Update documentation and create usage examples", "description": "Update CLI documentation to explain positional argument support and provide clear examples showing how to use positional arguments with different commands.", - "dependencies": [ - 2, - 3, - 4 - ], + "dependencies": [2, 3, 4], "details": "Revise user documentation to include positional argument syntax, update command reference with positional argument information, and create example command snippets showing both positional and named argument usage. Include a migration guide for users transitioning from named-only to positional arguments.", "status": "pending" } @@ -3542,9 +3000,7 @@ "id": 3, "title": "Implement Progress Indicators and Loading Animations", "description": "Add visual feedback for long-running operations", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Create spinner animations for operations that take time to complete. Implement progress bars for operations with known completion percentages. Ensure animations degrade gracefully in terminals with limited capabilities. Add estimated time remaining calculations where possible.", "status": "pending" }, @@ -3552,9 +3008,7 @@ "id": 4, "title": "Develop Interactive Selection Menus", "description": "Create interactive menus for task selection and configuration", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Implement arrow-key navigation for selecting tasks from a list. Add checkbox and radio button interfaces for multi-select and single-select options. Include search/filter functionality for large task lists. Ensure keyboard shortcuts are consistent and documented.", "status": "pending" }, @@ -3562,9 +3016,7 @@ "id": 5, "title": "Design Tabular and Structured Output Formats", "description": "Improve the formatting of task lists and detailed information", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Create table layouts with proper column alignment for task lists. Implement tree views for displaying task hierarchies and dependencies. Add support for different output formats (plain text, JSON, CSV). Ensure outputs are properly paginated for large datasets.", "status": "pending" }, @@ -3572,11 +3024,7 @@ "id": 6, "title": "Create Help System and Interactive Documentation", "description": "Develop an in-CLI help system with examples and contextual assistance", - "dependencies": [ - 2, - 4, - 5 - ], + "dependencies": [2, 4, 5], "details": "Implement a comprehensive help command with examples for each feature. Add contextual help that suggests relevant commands based on user actions. Create interactive tutorials for new users. Include command auto-completion suggestions and syntax highlighting for command examples.", "status": "pending" } @@ -3614,9 +3062,7 @@ "id": 2, "title": "Remove Manual Dependency Modifications", "description": "Eliminate any custom scripts or manual steps that alter dependencies outside of npm's standard workflow.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Refactor or delete code that manually installs, updates, or modifies dependencies, ensuring all dependency management is handled via npm.", "status": "done" }, @@ -3624,9 +3070,7 @@ "id": 3, "title": "Update npm Dependencies", "description": "Update all project dependencies using npm, ensuring versions are current and compatible, and resolve any conflicts.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Run npm update, audit for vulnerabilities, and adjust package.json and package-lock.json as needed.", "status": "done" }, @@ -3634,9 +3078,7 @@ "id": 4, "title": "Update Initialization and Installation Commands", "description": "Revise project setup scripts and documentation to reflect the new npm-based dependency management approach.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Ensure that all initialization commands (e.g., npm install) are up-to-date and remove references to deprecated manual steps.", "status": "done" }, @@ -3644,9 +3086,7 @@ "id": 5, "title": "Update Documentation", "description": "Revise project documentation to describe the new dependency management process and provide clear setup instructions.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Update README, onboarding guides, and any developer documentation to align with npm best practices.", "status": "done" }, @@ -3654,9 +3094,7 @@ "id": 6, "title": "Perform Regression Testing", "description": "Run comprehensive tests to ensure that the refactor has not introduced any regressions or broken existing functionality.", - "dependencies": [ - 5 - ], + "dependencies": [5], "details": "Execute automated and manual tests, focusing on areas affected by dependency management changes.", "status": "done" } @@ -3684,9 +3122,7 @@ "id": 2, "title": "Implement Mentor Profile Management", "description": "Develop the functionality for creating, editing, and managing mentor profiles in the system.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Build UI components for mentor profile creation and editing. Implement backend APIs for profile CRUD operations. Create expertise tagging system and availability calendar. Add profile verification and approval workflows for quality control.", "status": "pending" }, @@ -3694,9 +3130,7 @@ "id": 3, "title": "Develop Round-Table Discussion Framework", "description": "Create the core framework for hosting and managing round-table discussions between mentors and users.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Design the discussion room data model and state management. Implement discussion scheduling and participant management. Create discussion topic and agenda setting functionality. Develop discussion moderation tools and rules enforcement mechanisms.", "status": "pending" }, @@ -3704,9 +3138,7 @@ "id": 4, "title": "Implement LLM Integration for AI Mentors", "description": "Integrate LLM capabilities to simulate AI mentors that can participate in round-table discussions.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Select appropriate LLM models for mentor simulation. Develop prompt engineering templates for different mentor personas and expertise areas. Implement context management to maintain conversation coherence. Create fallback mechanisms for handling edge cases in discussions.", "status": "pending" }, @@ -3714,10 +3146,7 @@ "id": 5, "title": "Build Discussion Output Formatter", "description": "Create a system to format and present round-table discussion outputs in a structured, readable format.", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Design templates for discussion summaries and transcripts. Implement real-time formatting of ongoing discussions. Create exportable formats for discussion outcomes (PDF, markdown, etc.). Develop highlighting and annotation features for key insights.", "status": "pending" }, @@ -3725,10 +3154,7 @@ "id": 6, "title": "Integrate Mentor System with Task Management", "description": "Connect the mentor system with the existing task management functionality to enable task-specific mentoring.", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "Create APIs to link tasks with relevant mentors based on expertise. Implement functionality to initiate discussions around specific tasks. Develop mechanisms for mentors to provide feedback and guidance on tasks. Build notification system for task-related mentor interactions.", "status": "pending" }, @@ -3736,11 +3162,7 @@ "id": 7, "title": "Test and Optimize Round-Table Discussions", "description": "Conduct comprehensive testing of the round-table discussion feature and optimize for performance and user experience.", - "dependencies": [ - 4, - 5, - 6 - ], + "dependencies": [4, 5, 6], "details": "Perform load testing with multiple concurrent discussions. Test AI mentor responses for quality and relevance. Optimize LLM usage for cost efficiency. Conduct user testing sessions and gather feedback. Implement performance monitoring and analytics for ongoing optimization.", "status": "pending" } @@ -3769,9 +3191,7 @@ "id": 2, "title": "Implement CLI Command Parser for Model Management", "description": "Extend the CLI command parser to handle the new 'models' command and associated flags for model management.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "1. Update the CLI command parser to recognize the 'models' command\n2. Add support for '--set-main' and '--set-research' flags\n3. Implement validation for command arguments\n4. Create help text and usage examples for the models command\n5. Add error handling for invalid command usage\n6. Connect CLI parser to the configuration manager\n7. Implement command output formatting for model listings\n8. Testing approach: Create integration tests that verify CLI commands correctly interact with the configuration manager", "status": "done", "parentTaskId": 61 @@ -3780,9 +3200,7 @@ "id": 3, "title": "Integrate Vercel AI SDK and Create Client Factory", "description": "Set up Vercel AI SDK integration and implement a client factory pattern to create and manage AI model clients.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "1. Install Vercel AI SDK: `npm install @vercel/ai`\n2. Create an `ai-client-factory.js` module that implements the Factory pattern\n3. Define client creation functions for each supported model (Claude, OpenAI, Ollama, Gemini, OpenRouter, Perplexity, Grok)\n4. Implement error handling for missing API keys or configuration issues\n5. Add caching mechanism to reuse existing clients\n6. Create a unified interface for all clients regardless of the underlying model\n7. Implement client validation to ensure proper initialization\n8. Testing approach: Mock API responses to test client creation and error handling\n\n<info added on 2025-04-14T23:02:30.519Z>\nHere's additional information for the client factory implementation:\n\nFor the client factory implementation:\n\n1. Structure the factory with a modular approach:\n```javascript\n// ai-client-factory.js\nimport { createOpenAI } from '@ai-sdk/openai';\nimport { createAnthropic } from '@ai-sdk/anthropic';\nimport { createGoogle } from '@ai-sdk/google';\nimport { createPerplexity } from '@ai-sdk/perplexity';\n\nconst clientCache = new Map();\n\nexport function createClientInstance(providerName, options = {}) {\n // Implementation details below\n}\n```\n\n2. For OpenAI-compatible providers (Ollama), implement specific configuration:\n```javascript\ncase 'ollama':\n const ollamaBaseUrl = process.env.OLLAMA_BASE_URL || 'http://localhost:11434';\n return createOpenAI({\n baseURL: ollamaBaseUrl,\n apiKey: 'ollama', // Ollama doesn't require a real API key\n ...options\n });\n```\n\n3. Add provider-specific model mapping:\n```javascript\n// Model mapping helper\nconst getModelForProvider = (provider, requestedModel) => {\n const modelMappings = {\n openai: {\n default: 'gpt-3.5-turbo',\n // Add other mappings\n },\n anthropic: {\n default: 'claude-3-opus-20240229',\n // Add other mappings\n },\n // Add mappings for other providers\n };\n \n return (modelMappings[provider] && modelMappings[provider][requestedModel]) \n || modelMappings[provider]?.default \n || requestedModel;\n};\n```\n\n4. Implement caching with provider+model as key:\n```javascript\nexport function getClient(providerName, model) {\n const cacheKey = `${providerName}:${model || 'default'}`;\n \n if (clientCache.has(cacheKey)) {\n return clientCache.get(cacheKey);\n }\n \n const modelName = getModelForProvider(providerName, model);\n const client = createClientInstance(providerName, { model: modelName });\n clientCache.set(cacheKey, client);\n \n return client;\n}\n```\n\n5. Add detailed environment variable validation:\n```javascript\nfunction validateEnvironment(provider) {\n const requirements = {\n openai: ['OPENAI_API_KEY'],\n anthropic: ['ANTHROPIC_API_KEY'],\n google: ['GOOGLE_API_KEY'],\n perplexity: ['PERPLEXITY_API_KEY'],\n openrouter: ['OPENROUTER_API_KEY'],\n ollama: ['OLLAMA_BASE_URL'],\n xai: ['XAI_API_KEY']\n };\n \n const missing = requirements[provider]?.filter(env => !process.env[env]) || [];\n \n if (missing.length > 0) {\n throw new Error(`Missing environment variables for ${provider}: ${missing.join(', ')}`);\n }\n}\n```\n\n6. Add Jest test examples:\n```javascript\n// ai-client-factory.test.js\ndescribe('AI Client Factory', () => {\n beforeEach(() => {\n // Mock environment variables\n process.env.OPENAI_API_KEY = 'test-openai-key';\n process.env.ANTHROPIC_API_KEY = 'test-anthropic-key';\n // Add other mocks\n });\n \n test('creates OpenAI client with correct configuration', () => {\n const client = getClient('openai');\n expect(client).toBeDefined();\n // Add assertions for client configuration\n });\n \n test('throws error when environment variables are missing', () => {\n delete process.env.OPENAI_API_KEY;\n expect(() => getClient('openai')).toThrow(/Missing environment variables/);\n });\n \n // Add tests for other providers\n});\n```\n</info added on 2025-04-14T23:02:30.519Z>", "status": "done", "parentTaskId": 61 @@ -3791,9 +3209,7 @@ "id": 4, "title": "Develop Centralized AI Services Module", "description": "Create a centralized AI services module that abstracts all AI interactions through a unified interface, using the Decorator pattern for adding functionality like logging and retries.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "1. Create `ai-services.js` module to consolidate all AI model interactions\n2. Implement wrapper functions for text generation and streaming\n3. Add retry mechanisms for handling API rate limits and transient errors\n4. Implement logging for all AI interactions for observability\n5. Create model-specific adapters to normalize responses across different providers\n6. Add caching layer for frequently used responses to optimize performance\n7. Implement graceful fallback mechanisms when primary models fail\n8. Testing approach: Create unit tests with mocked responses to verify service behavior\n\n<info added on 2025-04-19T23:51:22.219Z>\nBased on the exploration findings, here's additional information for the AI services module refactoring:\n\nThe existing `ai-services.js` should be refactored to:\n\n1. Leverage the `ai-client-factory.js` for model instantiation while providing a higher-level service abstraction\n2. Implement a layered architecture:\n - Base service layer handling common functionality (retries, logging, caching)\n - Model-specific service implementations extending the base\n - Facade pattern to provide a unified API for all consumers\n\n3. Integration points:\n - Replace direct OpenAI client usage with factory-provided clients\n - Maintain backward compatibility with existing service consumers\n - Add service registration mechanism for new AI providers\n\n4. Performance considerations:\n - Implement request batching for high-volume operations\n - Add request priority queuing for critical vs non-critical operations\n - Implement circuit breaker pattern to prevent cascading failures\n\n5. Monitoring enhancements:\n - Add detailed telemetry for response times, token usage, and costs\n - Implement standardized error classification for better diagnostics\n\n6. Implementation sequence:\n - Start with abstract base service class\n - Refactor existing OpenAI implementations\n - Add adapter layer for new providers\n - Implement the unified facade\n</info added on 2025-04-19T23:51:22.219Z>", "status": "done", "parentTaskId": 61 @@ -3802,10 +3218,7 @@ "id": 5, "title": "Implement Environment Variable Management", "description": "Update environment variable handling to support multiple AI models and create documentation for configuration options.", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "details": "1. Update `.env.example` with all required API keys for supported models\n2. Implement environment variable validation on startup\n3. Create clear error messages for missing or invalid environment variables\n4. Add support for model-specific configuration options\n5. Document all environment variables and their purposes\n6. Implement a check to ensure required API keys are present for selected models\n7. Add support for optional configuration parameters for each model\n8. Testing approach: Create tests that verify environment variable validation logic", "status": "done", "parentTaskId": 61 @@ -3814,11 +3227,7 @@ "id": 6, "title": "Implement Model Listing Command", "description": "Implement the 'task-master models' command to display currently configured models and available options.", - "dependencies": [ - 1, - 2, - 4 - ], + "dependencies": [1, 2, 4], "details": "1. Create handler for the models command without flags\n2. Implement formatted output showing current model configuration\n3. Add color-coding for better readability using a library like chalk\n4. Include version information for each configured model\n5. Show API status indicators (connected/disconnected)\n6. Display usage examples for changing models\n7. Add support for verbose output with additional details\n8. Testing approach: Create integration tests that verify correct output formatting and content", "status": "done", "parentTaskId": 61 @@ -3827,12 +3236,7 @@ "id": 7, "title": "Implement Model Setting Commands", "description": "Implement the commands to set main and research models with proper validation and feedback.", - "dependencies": [ - 1, - 2, - 4, - 6 - ], + "dependencies": [1, 2, 4, 6], "details": "1. Create handlers for '--set-main' and '--set-research' flags\n2. Implement validation logic for model names\n3. Add clear error messages for invalid model selections\n4. Implement confirmation messages for successful model changes\n5. Add support for setting both models in a single command\n6. Implement dry-run option to validate without making changes\n7. Add verbose output option for debugging\n8. Testing approach: Create integration tests that verify model setting functionality with various inputs", "status": "done", "parentTaskId": 61 @@ -3841,11 +3245,7 @@ "id": 8, "title": "Update Main Task Processing Logic", "description": "Refactor the main task processing logic to use the new AI services module and support dynamic model selection.", - "dependencies": [ - 4, - 5, - "61.18" - ], + "dependencies": [4, 5, "61.18"], "details": "1. Update task processing functions to use the centralized AI services\n2. Implement dynamic model selection based on configuration\n3. Add error handling for model-specific failures\n4. Implement graceful degradation when preferred models are unavailable\n5. Update prompts to be model-agnostic where possible\n6. Add telemetry for model performance monitoring\n7. Implement response validation to ensure quality across different models\n8. Testing approach: Create integration tests that verify task processing with different model configurations\n\n<info added on 2025-04-20T03:55:56.310Z>\nWhen updating the main task processing logic, implement the following changes to align with the new configuration system:\n\n1. Replace direct environment variable access with calls to the configuration manager:\n ```javascript\n // Before\n const apiKey = process.env.OPENAI_API_KEY;\n const modelId = process.env.MAIN_MODEL || \"gpt-4\";\n \n // After\n import { getMainProvider, getMainModelId, getMainMaxTokens, getMainTemperature } from './config-manager.js';\n \n const provider = getMainProvider();\n const modelId = getMainModelId();\n const maxTokens = getMainMaxTokens();\n const temperature = getMainTemperature();\n ```\n\n2. Implement model fallback logic using the configuration hierarchy:\n ```javascript\n async function processTaskWithFallback(task) {\n try {\n return await processWithModel(task, getMainModelId());\n } catch (error) {\n logger.warn(`Primary model failed: ${error.message}`);\n const fallbackModel = getMainFallbackModelId();\n if (fallbackModel) {\n return await processWithModel(task, fallbackModel);\n }\n throw error;\n }\n }\n ```\n\n3. Add configuration-aware telemetry points to track model usage and performance:\n ```javascript\n function trackModelPerformance(modelId, startTime, success) {\n const duration = Date.now() - startTime;\n telemetry.trackEvent('model_usage', {\n modelId,\n provider: getMainProvider(),\n duration,\n success,\n configVersion: getConfigVersion()\n });\n }\n ```\n\n4. Ensure all prompt templates are loaded through the configuration system rather than hardcoded:\n ```javascript\n const promptTemplate = getPromptTemplate('task_processing');\n const prompt = formatPrompt(promptTemplate, { task: taskData });\n ```\n</info added on 2025-04-20T03:55:56.310Z>", "status": "done", "parentTaskId": 61 @@ -3854,12 +3254,7 @@ "id": 9, "title": "Update Research Processing Logic", "description": "Refactor the research processing logic to use the new AI services module and support dynamic model selection for research operations.", - "dependencies": [ - 4, - 5, - 8, - "61.18" - ], + "dependencies": [4, 5, 8, "61.18"], "details": "1. Update research functions to use the centralized AI services\n2. Implement dynamic model selection for research operations\n3. Add specialized error handling for research-specific issues\n4. Optimize prompts for research-focused models\n5. Implement result caching for research operations\n6. Add support for model-specific research parameters\n7. Create fallback mechanisms for research operations\n8. Testing approach: Create integration tests that verify research functionality with different model configurations\n\n<info added on 2025-04-20T03:55:39.633Z>\nWhen implementing the refactored research processing logic, ensure the following:\n\n1. Replace direct environment variable access with the new configuration system:\n ```javascript\n // Old approach\n const apiKey = process.env.OPENAI_API_KEY;\n const model = \"gpt-4\";\n \n // New approach\n import { getResearchProvider, getResearchModelId, getResearchMaxTokens, \n getResearchTemperature } from './config-manager.js';\n \n const provider = getResearchProvider();\n const modelId = getResearchModelId();\n const maxTokens = getResearchMaxTokens();\n const temperature = getResearchTemperature();\n ```\n\n2. Implement model fallback chains using the configuration system:\n ```javascript\n async function performResearch(query) {\n try {\n return await callAIService({\n provider: getResearchProvider(),\n modelId: getResearchModelId(),\n maxTokens: getResearchMaxTokens(),\n temperature: getResearchTemperature()\n });\n } catch (error) {\n logger.warn(`Primary research model failed: ${error.message}`);\n return await callAIService({\n provider: getResearchProvider('fallback'),\n modelId: getResearchModelId('fallback'),\n maxTokens: getResearchMaxTokens('fallback'),\n temperature: getResearchTemperature('fallback')\n });\n }\n }\n ```\n\n3. Add support for dynamic parameter adjustment based on research type:\n ```javascript\n function getResearchParameters(researchType) {\n // Get base parameters\n const baseParams = {\n provider: getResearchProvider(),\n modelId: getResearchModelId(),\n maxTokens: getResearchMaxTokens(),\n temperature: getResearchTemperature()\n };\n \n // Adjust based on research type\n switch(researchType) {\n case 'deep':\n return {...baseParams, maxTokens: baseParams.maxTokens * 1.5};\n case 'creative':\n return {...baseParams, temperature: Math.min(baseParams.temperature + 0.2, 1.0)};\n case 'factual':\n return {...baseParams, temperature: Math.max(baseParams.temperature - 0.2, 0)};\n default:\n return baseParams;\n }\n }\n ```\n\n4. Ensure the caching mechanism uses configuration-based TTL settings:\n ```javascript\n const researchCache = new Cache({\n ttl: getResearchCacheTTL(),\n maxSize: getResearchCacheMaxSize()\n });\n ```\n</info added on 2025-04-20T03:55:39.633Z>", "status": "done", "parentTaskId": 61 @@ -3868,12 +3263,7 @@ "id": 10, "title": "Create Comprehensive Documentation and Examples", "description": "Develop comprehensive documentation for the new model management features, including examples, troubleshooting guides, and best practices.", - "dependencies": [ - 6, - 7, - 8, - 9 - ], + "dependencies": [6, 7, 8, 9], "details": "1. Update README.md with new model management commands\n2. Create usage examples for all supported models\n3. Document environment variable requirements for each model\n4. Create troubleshooting guide for common issues\n5. Add performance considerations and best practices\n6. Document API key acquisition process for each supported service\n7. Create comparison chart of model capabilities and limitations\n8. Testing approach: Conduct user testing with the documentation to ensure clarity and completeness\n\n<info added on 2025-04-20T03:55:20.433Z>\n## Documentation Update for Configuration System Refactoring\n\n### Configuration System Architecture\n- Document the separation between environment variables and configuration file:\n - API keys: Sourced exclusively from environment variables (process.env or session.env)\n - All other settings: Centralized in `.taskmasterconfig` JSON file\n\n### `.taskmasterconfig` Structure\n```json\n{\n \"models\": {\n \"completion\": \"gpt-3.5-turbo\",\n \"chat\": \"gpt-4\",\n \"embedding\": \"text-embedding-ada-002\"\n },\n \"parameters\": {\n \"temperature\": 0.7,\n \"maxTokens\": 2000,\n \"topP\": 1\n },\n \"logging\": {\n \"enabled\": true,\n \"level\": \"info\"\n },\n \"defaults\": {\n \"outputFormat\": \"markdown\"\n }\n}\n```\n\n### Configuration Access Patterns\n- Document the getter functions in `config-manager.js`:\n - `getModelForRole(role)`: Returns configured model for a specific role\n - `getParameter(name)`: Retrieves model parameters\n - `getLoggingConfig()`: Access logging settings\n - Example usage: `const completionModel = getModelForRole('completion')`\n\n### Environment Variable Resolution\n- Explain the `resolveEnvVariable(key)` function:\n - Checks both process.env and session.env\n - Prioritizes session variables over process variables\n - Returns null if variable not found\n\n### Configuration Precedence\n- Document the order of precedence:\n 1. Command-line arguments (highest priority)\n 2. Session environment variables\n 3. Process environment variables\n 4. `.taskmasterconfig` settings\n 5. Hardcoded defaults (lowest priority)\n\n### Migration Guide\n- Steps for users to migrate from previous configuration approach\n- How to verify configuration is correctly loaded\n</info added on 2025-04-20T03:55:20.433Z>", "status": "done", "parentTaskId": 61 @@ -3884,9 +3274,7 @@ "description": "Update PRD processing logic (callClaude, processClaudeResponse, handleStreamingRequest in ai-services.js) to use the new `generateObjectService` from `ai-services-unified.js` with an appropriate Zod schema.", "details": "\n\n<info added on 2025-04-20T03:55:01.707Z>\nThe PRD parsing refactoring should align with the new configuration system architecture. When implementing this change:\n\n1. Replace direct environment variable access with `resolveEnvVariable` calls for API keys.\n\n2. Remove any hardcoded model names or parameters in the PRD processing functions. Instead, use the config-manager.js getters:\n - `getModelForRole('prd')` to determine the appropriate model\n - `getModelParameters('prd')` to retrieve temperature, maxTokens, etc.\n\n3. When constructing the generateObjectService call, ensure parameters are sourced from config:\n```javascript\nconst modelConfig = getModelParameters('prd');\nconst model = getModelForRole('prd');\n\nconst result = await generateObjectService({\n model,\n temperature: modelConfig.temperature,\n maxTokens: modelConfig.maxTokens,\n // other parameters as needed\n schema: prdSchema,\n // existing prompt/context parameters\n});\n```\n\n4. Update any logging to respect the logging configuration from config-manager (e.g., `isLoggingEnabled('ai')`)\n\n5. Ensure any default values previously hardcoded are now retrieved from the configuration system.\n</info added on 2025-04-20T03:55:01.707Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3895,9 +3283,7 @@ "description": "Update the `generateSubtasks` function in `ai-services.js` to use the new `generateObjectService` from `ai-services-unified.js` with a Zod schema for the subtask array.", "details": "\n\n<info added on 2025-04-20T03:54:45.542Z>\nThe refactoring should leverage the new configuration system:\n\n1. Replace direct model references with calls to config-manager.js getters:\n ```javascript\n const { getModelForRole, getModelParams } = require('./config-manager');\n \n // Instead of hardcoded models/parameters:\n const model = getModelForRole('subtask-generator');\n const modelParams = getModelParams('subtask-generator');\n ```\n\n2. Update API key handling to use the resolveEnvVariable pattern:\n ```javascript\n const { resolveEnvVariable } = require('./utils');\n const apiKey = resolveEnvVariable('OPENAI_API_KEY');\n ```\n\n3. When calling generateObjectService, pass the configuration parameters:\n ```javascript\n const result = await generateObjectService({\n schema: subtasksArraySchema,\n prompt: subtaskPrompt,\n model: model,\n temperature: modelParams.temperature,\n maxTokens: modelParams.maxTokens,\n // Other parameters from config\n });\n ```\n\n4. Add error handling that respects logging configuration:\n ```javascript\n const { isLoggingEnabled } = require('./config-manager');\n \n try {\n // Generation code\n } catch (error) {\n if (isLoggingEnabled('errors')) {\n console.error('Subtask generation error:', error);\n }\n throw error;\n }\n ```\n</info added on 2025-04-20T03:54:45.542Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3906,9 +3292,7 @@ "description": "Update the `generateSubtasksWithPerplexity` function in `ai-services.js` to first perform research (potentially keeping the Perplexity call separate or adapting it) and then use `generateObjectService` from `ai-services-unified.js` with research results included in the prompt.", "details": "\n\n<info added on 2025-04-20T03:54:26.882Z>\nThe refactoring should align with the new configuration system by:\n\n1. Replace direct environment variable access with `resolveEnvVariable` for API keys\n2. Use the config-manager.js getters to retrieve model parameters:\n - Replace hardcoded model names with `getModelForRole('research')`\n - Use `getParametersForRole('research')` to get temperature, maxTokens, etc.\n3. Implement proper error handling that respects the `getLoggingConfig()` settings\n4. Example implementation pattern:\n```javascript\nconst { getModelForRole, getParametersForRole, getLoggingConfig } = require('./config-manager');\nconst { resolveEnvVariable } = require('./environment-utils');\n\n// In the refactored function:\nconst researchModel = getModelForRole('research');\nconst { temperature, maxTokens } = getParametersForRole('research');\nconst apiKey = resolveEnvVariable('PERPLEXITY_API_KEY');\nconst { verbose } = getLoggingConfig();\n\n// Then use these variables in the API call configuration\n```\n5. Ensure the transition to generateObjectService maintains all existing functionality while leveraging the new configuration system\n</info added on 2025-04-20T03:54:26.882Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3917,9 +3301,7 @@ "description": "Update the `generateTaskDescriptionWithPerplexity` function in `ai-services.js` to first perform research and then use `generateObjectService` from `ai-services-unified.js` to generate the structured task description.", "details": "\n\n<info added on 2025-04-20T03:54:04.420Z>\nThe refactoring should incorporate the new configuration management system:\n\n1. Update imports to include the config-manager:\n```javascript\nconst { getModelForRole, getParametersForRole } = require('./config-manager');\n```\n\n2. Replace any hardcoded model selections or parameters with config-manager calls:\n```javascript\n// Replace direct model references like:\n// const model = \"perplexity-model-7b-online\" \n// With:\nconst model = getModelForRole('research');\nconst parameters = getParametersForRole('research');\n```\n\n3. For API key handling, use the resolveEnvVariable pattern:\n```javascript\nconst apiKey = resolveEnvVariable('PERPLEXITY_API_KEY');\n```\n\n4. When calling generateObjectService, pass the configuration-derived parameters:\n```javascript\nreturn generateObjectService({\n prompt: researchResults,\n schema: taskDescriptionSchema,\n role: 'taskDescription',\n // Config-driven parameters will be applied within generateObjectService\n});\n```\n\n5. Remove any hardcoded configuration values, ensuring all settings are retrieved from the centralized configuration system.\n</info added on 2025-04-20T03:54:04.420Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3928,9 +3310,7 @@ "description": "Update the logic that calls the AI after using `generateComplexityAnalysisPrompt` in `ai-services.js` to use the new `generateObjectService` from `ai-services-unified.js` with a Zod schema for the complexity report.", "details": "\n\n<info added on 2025-04-20T03:53:46.120Z>\nThe complexity analysis AI call should be updated to align with the new configuration system architecture. When refactoring to use `generateObjectService`, implement the following changes:\n\n1. Replace direct model references with calls to the appropriate config getter:\n ```javascript\n const modelName = getComplexityAnalysisModel(); // Use the specific getter from config-manager.js\n ```\n\n2. Retrieve AI parameters from the config system:\n ```javascript\n const temperature = getAITemperature('complexityAnalysis');\n const maxTokens = getAIMaxTokens('complexityAnalysis');\n ```\n\n3. When constructing the call to `generateObjectService`, pass these configuration values:\n ```javascript\n const result = await generateObjectService({\n prompt,\n schema: complexityReportSchema,\n modelName,\n temperature,\n maxTokens,\n sessionEnv: session?.env\n });\n ```\n\n4. Ensure API key resolution uses the `resolveEnvVariable` helper:\n ```javascript\n // Don't hardcode API keys or directly access process.env\n // The generateObjectService should handle this internally with resolveEnvVariable\n ```\n\n5. Add logging configuration based on settings:\n ```javascript\n const enableLogging = getAILoggingEnabled('complexityAnalysis');\n if (enableLogging) {\n // Use the logging mechanism defined in the configuration\n }\n ```\n</info added on 2025-04-20T03:53:46.120Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3939,9 +3319,7 @@ "description": "Update the logic that calls the AI after using `_buildAddTaskPrompt` in `ai-services.js` to use the new `generateObjectService` from `ai-services-unified.js` with a Zod schema for the single task object.", "details": "\n\n<info added on 2025-04-20T03:53:27.455Z>\nTo implement this refactoring, you'll need to:\n\n1. Replace direct AI calls with the new `generateObjectService` approach:\n ```javascript\n // OLD approach\n const aiResponse = await callLLM(prompt, modelName, temperature, maxTokens);\n const task = parseAIResponseToTask(aiResponse);\n \n // NEW approach using generateObjectService with config-manager\n import { generateObjectService } from '../services/ai-services-unified.js';\n import { getAIModelForRole, getAITemperature, getAIMaxTokens } from '../config/config-manager.js';\n import { taskSchema } from '../schemas/task-schema.js'; // Create this Zod schema for a single task\n \n const modelName = getAIModelForRole('taskCreation');\n const temperature = getAITemperature('taskCreation');\n const maxTokens = getAIMaxTokens('taskCreation');\n \n const task = await generateObjectService({\n prompt: _buildAddTaskPrompt(...),\n schema: taskSchema,\n modelName,\n temperature,\n maxTokens\n });\n ```\n\n2. Create a Zod schema for the task object in a new file `schemas/task-schema.js` that defines the expected structure.\n\n3. Ensure API key resolution uses the new pattern:\n ```javascript\n // This happens inside generateObjectService, but verify it uses:\n import { resolveEnvVariable } from '../config/config-manager.js';\n // Instead of direct process.env access\n ```\n\n4. Update any error handling to match the new service's error patterns.\n</info added on 2025-04-20T03:53:27.455Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3950,9 +3328,7 @@ "description": "Refactor functions like `sendChatWithContext` (and potentially related task update functions in `task-manager.js` if they make direct AI calls) to use `streamTextService` or `generateTextService` from `ai-services-unified.js`.", "details": "\n\n<info added on 2025-04-20T03:53:03.709Z>\nWhen refactoring `sendChatWithContext` and related functions, ensure they align with the new configuration system:\n\n1. Replace direct model references with config getter calls:\n ```javascript\n // Before\n const model = \"gpt-4\";\n \n // After\n import { getModelForRole } from './config-manager.js';\n const model = getModelForRole('chat'); // or appropriate role\n ```\n\n2. Extract AI parameters from config rather than hardcoding:\n ```javascript\n import { getAIParameters } from './config-manager.js';\n const { temperature, maxTokens } = getAIParameters('chat');\n ```\n\n3. When calling `streamTextService` or `generateTextService`, pass parameters from config:\n ```javascript\n await streamTextService({\n messages,\n model: getModelForRole('chat'),\n temperature: getAIParameters('chat').temperature,\n // other parameters as needed\n });\n ```\n\n4. For logging control, check config settings:\n ```javascript\n import { isLoggingEnabled } from './config-manager.js';\n \n if (isLoggingEnabled('aiCalls')) {\n console.log('AI request:', messages);\n }\n ```\n\n5. Ensure any default behaviors respect configuration defaults rather than hardcoded values.\n</info added on 2025-04-20T03:53:03.709Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -3970,9 +3346,7 @@ "description": "Refactor the AI call within `updateSubtaskById` in `task-manager.js` (which generates additional information based on a prompt) to use the appropriate unified service function (e.g., `generateTextService`) from `ai-services-unified.js`.", "details": "\n\n<info added on 2025-04-20T03:52:28.196Z>\nThe `updateSubtaskById` function currently makes direct AI calls with hardcoded parameters. When refactoring to use the unified service:\n\n1. Replace direct OpenAI calls with `generateTextService` from `ai-services-unified.js`\n2. Use configuration parameters from `config-manager.js`:\n - Replace hardcoded model with `getMainModel()`\n - Use `getMainMaxTokens()` for token limits\n - Apply `getMainTemperature()` for response randomness\n3. Ensure prompt construction remains consistent but passes these dynamic parameters\n4. Handle API key resolution through the unified service (which uses `resolveEnvVariable`)\n5. Update error handling to work with the unified service response format\n6. If the function uses any logging, ensure it respects `getLoggingEnabled()` setting\n\nExample refactoring pattern:\n```javascript\n// Before\nconst completion = await openai.chat.completions.create({\n model: \"gpt-4\",\n temperature: 0.7,\n max_tokens: 1000,\n messages: [/* prompt messages */]\n});\n\n// After\nconst completion = await generateTextService({\n model: getMainModel(),\n temperature: getMainTemperature(),\n max_tokens: getMainMaxTokens(),\n messages: [/* prompt messages */]\n});\n```\n</info added on 2025-04-20T03:52:28.196Z>\n\n<info added on 2025-04-22T06:05:42.437Z>\n- When testing the non-streaming `generateTextService` call within `updateSubtaskById`, ensure that the function awaits the full response before proceeding with subtask updates. This allows you to validate that the unified service returns the expected structure (e.g., `completion.choices.message.content`) and that error handling logic correctly interprets any error objects or status codes returned by the service.\n\n- Mock or stub the `generateTextService` in unit tests to simulate both successful and failed completions. For example, verify that when the service returns a valid completion, the subtask is updated with the generated content, and when an error is returned, the error handling path is triggered and logged appropriately.\n\n- Confirm that the non-streaming mode does not emit partial results or require event-based handling; the function should only process the final, complete response.\n\n- Example test assertion:\n ```javascript\n // Mocked response from generateTextService\n const mockCompletion = {\n choices: [{ message: { content: \"Generated subtask details.\" } }]\n };\n generateTextService.mockResolvedValue(mockCompletion);\n\n // Call updateSubtaskById and assert the subtask is updated\n await updateSubtaskById(...);\n expect(subtask.details).toBe(\"Generated subtask details.\");\n ```\n\n- If the unified service supports both streaming and non-streaming modes, explicitly set or verify the `stream` parameter is `false` (or omitted) to ensure non-streaming behavior during these tests.\n</info added on 2025-04-22T06:05:42.437Z>\n\n<info added on 2025-04-22T06:20:19.747Z>\nWhen testing the non-streaming `generateTextService` call in `updateSubtaskById`, implement these verification steps:\n\n1. Add unit tests that verify proper parameter transformation between the old and new implementation:\n ```javascript\n test('should correctly transform parameters when calling generateTextService', async () => {\n // Setup mocks for config values\n jest.spyOn(configManager, 'getMainModel').mockReturnValue('gpt-4');\n jest.spyOn(configManager, 'getMainTemperature').mockReturnValue(0.7);\n jest.spyOn(configManager, 'getMainMaxTokens').mockReturnValue(1000);\n \n const generateTextServiceSpy = jest.spyOn(aiServices, 'generateTextService')\n .mockResolvedValue({ choices: [{ message: { content: 'test content' } }] });\n \n await updateSubtaskById(/* params */);\n \n // Verify the service was called with correct transformed parameters\n expect(generateTextServiceSpy).toHaveBeenCalledWith({\n model: 'gpt-4',\n temperature: 0.7,\n max_tokens: 1000,\n messages: expect.any(Array)\n });\n });\n ```\n\n2. Implement response validation to ensure the subtask content is properly extracted:\n ```javascript\n // In updateSubtaskById function\n try {\n const completion = await generateTextService({\n // parameters\n });\n \n // Validate response structure before using\n if (!completion?.choices?.[0]?.message?.content) {\n throw new Error('Invalid response structure from AI service');\n }\n \n // Continue with updating subtask\n } catch (error) {\n // Enhanced error handling\n }\n ```\n\n3. Add integration tests that verify the end-to-end flow with actual configuration values.\n</info added on 2025-04-22T06:20:19.747Z>\n\n<info added on 2025-04-22T06:23:23.247Z>\n<info added on 2025-04-22T06:35:14.892Z>\nWhen testing the non-streaming `generateTextService` call in `updateSubtaskById`, implement these specific verification steps:\n\n1. Create a dedicated test fixture that isolates the AI service interaction:\n ```javascript\n describe('updateSubtaskById AI integration', () => {\n beforeEach(() => {\n // Reset all mocks and spies\n jest.clearAllMocks();\n // Setup environment with controlled config values\n process.env.OPENAI_API_KEY = 'test-key';\n });\n \n // Test cases follow...\n });\n ```\n\n2. Test error propagation from the unified service:\n ```javascript\n test('should properly handle AI service errors', async () => {\n const mockError = new Error('Service unavailable');\n mockError.status = 503;\n jest.spyOn(aiServices, 'generateTextService').mockRejectedValue(mockError);\n \n // Capture console errors if needed\n const consoleSpy = jest.spyOn(console, 'error').mockImplementation();\n \n // Execute with error expectation\n await expect(updateSubtaskById(1, { prompt: 'test' })).rejects.toThrow();\n \n // Verify error was logged with appropriate context\n expect(consoleSpy).toHaveBeenCalledWith(\n expect.stringContaining('AI service error'),\n expect.objectContaining({ status: 503 })\n );\n });\n ```\n\n3. Verify that the function correctly preserves existing subtask content when appending new AI-generated information:\n ```javascript\n test('should preserve existing content when appending AI-generated details', async () => {\n // Setup mock subtask with existing content\n const mockSubtask = {\n id: 1,\n details: 'Existing details.\\n\\n'\n };\n \n // Mock database retrieval\n getSubtaskById.mockResolvedValue(mockSubtask);\n \n // Mock AI response\n generateTextService.mockResolvedValue({\n choices: [{ message: { content: 'New AI content.' } }]\n });\n \n await updateSubtaskById(1, { prompt: 'Enhance this subtask' });\n \n // Verify the update preserves existing content\n expect(updateSubtaskInDb).toHaveBeenCalledWith(\n 1,\n expect.objectContaining({\n details: expect.stringContaining('Existing details.\\n\\n<info added on')\n })\n );\n \n // Verify the new content was added\n expect(updateSubtaskInDb).toHaveBeenCalledWith(\n 1,\n expect.objectContaining({\n details: expect.stringContaining('New AI content.')\n })\n );\n });\n ```\n\n4. Test that the function correctly formats the timestamp and wraps the AI-generated content:\n ```javascript\n test('should format timestamp and wrap content correctly', async () => {\n // Mock date for consistent testing\n const mockDate = new Date('2025-04-22T10:00:00Z');\n jest.spyOn(global, 'Date').mockImplementation(() => mockDate);\n \n // Setup and execute test\n // ...\n \n // Verify correct formatting\n expect(updateSubtaskInDb).toHaveBeenCalledWith(\n expect.any(Number),\n expect.objectContaining({\n details: expect.stringMatching(\n /<info added on 2025-04-22T10:00:00\\.000Z>\\n.*\\n<\\/info added on 2025-04-22T10:00:00\\.000Z>/s\n )\n })\n );\n });\n ```\n\n5. Verify that the function correctly handles the case when no existing details are present:\n ```javascript\n test('should handle subtasks with no existing details', async () => {\n // Setup mock subtask with no details\n const mockSubtask = { id: 1 };\n getSubtaskById.mockResolvedValue(mockSubtask);\n \n // Execute test\n // ...\n \n // Verify details were initialized properly\n expect(updateSubtaskInDb).toHaveBeenCalledWith(\n 1,\n expect.objectContaining({\n details: expect.stringMatching(/^<info added on/)\n })\n );\n });\n ```\n</info added on 2025-04-22T06:35:14.892Z>\n</info added on 2025-04-22T06:23:23.247Z>", "status": "done", - "dependencies": [ - "61.23" - ], + "dependencies": ["61.23"], "parentTaskId": 61 }, { @@ -4079,9 +3453,7 @@ "title": "Implement Integration Tests for Unified AI Service", "description": "Implement integration tests for `ai-services-unified.js`. These tests should verify the correct routing to different provider modules based on configuration and ensure the unified service functions (`generateTextService`, `generateObjectService`, etc.) work correctly when called from modules like `task-manager.js`. [Updated: 5/2/2025] [Updated: 5/2/2025] [Updated: 5/2/2025] [Updated: 5/2/2025]", "status": "done", - "dependencies": [ - "61.18" - ], + "dependencies": ["61.18"], "details": "\n\n<info added on 2025-04-20T03:51:23.368Z>\nFor the integration tests of the Unified AI Service, consider the following implementation details:\n\n1. Setup test fixtures:\n - Create a mock `.taskmasterconfig` file with different provider configurations\n - Define test cases with various model selections and parameter settings\n - Use environment variable mocks only for API keys (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`)\n\n2. Test configuration resolution:\n - Verify that `ai-services-unified.js` correctly retrieves settings from `config-manager.js`\n - Test that model selection follows the hierarchy defined in `.taskmasterconfig`\n - Ensure fallback mechanisms work when primary providers are unavailable\n\n3. Mock the provider modules:\n ```javascript\n jest.mock('../services/openai-service.js');\n jest.mock('../services/anthropic-service.js');\n ```\n\n4. Test specific scenarios:\n - Provider selection based on configured preferences\n - Parameter inheritance from config (temperature, maxTokens)\n - Error handling when API keys are missing\n - Proper routing when specific models are requested\n\n5. Verify integration with task-manager:\n ```javascript\n test('task-manager correctly uses unified AI service with config-based settings', async () => {\n // Setup mock config with specific settings\n mockConfigManager.getAIProviderPreference.mockReturnValue(['openai', 'anthropic']);\n mockConfigManager.getModelForRole.mockReturnValue('gpt-4');\n mockConfigManager.getParametersForModel.mockReturnValue({ temperature: 0.7, maxTokens: 2000 });\n \n // Verify task-manager uses these settings when calling the unified service\n // ...\n });\n ```\n\n6. Include tests for configuration changes at runtime and their effect on service behavior.\n</info added on 2025-04-20T03:51:23.368Z>\n\n<info added on 2025-05-02T18:41:13.374Z>\n]\n{\n \"id\": 31,\n \"title\": \"Implement Integration Test for Unified AI Service\",\n \"description\": \"Implement integration tests for `ai-services-unified.js`. These tests should verify the correct routing to different provider module based on configuration and ensure the unified service function (`generateTextService`, `generateObjectService`, etc.) work correctly when called from module like `task-manager.js`.\",\n \"details\": \"\\n\\n<info added on 2025-04-20T03:51:23.368Z>\\nFor the integration test of the Unified AI Service, consider the following implementation details:\\n\\n1. Setup test fixture:\\n - Create a mock `.taskmasterconfig` file with different provider configuration\\n - Define test case with various model selection and parameter setting\\n - Use environment variable mock only for API key (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`)\\n\\n2. Test configuration resolution:\\n - Verify that `ai-services-unified.js` correctly retrieve setting from `config-manager.js`\\n - Test that model selection follow the hierarchy defined in `.taskmasterconfig`\\n - Ensure fallback mechanism work when primary provider are unavailable\\n\\n3. Mock the provider module:\\n ```javascript\\n jest.mock('../service/openai-service.js');\\n jest.mock('../service/anthropic-service.js');\\n ```\\n\\n4. Test specific scenario:\\n - Provider selection based on configured preference\\n - Parameter inheritance from config (temperature, maxToken)\\n - Error handling when API key are missing\\n - Proper routing when specific model are requested\\n\\n5. Verify integration with task-manager:\\n ```javascript\\n test('task-manager correctly use unified AI service with config-based setting', async () => {\\n // Setup mock config with specific setting\\n mockConfigManager.getAIProviderPreference.mockReturnValue(['openai', 'anthropic']);\\n mockConfigManager.getModelForRole.mockReturnValue('gpt-4');\\n mockConfigManager.getParameterForModel.mockReturnValue({ temperature: 0.7, maxToken: 2000 });\\n \\n // Verify task-manager use these setting when calling the unified service\\n // ...\\n });\\n ```\\n\\n6. Include test for configuration change at runtime and their effect on service behavior.\\n</info added on 2025-04-20T03:51:23.368Z>\\n[2024-01-15 10:30:45] A custom e2e script was created to test all the CLI command but that we'll need one to test the MCP too and that task 76 are dedicated to that\",\n \"status\": \"pending\",\n \"dependency\": [\n \"61.18\"\n ],\n \"parentTaskId\": 61\n}\n</info added on 2025-05-02T18:41:13.374Z>\n[2023-11-24 20:05:45] It's my birthday today\n[2023-11-24 20:05:46] add more low level details\n[2023-11-24 20:06:45] Additional low-level details for integration tests:\n\n- Ensure that each test case logs detailed output for each step, including configuration retrieval, provider selection, and API call results.\n- Implement a utility function to reset mocks and configurations between tests to avoid state leakage.\n- Use a combination of spies and mocks to verify that internal methods are called with expected arguments, especially for critical functions like `generateTextService`.\n- Consider edge cases such as empty configurations, invalid API keys, and network failures to ensure robustness.\n- Document each test case with expected outcomes and any assumptions made during the test design.\n- Leverage parallel test execution where possible to reduce test suite runtime, ensuring that tests are independent and do not interfere with each other.\n<info added on 2025-05-02T20:42:14.388Z>\n<info added on 2025-04-20T03:51:23.368Z>\nFor the integration tests of the Unified AI Service, consider the following implementation details:\n\n1. Setup test fixtures:\n - Create a mock `.taskmasterconfig` file with different provider configurations\n - Define test cases with various model selections and parameter settings\n - Use environment variable mocks only for API keys (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`)\n\n2. Test configuration resolution:\n - Verify that `ai-services-unified.js` correctly retrieves settings from `config-manager.js`\n - Test that model selection follows the hierarchy defined in `.taskmasterconfig`\n - Ensure fallback mechanisms work when primary providers are unavailable\n\n3. Mock the provider modules:\n ```javascript\n jest.mock('../services/openai-service.js');\n jest.mock('../services/anthropic-service.js');\n ```\n\n4. Test specific scenarios:\n - Provider selection based on configured preferences\n - Parameter inheritance from config (temperature, maxTokens)\n - Error handling when API keys are missing\n - Proper routing when specific models are requested\n\n5. Verify integration with task-manager:\n ```javascript\n test('task-manager correctly uses unified AI service with config-based settings', async () => {\n // Setup mock config with specific settings\n mockConfigManager.getAIProviderPreference.mockReturnValue(['openai', 'anthropic']);\n mockConfigManager.getModelForRole.mockReturnValue('gpt-4');\n mockConfigManager.getParametersForModel.mockReturnValue({ temperature: 0.7, maxTokens: 2000 });\n \n // Verify task-manager uses these settings when calling the unified service\n // ...\n });\n ```\n\n6. Include tests for configuration changes at runtime and their effect on service behavior.\n</info added on 2025-04-20T03:51:23.368Z>\n\n<info added on 2025-05-02T18:41:13.374Z>\n]\n{\n \"id\": 31,\n \"title\": \"Implement Integration Test for Unified AI Service\",\n \"description\": \"Implement integration tests for `ai-services-unified.js`. These tests should verify the correct routing to different provider module based on configuration and ensure the unified service function (`generateTextService`, `generateObjectService`, etc.) work correctly when called from module like `task-manager.js`.\",\n \"details\": \"\\n\\n<info added on 2025-04-20T03:51:23.368Z>\\nFor the integration test of the Unified AI Service, consider the following implementation details:\\n\\n1. Setup test fixture:\\n - Create a mock `.taskmasterconfig` file with different provider configuration\\n - Define test case with various model selection and parameter setting\\n - Use environment variable mock only for API key (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`)\\n\\n2. Test configuration resolution:\\n - Verify that `ai-services-unified.js` correctly retrieve setting from `config-manager.js`\\n - Test that model selection follow the hierarchy defined in `.taskmasterconfig`\\n - Ensure fallback mechanism work when primary provider are unavailable\\n\\n3. Mock the provider module:\\n ```javascript\\n jest.mock('../service/openai-service.js');\\n jest.mock('../service/anthropic-service.js');\\n ```\\n\\n4. Test specific scenario:\\n - Provider selection based on configured preference\\n - Parameter inheritance from config (temperature, maxToken)\\n - Error handling when API key are missing\\n - Proper routing when specific model are requested\\n\\n5. Verify integration with task-manager:\\n ```javascript\\n test('task-manager correctly use unified AI service with config-based setting', async () => {\\n // Setup mock config with specific setting\\n mockConfigManager.getAIProviderPreference.mockReturnValue(['openai', 'anthropic']);\\n mockConfigManager.getModelForRole.mockReturnValue('gpt-4');\\n mockConfigManager.getParameterForModel.mockReturnValue({ temperature: 0.7, maxToken: 2000 });\\n \\n // Verify task-manager use these setting when calling the unified service\\n // ...\\n });\\n ```\\n\\n6. Include test for configuration change at runtime and their effect on service behavior.\\n</info added on 2025-04-20T03:51:23.368Z>\\n[2024-01-15 10:30:45] A custom e2e script was created to test all the CLI command but that we'll need one to test the MCP too and that task 76 are dedicated to that\",\n \"status\": \"pending\",\n \"dependency\": [\n \"61.18\"\n ],\n \"parentTaskId\": 61\n}\n</info added on 2025-05-02T18:41:13.374Z>\n[2023-11-24 20:05:45] It's my birthday today\n[2023-11-24 20:05:46] add more low level details\n[2023-11-24 20:06:45] Additional low-level details for integration tests:\n\n- Ensure that each test case logs detailed output for each step, including configuration retrieval, provider selection, and API call results.\n- Implement a utility function to reset mocks and configurations between tests to avoid state leakage.\n- Use a combination of spies and mocks to verify that internal methods are called with expected arguments, especially for critical functions like `generateTextService`.\n- Consider edge cases such as empty configurations, invalid API keys, and network failures to ensure robustness.\n- Document each test case with expected outcomes and any assumptions made during the test design.\n- Leverage parallel test execution where possible to reduce test suite runtime, ensuring that tests are independent and do not interfere with each other.\n\n<info added on 2023-11-24T20:10:00.000Z>\n- Implement detailed logging for each API call, capturing request and response data to facilitate debugging.\n- Create a comprehensive test matrix to cover all possible combinations of provider configurations and model selections.\n- Use snapshot testing to verify that the output of `generateTextService` and `generateObjectService` remains consistent across code changes.\n- Develop a set of utility functions to simulate network latency and failures, ensuring the service handles such scenarios gracefully.\n- Regularly review and update test cases to reflect changes in the configuration management or provider APIs.\n- Ensure that all test data is anonymized and does not contain sensitive information.\n</info added on 2023-11-24T20:10:00.000Z>\n</info added on 2025-05-02T20:42:14.388Z>" }, { @@ -4090,9 +3462,7 @@ "description": "Update relevant documentation files (e.g., `architecture.mdc`, `taskmaster.mdc`, environment variable guides, README) to accurately reflect the new AI service architecture using `ai-services-unified.js`, provider modules, the Vercel AI SDK, and the updated configuration approach.", "details": "\n\n<info added on 2025-04-20T03:51:04.461Z>\nThe new AI architecture introduces a clear separation between sensitive credentials and configuration settings:\n\n## Environment Variables vs Configuration File\n\n- **Environment Variables (.env)**: \n - Store only sensitive API keys and credentials\n - Accessed via `resolveEnvVariable()` which checks both process.env and session.env\n - Example: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_API_KEY`\n - No model names, parameters, or non-sensitive settings should be here\n\n- **.taskmasterconfig File**:\n - Central location for all non-sensitive configuration\n - Structured JSON with clear sections for different aspects of the system\n - Contains:\n - Model mappings by role (e.g., `systemModels`, `userModels`)\n - Default parameters (temperature, maxTokens, etc.)\n - Logging preferences\n - Provider-specific settings\n - Accessed via getter functions from `config-manager.js` like:\n ```javascript\n import { getModelForRole, getDefaultTemperature } from './config-manager.js';\n \n // Usage examples\n const model = getModelForRole('system');\n const temp = getDefaultTemperature();\n ```\n\n## Implementation Notes\n- Document the structure of `.taskmasterconfig` with examples\n- Explain the migration path for users with existing setups\n- Include a troubleshooting section for common configuration issues\n- Add a configuration validation section explaining how the system verifies settings\n</info added on 2025-04-20T03:51:04.461Z>", "status": "done", - "dependencies": [ - "61.31" - ], + "dependencies": ["61.31"], "parentTaskId": 61 }, { @@ -4101,10 +3471,7 @@ "description": "After all other migration subtasks (refactoring, provider implementation, testing, documentation) are complete and verified, remove the old `ai-services.js` and `ai-client-factory.js` files from the `scripts/modules/` directory. Ensure no code still references them.", "details": "\n\n<info added on 2025-04-22T06:51:02.444Z>\nI'll provide additional technical information to enhance the \"Cleanup Old AI Service Files\" subtask:\n\n## Implementation Details\n\n**Pre-Cleanup Verification Steps:**\n- Run a comprehensive codebase search for any remaining imports or references to `ai-services.js` and `ai-client-factory.js` using grep or your IDE's search functionality[1][4]\n- Check for any dynamic imports that might not be caught by static analysis tools\n- Verify that all dependent modules have been properly migrated to the new AI service architecture\n\n**Cleanup Process:**\n- Create a backup of the files before deletion in case rollback is needed\n- Document the file removal in the migration changelog with timestamps and specific file paths[5]\n- Update any build configuration files that might reference these files (webpack configs, etc.)\n- Run a full test suite after removal to ensure no runtime errors occur[2]\n\n**Post-Cleanup Validation:**\n- Implement automated tests to verify the application functions correctly without the removed files\n- Monitor application logs and error reporting systems for 48-72 hours after deployment to catch any missed dependencies[3]\n- Perform a final code review to ensure clean architecture principles are maintained in the new implementation\n\n**Technical Considerations:**\n- Check for any circular dependencies that might have been created during the migration process\n- Ensure proper garbage collection by removing any cached instances of the old services\n- Verify that performance metrics remain stable after the removal of legacy code\n</info added on 2025-04-22T06:51:02.444Z>", "status": "done", - "dependencies": [ - "61.31", - "61.32" - ], + "dependencies": ["61.31", "61.32"], "parentTaskId": 61 }, { @@ -4240,9 +3607,7 @@ "id": 2, "title": "Implement conditional logic to bypass AI processing", "description": "Modify the update logic to check for the --simple flag and conditionally skip the AI processing pipeline when the flag is present.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "In the update handlers for both commands, add a condition to check if the --simple flag is set. If it is, create a path that bypasses the normal AI processing flow. This will require modifying the update functions to accept the flag parameter and branch the execution flow accordingly.", "status": "pending", "testStrategy": "Test that when the --simple flag is provided, the AI processing functions are not called, and when the flag is not provided, the normal AI processing flow is maintained." @@ -4251,9 +3616,7 @@ "id": 3, "title": "Format user input with timestamp for simple updates", "description": "Implement functionality to format the user's direct text input with a timestamp in the same format as AI-processed updates when the --simple flag is used.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Create a utility function that takes the user's raw input text and prepends a timestamp in the same format used for AI-generated updates. This function should be called when the --simple flag is active. Ensure the timestamp format is consistent with the existing format used throughout the application.", "status": "pending", "testStrategy": "Verify that the timestamp format matches the AI-generated updates and that the user's text is preserved exactly as entered." @@ -4262,9 +3625,7 @@ "id": 4, "title": "Add visual indicator for manual updates", "description": "Make simple updates visually distinguishable from AI-processed updates by adding a 'manual update' indicator or other visual differentiation.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Modify the update formatting to include a visual indicator (such as '[Manual Update]' prefix or different styling) when displaying updates that were created using the --simple flag. This will help users distinguish between AI-processed and manually entered updates.", "status": "pending", "testStrategy": "Check that updates made with the --simple flag are visually distinct from AI-processed updates when displayed in the task or subtask history." @@ -4273,10 +3634,7 @@ "id": 5, "title": "Implement storage of simple updates in history", "description": "Ensure that updates made with the --simple flag are properly saved to the task or subtask's history in the same way as AI-processed updates.", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Modify the storage logic to save the formatted simple updates to the task or subtask history. The storage format should be consistent with AI-processed updates, but include the manual indicator. Ensure that the update is properly associated with the correct task or subtask.", "status": "pending", "testStrategy": "Test that updates made with the --simple flag are correctly saved to the history and persist between application restarts." @@ -4285,9 +3643,7 @@ "id": 6, "title": "Update help documentation for the new flag", "description": "Update the help documentation for both update-task and update-subtask commands to include information about the new --simple flag.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Add clear descriptions of the --simple flag to the help text for both commands. The documentation should explain that the flag allows users to add timestamped notes without AI processing, directly using the text from the prompt. Include examples of how to use the flag.", "status": "pending", "testStrategy": "Verify that the help command correctly displays information about the --simple flag for both update commands." @@ -4296,13 +3652,7 @@ "id": 7, "title": "Implement integration tests for the simple update feature", "description": "Create comprehensive integration tests to verify that the --simple flag works correctly in both commands and integrates properly with the rest of the system.", - "dependencies": [ - 1, - 2, - 3, - 4, - 5 - ], + "dependencies": [1, 2, 3, 4, 5], "details": "Develop integration tests that verify the entire flow of using the --simple flag with both update commands. Tests should confirm that updates are correctly formatted, stored, and displayed. Include edge cases such as empty input, very long input, and special characters.", "status": "pending", "testStrategy": "Run integration tests that simulate user input with and without the --simple flag and verify the correct behavior in each case." @@ -4311,15 +3661,7 @@ "id": 8, "title": "Perform final validation and documentation", "description": "Conduct final validation of the feature across all use cases and update the user documentation to include the new functionality.", - "dependencies": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], + "dependencies": [1, 2, 3, 4, 5, 6, 7], "details": "Perform end-to-end testing of the feature to ensure it works correctly in all scenarios. Update the user documentation with detailed information about the new --simple flag, including its purpose, how to use it, and examples. Ensure that the documentation clearly explains the difference between AI-processed updates and simple updates.", "status": "pending", "testStrategy": "Manually test all use cases and review documentation for completeness and clarity." @@ -4349,9 +3691,7 @@ "id": 2, "title": "Ensure Package Scripts Compatibility with pnpm", "description": "Review and update package.json scripts to ensure they work seamlessly with pnpm's execution model. Confirm that any scripts responsible for showing a website or prompt during install behave identically with pnpm and npm. Ensure compatibility with 'module' package type and correct binary definitions.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Test all scripts using `pnpm run <script>`, address any pnpm-specific path or execution differences, and modify scripts as needed for compatibility. Pay special attention to any scripts that trigger a website or prompt during installation, ensuring they serve the same content as npm. Validate that scripts/init.js and binaries are referenced correctly for ESM ('module') projects.", "status": "done", "testStrategy": "Run all package scripts using pnpm and confirm expected behavior matches npm, especially for any website or UI shown during install. Validate correct execution of scripts/init.js and binary linking." @@ -4360,9 +3700,7 @@ "id": 3, "title": "Generate and Validate pnpm Lockfile", "description": "Install dependencies using pnpm to create a pnpm-lock.yaml file and ensure it accurately reflects the project's dependency tree, considering the 'module' package type.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Run `pnpm install` to generate the lockfile, check it into version control, and verify that dependency resolution is correct and consistent. Ensure that all dependencies listed in package.json are resolved as expected for an ESM project.", "status": "done", "testStrategy": "Compare dependency trees between npm and pnpm; ensure no missing or extraneous dependencies. Validate that the lockfile works for both CLI and init.js flows." @@ -4371,9 +3709,7 @@ "id": 4, "title": "Test Taskmaster Installation and Operation with pnpm", "description": "Thoroughly test Taskmaster's installation and CLI operation when installed via pnpm, both globally and locally. Confirm that any website or UI shown during installation is identical to npm. Validate that binaries and the init process (scripts/init.js) work as expected.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Perform global (`pnpm add -g taskmaster`) and local installations, verify CLI commands, and check for any pnpm-specific issues or incompatibilities. Ensure any installation UIs or websites appear identical to npm installations, including any website or prompt shown during install. Test that binaries 'task-master' and 'task-master-mcp' are linked and that scripts/init.js creates the correct structure and templates.", "status": "done", "testStrategy": "Document and resolve any errors encountered during installation or usage with pnpm. Compare the installation experience side-by-side with npm, including any website or UI shown during install. Validate directory and template setup as per scripts/init.js." @@ -4382,9 +3718,7 @@ "id": 5, "title": "Integrate pnpm into CI/CD Pipeline", "description": "Update CI/CD workflows to include pnpm in the test matrix, ensuring all tests pass when dependencies are installed with pnpm. Confirm that tests cover the 'module' package type, binaries, and init process.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Modify GitHub Actions or other CI configurations to use pnpm/action-setup, run tests with pnpm, and cache pnpm dependencies for efficiency. Ensure that CI covers CLI commands, binary linking, and the directory/template setup performed by scripts/init.js.", "status": "done", "testStrategy": "Confirm that CI passes for all supported package managers, including pnpm, and that pnpm-specific jobs are green. Validate that tests cover ESM usage, binaries, and init.js flows." @@ -4393,9 +3727,7 @@ "id": 6, "title": "Verify Installation UI/Website Consistency", "description": "Ensure any installation UIs, websites, or interactive prompts—including any website or prompt shown during install—appear and function identically when installing with pnpm compared to npm. Confirm that the experience is consistent for the 'module' package type and the init process.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Identify all user-facing elements during the installation process, including any website or prompt shown during install, and verify they are consistent across package managers. If a website is shown during installation, ensure it appears the same regardless of package manager used. Validate that any prompts or UIs triggered by scripts/init.js are identical.", "status": "done", "testStrategy": "Perform side-by-side installations with npm and pnpm, capturing screenshots of any UIs or websites for comparison. Test all interactive elements to ensure identical behavior, including any website or prompt shown during install and those from scripts/init.js." @@ -4404,9 +3736,7 @@ "id": 7, "title": "Test init.js Script with pnpm", "description": "Verify that the scripts/init.js file works correctly when Taskmaster is installed via pnpm, creating the proper directory structure and copying all required templates as defined in the project structure.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Test the init command to ensure it properly creates .cursor/rules, scripts, and tasks directories, copies templates (.env.example, .gitignore, rule files, dev.js), handles package.json merging, and sets up MCP config (.cursor/mcp.json) as per scripts/init.js.", "status": "done", "testStrategy": "Run the init command after installing with pnpm and verify all directories and files are created correctly. Compare the results with an npm installation to ensure identical behavior and structure." @@ -4415,9 +3745,7 @@ "id": 8, "title": "Verify Binary Links with pnpm", "description": "Ensure that the task-master and task-master-mcp binaries are properly defined in package.json, linked, and executable when installed via pnpm, in both global and local installations.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Check that the binaries defined in package.json are correctly linked in node_modules/.bin when installed with pnpm, and that they can be executed without errors. Validate that binaries work for ESM ('module') projects and are accessible after both global and local installs.", "status": "done", "testStrategy": "Install Taskmaster with pnpm and verify that the binaries are accessible and executable. Test both global and local installations, ensuring correct behavior for ESM projects." @@ -4447,9 +3775,7 @@ "id": 2, "title": "Add Yarn-Specific Configuration Files", "description": "Introduce Yarn-specific configuration files such as .yarnrc.yml if needed to optimize Yarn behavior and ensure consistent installs for 'module' package type and binary definitions.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Determine if Yarn v2+ (Berry) or classic requires additional configuration for the project, and add or update .yarnrc.yml or .yarnrc files accordingly. Ensure configuration supports ESM and binary linking.", "status": "done", "testStrategy": "Verify that Yarn respects the configuration by running installs and checking for expected behaviors (e.g., plug'n'play, nodeLinker settings, ESM support, binary linking)." @@ -4458,9 +3784,7 @@ "id": 3, "title": "Test and Fix Yarn Compatibility for Scripts and CLI", "description": "Ensure all scripts, post-install hooks, and CLI commands function correctly when Taskmaster is installed and managed via Yarn. Confirm that any website or UI shown during installation is identical to npm. Validate that binaries and the init process (scripts/init.js) work as expected.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Test all lifecycle scripts, post-install actions, and CLI commands using Yarn. Address any issues related to environment variables, script execution, or dependency hoisting. Ensure any website or prompt shown during install is the same as with npm. Validate that binaries 'task-master' and 'task-master-mcp' are linked and that scripts/init.js creates the correct structure and templates.", "status": "done", "testStrategy": "Install Taskmaster using Yarn and run all documented scripts and CLI commands, comparing results to npm installations, especially for any website or UI shown during install. Validate directory and template setup as per scripts/init.js." @@ -4469,9 +3793,7 @@ "id": 4, "title": "Update Documentation for Yarn Installation and Usage", "description": "Revise installation and usage documentation to include clear instructions for installing and managing Taskmaster with Yarn. Clearly state that the installation process, including any website or UI shown, is identical to npm. Ensure documentation reflects the use of 'module' package type, binaries, and the init process as defined in scripts/init.js. If the installation process includes a website component or requires account setup, document the steps users must follow. If not, explicitly state that no website or account setup is required.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Add Yarn-specific installation commands, troubleshooting tips, and notes on version compatibility to the README and any relevant docs. Document that any installation website or prompt is the same as with npm. Include notes on the 'module' package type, binaries, and the directory/template setup performed by scripts/init.js. If website or account setup is required during installation, provide clear instructions; otherwise, confirm and document that no such steps are needed.", "status": "done", "testStrategy": "Review documentation for accuracy and clarity; have a user follow the Yarn instructions to verify successful installation and usage. Confirm that documentation explicitly states the identical experience for npm and Yarn, including any website or UI shown during install, and describes the init process and binaries. If website/account setup is required, verify that instructions are complete and accurate; if not, confirm this is documented." @@ -4480,9 +3802,7 @@ "id": 5, "title": "Implement and Test Package Manager Detection Logic", "description": "Update or add logic in the codebase to detect Yarn installations and handle Yarn-specific behaviors, ensuring feature parity across package managers. Ensure detection logic works for 'module' package type and binary definitions.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Modify detection logic to recognize Yarn (classic and berry), handle lockfile generation, and resolve any Yarn-specific package resolution or hoisting issues. Ensure detection logic supports ESM and binary linking.", "status": "done", "testStrategy": "Install Taskmaster using npm, pnpm, and Yarn (classic and berry), verifying that the application detects the package manager correctly and behaves consistently for ESM projects and binaries." @@ -4491,9 +3811,7 @@ "id": 6, "title": "Verify Installation UI/Website Consistency", "description": "Ensure any installation UIs, websites, or interactive prompts—including any website or prompt shown during install—appear and function identically when installing with Yarn compared to npm. Confirm that the experience is consistent for the 'module' package type and the init process. If the installation process includes a website or account setup, verify that all required website actions (e.g., account creation, login) are consistent and documented. If not, confirm and document that no website or account setup is needed.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Identify all user-facing elements during the installation process, including any website or prompt shown during install, and verify they are consistent across package managers. If a website is shown during installation or account setup is required, ensure it appears and functions the same regardless of package manager used, and document the steps. If not, confirm and document that no website or account setup is needed. Validate that any prompts or UIs triggered by scripts/init.js are identical.", "status": "done", "testStrategy": "Perform side-by-side installations with npm and Yarn, capturing screenshots of any UIs or websites for comparison. Test all interactive elements to ensure identical behavior, including any website or prompt shown during install and those from scripts/init.js. If website/account setup is required, verify and document the steps; if not, confirm this is documented." @@ -4502,9 +3820,7 @@ "id": 7, "title": "Test init.js Script with Yarn", "description": "Verify that the scripts/init.js file works correctly when Taskmaster is installed via Yarn, creating the proper directory structure and copying all required templates as defined in the project structure.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Test the init command to ensure it properly creates .cursor/rules, scripts, and tasks directories, copies templates (.env.example, .gitignore, rule files, dev.js), handles package.json merging, and sets up MCP config (.cursor/mcp.json) as per scripts/init.js.", "status": "done", "testStrategy": "Run the init command after installing with Yarn and verify all directories and files are created correctly. Compare the results with an npm installation to ensure identical behavior and structure." @@ -4513,9 +3829,7 @@ "id": 8, "title": "Verify Binary Links with Yarn", "description": "Ensure that the task-master and task-master-mcp binaries are properly defined in package.json, linked, and executable when installed via Yarn, in both global and local installations.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Check that the binaries defined in package.json are correctly linked in node_modules/.bin when installed with Yarn, and that they can be executed without errors. Validate that binaries work for ESM ('module') projects and are accessible after both global and local installs.", "status": "done", "testStrategy": "Install Taskmaster with Yarn and verify that the binaries are accessible and executable. Test both global and local installations, ensuring correct behavior for ESM projects." @@ -4524,9 +3838,7 @@ "id": 9, "title": "Test Website Account Setup with Yarn", "description": "If the installation process includes a website component, verify that account setup, registration, or any other user-specific configurations work correctly when Taskmaster is installed via Yarn. If no website or account setup is required, confirm and document this explicitly.", - "dependencies": [ - 6 - ], + "dependencies": [6], "details": "Test the complete user flow for any website component that appears during installation, including account creation, login, and configuration steps. Ensure that all website interactions work identically with Yarn as they do with npm or pnpm. Document any website-specific steps that users need to complete during the installation process. If no website or account setup is required, confirm and document this.\n\n<info added on 2025-04-25T08:45:48.709Z>\nSince the request is vague, I'll provide helpful implementation details for testing website account setup with Yarn:\n\nFor thorough testing, create a test matrix covering different browsers (Chrome, Firefox, Safari) and operating systems (Windows, macOS, Linux). Document specific Yarn-related environment variables that might affect website connectivity. Use tools like Playwright or Cypress to automate the account setup flow testing, capturing screenshots at each step for documentation. Implement network throttling tests to verify behavior under poor connectivity. Create a checklist of all UI elements that should be verified during the account setup process, including form validation, error messages, and success states. If no website component exists, explicitly document this in the project README and installation guides to prevent user confusion.\n</info added on 2025-04-25T08:45:48.709Z>\n\n<info added on 2025-04-25T08:46:08.651Z>\n- For environments where the website component requires integration with external authentication providers (such as OAuth, SSO, or LDAP), ensure that these flows are tested specifically when Taskmaster is installed via Yarn. Validate that redirect URIs, token exchanges, and session persistence behave as expected across all supported browsers.\n\n- If the website setup involves configuring application pools or web server settings (e.g., with IIS), document any Yarn-specific considerations, such as environment variable propagation or file permission differences, that could affect the web service's availability or configuration[2].\n\n- When automating tests, include validation for accessibility compliance (e.g., using axe-core or Lighthouse) during the account setup process to ensure the UI is usable for all users.\n\n- Capture and log all HTTP requests and responses during the account setup flow to help diagnose any discrepancies between Yarn and other package managers. This can be achieved by enabling network logging in Playwright or Cypress test runs.\n\n- If the website component supports batch operations or automated uploads (such as uploading user data or configuration files), verify that these automation features function identically after installation with Yarn[3].\n\n- For documentation, provide annotated screenshots or screen recordings of the account setup process, highlighting any Yarn-specific prompts, warnings, or differences encountered.\n\n- If the website component is not required, add a badge or prominent note in the README and installation guides stating \"No website or account setup required,\" and reference the test results confirming this.\n</info added on 2025-04-25T08:46:08.651Z>\n\n<info added on 2025-04-25T17:04:12.550Z>\nFor clarity, this task does not involve setting up a Yarn account. Yarn itself is just a package manager that doesn't require any account creation. The task is about testing whether any website component that is part of Taskmaster (if one exists) works correctly when Taskmaster is installed using Yarn as the package manager.\n\nTo be specific:\n- You don't need to create a Yarn account\n- Yarn is simply the tool used to install Taskmaster (`yarn add taskmaster` instead of `npm install taskmaster`)\n- The testing focuses on whether any web interfaces or account setup processes that are part of Taskmaster itself function correctly when the installation was done via Yarn\n- If Taskmaster includes a web dashboard or requires users to create accounts within the Taskmaster system, those features should be tested\n\nIf you're uncertain whether Taskmaster includes a website component at all, the first step would be to check the project documentation or perform an initial installation to determine if any web interface exists.\n</info added on 2025-04-25T17:04:12.550Z>\n\n<info added on 2025-04-25T17:19:03.256Z>\nWhen testing website account setup with Yarn after the codebase refactor, pay special attention to:\n\n- Verify that any environment-specific configuration files (like `.env` or config JSON files) are properly loaded when the application is installed via Yarn\n- Test the session management implementation to ensure user sessions persist correctly across page refreshes and browser restarts\n- Check that any database migrations or schema updates required for account setup execute properly when installed via Yarn\n- Validate that client-side form validation logic works consistently with server-side validation\n- Ensure that any WebSocket connections for real-time features initialize correctly after the refactor\n- Test account deletion and data export functionality to verify GDPR compliance remains intact\n- Document any changes to the authentication flow that resulted from the refactor and confirm they work identically with Yarn installation\n</info added on 2025-04-25T17:19:03.256Z>\n\n<info added on 2025-04-25T17:22:05.951Z>\nWhen testing website account setup with Yarn after the logging fix, implement these additional verification steps:\n\n1. Verify that all account-related actions are properly logged with the correct log levels (debug, info, warn, error) according to the updated logging framework\n2. Test the error handling paths specifically - force authentication failures and verify the logs contain sufficient diagnostic information\n3. Check that sensitive user information is properly redacted in logs according to privacy requirements\n4. Confirm that log rotation and persistence work correctly when high volumes of authentication attempts occur\n5. Validate that any custom logging middleware correctly captures HTTP request/response data for account operations\n6. Test that log aggregation tools (if used) can properly parse and display the account setup logs in their expected format\n7. Verify that performance metrics for account setup flows are correctly captured in logs for monitoring purposes\n8. Document any Yarn-specific environment variables that affect the logging configuration for the website component\n</info added on 2025-04-25T17:22:05.951Z>\n\n<info added on 2025-04-25T17:22:46.293Z>\nWhen testing website account setup with Yarn, consider implementing a positive user experience validation:\n\n1. Measure and document time-to-completion for the account setup process to ensure it meets usability standards\n2. Create a satisfaction survey for test users to rate the account setup experience on a 1-5 scale\n3. Implement A/B testing for different account setup flows to identify the most user-friendly approach\n4. Add delightful micro-interactions or success animations that make the setup process feel rewarding\n5. Test the \"welcome\" or \"onboarding\" experience that follows successful account creation\n6. Ensure helpful tooltips and contextual help are displayed at appropriate moments during setup\n7. Verify that error messages are friendly, clear, and provide actionable guidance rather than technical jargon\n8. Test the account recovery flow to ensure users have a smooth experience if they forget credentials\n</info added on 2025-04-25T17:22:46.293Z>", "status": "done", "testStrategy": "Perform a complete installation with Yarn and follow through any website account setup process. Compare the experience with npm installation to ensure identical behavior. Test edge cases such as account creation failures, login issues, and configuration changes. If no website or account setup is required, confirm and document this in the test results." @@ -4555,9 +3867,7 @@ "id": 2, "title": "Update installation scripts for Bun compatibility", "description": "Modify the existing installation scripts to detect and support Bun as a runtime environment.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Add Bun detection logic to installation scripts. Update package management commands to use Bun equivalents where needed. Ensure all dependencies are compatible with Bun. Modify any Node.js-specific code to work with Bun's runtime.", "status": "done" }, @@ -4565,9 +3875,7 @@ "id": 3, "title": "Create Bun-specific installation path", "description": "Implement a dedicated installation flow for Bun users that optimizes for Bun's capabilities.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Create a Bun-specific installation script that leverages Bun's performance advantages. Update any environment detection logic to properly identify Bun environments. Ensure proper path resolution and environment variable handling for Bun.", "status": "done" }, @@ -4575,9 +3883,7 @@ "id": 4, "title": "Test Taskmaster installation with Bun", "description": "Perform comprehensive testing of the installation process using Bun across different operating systems.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Test installation on Windows, macOS, and Linux using Bun. Verify that all Taskmaster features work correctly when installed via Bun. Document any issues encountered and implement fixes as needed.", "status": "done" }, @@ -4585,9 +3891,7 @@ "id": 5, "title": "Test Taskmaster operation with Bun", "description": "Ensure all Taskmaster functionality works correctly when running under Bun.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Test all Taskmaster commands and features when running with Bun. Compare performance metrics between Node.js and Bun. Identify and fix any runtime issues specific to Bun. Ensure all plugins and extensions are compatible.", "status": "done" }, @@ -4595,10 +3899,7 @@ "id": 6, "title": "Update documentation for Bun support", "description": "Update all relevant documentation to include information about installing and running Taskmaster with Bun.", - "dependencies": [ - 4, - 5 - ], + "dependencies": [4, 5], "details": "Add Bun installation instructions to README and documentation. Document any Bun-specific considerations or limitations. Update troubleshooting guides to include Bun-specific issues. Create examples showing Bun usage with Taskmaster.", "status": "done" } @@ -4638,9 +3939,7 @@ "id": 2, "title": "Extend JSON Output to All Relevant Commands and Ensure Schema Consistency", "description": "Apply the JSON output pattern established in subtask 1 to all other relevant Taskmaster CLI commands that display data (e.g., `list`, `status`, etc.). Ensure the JSON structure is consistent where applicable (e.g., task objects should have the same fields). Add help text mentioning the `--json` flag for each modified command.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "1. Create a JSON schema definition file at `src/schemas/task.json` to define the standard structure for task objects\n2. Modify the following command files to support the `--json` flag:\n - `src/commands/list.js`\n - `src/commands/status.js`\n - `src/commands/search.js`\n - `src/commands/summary.js`\n3. Refactor the `formatAsJson` utility to handle different data types (single task, task array, status object, etc.)\n4. Add a `validateJsonSchema` function in `src/utils/validation.js` to ensure output conforms to defined schemas\n5. Update each command's help text documentation to include the `--json` flag description\n6. Implement consistent error handling for JSON output (using a standard error object format)\n7. For list-type commands, ensure array outputs are properly formatted as JSON arrays", "status": "pending", "testStrategy": "1. Create unit tests for each modified command in their respective test files\n2. Test each command with the `--json` flag and validate output against the defined schemas\n3. Create specific test cases for edge conditions (empty lists, error states, etc.)\n4. Verify help text includes `--json` documentation for each command\n5. Test piping JSON output to tools like `jq` to confirm proper formatting\n6. Create integration tests that verify schema consistency across different commands" @@ -4658,9 +3957,7 @@ "id": 4, "title": "Implement Keybinding File Handling and Backup Logic", "description": "Implement the core logic within the `install-keybindings` command to read the target `keybindings.json` file. If it exists, create a backup. If it doesn't exist, create a new file with an empty JSON array `[]`. Prepare the structure to add new keybindings.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "1. Create a `KeybindingsManager` class in `src/utils/keybindings.js` with the following methods:\n - `checkFileExists(path)`: Verify if the keybindings file exists\n - `createBackup(path)`: Copy existing file to `keybindings.json.bak`\n - `readKeybindings(path)`: Read and parse the JSON file\n - `writeKeybindings(path, data)`: Serialize and write data to the file\n - `createEmptyFile(path)`: Create a new file with `[]` content\n2. In the command handler, use these methods to:\n - Check if the target file exists\n - Create a backup if it does (with timestamp in filename)\n - Read existing keybindings or create an empty file\n - Parse the JSON content with proper error handling\n3. Add a `--no-backup` flag to skip backup creation\n4. Implement verbose logging with a `--verbose` flag\n5. Handle all potential file system errors (permissions, disk space, etc.)\n6. Add a `--dry-run` option that shows what would be done without making changes", "status": "pending", "testStrategy": "1. Create unit tests for the `KeybindingsManager` class\n2. Test all file handling scenarios with mocked file system:\n - File exists with valid JSON\n - File exists with invalid JSON\n - File doesn't exist\n - File exists but is not writable\n - Backup creation succeeds/fails\n3. Test the `--no-backup` and `--dry-run` flags\n4. Verify error messages are clear and actionable\n5. Test with various mock file contents to ensure proper parsing" @@ -4669,9 +3966,7 @@ "id": 5, "title": "Add Taskmaster Keybindings, Prevent Duplicates, and Support Customization", "description": "Define the specific Taskmaster keybindings (e.g., next task to clipboard, status update, open agent chat) and implement the logic to merge them into the user's `keybindings.json` data. Prevent adding duplicate keybindings (based on command ID or key combination). Add support for custom key combinations via command flags.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "1. Define default Taskmaster keybindings in `src/config/default-keybindings.js` as an array of objects with:\n - `key`: Default key combination (e.g., `\"ctrl+alt+n\"`)\n - `command`: Cursor command ID (e.g., `\"taskmaster.nextTask\"`)\n - `when`: Context when keybinding is active (e.g., `\"editorTextFocus\"`)\n - `args`: Any command arguments as an object\n - `description`: Human-readable description of what the keybinding does\n2. Implement the following keybindings:\n - Next task to clipboard: `ctrl+alt+n`\n - Update task status: `ctrl+alt+u`\n - Open agent chat with task context: `ctrl+alt+a`\n - Show task details: `ctrl+alt+d`\n3. Add command-line options to customize each keybinding:\n - `--next-key=\"ctrl+alt+n\"`\n - `--update-key=\"ctrl+alt+u\"`\n - `--agent-key=\"ctrl+alt+a\"`\n - `--details-key=\"ctrl+alt+d\"`\n4. Implement a `mergeKeybindings(existing, new)` function that:\n - Checks for duplicates based on command ID\n - Checks for key combination conflicts\n - Warns about conflicts but allows override with `--force` flag\n - Preserves existing non-Taskmaster keybindings\n5. Add a `--reset` flag to remove all existing Taskmaster keybindings before adding new ones\n6. Add a `--list` option to display currently installed Taskmaster keybindings\n7. Implement an `--uninstall` option to remove all Taskmaster keybindings", "status": "pending", "testStrategy": "1. Create unit tests for the keybinding merging logic\n2. Test duplicate detection and conflict resolution\n3. Test each customization flag to verify it properly overrides defaults\n4. Test the `--reset`, `--list`, and `--uninstall` options\n5. Create integration tests with various starting keybindings.json states\n6. Manually verify the installed keybindings work in Cursor\n7. Test edge cases like:\n - All keybindings customized\n - Conflicting key combinations with `--force` and without\n - Empty initial keybindings file\n - File with existing Taskmaster keybindings" @@ -4700,9 +3995,7 @@ "id": 2, "title": "Implement task saving functionality", "description": "Develop the backend functionality to save manually created tasks to the database", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create API endpoints to handle task creation requests from the frontend. Implement data validation, error handling, and confirmation messages. Ensure the saved tasks appear in the task list view and can be edited or deleted like PRD-parsed tasks.", "status": "done" } @@ -4730,9 +4023,7 @@ "id": 2, "title": "Update CLI interface for task-specific complexity analysis", "description": "Extend the CLI to accept task IDs or ranges as parameters for the complexity analysis command", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Add new flags `--id/-i`, `--from/-f`, and `--to/-t` to the CLI that allow users to specify task IDs or ranges for targeted complexity analysis. Update the command parser, help documentation, and ensure proper validation of the provided values.", "status": "done" }, @@ -4740,9 +4031,7 @@ "id": 3, "title": "Integrate task-specific analysis with MCP tool", "description": "Update the MCP tool interface to support analyzing complexity for specific tasks or ranges", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Modify the MCP tool's API endpoints and UI components to allow users to select specific tasks or ranges for complexity analysis. Ensure the UI provides clear feedback about which tasks are being analyzed and update the visualization components to properly display partial analysis results.", "status": "done" }, @@ -4750,11 +4039,7 @@ "id": 4, "title": "Create comprehensive tests for task-specific complexity analysis", "description": "Develop test cases to verify the correct functioning of task-specific complexity analysis", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "details": "Create unit and integration tests that verify the task-specific complexity analysis works correctly across both CLI and MCP interfaces. Include tests for edge cases such as invalid task IDs, tasks with dependencies outside the selected set, and performance tests for large task sets.", "status": "done" } @@ -4782,9 +4067,7 @@ "id": 2, "title": "Implement Mermaid diagram generation core functionality", "description": "Create the core logic to parse Mermaid syntax and generate diagram output", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Integrate with the Mermaid library to parse diagram syntax. Implement error handling for invalid syntax. Create the rendering pipeline to generate the diagram in memory before output. Support all standard Mermaid diagram types (flowchart, sequence, class, etc.). Include proper logging for the generation process.", "status": "pending" }, @@ -4792,9 +4075,7 @@ "id": 3, "title": "Develop output handling mechanisms", "description": "Implement different output options for the generated diagrams", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Create handlers for different output formats (SVG, PNG, PDF). Implement file output with appropriate naming conventions and directory handling. Add clipboard support for direct pasting. Implement stdout output for piping to other commands. Include progress indicators for longer rendering operations.", "status": "pending" }, @@ -4802,9 +4083,7 @@ "id": 4, "title": "Create documentation and examples", "description": "Provide comprehensive documentation and examples for the 'diagram' command", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Write detailed command documentation with all options explained. Create example diagrams covering different diagram types. Include troubleshooting section for common errors. Add documentation on extending the command with custom themes or templates. Create integration examples showing how to use the command in workflows with other tools.", "status": "pending" } @@ -4843,9 +4122,7 @@ "id": 2, "title": "Design PDF template and layout", "description": "Create a template design for the project progress PDF including sections for summary, metrics, and dependency visualization", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Design should include header/footer, progress summary section, key metrics visualization, dependency diagram placement, and styling guidelines. Create a mockup of the final PDF output for approval.", "status": "pending" }, @@ -4853,9 +4130,7 @@ "id": 3, "title": "Implement project progress data collection module", "description": "Develop functionality to gather and process project data for the PDF report", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create functions to extract task completion percentages, milestone status, timeline adherence, and other relevant metrics from the project database. Include data transformation logic to prepare for PDF rendering.", "status": "pending" }, @@ -4863,10 +4138,7 @@ "id": 4, "title": "Integrate with dependency visualization system", "description": "Connect to the existing diagram command to generate visual representation of task dependencies", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "details": "Implement adapter for the diagram command output to be compatible with the PDF generation library. Handle different scales of dependency chains and ensure proper rendering of complex relationships.", "status": "pending" }, @@ -4874,11 +4146,7 @@ "id": 5, "title": "Build PDF generation core functionality", "description": "Develop the main module that combines data and visualizations into a formatted PDF document", - "dependencies": [ - 2, - 3, - 4 - ], + "dependencies": [2, 3, 4], "details": "Implement the core PDF generation logic using the selected library. Include functions for adding text sections, embedding visualizations, formatting tables, and applying the template design. Add pagination and document metadata.", "status": "pending" }, @@ -4886,9 +4154,7 @@ "id": 6, "title": "Create export options and command interface", "description": "Implement user-facing commands and options for generating and saving PDF reports", - "dependencies": [ - 5 - ], + "dependencies": [5], "details": "Develop CLI commands for PDF generation with parameters for customization (time period, detail level, etc.). Include options for automatic saving to specified locations, email distribution, and integration with existing project workflows.", "status": "pending" } @@ -4948,9 +4214,7 @@ "id": 2, "title": "Implement conditional logic for research role detection", "description": "Create logic to detect when a conversation is in 'research mode' and should trigger the Google Search Grounding functionality.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Develop heuristics or machine learning-based detection to identify when a user's query requires research capabilities. Implement a decision tree that determines when to activate Google Search Grounding based on conversation context, explicit user requests for research, or specific keywords. Include configuration options to adjust sensitivity of the detection mechanism.", "status": "pending" }, @@ -4958,9 +4222,7 @@ "id": 3, "title": "Update supported models configuration", "description": "Modify the model configuration to specify which AI models can utilize the Google Search Grounding capability.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Update the model configuration files to include flags for Google Search Grounding compatibility. Create a registry of supported models with their specific parameters for optimal integration with the search API. Implement version checking to ensure compatibility between model versions and the Google Search Grounding API version.", "status": "pending" }, @@ -4968,11 +4230,7 @@ "id": 4, "title": "Create end-to-end testing suite for research functionality", "description": "Develop comprehensive tests to verify the correct operation of the Google Search Grounding integration in research contexts.", - "dependencies": [ - 1, - 2, - 3 - ], + "dependencies": [1, 2, 3], "details": "Build automated test cases that cover various research scenarios, including edge cases. Create mock responses for the Google Search API to enable testing without actual API calls. Implement integration tests that verify the entire flow from user query to research-enhanced response. Include performance benchmarks to ensure the integration doesn't significantly impact response times.", "status": "pending" } @@ -5000,9 +4258,7 @@ "id": 2, "title": "Implement FastMCP Server Launcher", "description": "Create a component that can programmatically launch and manage the FastMCP server process over stdio", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Develop a module that can spawn the FastMCP server as a child process, establish stdio communication channels, handle process lifecycle events, and implement proper cleanup procedures. Include error handling for process failures and timeout mechanisms.", "status": "pending" }, @@ -5010,9 +4266,7 @@ "id": 3, "title": "Develop Message Protocol Handler", "description": "Implement a handler that can serialize/deserialize messages according to the FastMCP protocol specification", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Create a protocol handler that formats outgoing messages and parses incoming messages according to the FastMCP protocol. Implement validation for message format compliance and error handling for malformed messages. Support all required message types defined in the protocol.", "status": "pending" }, @@ -5020,9 +4274,7 @@ "id": 4, "title": "Create Request/Response Correlation Mechanism", "description": "Implement a system to track and correlate requests with their corresponding responses", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Develop a correlation mechanism using unique identifiers to match requests with their responses. Implement timeout handling for unresponded requests and proper error propagation. Design the API to support both synchronous and asynchronous request patterns.", "status": "pending" }, @@ -5030,10 +4282,7 @@ "id": 5, "title": "Build Test Assertion Framework", "description": "Create a set of assertion utilities specific to FastMCP server testing", - "dependencies": [ - 3, - 4 - ], + "dependencies": [3, 4], "details": "Develop assertion utilities that can validate server responses against expected values, verify timing constraints, and check for proper error handling. Include support for complex response validation patterns and detailed failure reporting.", "status": "pending" }, @@ -5041,11 +4290,7 @@ "id": 6, "title": "Implement Test Cases", "description": "Develop a comprehensive set of test cases covering all FastMCP server functionality", - "dependencies": [ - 2, - 4, - 5 - ], + "dependencies": [2, 4, 5], "details": "Create test cases for basic server operations, error conditions, edge cases, and performance scenarios. Organize tests into logical groups and ensure proper isolation between test cases. Include documentation for each test explaining its purpose and expected outcomes.", "status": "pending" }, @@ -5053,9 +4298,7 @@ "id": 7, "title": "Create CI Integration and Documentation", "description": "Set up continuous integration for the test framework and create comprehensive documentation", - "dependencies": [ - 6 - ], + "dependencies": [6], "details": "Configure the test framework to run in CI environments, generate reports, and fail builds appropriately. Create documentation covering framework architecture, usage instructions, test case development guidelines, and troubleshooting procedures. Include examples of extending the framework for new test scenarios.", "status": "pending" } @@ -5084,9 +4327,7 @@ "id": 2, "title": "Implement secure telemetry transmission", "description": "Create a secure mechanism to transmit telemetry data to the external analytics endpoint", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implement HTTPS POST request functionality to securely send the telemetry payload to the closed-source analytics API. Include proper encryption in transit using TLS. Implement retry logic and graceful fallback mechanisms for handling transmission failures due to connectivity issues.\n<info added on 2025-05-14T17:52:40.647Z>\nTo securely send structured JSON telemetry payloads from a Node.js CLI tool to an external analytics backend, follow these steps:\n\n1. Use the Axios library for HTTPS POST requests. Install it with: npm install axios.\n2. Store sensitive configuration such as the analytics endpoint URL and any secret keys in environment variables (e.g., process.env.ANALYTICS_URL, process.env.ANALYTICS_KEY). Use dotenv or a similar library to load these securely.\n3. Construct the telemetry payload as a JSON object with the required fields: userId, commandName, modelUsed, inputTokens, outputTokens, totalTokens, totalCost, and timestamp (ISO 8601).\n4. Implement robust retry logic using the axios-retry package (npm install axios-retry). Configure exponential backoff with a recommended maximum of 3 retries and a base delay (e.g., 500ms).\n5. Ensure all requests use HTTPS to guarantee TLS encryption in transit. Axios automatically uses HTTPS when the endpoint URL starts with https://.\n6. Handle errors gracefully: catch all transmission errors, log them for diagnostics, and ensure failures do not interrupt or degrade the CLI user experience. Optionally, queue failed payloads for later retry if persistent connectivity issues occur.\n7. Example code snippet:\n\nrequire('dotenv').config();\nconst axios = require('axios');\nconst axiosRetry = require('axios-retry');\n\naxiosRetry(axios, {\n retries: 3,\n retryDelay: axiosRetry.exponentialDelay,\n retryCondition: (error) => axiosRetry.isNetworkOrIdempotentRequestError(error),\n});\n\nasync function sendTelemetry(payload) {\n try {\n await axios.post(process.env.ANALYTICS_URL, payload, {\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${process.env.ANALYTICS_KEY}`,\n },\n timeout: 5000,\n });\n } catch (error) {\n // Log error, do not throw to avoid impacting CLI UX\n console.error('Telemetry transmission failed:', error.message);\n // Optionally, queue payload for later retry\n }\n}\n\nconst telemetryPayload = {\n userId: 'user-123',\n commandName: 'expand',\n modelUsed: 'gpt-4',\n inputTokens: 100,\n outputTokens: 200,\n totalTokens: 300,\n totalCost: 0.0123,\n timestamp: new Date().toISOString(),\n};\n\nsendTelemetry(telemetryPayload);\n\n8. Best practices:\n- Never hardcode secrets or endpoint URLs in source code.\n- Use environment variables and restrict access permissions.\n- Validate all payload fields before transmission.\n- Ensure the CLI continues to function even if telemetry transmission fails.\n\nReferences: [1][2][3][5]\n</info added on 2025-05-14T17:52:40.647Z>\n<info added on 2025-05-14T17:57:18.218Z>\nUser ID Retrieval and Generation:\n\nThe telemetry system must securely retrieve the user ID from the .taskmasterconfig globals, where it should have been generated during the initialization phase. Implementation should:\n\n1. Check for an existing user ID in the .taskmasterconfig file before sending any telemetry data.\n2. If no user ID exists (for users who run AI commands without prior initialization or during upgrades), automatically generate a new UUID v4 and persist it to the .taskmasterconfig file.\n3. Implement a getOrCreateUserId() function that:\n - Reads from the global configuration file\n - Returns the existing ID if present\n - Generates a cryptographically secure UUID v4 if not present\n - Saves the newly generated ID to the configuration file\n - Handles file access errors gracefully\n\n4. Example implementation:\n```javascript\nconst fs = require('fs');\nconst path = require('path');\nconst { v4: uuidv4 } = require('uuid');\n\nfunction getOrCreateUserId() {\n const configPath = path.join(os.homedir(), '.taskmasterconfig');\n \n try {\n // Try to read existing config\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n \n if (config.userId) {\n return config.userId;\n }\n \n // No user ID found, generate and save\n config.userId = uuidv4();\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2));\n return config.userId;\n } catch (error) {\n // Handle case where config doesn't exist or is invalid\n const userId = uuidv4();\n const newConfig = { userId };\n \n try {\n fs.writeFileSync(configPath, JSON.stringify(newConfig, null, 2));\n } catch (writeError) {\n console.error('Failed to save user ID to config:', writeError.message);\n }\n \n return userId;\n }\n}\n```\n\n5. Ensure this function is called before constructing any telemetry payload to guarantee a consistent user ID across all telemetry events.\n</info added on 2025-05-14T17:57:18.218Z>\n<info added on 2025-05-15T18:45:32.123Z>\n**Invocation Point for Sending Telemetry:**\n* The primary invocation for sending the telemetry payload should occur in `scripts/modules/ai-services-unified.js`.\n* This should happen *after* the `telemetryData` object is fully constructed and *after* user consent (from subtask 77.3) has been confirmed.\n\n**Dedicated Module for Transmission Logic:**\n* The actual HTTPS POST request mechanism, including TLS encryption, retry logic, and graceful fallbacks, should be implemented in a new, separate module (e.g., `scripts/modules/telemetry-sender.js` or `scripts/utils/telemetry-client.js`).\n* This module will be imported and utilized by `scripts/modules/ai-services-unified.js`.\n\n**Key Considerations:**\n* Robust error handling must be in place for the telemetry transmission process; failures should be logged locally and must not disrupt core application functionality.\n* The entire telemetry sending process is contingent upon explicit user consent as outlined in subtask 77.3.\n\n**Implementation Plan:**\n1. Create a new module `scripts/utils/telemetry-client.js` with the following functions:\n - `sendTelemetryData(telemetryPayload)`: Main function that handles the HTTPS POST request\n - `isUserConsentGiven()`: Helper function to check if user has consented to telemetry\n - `logTelemetryError(error)`: Helper function for consistent error logging\n\n2. In `ai-services-unified.js`, after constructing the telemetryData object:\n ```javascript\n const telemetryClient = require('../utils/telemetry-client');\n \n // After telemetryData is constructed\n if (telemetryClient.isUserConsentGiven()) {\n // Non-blocking telemetry submission\n telemetryClient.sendTelemetryData(telemetryData)\n .catch(error => telemetryClient.logTelemetryError(error));\n }\n ```\n\n3. Ensure the telemetry-client module implements:\n - Axios with retry logic for robust HTTP requests\n - Proper TLS encryption via HTTPS\n - Comprehensive error handling\n - Configuration loading from environment variables\n - Validation of payload data before transmission\n</info added on 2025-05-15T18:45:32.123Z>", "status": "deferred", "testStrategy": "Test with mock endpoints to verify secure transmission and proper handling of various response scenarios" @@ -5104,10 +4345,7 @@ "id": 4, "title": "Integrate telemetry into Taskmaster commands", "description": "Integrate the telemetry utility across all relevant Taskmaster commands", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "details": "Modify each Taskmaster command (expand, parse-prd, research, etc.) to call the logAiUsage utility after AI interactions. Ensure telemetry is only sent if user has provided consent. Implement the integration in a way that doesn't impact command performance or user experience.\n<info added on 2025-05-06T17:57:13.980Z>\nModify each Taskmaster command (expand, parse-prd, research, etc.) to call the logAiUsage utility after AI interactions. Ensure telemetry is only sent if user has provided consent. Implement the integration in a way that doesn't impact command performance or user experience.\n\nSuccessfully integrated telemetry calls into `addTask` (core) and `addTaskDirect` (MCP) functions by passing `commandName` and `outputType` parameters to the telemetry system. The `ai-services-unified.js` module now logs basic telemetry data, including calculated cost information, whenever the `add-task` command or tool is invoked. This integration respects user consent settings and maintains performance standards.\n</info added on 2025-05-06T17:57:13.980Z>", "status": "done", "testStrategy": "Integration tests to verify telemetry is correctly triggered across different commands with proper data" @@ -5116,10 +4354,7 @@ "id": 5, "title": "Implement usage summary display", "description": "Create an optional feature to display AI usage summary in the CLI output", - "dependencies": [ - 1, - 4 - ], + "dependencies": [1, 4], "details": "Develop functionality to display a concise summary of AI usage (tokens used, estimated cost) directly in the CLI output after command execution. Make this feature configurable through Taskmaster settings. Ensure the display is formatted clearly and doesn't clutter the main command output.", "status": "done", "testStrategy": "User acceptance testing to verify the summary display is clear, accurate, and properly configurable" @@ -5244,10 +4479,7 @@ "description": "Implement a separate module for handling telemetry transmission logic", "details": "Create a new module (e.g., `scripts/utils/telemetry-client.js`) that encapsulates all telemetry transmission functionality:\n\n1. Implement core functions:\n - `sendTelemetryData(telemetryPayload)`: Main function to handle HTTPS POST requests\n - `isUserConsentGiven()`: Helper to check if user has consented to telemetry\n - `logTelemetryError(error)`: Helper for consistent error logging\n\n2. Use Axios with retry logic:\n - Configure with exponential backoff (max 3 retries, 500ms base delay)\n - Implement proper TLS encryption via HTTPS\n - Set appropriate timeouts (5000ms recommended)\n\n3. Implement robust error handling:\n - Catch all transmission errors\n - Log failures locally without disrupting application flow\n - Ensure failures are transparent to users\n\n4. Configure securely:\n - Load endpoint URL and authentication from environment variables\n - Never hardcode secrets in source code\n - Validate payload data before transmission\n\n5. Integration with ai-services-unified.js:\n - Import the telemetry-client module\n - Call after telemetryData object is constructed\n - Only send if user consent is confirmed\n - Use non-blocking approach to avoid performance impact", "status": "done", - "dependencies": [ - 1, - 3 - ], + "dependencies": [1, 3], "parentTaskId": 77, "testStrategy": "Unit test with mock endpoints to verify proper transmission, error handling, and respect for user consent settings" } @@ -5276,9 +4508,7 @@ "id": 2, "title": "Implement UUID generation functionality", "description": "Create a function to generate cryptographically secure UUIDs v4 for unique user identification.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implement a function called 'generateUniqueUserId()' that uses the crypto module to create a UUID v4. The function should follow RFC 4122 for UUID generation to ensure uniqueness and security. Include validation to verify the generated ID matches the expected UUID v4 format. Document the function with JSDoc comments explaining its purpose for anonymous telemetry.", "status": "pending", "testStrategy": "Write unit tests to verify UUID format compliance, uniqueness across multiple generations, and cryptographic randomness properties." @@ -5287,9 +4517,7 @@ "id": 3, "title": "Develop config file handling logic", "description": "Create functions to read, parse, modify, and write to the .taskmasterconfig file for storing the user ID.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implement functions to: 1) Check if .taskmasterconfig exists and create it if not, 2) Read and parse the existing config file, 3) Check if a user ID already exists in the globals section, 4) Add or update the user ID in the globals section, and 5) Write the updated config back to disk. Handle edge cases like malformed config files, permission issues, and concurrent access. Use atomic write operations to prevent config corruption.", "status": "pending", "testStrategy": "Test with various initial config states: non-existent config, config without globals section, config with existing user ID. Verify file integrity after operations and proper error handling." @@ -5298,10 +4526,7 @@ "id": 4, "title": "Integrate user ID generation with config storage", "description": "Connect the UUID generation with the config file handling to create and store user IDs during installation.", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "Combine the UUID generation and config handling functions to: 1) Check if a user ID already exists in config, 2) Generate a new ID only if needed, 3) Store the ID in the config file, and 4) Handle installation scenarios (fresh install vs. update). Add appropriate logging to inform users about the anonymous ID generation with privacy-focused messaging. Ensure the process is idempotent so running it multiple times won't create multiple IDs.", "status": "pending", "testStrategy": "Create integration tests simulating fresh installations and updates. Verify ID persistence across simulated updates and regeneration on fresh installs." @@ -5310,9 +4535,7 @@ "id": 5, "title": "Add documentation and telemetry system access", "description": "Document the user ID system and create an API for the telemetry system to access the user ID.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Create comprehensive documentation explaining: 1) The purpose of the anonymous ID, 2) How user privacy is protected, 3) How to opt out of telemetry, and 4) Technical details of the implementation. Implement a simple API function 'getUserId()' that reads the ID from config for use by the telemetry system. Update the README and user documentation to include information about anonymous usage tracking. Ensure cross-platform compatibility by testing on all supported operating systems. Make it clear in the documentation that while we're collecting this ID, the server-side collection is not yet implemented, so data remains local for now.", "status": "pending", "testStrategy": "Verify documentation accuracy and completeness. Test the getUserId() function across platforms to ensure consistent behavior. Create a mock telemetry system to verify proper ID access." @@ -5597,10 +4820,7 @@ "details": "## Core Problem Statement\n\nThe current help menu in `displayHelp()` function (ui.js:434-734) is hardcoded with static command information that can become outdated when:\n\n1. **Command Changes**: New options/flags are added to existing commands\n2. **New Commands**: New commands are added to commands.js but not reflected in help\n3. **Command Removal**: Commands are removed but help text remains\n4. **Inconsistent Documentation**: Help text doesn't match actual command behavior\n5. **Maintenance Burden**: Developers must remember to update help when modifying commands\n\n## Technical Implementation Requirements\n\n### 1. Command Introspection System\n- **Extract Command Metadata**: Parse Commander.js program instance to extract:\n - Command names and aliases\n - Command descriptions\n - All options/flags with their descriptions and default values\n - Required vs optional parameters\n - Argument specifications\n- **Command Categorization**: Implement intelligent categorization based on:\n - Command name patterns (e.g., 'add-*', 'remove-*', 'set-*')\n - Command descriptions containing keywords\n - Manual category overrides for edge cases\n- **Validation**: Ensure all registered commands are captured and categorized\n\n### 2. Dynamic Help Generation Engine\n- **Template System**: Create flexible templates for:\n - Category headers with consistent styling\n - Command entries with proper formatting\n - Option/flag documentation with type information\n - Example usage generation\n- **Formatting Logic**: Implement dynamic column width calculation based on:\n - Terminal width detection\n - Content length analysis\n - Responsive layout adjustments\n- **Content Optimization**: Handle text wrapping, truncation, and spacing automatically\n\n### 3. Enhanced Command Documentation\n- **Auto-Generated Examples**: Create realistic usage examples by:\n - Combining command names with common option patterns\n - Using project-specific values (task IDs, file paths)\n - Showing both simple and complex usage scenarios\n- **Option Details**: Display comprehensive option information:\n - Short and long flag variants (-f, --file)\n - Data types and format requirements\n - Default values and behavior\n - Required vs optional indicators\n- **Cross-References**: Add intelligent linking between related commands\n\n### 4. Integration Points\n- **Commands.js Integration**: \n - Access the programInstance after all commands are registered\n - Extract metadata without affecting command functionality\n - Handle edge cases like hidden commands or aliases\n- **UI.js Refactoring**:\n - Replace static commandCategories array with dynamic generation\n - Maintain existing visual styling and layout\n - Preserve terminal width responsiveness\n - Keep configuration and quick start sections\n\n### 5. Category Classification Logic\nImplement smart categorization rules:\n```javascript\nconst categoryRules = {\n 'Project Setup & Configuration': ['init', 'models'],\n 'Task Generation': ['parse-prd', 'generate'],\n 'Task Management': ['list', 'set-status', 'update', 'add-task', 'remove-task'],\n 'Subtask Management': ['add-subtask', 'remove-subtask', 'clear-subtasks'],\n 'Task Analysis & Breakdown': ['analyze-complexity', 'complexity-report', 'expand', 'research'],\n 'Task Navigation & Viewing': ['next', 'show'],\n 'Dependency Management': ['add-dependency', 'remove-dependency', 'validate-dependencies', 'fix-dependencies']\n};\n```\n\n### 6. Error Handling and Fallbacks\n- **Graceful Degradation**: Fall back to static help if introspection fails\n- **Missing Information**: Handle commands with incomplete metadata\n- **Performance Considerations**: Cache generated help content when possible\n- **Debug Mode**: Provide verbose output for troubleshooting categorization\n\n## Implementation Architecture\n\n### Core Functions to Implement:\n1. **`extractCommandMetadata(programInstance)`**\n - Parse Commander.js instance\n - Extract all command and option information\n - Return structured metadata object\n\n2. **`categorizeCommands(commandMetadata)`**\n - Apply categorization rules\n - Handle special cases and overrides\n - Return categorized command structure\n\n3. **`generateDynamicHelp(categorizedCommands)`**\n - Create formatted help content\n - Apply consistent styling\n - Handle responsive layout\n\n4. **`displayDynamicHelp(programInstance)`**\n - Replace current displayHelp() function\n - Integrate with existing banner and footer content\n - Maintain backward compatibility\n\n### File Structure Changes:\n- **ui.js**: Replace static help with dynamic generation\n- **commands.js**: Ensure all commands have proper descriptions and option documentation\n- **New utility functions**: Add command introspection helpers\n\n## Testing Requirements\n\n### Unit Tests:\n- Command metadata extraction accuracy\n- Categorization logic correctness\n- Help content generation formatting\n- Terminal width responsiveness\n\n### Integration Tests:\n- Full help menu generation from actual commands\n- Consistency between help and actual command behavior\n- Performance with large numbers of commands\n\n### Manual Testing:\n- Visual verification of help output\n- Terminal width adaptation testing\n- Comparison with current static help for completeness\n\n## Benefits\n\n1. **Automatic Synchronization**: Help always reflects actual command state\n2. **Reduced Maintenance**: No manual help updates needed for command changes\n3. **Consistency**: Guaranteed alignment between help and implementation\n4. **Extensibility**: Easy to add new categorization rules or formatting\n5. **Accuracy**: Eliminates human error in help documentation\n6. **Developer Experience**: Faster development with automatic documentation\n\n## Migration Strategy\n\n1. **Phase 1**: Implement introspection system alongside existing static help\n2. **Phase 2**: Add categorization and dynamic generation\n3. **Phase 3**: Replace static help with dynamic system\n4. **Phase 4**: Remove static command definitions and add validation tests\n\nThis implementation will create a self-documenting CLI that maintains accuracy and reduces the burden on developers to manually maintain help documentation.", "testStrategy": "", "status": "pending", - "dependencies": [ - 2, - 4 - ], + "dependencies": [2, 4], "priority": "medium", "subtasks": [ { @@ -5618,9 +4838,7 @@ "description": "Implement smart categorization logic to group commands into logical categories for the help menu", "details": "## Implementation Requirements\n\n### Core Function: `categorizeCommands(commandMetadata)`\n\n**Location**: Add to `ui.js` or `help-utils.js` module\n\n**Functionality**:\n1. **Category Definition System**:\n - Define category rules with command name patterns\n - Support keyword-based categorization from descriptions\n - Allow manual overrides for edge cases\n - Maintain existing category structure for consistency\n\n2. **Categorization Rules**:\n```javascript\nconst categoryRules = {\n 'Project Setup & Configuration': {\n commands: ['init', 'models'],\n patterns: [/^models/, /^init/],\n keywords: ['setup', 'configure', 'initialization'],\n color: 'blue'\n },\n 'Task Generation': {\n commands: ['parse-prd', 'generate'],\n patterns: [/^parse/, /^generate/],\n keywords: ['create', 'generate', 'parse'],\n color: 'cyan'\n },\n 'Task Management': {\n commands: ['list', 'set-status', 'update', 'add-task', 'remove-task'],\n patterns: [/^(list|set-|update|add-|remove-)/, /status$/],\n keywords: ['manage', 'update', 'modify', 'status'],\n color: 'green'\n },\n 'Subtask Management': {\n commands: ['add-subtask', 'remove-subtask', 'clear-subtasks'],\n patterns: [/subtask/],\n keywords: ['subtask', 'sub-task'],\n color: 'yellow'\n },\n 'Task Analysis & Breakdown': {\n commands: ['analyze-complexity', 'complexity-report', 'expand', 'research'],\n patterns: [/^(analyze|complexity|expand|research)/],\n keywords: ['analyze', 'complexity', 'expand', 'research', 'breakdown'],\n color: 'magenta'\n },\n 'Task Navigation & Viewing': {\n commands: ['next', 'show'],\n patterns: [/^(next|show|view|display)/],\n keywords: ['view', 'show', 'display', 'navigate'],\n color: 'cyan'\n },\n 'Dependency Management': {\n commands: ['add-dependency', 'remove-dependency', 'validate-dependencies', 'fix-dependencies'],\n patterns: [/dependency|dependencies/],\n keywords: ['dependency', 'dependencies', 'depend'],\n color: 'blue'\n }\n};\n```\n\n3. **Categorization Algorithm**:\n - **Exact Match**: Check if command name is in category's command list\n - **Pattern Matching**: Test command name against regex patterns\n - **Keyword Analysis**: Search command description for category keywords\n - **Fallback Category**: Create \"Other Commands\" for uncategorized commands\n - **Priority System**: Handle commands that match multiple categories\n\n4. **Category Validation**:\n - Ensure all commands are categorized\n - Detect and warn about duplicate categorizations\n - Validate category color assignments\n - Check for empty categories\n\n### Technical Implementation:\n1. **Categorization Logic**:\n```javascript\nfunction categorizeCommands(commandMetadata) {\n const categorizedCommands = {};\n const uncategorized = [];\n \n // Initialize categories\n Object.keys(categoryRules).forEach(categoryName => {\n categorizedCommands[categoryName] = {\n ...categoryRules[categoryName],\n commands: []\n };\n });\n \n // Categorize each command\n Object.values(commandMetadata).forEach(command => {\n const category = findBestCategory(command);\n if (category) {\n categorizedCommands[category].commands.push(command);\n } else {\n uncategorized.push(command);\n }\n });\n \n // Handle uncategorized commands\n if (uncategorized.length > 0) {\n categorizedCommands['Other Commands'] = {\n color: 'gray',\n commands: uncategorized\n };\n }\n \n return categorizedCommands;\n}\n```\n\n2. **Best Category Detection**:\n - Score each category based on match strength\n - Prefer exact command name matches over patterns\n - Weight keyword matches by frequency and relevance\n - Return highest-scoring category\n\n3. **Dynamic Category Creation**:\n - Support adding new categories without code changes\n - Allow category rules to be loaded from configuration\n - Handle category inheritance and hierarchies\n\n### Testing Requirements:\n- Test categorization accuracy for all existing commands\n- Verify handling of new commands not in predefined lists\n- Test pattern matching and keyword detection\n- Validate category completeness and no duplicates", "status": "pending", - "dependencies": [ - 1 - ], + "dependencies": [1], "parentTaskId": 85 }, { @@ -5629,9 +4847,7 @@ "description": "Create the core help content generation system that formats command metadata into user-friendly help text", "details": "## Implementation Requirements\n\n### Core Function: `generateHelpContent(categorizedCommands)`\n\n**Location**: Replace existing `displayHelp()` logic in `ui.js`\n\n**Functionality**:\n1. **Help Section Generation**:\n - Generate header with tool name and version\n - Create usage section with basic syntax\n - Build categorized command sections\n - Add footer with additional resources\n\n2. **Command Formatting Logic**:\n```javascript\nfunction formatCommand(command) {\n const { name, description, options, arguments: args, aliases } = command;\n \n // Build usage line\n let usage = `task-master ${name}`;\n \n // Add arguments\n if (args && args.length > 0) {\n args.forEach(arg => {\n if (arg.required) {\n usage += ` <${arg.name}>`;\n } else {\n usage += ` [${arg.name}]`;\n }\n });\n }\n \n // Add options indicator\n if (options && options.length > 0) {\n usage += ' [options]';\n }\n \n // Format aliases\n const aliasText = aliases && aliases.length > 0 \n ? ` (aliases: ${aliases.join(', ')})` \n : '';\n \n return {\n usage,\n description: description || 'No description available',\n aliasText,\n options: formatOptions(options)\n };\n}\n```\n\n3. **Option Formatting**:\n - Format flags with proper spacing and alignment\n - Include descriptions and default values\n - Highlight required vs optional parameters\n - Group related options together\n\n4. **Category Section Generation**:\n```javascript\nfunction generateCategorySection(categoryName, categoryData) {\n const { color, commands } = categoryData;\n \n let section = `\\n${chalk[color].bold(categoryName)}:\\n`;\n \n commands.forEach(command => {\n const formatted = formatCommand(command);\n section += ` ${chalk.cyan(formatted.usage)}${formatted.aliasText}\\n`;\n section += ` ${formatted.description}\\n`;\n \n if (formatted.options.length > 0) {\n section += ` Options:\\n`;\n formatted.options.forEach(option => {\n section += ` ${option.flags.padEnd(20)} ${option.description}\\n`;\n });\n }\n section += '\\n';\n });\n \n return section;\n}\n```\n\n5. **Responsive Formatting**:\n - Detect terminal width for optimal formatting\n - Adjust column widths based on content length\n - Handle long descriptions with proper wrapping\n - Maintain consistent indentation and spacing\n\n### Technical Implementation:\n1. **Content Assembly**:\n - Build help content in logical sections\n - Apply consistent styling and colors\n - Handle empty categories gracefully\n - Support different output formats (terminal, plain text)\n\n2. **Performance Optimization**:\n - Cache generated help content\n - Lazy-load command metadata only when needed\n - Minimize string concatenation overhead\n - Support incremental updates\n\n3. **Accessibility Features**:\n - Support no-color output for accessibility\n - Provide plain text fallbacks\n - Ensure proper screen reader compatibility\n - Support different terminal capabilities\n\n4. **Customization Options**:\n - Allow filtering by category\n - Support command-specific help\n - Enable verbose vs compact modes\n - Provide search functionality\n\n### Integration Points:\n1. **Replace Existing displayHelp()**:\n - Maintain same function signature\n - Preserve existing color scheme\n - Keep backward compatibility\n - Update all call sites\n\n2. **Add New Help Variants**:\n - `displayHelp(category)` - Show specific category\n - `displayCommandHelp(commandName)` - Detailed command help\n - `displayHelpSearch(query)` - Search-based help\n\n### Testing Requirements:\n- Test help generation for all command categories\n- Verify formatting consistency across different terminals\n- Test with various terminal widths and capabilities\n- Validate color output and no-color fallbacks\n- Performance testing with large command sets", "status": "pending", - "dependencies": [ - 2 - ], + "dependencies": [2], "parentTaskId": 85 }, { @@ -5640,9 +4856,7 @@ "description": "Replace the static help system with the new dynamic help generation and ensure seamless integration", "details": "## Implementation Requirements\n\n### Core Integration Tasks:\n\n1. **Replace displayHelp() Function**:\n - **Location**: `ui.js` lines 434-734\n - **Action**: Replace static help content with dynamic generation\n - **Preserve**: Existing function signature and color scheme\n - **Enhance**: Add new parameters for filtering and customization\n\n2. **Update Function Signature**:\n```javascript\n// Current: displayHelp()\n// New: displayHelp(options = {})\nfunction displayHelp(options = {}) {\n const {\n category = null, // Filter by specific category\n command = null, // Show help for specific command\n search = null, // Search query for commands\n verbose = false, // Show detailed help\n noColor = false // Disable colors for accessibility\n } = options;\n \n // Dynamic help generation logic\n}\n```\n\n3. **Integration with commands.js**:\n - **Access Program Instance**: Get reference to Commander.js program\n - **Timing**: Ensure commands are fully registered before help generation\n - **Caching**: Cache command metadata to avoid repeated parsing\n\n4. **Update Help Command Registration**:\n```javascript\n// In commands.js, update help command\nprogram\n .command('help [command]')\n .description('Display help information')\n .option('-c, --category <category>', 'Show help for specific category')\n .option('-s, --search <query>', 'Search commands by keyword')\n .option('-v, --verbose', 'Show detailed help information')\n .option('--no-color', 'Disable colored output')\n .action(async (command, options) => {\n displayHelp({\n command,\n category: options.category,\n search: options.search,\n verbose: options.verbose,\n noColor: !options.color\n });\n });\n```\n\n5. **Fallback and Error Handling**:\n - **Graceful Degradation**: Fall back to static help if dynamic generation fails\n - **Error Recovery**: Handle malformed command definitions\n - **Performance**: Ensure help generation doesn't slow down CLI startup\n\n### Technical Implementation:\n\n1. **Program Instance Access**:\n```javascript\n// Method 1: Pass program instance to displayHelp\nfunction displayHelp(options = {}, programInstance = null) {\n if (!programInstance) {\n // Fallback to static help or error\n console.warn('Dynamic help unavailable, using static fallback');\n return displayStaticHelp();\n }\n \n const commandMetadata = extractCommandMetadata(programInstance);\n const categorizedCommands = categorizeCommands(commandMetadata);\n return generateHelpContent(categorizedCommands, options);\n}\n\n// Method 2: Global program reference\nlet globalProgramInstance = null;\nexport function setProgramInstance(program) {\n globalProgramInstance = program;\n}\n```\n\n2. **Initialization Sequence**:\n - Commands are registered in `commands.js`\n - Program instance is made available to help system\n - Help system caches command metadata on first use\n - Subsequent help calls use cached data\n\n3. **Backward Compatibility**:\n - Maintain existing `displayHelp()` calls without parameters\n - Preserve existing color scheme and formatting style\n - Keep same output structure for scripts that parse help output\n\n4. **Performance Optimization**:\n - Cache command metadata after first extraction\n - Lazy-load help content generation\n - Minimize impact on CLI startup time\n - Support incremental cache updates\n\n### Integration Points:\n\n1. **Update All Help Call Sites**:\n - Search codebase for `displayHelp()` calls\n - Update calls to pass program instance or use global reference\n - Test all help invocation paths\n\n2. **Enhanced Help Commands**:\n - `task-master help` - General help (existing behavior)\n - `task-master help <command>` - Command-specific help\n - `task-master help --category <cat>` - Category-specific help\n - `task-master help --search <query>` - Search-based help\n\n3. **Error Handling Integration**:\n - Update error messages to suggest relevant help commands\n - Provide contextual help suggestions based on failed commands\n - Integrate with existing error reporting system\n\n### Testing Requirements:\n\n1. **Integration Testing**:\n - Test help system with all existing commands\n - Verify backward compatibility with existing help calls\n - Test new help command options and parameters\n\n2. **Performance Testing**:\n - Measure help generation time with full command set\n - Test CLI startup time impact\n - Verify caching effectiveness\n\n3. **Compatibility Testing**:\n - Test with different terminal types and capabilities\n - Verify color output and no-color modes\n - Test with various screen sizes and widths\n\n4. **Error Scenario Testing**:\n - Test behavior with malformed command definitions\n - Verify fallback to static help when needed\n - Test graceful handling of missing metadata\n\n### Migration Strategy:\n\n1. **Phase 1**: Implement dynamic help system alongside existing static help\n2. **Phase 2**: Update help command to use dynamic system with fallback\n3. **Phase 3**: Replace all displayHelp() calls with dynamic version\n4. **Phase 4**: Remove static help content and cleanup old code\n5. **Phase 5**: Add enhanced help features (search, filtering, etc.)", "status": "pending", - "dependencies": [ - 3 - ], + "dependencies": [3], "parentTaskId": 85 }, { @@ -5651,9 +4865,7 @@ "description": "Implement advanced help features including command search, category filtering, and contextual help suggestions", "details": "## Implementation Requirements\n\n### Enhanced Help Features:\n\n1. **Command Search Functionality**:\n```javascript\nfunction searchCommands(query, commandMetadata) {\n const results = [];\n const searchTerms = query.toLowerCase().split(' ');\n \n Object.values(commandMetadata).forEach(command => {\n let score = 0;\n \n // Search in command name (highest weight)\n if (command.name.toLowerCase().includes(query.toLowerCase())) {\n score += 10;\n }\n \n // Search in description (medium weight)\n if (command.description && command.description.toLowerCase().includes(query.toLowerCase())) {\n score += 5;\n }\n \n // Search in option descriptions (lower weight)\n command.options?.forEach(option => {\n if (option.description.toLowerCase().includes(query.toLowerCase())) {\n score += 2;\n }\n });\n \n // Fuzzy matching for command names\n if (fuzzyMatch(command.name, query)) {\n score += 3;\n }\n \n if (score > 0) {\n results.push({ command, score });\n }\n });\n \n return results.sort((a, b) => b.score - a.score);\n}\n```\n\n2. **Category Filtering**:\n - Allow users to view help for specific categories only\n - Support partial category name matching\n - Provide category list when invalid category specified\n - Enable multiple category selection\n\n3. **Contextual Help Suggestions**:\n```javascript\nfunction suggestRelatedCommands(commandName, commandMetadata) {\n const suggestions = [];\n const command = commandMetadata[commandName];\n \n if (!command) return suggestions;\n \n // Find commands in same category\n const category = findCommandCategory(commandName);\n if (category) {\n suggestions.push(...getCategoryCommands(category));\n }\n \n // Find commands with similar names\n Object.keys(commandMetadata).forEach(name => {\n if (name !== commandName && similarity(name, commandName) > 0.6) {\n suggestions.push(commandMetadata[name]);\n }\n });\n \n // Find commands with related functionality\n const keywords = extractKeywords(command.description);\n keywords.forEach(keyword => {\n const related = findCommandsByKeyword(keyword, commandMetadata);\n suggestions.push(...related);\n });\n \n return deduplicateAndScore(suggestions);\n}\n```\n\n4. **Interactive Help Mode**:\n - Implement step-by-step help wizard\n - Guide users through command selection\n - Provide examples and use cases\n - Support help history and bookmarks\n\n### Advanced Features:\n\n1. **Help Caching and Performance**:\n```javascript\nclass HelpCache {\n constructor() {\n this.cache = new Map();\n this.lastUpdate = null;\n this.commandMetadata = null;\n }\n \n getHelp(key, generator) {\n if (this.cache.has(key) && !this.isStale()) {\n return this.cache.get(key);\n }\n \n const content = generator();\n this.cache.set(key, content);\n return content;\n }\n \n invalidate() {\n this.cache.clear();\n this.lastUpdate = Date.now();\n }\n \n isStale() {\n return Date.now() - this.lastUpdate > 300000; // 5 minutes\n }\n}\n```\n\n2. **Help Export and Documentation**:\n - Export help content to markdown format\n - Generate man pages from command metadata\n - Create HTML documentation\n - Support JSON export for API documentation\n\n3. **Accessibility Enhancements**:\n - Screen reader friendly output\n - High contrast mode support\n - Keyboard navigation for interactive help\n - Alternative text descriptions for visual elements\n\n4. **Internationalization Support**:\n - Support for multiple languages\n - Localized command descriptions\n - Cultural formatting preferences\n - RTL language support\n\n### Command-Specific Help Features:\n\n1. **Detailed Command Help**:\n```javascript\nfunction displayCommandHelp(commandName, commandMetadata) {\n const command = commandMetadata[commandName];\n if (!command) {\n console.error(`Command '${commandName}' not found.`);\n suggestSimilarCommands(commandName, commandMetadata);\n return;\n }\n \n console.log(chalk.cyan.bold(`\\\\n${command.name.toUpperCase()} COMMAND HELP\\\\n`));\n console.log(`Description: ${command.description}\\\\n`);\n \n // Usage examples\n if (command.examples) {\n console.log(chalk.yellow.bold('Examples:'));\n command.examples.forEach(example => {\n console.log(` ${chalk.green(example.command)}`);\n console.log(` ${example.description}\\\\n`);\n });\n }\n \n // Detailed options\n if (command.options && command.options.length > 0) {\n console.log(chalk.yellow.bold('Options:'));\n command.options.forEach(option => {\n console.log(` ${chalk.cyan(option.flags.padEnd(20))} ${option.description}`);\n if (option.defaultValue) {\n console.log(`${' '.repeat(22)}Default: ${option.defaultValue}`);\n }\n if (option.examples) {\n console.log(`${' '.repeat(22)}Example: ${option.examples[0]}`);\n }\n });\n }\n \n // Related commands\n const related = suggestRelatedCommands(commandName, commandMetadata);\n if (related.length > 0) {\n console.log(chalk.yellow.bold('\\\\nRelated Commands:'));\n related.slice(0, 5).forEach(cmd => {\n console.log(` ${chalk.cyan(cmd.name)} - ${cmd.description}`);\n });\n }\n}\n```\n\n2. **Usage Examples Generation**:\n - Auto-generate common usage patterns\n - Include real-world scenarios\n - Show before/after examples\n - Provide troubleshooting tips\n\n### Error Integration:\n\n1. **Smart Error Messages**:\n```javascript\nfunction enhanceErrorWithHelp(error, commandName, commandMetadata) {\n console.error(chalk.red(error.message));\n \n // Suggest correct usage\n if (commandMetadata[commandName]) {\n console.log(chalk.yellow('\\\\nCorrect usage:'));\n console.log(` ${formatCommandUsage(commandMetadata[commandName])}`);\n }\n \n // Suggest similar commands\n const suggestions = findSimilarCommands(commandName, commandMetadata);\n if (suggestions.length > 0) {\n console.log(chalk.yellow('\\\\nDid you mean:'));\n suggestions.slice(0, 3).forEach(cmd => {\n console.log(` ${chalk.cyan(cmd.name)} - ${cmd.description}`);\n });\n }\n \n // Provide help command\n console.log(chalk.gray(`\\\\nFor more help: task-master help ${commandName}`));\n}\n```\n\n### Testing Requirements:\n\n1. **Search Functionality Testing**:\n - Test search accuracy with various queries\n - Verify fuzzy matching and scoring\n - Test performance with large command sets\n - Validate search result ranking\n\n2. **Feature Integration Testing**:\n - Test all new help command options\n - Verify category filtering accuracy\n - Test contextual suggestions relevance\n - Validate caching behavior\n\n3. **Accessibility Testing**:\n - Test with screen readers\n - Verify keyboard navigation\n - Test color contrast and no-color modes\n - Validate output formatting\n\n4. **Performance Testing**:\n - Measure search response times\n - Test caching effectiveness\n - Verify memory usage with large datasets\n - Test concurrent help requests\n\n### Documentation Updates:\n\n1. **Update README**:\n - Document new help features\n - Provide usage examples\n - Update command reference\n - Add troubleshooting section\n\n2. **Create Help Documentation**:\n - Comprehensive help system guide\n - Advanced usage patterns\n - Customization options\n - Integration examples", "status": "pending", - "dependencies": [ - 4 - ], + "dependencies": [4], "parentTaskId": 85 }, { @@ -5662,9 +4874,7 @@ "description": "Implement thorough testing for the dynamic help system and update all relevant documentation", "details": "## Implementation Requirements\n\n### Testing Strategy:\n\n1. **Unit Tests for Core Functions**:\n```javascript\n// tests/unit/help-system.test.js\ndescribe('Dynamic Help System', () => {\n describe('extractCommandMetadata', () => {\n test('should extract basic command information', () => {\n const mockProgram = createMockProgram();\n const metadata = extractCommandMetadata(mockProgram);\n \n expect(metadata).toHaveProperty('init');\n expect(metadata.init.name).toBe('init');\n expect(metadata.init.description).toBeDefined();\n expect(metadata.init.options).toBeArray();\n });\n \n test('should handle commands with complex options', () => {\n const mockProgram = createComplexMockProgram();\n const metadata = extractCommandMetadata(mockProgram);\n \n expect(metadata.parseRrd.options).toHaveLength(5);\n expect(metadata.parseRrd.options[0]).toHaveProperty('flags');\n expect(metadata.parseRrd.options[0]).toHaveProperty('description');\n });\n \n test('should handle missing descriptions gracefully', () => {\n const mockProgram = createIncompleteProgram();\n const metadata = extractCommandMetadata(mockProgram);\n \n expect(metadata.undocumented.description).toBe('No description available');\n });\n });\n \n describe('categorizeCommands', () => {\n test('should categorize commands correctly', () => {\n const mockMetadata = createMockMetadata();\n const categorized = categorizeCommands(mockMetadata);\n \n expect(categorized).toHaveProperty('Project Setup & Configuration');\n expect(categorized['Project Setup & Configuration'].commands).toContainEqual(\n expect.objectContaining({ name: 'init' })\n );\n });\n \n test('should handle uncategorized commands', () => {\n const mockMetadata = { unknownCommand: { name: 'unknown', description: 'test' } };\n const categorized = categorizeCommands(mockMetadata);\n \n expect(categorized).toHaveProperty('Other Commands');\n expect(categorized['Other Commands'].commands).toHaveLength(1);\n });\n });\n \n describe('generateHelpContent', () => {\n test('should generate properly formatted help content', () => {\n const mockCategorized = createMockCategorizedCommands();\n const content = generateHelpContent(mockCategorized);\n \n expect(content).toContain('Task Master CLI');\n expect(content).toContain('Project Setup & Configuration');\n expect(content).toContain('task-master init');\n });\n \n test('should handle empty categories', () => {\n const emptyCategorized = { 'Empty Category': { commands: [] } };\n const content = generateHelpContent(emptyCategorized);\n \n expect(content).not.toContain('Empty Category');\n });\n });\n});\n```\n\n2. **Integration Tests**:\n```javascript\n// tests/integration/help-integration.test.js\ndescribe('Help System Integration', () => {\n test('should integrate with actual CLI commands', async () => {\n const { program } = await import('../../scripts/modules/commands.js');\n const metadata = extractCommandMetadata(program);\n \n // Verify all expected commands are present\n const expectedCommands = ['init', 'parse-prd', 'list', 'add-task', 'expand'];\n expectedCommands.forEach(cmd => {\n expect(metadata).toHaveProperty(cmd);\n });\n });\n \n test('should maintain backward compatibility', () => {\n const originalHelp = captureConsoleOutput(() => {\n displayHelp(); // Original function call\n });\n \n expect(originalHelp).toContain('Task Master CLI');\n expect(originalHelp).toContain('Available Commands');\n });\n \n test('should handle help command with options', () => {\n const categoryHelp = captureConsoleOutput(() => {\n displayHelp({ category: 'Task Management' });\n });\n \n expect(categoryHelp).toContain('Task Management');\n expect(categoryHelp).toContain('list');\n expect(categoryHelp).not.toContain('init'); // Should not contain other categories\n });\n});\n```\n\n3. **Performance Tests**:\n```javascript\n// tests/performance/help-performance.test.js\ndescribe('Help System Performance', () => {\n test('should extract metadata within acceptable time', () => {\n const start = performance.now();\n const metadata = extractCommandMetadata(largeMockProgram);\n const end = performance.now();\n \n expect(end - start).toBeLessThan(100); // Should complete in under 100ms\n });\n \n test('should cache help content effectively', () => {\n const cache = new HelpCache();\n \n const start1 = performance.now();\n const content1 = cache.getHelp('main', () => generateHelpContent(mockData));\n const end1 = performance.now();\n \n const start2 = performance.now();\n const content2 = cache.getHelp('main', () => generateHelpContent(mockData));\n const end2 = performance.now();\n \n expect(content1).toBe(content2);\n expect(end2 - start2).toBeLessThan((end1 - start1) / 10); // Cached should be 10x faster\n });\n});\n```\n\n4. **Accessibility Tests**:\n```javascript\n// tests/accessibility/help-accessibility.test.js\ndescribe('Help System Accessibility', () => {\n test('should provide no-color output', () => {\n const noColorHelp = captureConsoleOutput(() => {\n displayHelp({ noColor: true });\n });\n \n // Should not contain ANSI color codes\n expect(noColorHelp).not.toMatch(/\\u001b\\[[0-9;]*m/);\n });\n \n test('should format content for screen readers', () => {\n const accessibleHelp = generateAccessibleHelp(mockMetadata);\n \n expect(accessibleHelp).toContain('Heading level 1: Task Master CLI');\n expect(accessibleHelp).toContain('List item: init command');\n });\n});\n```\n\n### Mock Data and Utilities:\n\n1. **Mock Program Creation**:\n```javascript\n// tests/utils/mock-program.js\nexport function createMockProgram() {\n return {\n commands: [\n {\n _name: 'init',\n _description: 'Initialize a new Task Master project',\n _aliases: [],\n options: [\n {\n flags: '-y, --yes',\n description: 'Skip prompts and use defaults',\n required: false,\n defaultValue: false\n }\n ],\n _args: []\n },\n {\n _name: 'list',\n _description: 'List all tasks',\n _aliases: ['ls'],\n options: [\n {\n flags: '-s, --status <status>',\n description: 'Filter by status',\n required: false\n }\n ],\n _args: []\n }\n ]\n };\n}\n```\n\n2. **Test Utilities**:\n```javascript\n// tests/utils/test-helpers.js\nexport function captureConsoleOutput(fn) {\n const originalLog = console.log;\n let output = '';\n \n console.log = (...args) => {\n output += args.join(' ') + '\\n';\n };\n \n try {\n fn();\n return output;\n } finally {\n console.log = originalLog;\n }\n}\n\nexport function stripAnsiColors(text) {\n return text.replace(/\\u001b\\[[0-9;]*m/g, '');\n}\n```\n\n### Documentation Updates:\n\n1. **README.md Updates**:\n```markdown\n## Enhanced Help System\n\nTask Master now features a dynamic help system that automatically generates help content from your CLI commands.\n\n### Basic Help\n```bash\ntask-master help\n```\n\n### Category-Specific Help\n```bash\ntask-master help --category \"Task Management\"\n```\n\n### Command Search\n```bash\ntask-master help --search \"dependency\"\n```\n\n### Command-Specific Help\n```bash\ntask-master help add-task\n```\n\n### Advanced Options\n- `--verbose`: Show detailed help with examples\n- `--no-color`: Disable colored output for accessibility\n- `--search <query>`: Search commands by keyword\n- `--category <name>`: Filter by command category\n```\n\n2. **API Documentation**:\n```markdown\n## Help System API\n\n### Core Functions\n\n#### `extractCommandMetadata(programInstance)`\nExtracts command metadata from a Commander.js program instance.\n\n**Parameters:**\n- `programInstance` (Object): Commander.js program instance\n\n**Returns:**\n- Object containing command metadata\n\n#### `categorizeCommands(commandMetadata)`\nCategorizes commands into logical groups.\n\n**Parameters:**\n- `commandMetadata` (Object): Command metadata from extractCommandMetadata\n\n**Returns:**\n- Object with categorized commands\n\n#### `generateHelpContent(categorizedCommands, options)`\nGenerates formatted help content.\n\n**Parameters:**\n- `categorizedCommands` (Object): Categorized command data\n- `options` (Object): Formatting options\n\n**Returns:**\n- String containing formatted help content\n```\n\n3. **Developer Guide**:\n```markdown\n## Extending the Help System\n\n### Adding New Categories\nTo add a new command category, update the `categoryRules` object:\n\n```javascript\nconst categoryRules = {\n 'Your New Category': {\n commands: ['command1', 'command2'],\n patterns: [/^pattern/],\n keywords: ['keyword1', 'keyword2'],\n color: 'blue'\n }\n};\n```\n\n### Custom Help Formatters\nCreate custom help formatters for specific use cases:\n\n```javascript\nfunction customHelpFormatter(command) {\n // Your custom formatting logic\n return formattedContent;\n}\n```\n```\n\n### Continuous Integration:\n\n1. **GitHub Actions Workflow**:\n```yaml\n# .github/workflows/help-system-tests.yml\nname: Help System Tests\n\non: [push, pull_request]\n\njobs:\n test-help-system:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - uses: actions/setup-node@v3\n with:\n node-version: '18'\n - run: npm ci\n - run: npm run test:help-system\n - run: npm run test:help-accessibility\n - run: npm run test:help-performance\n```\n\n2. **Test Scripts in package.json**:\n```json\n{\n \"scripts\": {\n \"test:help-system\": \"jest tests/unit/help-system.test.js tests/integration/help-integration.test.js\",\n \"test:help-accessibility\": \"jest tests/accessibility/help-accessibility.test.js\",\n \"test:help-performance\": \"jest tests/performance/help-performance.test.js\",\n \"test:help-all\": \"npm run test:help-system && npm run test:help-accessibility && npm run test:help-performance\"\n }\n}\n```\n\n### Quality Assurance:\n\n1. **Code Coverage Requirements**:\n - Minimum 90% coverage for help system functions\n - 100% coverage for critical path functions\n - Integration test coverage for all CLI commands\n\n2. **Performance Benchmarks**:\n - Help generation: < 100ms for full help\n - Command search: < 50ms for typical queries\n - Cache hit ratio: > 95% for repeated requests\n\n3. **Accessibility Standards**:\n - WCAG 2.1 AA compliance for terminal output\n - Screen reader compatibility testing\n - High contrast mode support\n - Keyboard navigation support", "status": "pending", - "dependencies": [ - 5 - ], + "dependencies": [5], "parentTaskId": 85 } ] @@ -5676,9 +4886,7 @@ "details": "Implement a robust 'export_task' command with the following components:\n\n1. **Command Structure**:\n - Create a new 'export_task' command with destination-specific subcommands\n - Initial implementation should focus on GitHub integration\n - Command syntax: `taskmaster export_task github [options] <task_id>`\n - Support options for repository selection, issue type, and export configuration\n\n2. **GitHub Issue Creation**:\n - Convert Task Master tasks into properly formatted GitHub issues\n - Map task title and description to GitHub issue fields\n - Convert implementation details and test strategy into well-structured issue body sections\n - Transform subtasks into GitHub task lists or optionally create separate linked issues\n - Map Task Master priorities, tags, and assignees to GitHub labels and assignees\n - Add Task Master metadata as hidden comments for bidirectional linking\n\n3. **GitHub API Integration**:\n - Implement GitHub API client for issue creation and management\n - Support authentication via GITHUB_API_KEY environment variable\n - Handle repository access for both public and private repositories\n - Implement proper error handling for API failures\n - Add rate limiting support to prevent API abuse\n - Support milestone assignment if applicable\n\n4. **Bidirectional Linking**:\n - Store GitHub issue URL and ID in task metadata\n - Use consistent metadata schema compatible with the import feature\n - Implement checks to prevent duplicate exports\n - Support updating existing GitHub issues if task has been modified\n - Enable round-trip workflows (export → modify in GitHub → re-import)\n\n5. **Extensible Architecture**:\n - Design the export system to be platform-agnostic\n - Create adapter interfaces for different export destinations\n - Implement the GitHub adapter as the first concrete implementation\n - Allow for custom export templates and formatting rules\n - Document extension points for future platforms (GitLab, Linear, Jira, etc.)\n\n6. **Content Formatting**:\n - Implement smart content conversion from Task Master format to GitHub-optimized format\n - Handle markdown conversion appropriately\n - Format code blocks, tables, and other structured content\n - Add appropriate GitHub-specific references and formatting\n - Ensure proper rendering of task relationships and dependencies\n\n7. **Configuration and Settings**:\n - Add export-related configuration to Task Master settings\n - Support default repositories and export preferences\n - Allow customization of export templates and formatting\n - Implement export history tracking\n\n8. **Documentation**:\n - Create comprehensive documentation for the export feature\n - Include examples and best practices\n - Document the bidirectional workflow with import feature", "testStrategy": "1. **Unit Tests**:\n - Create unit tests for each component of the export system\n - Test GitHub API client with mock responses\n - Verify correct task-to-issue conversion logic\n - Test bidirectional linking metadata handling\n - Validate error handling and edge cases\n\n2. **Integration Tests**:\n - Test end-to-end export workflow with test GitHub repository\n - Verify created GitHub issues match expected format and content\n - Test round-trip workflow (export → import) to ensure data integrity\n - Validate behavior with various task types and structures\n - Test with both simple and complex tasks with subtasks\n\n3. **Manual Testing Checklist**:\n - Export a simple task and verify all fields are correctly mapped\n - Export a complex task with subtasks and verify correct representation\n - Test exporting to different repositories and with different user permissions\n - Verify error messages are clear and helpful\n - Test updating an already-exported task\n - Verify bidirectional linking works correctly\n - Test the round-trip workflow with modifications in GitHub\n\n4. **Edge Case Testing**:\n - Test with missing GitHub credentials\n - Test with invalid repository names\n - Test with rate-limited API responses\n - Test with very large tasks and content\n - Test with special characters and formatting in task content\n - Verify behavior when GitHub is unreachable\n\n5. **Performance Testing**:\n - Measure export time for different task sizes\n - Test batch export of multiple tasks\n - Verify system handles GitHub API rate limits appropriately", "status": "pending", - "dependencies": [ - 45 - ], + "dependencies": [45], "priority": "high", "subtasks": [ { @@ -5701,9 +4909,7 @@ "id": 3, "title": "Implement Authentication System", "description": "Build a secure authentication system for GitHub API access", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Develop authentication flows supporting personal access tokens, OAuth, and GitHub Apps. Implement secure credential storage with appropriate encryption. Create comprehensive error handling for authentication failures, token expiration, and permission issues with clear user feedback.", "status": "pending" }, @@ -5711,10 +4917,7 @@ "id": 4, "title": "Create Task-to-Issue Mapping Logic", "description": "Develop the core logic for mapping GitHub issues to task structures", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "Implement data models and transformation logic to convert GitHub issues into structured task objects. Handle relationships between issues including parent-child relationships, dependencies, and linked issues. Support task lists within issue bodies and map them to subtasks with appropriate status tracking.", "status": "pending" }, @@ -5722,9 +4925,7 @@ "id": 5, "title": "Build Content Formatting Engine", "description": "Create a system for formatting and converting issue content", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Develop a markdown processing engine that handles GitHub Flavored Markdown. Implement converters for transforming content to various formats (plain text, HTML, etc.). Create utilities for handling embedded images, code blocks, and other rich content elements while preserving formatting integrity.", "status": "pending" }, @@ -5732,10 +4933,7 @@ "id": 6, "title": "Implement Bidirectional Linking System", "description": "Develop mechanisms for maintaining bidirectional links between exported data and GitHub", - "dependencies": [ - 4, - 5 - ], + "dependencies": [4, 5], "details": "Create a reference system that maintains links between exported tasks and their source GitHub issues. Implement metadata preservation to enable round-trip workflows. Design a change tracking system to support future synchronization capabilities between exported data and GitHub.", "status": "pending" }, @@ -5743,11 +4941,7 @@ "id": 7, "title": "Design Extensible Architecture", "description": "Create an adapter-based architecture for supporting multiple export formats and destinations", - "dependencies": [ - 4, - 5, - 6 - ], + "dependencies": [4, 5, 6], "details": "Implement a plugin architecture with adapter interfaces for different output formats (JSON, CSV, XLSX) and destinations (file system, cloud storage, third-party tools). Create a registry system for dynamically loading adapters. Design clean separation between core logic and format-specific implementations.", "status": "pending" }, @@ -5755,10 +4949,7 @@ "id": 8, "title": "Develop Configuration Management", "description": "Build a robust system for managing user configurations and preferences", - "dependencies": [ - 1, - 7 - ], + "dependencies": [1, 7], "details": "Implement configuration file handling with support for multiple locations (global, project-specific). Create a settings management system with validation and defaults. Support environment variable overrides and command-line parameter precedence. Include migration paths for configuration format changes.", "status": "pending" }, @@ -5766,11 +4957,7 @@ "id": 9, "title": "Create Comprehensive Documentation", "description": "Develop detailed documentation for users and contributors", - "dependencies": [ - 1, - 7, - 8 - ], + "dependencies": [1, 7, 8], "details": "Write user-facing documentation including installation guides, command references, and usage examples. Create developer documentation covering architecture, extension points, and contribution guidelines. Implement automated documentation generation from code comments. Prepare tutorials for common use cases and integration scenarios.", "status": "pending" }, @@ -5778,16 +4965,7 @@ "id": 10, "title": "Implement Testing Framework", "description": "Develop a comprehensive testing strategy and implementation", - "dependencies": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], + "dependencies": [1, 2, 3, 4, 5, 6, 7, 8], "details": "Create unit tests for all core components with high coverage targets. Implement integration tests for GitHub API interactions using mocks and fixtures. Design end-to-end tests for complete workflows. Develop performance tests for large repositories and stress testing. Create a test suite for edge cases including rate limiting, network failures, and malformed data.", "status": "pending" } @@ -5902,10 +5080,7 @@ "details": "1. Create a new provider class in `src/ai-providers/google-vertex.js` that extends the existing BaseAIProvider, following the established structure used by other providers (e.g., google.js, openai.js).\n2. Integrate the Vercel AI SDK's `@ai-sdk/google-vertex` package. Use the default `vertex` provider for standard usage, and allow for custom configuration via `createVertex` for advanced scenarios (e.g., specifying project ID, location, and credentials).\n3. Implement all required interface methods (such as `getClient`, `generateText`, etc.) to ensure compatibility with the provider system. Reference the implementation patterns from other providers for consistency.\n4. Handle Vertex AI-specific configuration, including project ID, location, and Google Cloud authentication. Support both environment-based authentication and explicit service account credentials via `googleAuthOptions`.\n5. Implement robust error handling for Vertex-specific issues, including authentication failures and API errors, leveraging the system-wide error handling patterns.\n6. Update `src/ai-providers/index.js` to export the new provider, and add the 'vertex' entry to the PROVIDERS object in `scripts/modules/ai-services-unified.js`.\n7. Update documentation to provide clear setup instructions for Google Vertex AI, including required environment variables, service account setup, and configuration examples.\n8. Ensure the implementation is modular and maintainable, supporting future expansion for additional Vertex AI features or models.", "testStrategy": "- Write unit tests for the new provider class, covering all interface methods and configuration scenarios (default, custom, error cases).\n- Verify that the provider can successfully authenticate using both environment-based and explicit service account credentials.\n- Test integration with the provider system by selecting 'vertex' as the provider and generating text using supported Vertex AI models (e.g., Gemini).\n- Simulate authentication and API errors to confirm robust error handling and user feedback.\n- Confirm that the provider is correctly exported and available in the PROVIDERS object.\n- Review and validate the updated documentation for accuracy and completeness.", "status": "pending", - "dependencies": [ - 19, - 89 - ], + "dependencies": [19, 89], "priority": "medium", "subtasks": [ { @@ -5922,9 +5097,7 @@ "id": 2, "title": "Integrate Vercel AI SDK Google Vertex Package", "description": "Integrate the `@ai-sdk/google-vertex` package, supporting both the default provider and custom configuration via `createVertex`.", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Allow for standard usage with the default `vertex` provider and advanced scenarios using `createVertex` for custom project ID, location, and credentials as per SDK documentation.", "status": "pending", "testStrategy": "Write unit tests to ensure both default and custom provider instances can be created and configured.", @@ -5934,9 +5107,7 @@ "id": 3, "title": "Implement Provider Interface Methods", "description": "Implement all required interface methods (e.g., `getClient`, `generateText`) to ensure compatibility with the provider system.", - "dependencies": [ - 2 - ], + "dependencies": [2], "details": "Reference implementation patterns from other providers to maintain consistency and ensure all required methods are present and functional.", "status": "pending", "testStrategy": "Run integration tests to confirm the provider responds correctly to all interface method calls.", @@ -5946,9 +5117,7 @@ "id": 4, "title": "Handle Vertex AI Configuration and Authentication", "description": "Implement support for Vertex AI-specific configuration, including project ID, location, and authentication via environment variables or explicit service account credentials.", - "dependencies": [ - 3 - ], + "dependencies": [3], "details": "Support both environment-based authentication and explicit credentials using `googleAuthOptions`, following Google Cloud and Vertex AI setup best practices.", "status": "pending", "testStrategy": "Test with both environment variable-based and explicit service account authentication to ensure both methods work as expected.", @@ -5958,9 +5127,7 @@ "id": 5, "title": "Update Exports, Documentation, and Error Handling", "description": "Export the new provider, update the PROVIDERS object, and document setup instructions, including robust error handling for Vertex-specific issues.", - "dependencies": [ - 4 - ], + "dependencies": [4], "details": "Update `src/ai-providers/index.js` and `scripts/modules/ai-services-unified.js`, and provide clear documentation for setup, configuration, and error handling patterns.", "status": "pending", "testStrategy": "Verify the provider is available for import, documentation is accurate, and error handling works by simulating common failure scenarios.", @@ -5975,10 +5142,7 @@ "details": "Implement the Azure OpenAI provider following the established provider pattern:\n\n1. **Create Azure Provider Class** (`src/ai-providers/azure.js`):\n - Extend BaseAIProvider class following the same pattern as openai.js and google.js\n - Import and use `createAzureOpenAI` from `@ai-sdk/azure` package\n - Implement required interface methods: `getClient()`, `validateConfig()`, and any other abstract methods\n - Handle Azure-specific configuration: endpoint URL, API key, and deployment name\n - Add proper error handling for missing or invalid Azure configuration\n\n2. **Configuration Management**:\n - Support environment variables: AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, AZURE_OPENAI_DEPLOYMENT\n - Validate that both endpoint and API key are provided\n - Provide clear error messages for configuration issues\n - Follow the same configuration pattern as other providers\n\n3. **Integration Updates**:\n - Update `src/ai-providers/index.js` to export the new AzureProvider\n - Add 'azure' entry to the PROVIDERS object in `scripts/modules/ai-services-unified.js`\n - Ensure the provider is properly registered and accessible through the unified AI services\n\n4. **Error Handling**:\n - Implement Azure-specific error handling for authentication failures\n - Handle endpoint connectivity issues with helpful error messages\n - Validate deployment name and provide guidance for common configuration mistakes\n - Follow the established error handling patterns from Task 19\n\n5. **Documentation Updates**:\n - Update any provider documentation to include Azure OpenAI setup instructions\n - Add configuration examples for Azure OpenAI environment variables\n - Include troubleshooting guidance for common Azure-specific issues\n\nThe implementation should maintain consistency with existing provider implementations while handling Azure's unique authentication and endpoint requirements.", "testStrategy": "Verify the Azure OpenAI provider implementation through comprehensive testing:\n\n1. **Unit Testing**:\n - Test provider class instantiation and configuration validation\n - Verify getClient() method returns properly configured Azure OpenAI client\n - Test error handling for missing/invalid configuration parameters\n - Validate that the provider correctly extends BaseAIProvider\n\n2. **Integration Testing**:\n - Test provider registration in the unified AI services system\n - Verify the provider appears in the PROVIDERS object and is accessible\n - Test end-to-end functionality with valid Azure OpenAI credentials\n - Validate that the provider works with existing AI operation workflows\n\n3. **Configuration Testing**:\n - Test with various environment variable combinations\n - Verify proper error messages for missing endpoint or API key\n - Test with invalid endpoint URLs and ensure graceful error handling\n - Validate deployment name handling and error reporting\n\n4. **Manual Verification**:\n - Set up test Azure OpenAI credentials and verify successful connection\n - Test actual AI operations (like task expansion) using the Azure provider\n - Verify that the provider selection works correctly in the CLI\n - Confirm that error messages are helpful and actionable for users\n\n5. **Documentation Verification**:\n - Ensure all configuration examples work as documented\n - Verify that setup instructions are complete and accurate\n - Test troubleshooting guidance with common error scenarios", "status": "done", - "dependencies": [ - 19, - 26 - ], + "dependencies": [19, 26], "priority": "medium", "subtasks": [ { @@ -5995,9 +5159,7 @@ "id": 2, "title": "Implement Configuration Management", "description": "Add support for Azure OpenAI environment variables and configuration validation", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Implement configuration management for Azure OpenAI provider that supports environment variables: AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, and AZURE_OPENAI_DEPLOYMENT. Add validation logic to ensure both endpoint and API key are provided. Create clear error messages for configuration issues. Follow the same configuration pattern as implemented in other providers. Ensure the validateConfig() method properly checks all required Azure configuration parameters.", "status": "done", "testStrategy": "Test configuration validation with various combinations of missing or invalid parameters. Verify environment variables are correctly loaded and applied to the provider configuration.", @@ -6007,10 +5169,7 @@ "id": 3, "title": "Update Provider Integration", "description": "Integrate the Azure provider into the existing AI provider system", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Update src/ai-providers/index.js to export the new AzureProvider class. Add 'azure' entry to the PROVIDERS object in scripts/modules/ai-services-unified.js. Ensure the provider is properly registered and accessible through the unified AI services. Test that the provider can be instantiated and used through the provider selection mechanism. Follow the same integration pattern used for existing providers.", "status": "done", "testStrategy": "Create integration tests that verify the Azure provider is correctly registered and can be selected through the provider system. Test that the provider is properly initialized when selected.", @@ -6020,10 +5179,7 @@ "id": 4, "title": "Implement Azure-Specific Error Handling", "description": "Add specialized error handling for Azure OpenAI-specific issues", - "dependencies": [ - 1, - 2 - ], + "dependencies": [1, 2], "details": "Implement Azure-specific error handling for authentication failures, endpoint connectivity issues, and deployment name validation. Provide helpful error messages that guide users to resolve common configuration mistakes. Follow the established error handling patterns from Task 19. Create custom error classes if needed for Azure-specific errors. Ensure errors are properly propagated and formatted for user display.", "status": "done", "testStrategy": "Test error handling by simulating various failure scenarios including authentication failures, invalid endpoints, and missing deployment names. Verify appropriate error messages are generated.", @@ -6033,12 +5189,7 @@ "id": 5, "title": "Update Documentation", "description": "Create comprehensive documentation for the Azure OpenAI provider integration", - "dependencies": [ - 1, - 2, - 3, - 4 - ], + "dependencies": [1, 2, 3, 4], "details": "Update provider documentation to include Azure OpenAI setup instructions. Add configuration examples for Azure OpenAI environment variables. Include troubleshooting guidance for common Azure-specific issues. Document the required Azure resource creation process with references to Microsoft's documentation. Provide examples of valid configuration settings and explain each required parameter. Include information about Azure OpenAI model deployment requirements.", "status": "done", "testStrategy": "Review documentation for completeness, accuracy, and clarity. Ensure all configuration options are documented and examples are provided. Verify troubleshooting guidance addresses common issues identified during implementation.", @@ -6051,12 +5202,7 @@ "title": "Implement .taskmaster Directory Structure", "description": "Consolidate all Task Master-managed files in user projects into a clean, centralized .taskmaster/ directory structure to improve organization and keep user project directories clean, based on GitHub issue #275.", "status": "done", - "dependencies": [ - 1, - 3, - 4, - 17 - ], + "dependencies": [1, 3, 4, 17], "priority": "high", "details": "This task involves restructuring how Task Master organizes files within user projects to improve maintainability and keep project directories clean:\n\n1. Create a new `.taskmaster/` directory structure in user projects:\n - Move task files from `tasks/` to `.taskmaster/tasks/`\n - Move PRD files from `scripts/` to `.taskmaster/docs/`\n - Move analysis reports to `.taskmaster/reports/`\n - Move configuration from `.taskmasterconfig` to `.taskmaster/config.json`\n - Create `.taskmaster/templates/` for user templates\n\n2. Update all Task Master code that creates/reads user files:\n - Modify task file generation to use `.taskmaster/tasks/`\n - Update PRD file handling to use `.taskmaster/docs/`\n - Adjust report generation to save to `.taskmaster/reports/`\n - Update configuration loading to look for `.taskmaster/config.json`\n - Modify any path resolution logic in Task Master's codebase\n\n3. Ensure backward compatibility during migration:\n - Implement path fallback logic that checks both old and new locations\n - Add deprecation warnings when old paths are detected\n - Create a migration command to help users transition to the new structure\n - Preserve existing user data during migration\n\n4. Update the project initialization process:\n - Modify the init command to create the new `.taskmaster/` directory structure\n - Update default file creation to use new paths\n\n5. Benefits of the new structure:\n - Keeps user project directories clean and organized\n - Clearly separates Task Master files from user project files\n - Makes it easier to add Task Master to .gitignore if desired\n - Provides logical grouping of different file types\n\n6. Test thoroughly to ensure all functionality works with the new structure:\n - Verify all Task Master commands work with the new paths\n - Ensure backward compatibility functions correctly\n - Test migration process preserves all user data\n\n7. Update documentation:\n - Update README.md to reflect the new user file structure\n - Add migration guide for existing users\n - Document the benefits of the cleaner organization", "testStrategy": "1. Unit Testing:\n - Create unit tests for path resolution that verify both new and old paths work\n - Test configuration loading with both `.taskmasterconfig` and `.taskmaster/config.json`\n - Verify the migration command correctly moves files and preserves content\n - Test file creation in all new subdirectories\n\n2. Integration Testing:\n - Run all existing integration tests with the new directory structure\n - Verify that all Task Master commands function correctly with new paths\n - Test backward compatibility by running commands with old file structure\n\n3. Migration Testing:\n - Test the migration process on sample projects with existing tasks and files\n - Verify all tasks, PRDs, reports, and configurations are correctly moved\n - Ensure no data loss occurs during migration\n - Test migration with partial existing structures (e.g., only tasks/ exists)\n\n4. User Workflow Testing:\n - Test complete workflows: init → create tasks → generate reports → update PRDs\n - Verify all generated files go to correct locations in `.taskmaster/`\n - Test that user project directories remain clean\n\n5. Manual Testing:\n - Perform end-to-end testing with the new structure\n - Create, update, and delete tasks using the new structure\n - Generate reports and verify they're saved to `.taskmaster/reports/`\n\n6. Documentation Verification:\n - Review all documentation to ensure it accurately reflects the new user file structure\n - Verify the migration guide provides clear instructions\n\n7. Regression Testing:\n - Run the full test suite to ensure no regressions were introduced\n - Verify existing user projects continue to work during transition period", @@ -6074,9 +5220,7 @@ "id": 2, "title": "Update Task Master code for new user file paths", "description": "Modify all Task Master code that creates or reads user project files to use the new .taskmaster structure", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Update Task Master's file handling code to use the new paths: tasks in .taskmaster/tasks/, PRD files in .taskmaster/docs/, reports in .taskmaster/reports/, and config in .taskmaster/config.json. Modify path resolution logic throughout the Task Master codebase to reference the new user file locations.", "status": "done", "testStrategy": "Run unit tests to ensure all Task Master modules can properly create and access user files in new locations. Test configuration loading with the new path structure." @@ -6085,9 +5229,7 @@ "id": 3, "title": "Update task file generation system", "description": "Modify the task file generation system to use the new directory structure", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Update the task file generation system to create and read task files from .taskmaster/tasks/ instead of tasks/. Ensure all template paths are updated. Modify any path resolution logic specific to task file handling.", "status": "done", "testStrategy": "Test creating new tasks and verify they're saved to the correct location. Verify existing tasks can be read from the new location." @@ -6096,10 +5238,7 @@ "id": 4, "title": "Implement backward compatibility logic", "description": "Add fallback mechanisms to support both old and new file locations during transition", - "dependencies": [ - 2, - 3 - ], + "dependencies": [2, 3], "details": "Implement path fallback logic that checks both old and new locations when files aren't found. Add deprecation warnings when old paths are used, informing users about the new structure. Ensure error messages are clear about the transition.", "status": "done", "testStrategy": "Test with both old and new directory structures to verify fallback works correctly. Verify deprecation warnings appear when using old paths." @@ -6108,10 +5247,7 @@ "id": 5, "title": "Create migration command for users", "description": "Develop a Task Master command to help users transition their existing projects to the new structure", - "dependencies": [ - 1, - 4 - ], + "dependencies": [1, 4], "details": "Create a 'taskmaster migrate' command that automatically moves user files from old locations to the new .taskmaster structure. Move tasks/ to .taskmaster/tasks/, scripts/prd.txt to .taskmaster/docs/, reports to .taskmaster/reports/, and .taskmasterconfig to .taskmaster/config.json. Include backup functionality and validation to ensure migration completed successfully.", "status": "done", "testStrategy": "Test the migration command on various user project configurations. Verify it handles edge cases like missing directories or partial existing structures." @@ -6120,9 +5256,7 @@ "id": 6, "title": "Update project initialization process", "description": "Modify the init command to create the new directory structure for new projects", - "dependencies": [ - 1 - ], + "dependencies": [1], "details": "Update the init command to create the .taskmaster directory and its subdirectories (tasks/, docs/, reports/, templates/). Modify default file creation to use the new paths. Ensure new projects are created with the correct structure from the start.", "status": "done", "testStrategy": "Test initializing new projects and verify the correct .taskmaster directory structure is created. Check that default configurations are properly set up in the new location." @@ -6131,10 +5265,7 @@ "id": 7, "title": "Update PRD and report file handling", "description": "Modify PRD file creation and report generation to use the new directory structure", - "dependencies": [ - 2, - 6 - ], + "dependencies": [2, 6], "details": "Update PRD file handling to create and read files from .taskmaster/docs/ instead of scripts/. Modify report generation (like task-complexity-report.json) to save to .taskmaster/reports/. Ensure all file operations use the new paths consistently.", "status": "done", "testStrategy": "Test PRD file creation and updates in the new location. Verify reports are generated and saved to .taskmaster/reports/. Test reading existing PRD files from new location." @@ -6143,11 +5274,7 @@ "id": 8, "title": "Update documentation and create migration guide", "description": "Update all documentation to reflect the new directory structure and provide migration guidance", - "dependencies": [ - 5, - 6, - 7 - ], + "dependencies": [5, 6, 7], "details": "Update README.md and other documentation to reflect the new .taskmaster structure for user projects. Create a comprehensive migration guide explaining the benefits of the new structure and how to migrate existing projects. Include examples of the new directory layout and explain how it keeps user project directories clean.", "status": "done", "testStrategy": "Review documentation for accuracy and completeness. Have users follow the migration guide to verify it's clear and effective." @@ -6156,10 +5283,7 @@ "id": 9, "title": "Add templates directory support", "description": "Implement support for user templates in the .taskmaster/templates/ directory", - "dependencies": [ - 2, - 6 - ], + "dependencies": [2, 6], "details": "Create functionality to support user-defined templates in .taskmaster/templates/. Allow users to store custom task templates, PRD templates, or other reusable files. Update Task Master commands to recognize and use templates from this directory when available.", "status": "done", "testStrategy": "Test creating and using custom templates from .taskmaster/templates/. Verify template discovery and usage works correctly. Test that missing templates directory doesn't break functionality." @@ -6168,10 +5292,7 @@ "id": 10, "title": "Verify clean user project directories", "description": "Ensure the new structure keeps user project root directories clean and organized", - "dependencies": [ - 8, - 9 - ], + "dependencies": [8, 9], "details": "Validate that after implementing the new structure, user project root directories only contain their actual project files plus the single .taskmaster/ directory. Verify that no Task Master files are created outside of .taskmaster/. Test that users can easily add .taskmaster/ to .gitignore if they choose to exclude Task Master files from version control.", "status": "done", "testStrategy": "Test complete workflows and verify only .taskmaster/ directory is created in project root. Check that all Task Master operations respect the new file organization. Verify .gitignore compatibility." @@ -6179,4 +5300,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index a07ac671..fad3d849 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "task-master-ai", - "version": "0.16.1", + "version": "0.16.2-rc.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "task-master-ai", - "version": "0.16.1", + "version": "0.16.2-rc.0", "license": "MIT WITH Commons-Clause", "dependencies": { "@ai-sdk/amazon-bedrock": "^2.2.9", @@ -29,7 +29,7 @@ "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.21.2", - "fastmcp": "^1.20.5", + "fastmcp": "^2.2.2", "figlet": "^1.8.0", "fuse.js": "^7.1.0", "gradient-string": "^3.0.0", @@ -3593,18 +3593,19 @@ } }, "node_modules/@modelcontextprotocol/sdk": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.8.0.tgz", - "integrity": "sha512-e06W7SwrontJDHwCawNO5SGxG+nU9AAx+jpHHZqGl/WrDBdWOpvirC+s58VpJTB5QemI4jTRcjWT4Pt3Q1NPQQ==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.12.1.tgz", + "integrity": "sha512-KG1CZhZfWg+u8pxeM/mByJDScJSrjjxLc8fwQqbsS8xCjBmQfMNEBTotYdNanKekepnfRI85GtgQlctLFpcYPw==", "license": "MIT", "dependencies": { + "ajv": "^6.12.6", "content-type": "^1.0.5", "cors": "^2.8.5", - "cross-spawn": "^7.0.3", + "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", - "pkce-challenge": "^4.1.0", + "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" @@ -3668,84 +3669,45 @@ } }, "node_modules/@modelcontextprotocol/sdk/node_modules/express": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/express/-/express-5.0.1.tgz", - "integrity": "sha512-ORF7g6qGnD+YtUG9yx4DFoqCShNMmUKiXuT5oWMHiOvt/4WFbHC6yCwQMTSBMno7AqntNCAzzcnnjowRkTL9eQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", "license": "MIT", "dependencies": { "accepts": "^2.0.0", - "body-parser": "^2.0.1", + "body-parser": "^2.2.0", "content-disposition": "^1.0.0", - "content-type": "~1.0.4", - "cookie": "0.7.1", + "content-type": "^1.0.5", + "cookie": "^0.7.1", "cookie-signature": "^1.2.1", - "debug": "4.3.6", - "depd": "2.0.0", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "^2.0.0", - "fresh": "2.0.0", - "http-errors": "2.0.0", + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", - "methods": "~1.1.2", "mime-types": "^3.0.0", - "on-finished": "2.4.1", - "once": "1.4.0", - "parseurl": "~1.3.3", - "proxy-addr": "~2.0.7", - "qs": "6.13.0", - "range-parser": "~1.2.1", - "router": "^2.0.0", - "safe-buffer": "5.2.1", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", "send": "^1.1.0", - "serve-static": "^2.1.0", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "^2.0.0", - "utils-merge": "1.0.1", - "vary": "~1.1.2" + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" }, "engines": { "node": ">= 18" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "license": "MIT" - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.0.6" - }, - "engines": { - "node": ">=0.6" }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/@modelcontextprotocol/sdk/node_modules/finalhandler": { @@ -4640,6 +4602,12 @@ "node": ">=18.0.0" } }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", + "license": "MIT" + }, "node_modules/@tokenizer/inflate": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.2.7.tgz", @@ -4884,6 +4852,22 @@ } } }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/ansi-align": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", @@ -6432,9 +6416,9 @@ } }, "node_modules/eventsource": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.6.tgz", - "integrity": "sha512-l19WpE2m9hSuyP06+FbuUUf1G+R0SFLrtQfbRb9PRr+oimOfxQhgGCbVaXg5IvZyyTThJsxh6L/srkMiCeBPDA==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", "license": "MIT", "dependencies": { "eventsource-parser": "^3.0.1" @@ -6636,6 +6620,12 @@ "node": ">=4" } }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, "node_modules/fast-glob": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", @@ -6657,7 +6647,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true, "license": "MIT" }, "node_modules/fast-safe-stringify": { @@ -6690,22 +6679,24 @@ } }, "node_modules/fastmcp": { - "version": "1.20.5", - "resolved": "https://registry.npmjs.org/fastmcp/-/fastmcp-1.20.5.tgz", - "integrity": "sha512-jwcPgMF9bcE9qsEG82YMlAG26/n5CSYsr95e60ntqWWd+3kgTBbUIasB3HfpqHLTNaQuoX6/jl18fpDcybBjcQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/fastmcp/-/fastmcp-2.2.2.tgz", + "integrity": "sha512-V6qEfOnABo7lDrwHqZQhCYd52KXzK85/ipllmUyaos8WLAjygP9NuuKcm1kiEWa0jjsFxe2kf/Y+T4PRE+0rEw==", "license": "MIT", "dependencies": { - "@modelcontextprotocol/sdk": "^1.6.0", + "@modelcontextprotocol/sdk": "^1.10.2", + "@standard-schema/spec": "^1.0.0", "execa": "^9.5.2", - "file-type": "^20.3.0", + "file-type": "^20.4.1", "fuse.js": "^7.1.0", - "mcp-proxy": "^2.10.4", + "mcp-proxy": "^3.0.3", "strict-event-emitter-types": "^2.0.0", - "undici": "^7.4.0", + "undici": "^7.8.0", "uri-templates": "^0.2.0", + "xsschema": "0.3.0-beta.1", "yargs": "^17.7.2", - "zod": "^3.24.2", - "zod-to-json-schema": "^3.24.3" + "zod": "^3.25.12", + "zod-to-json-schema": "^3.24.5" }, "bin": { "fastmcp": "dist/bin/fastmcp.js" @@ -9104,6 +9095,12 @@ "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", "license": "(AFL-2.1 OR BSD-3-Clause)" }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT" + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -9383,19 +9380,31 @@ } }, "node_modules/mcp-proxy": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/mcp-proxy/-/mcp-proxy-2.12.0.tgz", - "integrity": "sha512-hL2Y6EtK7vkgAOZxOQe9M4Z9g5xEnvR4ZYBKqFi/5tjhz/1jyNEz5NL87Uzv46k8iZQPVNEof/T6arEooBU5bQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/mcp-proxy/-/mcp-proxy-3.3.0.tgz", + "integrity": "sha512-xyFKQEZ64HC7lxScBHjb5fxiPoyJjjkPhwH5hWUT0oL/ttCpMGZDJrYZRGFKVJiLLkrZPAkHnMGkI+WMlyD/cg==", "license": "MIT", "dependencies": { - "@modelcontextprotocol/sdk": "^1.6.0", - "eventsource": "^3.0.5", + "@modelcontextprotocol/sdk": "^1.11.4", + "eventsource": "^4.0.0", "yargs": "^17.7.2" }, "bin": { "mcp-proxy": "dist/bin/mcp-proxy.js" } }, + "node_modules/mcp-proxy/node_modules/eventsource": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-4.0.0.tgz", + "integrity": "sha512-fvIkb9qZzdMxgZrEQDyll+9oJsyaVvY92I2Re+qK0qEJ+w5s0X3dtz+M0VAPOjP1gtU3iqWyjQ0G3nvd5CLZ2g==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -10085,9 +10094,9 @@ } }, "node_modules/pkce-challenge": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-4.1.0.tgz", - "integrity": "sha512-ZBmhE1C9LcPoH9XZSdwiPtbPHZROwAnMy+kIFQVrnMCxY4Cudlz3gBOpzilgc0jOgRaiT3sIWfpMomW2ar2orQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", + "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==", "license": "MIT", "engines": { "node": ">=16.20.0" @@ -11319,9 +11328,9 @@ } }, "node_modules/undici": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.6.0.tgz", - "integrity": "sha512-gaFsbThjrDGvAaD670r81RZro/s6H2PVZF640Qn0p5kZK+/rim7/mmyfp2W7VB5vOMaFM8vuFBJUaMlaZTYHlA==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.10.0.tgz", + "integrity": "sha512-u5otvFBOBZvmdjWLVW+5DAc9Nkq8f24g0O9oY7qw2JVIF1VocIFoyz9JFkuVOS2j41AufeO0xnlweJ2RLT8nGw==", "license": "MIT", "engines": { "node": ">=20.18.1" @@ -11395,6 +11404,15 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/uri-templates": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/uri-templates/-/uri-templates-0.2.0.tgz", @@ -11605,6 +11623,40 @@ } } }, + "node_modules/xsschema": { + "version": "0.3.0-beta.1", + "resolved": "https://registry.npmjs.org/xsschema/-/xsschema-0.3.0-beta.1.tgz", + "integrity": "sha512-Z7ZlPKLTc8iUKVfic0Lr66NB777wJqZl3JVLIy1vaNxx6NNTuylYm4wbK78Sgg7kHwaPRqFnuT4IliQM1sDxvg==", + "license": "MIT", + "peerDependencies": { + "@valibot/to-json-schema": "^1.0.0", + "arktype": "^2.1.16", + "effect": "^3.14.5", + "sury": "^10.0.0-rc", + "zod": "^3.25.0", + "zod-to-json-schema": "^3.24.5" + }, + "peerDependenciesMeta": { + "@valibot/to-json-schema": { + "optional": true + }, + "arktype": { + "optional": true + }, + "effect": { + "optional": true + }, + "sury": { + "optional": true + }, + "zod": { + "optional": true + }, + "zod-to-json-schema": { + "optional": true + } + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -11734,9 +11786,9 @@ "license": "MIT" }, "node_modules/zod": { - "version": "3.24.2", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", - "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", + "version": "3.25.56", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.56.tgz", + "integrity": "sha512-rd6eEF3BTNvQnR2e2wwolfTmUTnp70aUTqr0oaGbHifzC3BKJsoV+Gat8vxUMR1hwOKBs6El+qWehrHbCpW6SQ==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/scripts/modules/ai-services-unified.js b/scripts/modules/ai-services-unified.js index ca702701..adcad88d 100644 --- a/scripts/modules/ai-services-unified.js +++ b/scripts/modules/ai-services-unified.js @@ -8,82 +8,82 @@ // --- Core Dependencies --- import { - getMainProvider, - getMainModelId, - getResearchProvider, - getResearchModelId, - getFallbackProvider, - getFallbackModelId, - getParametersForRole, - getUserId, - MODEL_MAP, - getDebugFlag, - getBaseUrlForRole, - isApiKeySet, - getOllamaBaseURL, - getAzureBaseURL, - getBedrockBaseURL, - getVertexProjectId, - getVertexLocation -} from './config-manager.js'; -import { log, findProjectRoot, resolveEnvVariable } from './utils.js'; + getMainProvider, + getMainModelId, + getResearchProvider, + getResearchModelId, + getFallbackProvider, + getFallbackModelId, + getParametersForRole, + getUserId, + MODEL_MAP, + getDebugFlag, + getBaseUrlForRole, + isApiKeySet, + getOllamaBaseURL, + getAzureBaseURL, + getBedrockBaseURL, + getVertexProjectId, + getVertexLocation, +} from "./config-manager.js"; +import { log, findProjectRoot, resolveEnvVariable } from "./utils.js"; // Import provider classes import { - AnthropicAIProvider, - PerplexityAIProvider, - GoogleAIProvider, - OpenAIProvider, - XAIProvider, - OpenRouterAIProvider, - OllamaAIProvider, - BedrockAIProvider, - AzureProvider, - VertexAIProvider -} from '../../src/ai-providers/index.js'; + AnthropicAIProvider, + PerplexityAIProvider, + GoogleAIProvider, + OpenAIProvider, + XAIProvider, + OpenRouterAIProvider, + OllamaAIProvider, + BedrockAIProvider, + AzureProvider, + VertexAIProvider, +} from "../../src/ai-providers/index.js"; // Create provider instances const PROVIDERS = { - anthropic: new AnthropicAIProvider(), - perplexity: new PerplexityAIProvider(), - google: new GoogleAIProvider(), - openai: new OpenAIProvider(), - xai: new XAIProvider(), - openrouter: new OpenRouterAIProvider(), - ollama: new OllamaAIProvider(), - bedrock: new BedrockAIProvider(), - azure: new AzureProvider(), - vertex: new VertexAIProvider() + anthropic: new AnthropicAIProvider(), + perplexity: new PerplexityAIProvider(), + google: new GoogleAIProvider(), + openai: new OpenAIProvider(), + xai: new XAIProvider(), + openrouter: new OpenRouterAIProvider(), + ollama: new OllamaAIProvider(), + bedrock: new BedrockAIProvider(), + azure: new AzureProvider(), + vertex: new VertexAIProvider(), }; // Helper function to get cost for a specific model function _getCostForModel(providerName, modelId) { - if (!MODEL_MAP || !MODEL_MAP[providerName]) { - log( - 'warn', - `Provider "${providerName}" not found in MODEL_MAP. Cannot determine cost for model ${modelId}.` - ); - return { inputCost: 0, outputCost: 0, currency: 'USD' }; // Default to zero cost - } + if (!MODEL_MAP || !MODEL_MAP[providerName]) { + log( + "warn", + `Provider "${providerName}" not found in MODEL_MAP. Cannot determine cost for model ${modelId}.` + ); + return { inputCost: 0, outputCost: 0, currency: "USD" }; // Default to zero cost + } - const modelData = MODEL_MAP[providerName].find((m) => m.id === modelId); + const modelData = MODEL_MAP[providerName].find((m) => m.id === modelId); - if (!modelData || !modelData.cost_per_1m_tokens) { - log( - 'debug', - `Cost data not found for model "${modelId}" under provider "${providerName}". Assuming zero cost.` - ); - return { inputCost: 0, outputCost: 0, currency: 'USD' }; // Default to zero cost - } + if (!modelData || !modelData.cost_per_1m_tokens) { + log( + "debug", + `Cost data not found for model "${modelId}" under provider "${providerName}". Assuming zero cost.` + ); + return { inputCost: 0, outputCost: 0, currency: "USD" }; // Default to zero cost + } - // Ensure currency is part of the returned object, defaulting if not present - const currency = modelData.cost_per_1m_tokens.currency || 'USD'; + // Ensure currency is part of the returned object, defaulting if not present + const currency = modelData.cost_per_1m_tokens.currency || "USD"; - return { - inputCost: modelData.cost_per_1m_tokens.input || 0, - outputCost: modelData.cost_per_1m_tokens.output || 0, - currency: currency - }; + return { + inputCost: modelData.cost_per_1m_tokens.input || 0, + outputCost: modelData.cost_per_1m_tokens.output || 0, + currency: currency, + }; } // --- Configuration for Retries --- @@ -92,16 +92,16 @@ const INITIAL_RETRY_DELAY_MS = 1000; // Helper function to check if an error is retryable function isRetryableError(error) { - const errorMessage = error.message?.toLowerCase() || ''; - return ( - errorMessage.includes('rate limit') || - errorMessage.includes('overloaded') || - errorMessage.includes('service temporarily unavailable') || - errorMessage.includes('timeout') || - errorMessage.includes('network error') || - error.status === 429 || - error.status >= 500 - ); + const errorMessage = error.message?.toLowerCase() || ""; + return ( + errorMessage.includes("rate limit") || + errorMessage.includes("overloaded") || + errorMessage.includes("service temporarily unavailable") || + errorMessage.includes("timeout") || + errorMessage.includes("network error") || + error.status === 429 || + error.status >= 500 + ); } /** @@ -111,45 +111,45 @@ function isRetryableError(error) { * @returns {string} A concise error message. */ function _extractErrorMessage(error) { - try { - // Attempt 1: Look for Vercel SDK specific nested structure (common) - if (error?.data?.error?.message) { - return error.data.error.message; - } + try { + // Attempt 1: Look for Vercel SDK specific nested structure (common) + if (error?.data?.error?.message) { + return error.data.error.message; + } - // Attempt 2: Look for nested error message directly in the error object - if (error?.error?.message) { - return error.error.message; - } + // Attempt 2: Look for nested error message directly in the error object + if (error?.error?.message) { + return error.error.message; + } - // Attempt 3: Look for nested error message in response body if it's JSON string - if (typeof error?.responseBody === 'string') { - try { - const body = JSON.parse(error.responseBody); - if (body?.error?.message) { - return body.error.message; - } - } catch (parseError) { - // Ignore if responseBody is not valid JSON - } - } + // Attempt 3: Look for nested error message in response body if it's JSON string + if (typeof error?.responseBody === "string") { + try { + const body = JSON.parse(error.responseBody); + if (body?.error?.message) { + return body.error.message; + } + } catch (parseError) { + // Ignore if responseBody is not valid JSON + } + } - // Attempt 4: Use the top-level message if it exists - if (typeof error?.message === 'string' && error.message) { - return error.message; - } + // Attempt 4: Use the top-level message if it exists + if (typeof error?.message === "string" && error.message) { + return error.message; + } - // Attempt 5: Handle simple string errors - if (typeof error === 'string') { - return error; - } + // Attempt 5: Handle simple string errors + if (typeof error === "string") { + return error; + } - // Fallback - return 'An unknown AI service error occurred.'; - } catch (e) { - // Safety net - return 'Failed to extract error message.'; - } + // Fallback + return "An unknown AI service error occurred."; + } catch (e) { + // Safety net + return "Failed to extract error message."; + } } /** @@ -161,40 +161,40 @@ function _extractErrorMessage(error) { * @throws {Error} If a required API key is missing. */ function _resolveApiKey(providerName, session, projectRoot = null) { - const keyMap = { - openai: 'OPENAI_API_KEY', - anthropic: 'ANTHROPIC_API_KEY', - google: 'GOOGLE_API_KEY', - perplexity: 'PERPLEXITY_API_KEY', - mistral: 'MISTRAL_API_KEY', - azure: 'AZURE_OPENAI_API_KEY', - openrouter: 'OPENROUTER_API_KEY', - xai: 'XAI_API_KEY', - ollama: 'OLLAMA_API_KEY', - bedrock: 'AWS_ACCESS_KEY_ID', - vertex: 'GOOGLE_API_KEY' - }; + const keyMap = { + openai: "OPENAI_API_KEY", + anthropic: "ANTHROPIC_API_KEY", + google: "GOOGLE_API_KEY", + perplexity: "PERPLEXITY_API_KEY", + mistral: "MISTRAL_API_KEY", + azure: "AZURE_OPENAI_API_KEY", + openrouter: "OPENROUTER_API_KEY", + xai: "XAI_API_KEY", + ollama: "OLLAMA_API_KEY", + bedrock: "AWS_ACCESS_KEY_ID", + vertex: "GOOGLE_API_KEY", + }; - const envVarName = keyMap[providerName]; - if (!envVarName) { - throw new Error( - `Unknown provider '${providerName}' for API key resolution.` - ); - } + const envVarName = keyMap[providerName]; + if (!envVarName) { + throw new Error( + `Unknown provider '${providerName}' for API key resolution.` + ); + } - const apiKey = resolveEnvVariable(envVarName, session, projectRoot); + const apiKey = resolveEnvVariable(envVarName, session, projectRoot); - // Special handling for providers that can use alternative auth - if (providerName === 'ollama' || providerName === 'bedrock') { - return apiKey || null; - } + // Special handling for providers that can use alternative auth + if (providerName === "ollama" || providerName === "bedrock") { + return apiKey || null; + } - if (!apiKey) { - throw new Error( - `Required API key ${envVarName} for provider '${providerName}' is not set in environment, session, or .env file.` - ); - } - return apiKey; + if (!apiKey) { + throw new Error( + `Required API key ${envVarName} for provider '${providerName}' is not set in environment, session, or .env file.` + ); + } + return apiKey; } /** @@ -209,62 +209,62 @@ function _resolveApiKey(providerName, session, projectRoot = null) { * @throws {Error} If the call fails after all retries. */ async function _attemptProviderCallWithRetries( - provider, - serviceType, - callParams, - providerName, - modelId, - attemptRole + provider, + serviceType, + callParams, + providerName, + modelId, + attemptRole ) { - let retries = 0; - const fnName = serviceType; + let retries = 0; + const fnName = serviceType; - while (retries <= MAX_RETRIES) { - try { - if (getDebugFlag()) { - log( - 'info', - `Attempt ${retries + 1}/${MAX_RETRIES + 1} calling ${fnName} (Provider: ${providerName}, Model: ${modelId}, Role: ${attemptRole})` - ); - } + while (retries <= MAX_RETRIES) { + try { + if (getDebugFlag()) { + log( + "info", + `Attempt ${retries + 1}/${MAX_RETRIES + 1} calling ${fnName} (Provider: ${providerName}, Model: ${modelId}, Role: ${attemptRole})` + ); + } - // Call the appropriate method on the provider instance - const result = await provider[serviceType](callParams); + // Call the appropriate method on the provider instance + const result = await provider[serviceType](callParams); - if (getDebugFlag()) { - log( - 'info', - `${fnName} succeeded for role ${attemptRole} (Provider: ${providerName}) on attempt ${retries + 1}` - ); - } - return result; - } catch (error) { - log( - 'warn', - `Attempt ${retries + 1} failed for role ${attemptRole} (${fnName} / ${providerName}): ${error.message}` - ); + if (getDebugFlag()) { + log( + "info", + `${fnName} succeeded for role ${attemptRole} (Provider: ${providerName}) on attempt ${retries + 1}` + ); + } + return result; + } catch (error) { + log( + "warn", + `Attempt ${retries + 1} failed for role ${attemptRole} (${fnName} / ${providerName}): ${error.message}` + ); - if (isRetryableError(error) && retries < MAX_RETRIES) { - retries++; - const delay = INITIAL_RETRY_DELAY_MS * Math.pow(2, retries - 1); - log( - 'info', - `Something went wrong on the provider side. Retrying in ${delay / 1000}s...` - ); - await new Promise((resolve) => setTimeout(resolve, delay)); - } else { - log( - 'error', - `Something went wrong on the provider side. Max retries reached for role ${attemptRole} (${fnName} / ${providerName}).` - ); - throw error; - } - } - } - // Should not be reached due to throw in the else block - throw new Error( - `Exhausted all retries for role ${attemptRole} (${fnName} / ${providerName})` - ); + if (isRetryableError(error) && retries < MAX_RETRIES) { + retries++; + const delay = INITIAL_RETRY_DELAY_MS * Math.pow(2, retries - 1); + log( + "info", + `Something went wrong on the provider side. Retrying in ${delay / 1000}s...` + ); + await new Promise((resolve) => setTimeout(resolve, delay)); + } else { + log( + "error", + `Something went wrong on the provider side. Max retries reached for role ${attemptRole} (${fnName} / ${providerName}).` + ); + throw error; + } + } + } + // Should not be reached due to throw in the else block + throw new Error( + `Exhausted all retries for role ${attemptRole} (${fnName} / ${providerName})` + ); } /** @@ -283,312 +283,313 @@ async function _attemptProviderCallWithRetries( * @returns {Promise<any>} Result from the underlying provider call. */ async function _unifiedServiceRunner(serviceType, params) { - const { - role: initialRole, - session, - projectRoot, - systemPrompt, - prompt, - schema, - objectName, - commandName, - outputType, - ...restApiParams - } = params; - if (getDebugFlag()) { - log('info', `${serviceType}Service called`, { - role: initialRole, - commandName, - outputType, - projectRoot - }); - } + const { + role: initialRole, + session, + projectRoot, + systemPrompt, + prompt, + schema, + objectName, + commandName, + outputType, + ...restApiParams + } = params; + if (getDebugFlag()) { + log("info", `${serviceType}Service called`, { + role: initialRole, + commandName, + outputType, + projectRoot, + }); + } - const effectiveProjectRoot = projectRoot || findProjectRoot(); - const userId = getUserId(effectiveProjectRoot); + const effectiveProjectRoot = projectRoot || findProjectRoot(); + const userId = getUserId(effectiveProjectRoot); - let sequence; - if (initialRole === 'main') { - sequence = ['main', 'fallback', 'research']; - } else if (initialRole === 'research') { - sequence = ['research', 'fallback', 'main']; - } else if (initialRole === 'fallback') { - sequence = ['fallback', 'main', 'research']; - } else { - log( - 'warn', - `Unknown initial role: ${initialRole}. Defaulting to main -> fallback -> research sequence.` - ); - sequence = ['main', 'fallback', 'research']; - } + let sequence; + if (initialRole === "main") { + sequence = ["main", "fallback", "research"]; + } else if (initialRole === "research") { + sequence = ["research", "fallback", "main"]; + } else if (initialRole === "fallback") { + sequence = ["fallback", "main", "research"]; + } else { + log( + "warn", + `Unknown initial role: ${initialRole}. Defaulting to main -> fallback -> research sequence.` + ); + sequence = ["main", "fallback", "research"]; + } - let lastError = null; - let lastCleanErrorMessage = - 'AI service call failed for all configured roles.'; + let lastError = null; + let lastCleanErrorMessage = + "AI service call failed for all configured roles."; - for (const currentRole of sequence) { - let providerName, - modelId, - apiKey, - roleParams, - provider, - baseURL, - providerResponse, - telemetryData = null; + for (const currentRole of sequence) { + let providerName, + modelId, + apiKey, + roleParams, + provider, + baseURL, + providerResponse, + telemetryData = null; - try { - log('info', `New AI service call with role: ${currentRole}`); + try { + log("info", `New AI service call with role: ${currentRole}`); - if (currentRole === 'main') { - providerName = getMainProvider(effectiveProjectRoot); - modelId = getMainModelId(effectiveProjectRoot); - } else if (currentRole === 'research') { - providerName = getResearchProvider(effectiveProjectRoot); - modelId = getResearchModelId(effectiveProjectRoot); - } else if (currentRole === 'fallback') { - providerName = getFallbackProvider(effectiveProjectRoot); - modelId = getFallbackModelId(effectiveProjectRoot); - } else { - log( - 'error', - `Unknown role encountered in _unifiedServiceRunner: ${currentRole}` - ); - lastError = - lastError || new Error(`Unknown AI role specified: ${currentRole}`); - continue; - } + if (currentRole === "main") { + providerName = getMainProvider(effectiveProjectRoot); + modelId = getMainModelId(effectiveProjectRoot); + } else if (currentRole === "research") { + providerName = getResearchProvider(effectiveProjectRoot); + modelId = getResearchModelId(effectiveProjectRoot); + } else if (currentRole === "fallback") { + providerName = getFallbackProvider(effectiveProjectRoot); + modelId = getFallbackModelId(effectiveProjectRoot); + } else { + log( + "error", + `Unknown role encountered in _unifiedServiceRunner: ${currentRole}` + ); + lastError = + lastError || new Error(`Unknown AI role specified: ${currentRole}`); + continue; + } - if (!providerName || !modelId) { - log( - 'warn', - `Skipping role '${currentRole}': Provider or Model ID not configured.` - ); - lastError = - lastError || - new Error( - `Configuration missing for role '${currentRole}'. Provider: ${providerName}, Model: ${modelId}` - ); - continue; - } + if (!providerName || !modelId) { + log( + "warn", + `Skipping role '${currentRole}': Provider or Model ID not configured.` + ); + lastError = + lastError || + new Error( + `Configuration missing for role '${currentRole}'. Provider: ${providerName}, Model: ${modelId}` + ); + continue; + } - // Get provider instance - provider = PROVIDERS[providerName?.toLowerCase()]; - if (!provider) { - log( - 'warn', - `Skipping role '${currentRole}': Provider '${providerName}' not supported.` - ); - lastError = - lastError || - new Error(`Unsupported provider configured: ${providerName}`); - continue; - } + // Get provider instance + provider = PROVIDERS[providerName?.toLowerCase()]; + if (!provider) { + log( + "warn", + `Skipping role '${currentRole}': Provider '${providerName}' not supported.` + ); + lastError = + lastError || + new Error(`Unsupported provider configured: ${providerName}`); + continue; + } - // Check API key if needed - if (providerName?.toLowerCase() !== 'ollama') { - if (!isApiKeySet(providerName, session, effectiveProjectRoot)) { - log( - 'warn', - `Skipping role '${currentRole}' (Provider: ${providerName}): API key not set or invalid.` - ); - lastError = - lastError || - new Error( - `API key for provider '${providerName}' (role: ${currentRole}) is not set.` - ); - continue; // Skip to the next role in the sequence - } - } + // Check API key if needed + if (providerName?.toLowerCase() !== "ollama") { + if (!isApiKeySet(providerName, session, effectiveProjectRoot)) { + log( + "warn", + `Skipping role '${currentRole}' (Provider: ${providerName}): API key not set or invalid.` + ); + lastError = + lastError || + new Error( + `API key for provider '${providerName}' (role: ${currentRole}) is not set.` + ); + continue; // Skip to the next role in the sequence + } + } - // Get base URL if configured (optional for most providers) - baseURL = getBaseUrlForRole(currentRole, effectiveProjectRoot); + // Get base URL if configured (optional for most providers) + baseURL = getBaseUrlForRole(currentRole, effectiveProjectRoot); - // For Azure, use the global Azure base URL if role-specific URL is not configured - if (providerName?.toLowerCase() === 'azure' && !baseURL) { - baseURL = getAzureBaseURL(effectiveProjectRoot); - log('debug', `Using global Azure base URL: ${baseURL}`); - } else if (providerName?.toLowerCase() === 'ollama' && !baseURL) { - // For Ollama, use the global Ollama base URL if role-specific URL is not configured - baseURL = getOllamaBaseURL(effectiveProjectRoot); - log('debug', `Using global Ollama base URL: ${baseURL}`); - } else if (providerName?.toLowerCase() === 'bedrock' && !baseURL) { - // For Bedrock, use the global Bedrock base URL if role-specific URL is not configured - baseURL = getBedrockBaseURL(effectiveProjectRoot); - log('debug', `Using global Bedrock base URL: ${baseURL}`); - } + // For Azure, use the global Azure base URL if role-specific URL is not configured + if (providerName?.toLowerCase() === "azure" && !baseURL) { + baseURL = getAzureBaseURL(effectiveProjectRoot); + log("debug", `Using global Azure base URL: ${baseURL}`); + } else if (providerName?.toLowerCase() === "ollama" && !baseURL) { + // For Ollama, use the global Ollama base URL if role-specific URL is not configured + baseURL = getOllamaBaseURL(effectiveProjectRoot); + log("debug", `Using global Ollama base URL: ${baseURL}`); + } else if (providerName?.toLowerCase() === "bedrock" && !baseURL) { + // For Bedrock, use the global Bedrock base URL if role-specific URL is not configured + baseURL = getBedrockBaseURL(effectiveProjectRoot); + log("debug", `Using global Bedrock base URL: ${baseURL}`); + } - // Get AI parameters for the current role - roleParams = getParametersForRole(currentRole, effectiveProjectRoot); - apiKey = _resolveApiKey( - providerName?.toLowerCase(), - session, - effectiveProjectRoot - ); + // Get AI parameters for the current role + roleParams = getParametersForRole(currentRole, effectiveProjectRoot); + apiKey = _resolveApiKey( + providerName?.toLowerCase(), + session, + effectiveProjectRoot + ); - // Prepare provider-specific configuration - let providerSpecificParams = {}; + // Prepare provider-specific configuration + let providerSpecificParams = {}; - // Handle Vertex AI specific configuration - if (providerName?.toLowerCase() === 'vertex') { - // Get Vertex project ID and location - const projectId = - getVertexProjectId(effectiveProjectRoot) || - resolveEnvVariable( - 'VERTEX_PROJECT_ID', - session, - effectiveProjectRoot - ); + // Handle Vertex AI specific configuration + if (providerName?.toLowerCase() === "vertex") { + // Get Vertex project ID and location + const projectId = + getVertexProjectId(effectiveProjectRoot) || + resolveEnvVariable( + "VERTEX_PROJECT_ID", + session, + effectiveProjectRoot + ); - const location = - getVertexLocation(effectiveProjectRoot) || - resolveEnvVariable( - 'VERTEX_LOCATION', - session, - effectiveProjectRoot - ) || - 'us-central1'; + const location = + getVertexLocation(effectiveProjectRoot) || + resolveEnvVariable( + "VERTEX_LOCATION", + session, + effectiveProjectRoot + ) || + "us-central1"; - // Get credentials path if available - const credentialsPath = resolveEnvVariable( - 'GOOGLE_APPLICATION_CREDENTIALS', - session, - effectiveProjectRoot - ); + // Get credentials path if available + const credentialsPath = resolveEnvVariable( + "GOOGLE_APPLICATION_CREDENTIALS", + session, + effectiveProjectRoot + ); - // Add Vertex-specific parameters - providerSpecificParams = { - projectId, - location, - ...(credentialsPath && { credentials: { credentialsFromEnv: true } }) - }; + // Add Vertex-specific parameters + providerSpecificParams = { + projectId, + location, + ...(credentialsPath && { credentials: { credentialsFromEnv: true } }), + }; - log( - 'debug', - `Using Vertex AI configuration: Project ID=${projectId}, Location=${location}` - ); - } + log( + "debug", + `Using Vertex AI configuration: Project ID=${projectId}, Location=${location}` + ); + } - const messages = []; - if (systemPrompt) { - messages.push({ role: 'system', content: systemPrompt }); - } + const messages = []; + if (systemPrompt) { + messages.push({ role: "system", content: systemPrompt }); + } - // IN THE FUTURE WHEN DOING CONTEXT IMPROVEMENTS - // { - // type: 'text', - // text: 'Large cached context here like a tasks json', - // providerOptions: { - // anthropic: { cacheControl: { type: 'ephemeral' } } - // } - // } + // IN THE FUTURE WHEN DOING CONTEXT IMPROVEMENTS + // { + // type: 'text', + // text: 'Large cached context here like a tasks json', + // providerOptions: { + // anthropic: { cacheControl: { type: 'ephemeral' } } + // } + // } - // Example - // if (params.context) { // context is a json string of a tasks object or some other stu - // messages.push({ - // type: 'text', - // text: params.context, - // providerOptions: { anthropic: { cacheControl: { type: 'ephemeral' } } } - // }); - // } + // Example + // if (params.context) { // context is a json string of a tasks object or some other stu + // messages.push({ + // type: 'text', + // text: params.context, + // providerOptions: { anthropic: { cacheControl: { type: 'ephemeral' } } } + // }); + // } - if (prompt) { - messages.push({ role: 'user', content: prompt }); - } else { - throw new Error('User prompt content is missing.'); - } + if (prompt) { + messages.push({ role: "user", content: prompt }); + } else { + throw new Error("User prompt content is missing."); + } - const callParams = { - apiKey, - modelId, - maxTokens: roleParams.maxTokens, - temperature: roleParams.temperature, - messages, - ...(baseURL && { baseURL }), - ...(serviceType === 'generateObject' && { schema, objectName }), - ...providerSpecificParams, - ...restApiParams - }; + const callParams = { + apiKey, + modelId, + maxTokens: roleParams.maxTokens, + temperature: roleParams.temperature, + messages, + ...(baseURL && { baseURL }), + ...(serviceType === "generateObject" && { schema, objectName }), + ...providerSpecificParams, + ...restApiParams, + }; - providerResponse = await _attemptProviderCallWithRetries( - provider, - serviceType, - callParams, - providerName, - modelId, - currentRole - ); + providerResponse = await _attemptProviderCallWithRetries( + provider, + serviceType, + callParams, + providerName, + modelId, + currentRole + ); - if (userId && providerResponse && providerResponse.usage) { - try { - telemetryData = await logAiUsage({ - userId, - commandName, - providerName, - modelId, - inputTokens: providerResponse.usage.inputTokens, - outputTokens: providerResponse.usage.outputTokens, - outputType - }); - } catch (telemetryError) { - // logAiUsage already logs its own errors and returns null on failure - // No need to log again here, telemetryData will remain null - } - } else if (userId && providerResponse && !providerResponse.usage) { - log( - 'warn', - `Cannot log telemetry for ${commandName} (${providerName}/${modelId}): AI result missing 'usage' data. (May be expected for streams)` - ); - } + if (userId && providerResponse && providerResponse.usage) { + try { + telemetryData = await logAiUsage({ + userId, + commandName, + providerName, + modelId, + inputTokens: providerResponse.usage.inputTokens, + outputTokens: providerResponse.usage.outputTokens, + outputType, + }); + } catch (telemetryError) { + // logAiUsage already logs its own errors and returns null on failure + // No need to log again here, telemetryData will remain null + } + } else if (userId && providerResponse && !providerResponse.usage) { + log( + "warn", + `Cannot log telemetry for ${commandName} (${providerName}/${modelId}): AI result missing 'usage' data. (May be expected for streams)` + ); + } - let finalMainResult; - if (serviceType === 'generateText') { - finalMainResult = providerResponse.text; - } else if (serviceType === 'generateObject') { - finalMainResult = providerResponse.object; - } else if (serviceType === 'streamText') { - finalMainResult = providerResponse; - } else { - log( - 'error', - `Unknown serviceType in _unifiedServiceRunner: ${serviceType}` - ); - finalMainResult = providerResponse; - } + let finalMainResult; + if (serviceType === "generateText") { + finalMainResult = providerResponse.text; + } else if (serviceType === "generateObject") { + finalMainResult = providerResponse.object; + } else if (serviceType === "streamText") { + finalMainResult = providerResponse; + } else { + log( + "error", + `Unknown serviceType in _unifiedServiceRunner: ${serviceType}` + ); + finalMainResult = providerResponse; + } - return { - mainResult: finalMainResult, - telemetryData: telemetryData - }; - } catch (error) { - const cleanMessage = _extractErrorMessage(error); - log( - 'error', - `Service call failed for role ${currentRole} (Provider: ${providerName || 'unknown'}, Model: ${modelId || 'unknown'}): ${cleanMessage}` - ); - lastError = error; - lastCleanErrorMessage = cleanMessage; + return { + mainResult: finalMainResult, + telemetryData: telemetryData, + }; + } catch (error) { + const cleanMessage = _extractErrorMessage(error); + log( + "error", + `Service call failed for role ${currentRole} (Provider: ${providerName || "unknown"}, Model: ${modelId || "unknown"}): ${cleanMessage}` + ); + lastError = error; + lastCleanErrorMessage = cleanMessage; - if (serviceType === 'generateObject') { - const lowerCaseMessage = cleanMessage.toLowerCase(); - if ( - lowerCaseMessage.includes( - 'no endpoints found that support tool use' - ) || - lowerCaseMessage.includes('does not support tool_use') || - lowerCaseMessage.includes('tool use is not supported') || - lowerCaseMessage.includes('tools are not supported') || - lowerCaseMessage.includes('function calling is not supported') - ) { - const specificErrorMsg = `Model '${modelId || 'unknown'}' via provider '${providerName || 'unknown'}' does not support the 'tool use' required by generateObjectService. Please configure a model that supports tool/function calling for the '${currentRole}' role, or use generateTextService if structured output is not strictly required.`; - log('error', `[Tool Support Error] ${specificErrorMsg}`); - throw new Error(specificErrorMsg); - } - } - } - } + if (serviceType === "generateObject") { + const lowerCaseMessage = cleanMessage.toLowerCase(); + if ( + lowerCaseMessage.includes( + "no endpoints found that support tool use" + ) || + lowerCaseMessage.includes("does not support tool_use") || + lowerCaseMessage.includes("tool use is not supported") || + lowerCaseMessage.includes("tools are not supported") || + lowerCaseMessage.includes("function calling is not supported") || + lowerCaseMessage.includes("tool use is not supported") + ) { + const specificErrorMsg = `Model '${modelId || "unknown"}' via provider '${providerName || "unknown"}' does not support the 'tool use' required by generateObjectService. Please configure a model that supports tool/function calling for the '${currentRole}' role, or use generateTextService if structured output is not strictly required.`; + log("error", `[Tool Support Error] ${specificErrorMsg}`); + throw new Error(specificErrorMsg); + } + } + } + } - log('error', `All roles in the sequence [${sequence.join(', ')}] failed.`); - throw new Error(lastCleanErrorMessage); + log("error", `All roles in the sequence [${sequence.join(", ")}] failed.`); + throw new Error(lastCleanErrorMessage); } /** @@ -606,11 +607,11 @@ async function _unifiedServiceRunner(serviceType, params) { * @returns {Promise<object>} Result object containing generated text and usage data. */ async function generateTextService(params) { - // Ensure default outputType if not provided - const defaults = { outputType: 'cli' }; - const combinedParams = { ...defaults, ...params }; - // TODO: Validate commandName exists? - return _unifiedServiceRunner('generateText', combinedParams); + // Ensure default outputType if not provided + const defaults = { outputType: "cli" }; + const combinedParams = { ...defaults, ...params }; + // TODO: Validate commandName exists? + return _unifiedServiceRunner("generateText", combinedParams); } /** @@ -628,13 +629,13 @@ async function generateTextService(params) { * @returns {Promise<object>} Result object containing the stream and usage data. */ async function streamTextService(params) { - const defaults = { outputType: 'cli' }; - const combinedParams = { ...defaults, ...params }; - // TODO: Validate commandName exists? - // NOTE: Telemetry for streaming might be tricky as usage data often comes at the end. - // The current implementation logs *after* the stream is returned. - // We might need to adjust how usage is captured/logged for streams. - return _unifiedServiceRunner('streamText', combinedParams); + const defaults = { outputType: "cli" }; + const combinedParams = { ...defaults, ...params }; + // TODO: Validate commandName exists? + // NOTE: Telemetry for streaming might be tricky as usage data often comes at the end. + // The current implementation logs *after* the stream is returned. + // We might need to adjust how usage is captured/logged for streams. + return _unifiedServiceRunner("streamText", combinedParams); } /** @@ -655,14 +656,14 @@ async function streamTextService(params) { * @returns {Promise<object>} Result object containing the generated object and usage data. */ async function generateObjectService(params) { - const defaults = { - objectName: 'generated_object', - maxRetries: 3, - outputType: 'cli' - }; - const combinedParams = { ...defaults, ...params }; - // TODO: Validate commandName exists? - return _unifiedServiceRunner('generateObject', combinedParams); + const defaults = { + objectName: "generated_object", + maxRetries: 3, + outputType: "cli", + }; + const combinedParams = { ...defaults, ...params }; + // TODO: Validate commandName exists? + return _unifiedServiceRunner("generateObject", combinedParams); } // --- Telemetry Function --- @@ -678,61 +679,61 @@ async function generateObjectService(params) { * @param {number} params.outputTokens - Number of output tokens. */ async function logAiUsage({ - userId, - commandName, - providerName, - modelId, - inputTokens, - outputTokens, - outputType + userId, + commandName, + providerName, + modelId, + inputTokens, + outputTokens, + outputType, }) { - try { - const isMCP = outputType === 'mcp'; - const timestamp = new Date().toISOString(); - const totalTokens = (inputTokens || 0) + (outputTokens || 0); + try { + const isMCP = outputType === "mcp"; + const timestamp = new Date().toISOString(); + const totalTokens = (inputTokens || 0) + (outputTokens || 0); - // Destructure currency along with costs - const { inputCost, outputCost, currency } = _getCostForModel( - providerName, - modelId - ); + // Destructure currency along with costs + const { inputCost, outputCost, currency } = _getCostForModel( + providerName, + modelId + ); - const totalCost = - ((inputTokens || 0) / 1_000_000) * inputCost + - ((outputTokens || 0) / 1_000_000) * outputCost; + const totalCost = + ((inputTokens || 0) / 1_000_000) * inputCost + + ((outputTokens || 0) / 1_000_000) * outputCost; - const telemetryData = { - timestamp, - userId, - commandName, - modelUsed: modelId, // Consistent field name from requirements - providerName, // Keep provider name for context - inputTokens: inputTokens || 0, - outputTokens: outputTokens || 0, - totalTokens, - totalCost: parseFloat(totalCost.toFixed(6)), - currency // Add currency to the telemetry data - }; + const telemetryData = { + timestamp, + userId, + commandName, + modelUsed: modelId, // Consistent field name from requirements + providerName, // Keep provider name for context + inputTokens: inputTokens || 0, + outputTokens: outputTokens || 0, + totalTokens, + totalCost: parseFloat(totalCost.toFixed(6)), + currency, // Add currency to the telemetry data + }; - if (getDebugFlag()) { - log('info', 'AI Usage Telemetry:', telemetryData); - } + if (getDebugFlag()) { + log("info", "AI Usage Telemetry:", telemetryData); + } - // TODO (Subtask 77.2): Send telemetryData securely to the external endpoint. + // TODO (Subtask 77.2): Send telemetryData securely to the external endpoint. - return telemetryData; - } catch (error) { - log('error', `Failed to log AI usage telemetry: ${error.message}`, { - error - }); - // Don't re-throw; telemetry failure shouldn't block core functionality. - return null; - } + return telemetryData; + } catch (error) { + log("error", `Failed to log AI usage telemetry: ${error.message}`, { + error, + }); + // Don't re-throw; telemetry failure shouldn't block core functionality. + return null; + } } export { - generateTextService, - streamTextService, - generateObjectService, - logAiUsage + generateTextService, + streamTextService, + generateObjectService, + logAiUsage, }; diff --git a/scripts/modules/supported-models.json b/scripts/modules/supported-models.json index 944abca3..fac3da0d 100644 --- a/scripts/modules/supported-models.json +++ b/scripts/modules/supported-models.json @@ -1,427 +1,427 @@ { - "anthropic": [ - { - "id": "claude-sonnet-4-20250514", - "swe_score": 0.727, - "cost_per_1m_tokens": { "input": 3.0, "output": 15.0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 64000 - }, - { - "id": "claude-opus-4-20250514", - "swe_score": 0.725, - "cost_per_1m_tokens": { "input": 15.0, "output": 75.0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 32000 - }, - { - "id": "claude-3-7-sonnet-20250219", - "swe_score": 0.623, - "cost_per_1m_tokens": { "input": 3.0, "output": 15.0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 120000 - }, - { - "id": "claude-3-5-sonnet-20241022", - "swe_score": 0.49, - "cost_per_1m_tokens": { "input": 3.0, "output": 15.0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 64000 - } - ], - "openai": [ - { - "id": "gpt-4o", - "swe_score": 0.332, - "cost_per_1m_tokens": { "input": 2.5, "output": 10.0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 16384 - }, - { - "id": "o1", - "swe_score": 0.489, - "cost_per_1m_tokens": { "input": 15.0, "output": 60.0 }, - "allowed_roles": ["main"] - }, - { - "id": "o3", - "swe_score": 0.5, - "cost_per_1m_tokens": { "input": 10.0, "output": 40.0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "o3-mini", - "swe_score": 0.493, - "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, - "allowed_roles": ["main"], - "max_tokens": 100000 - }, - { - "id": "o4-mini", - "swe_score": 0.45, - "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "o1-mini", - "swe_score": 0.4, - "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, - "allowed_roles": ["main"] - }, - { - "id": "o1-pro", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 150.0, "output": 600.0 }, - "allowed_roles": ["main"] - }, - { - "id": "gpt-4-5-preview", - "swe_score": 0.38, - "cost_per_1m_tokens": { "input": 75.0, "output": 150.0 }, - "allowed_roles": ["main"] - }, - { - "id": "gpt-4-1-mini", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.4, "output": 1.6 }, - "allowed_roles": ["main"] - }, - { - "id": "gpt-4-1-nano", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.1, "output": 0.4 }, - "allowed_roles": ["main"] - }, - { - "id": "gpt-4o-mini", - "swe_score": 0.3, - "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, - "allowed_roles": ["main"] - }, - { - "id": "gpt-4o-search-preview", - "swe_score": 0.33, - "cost_per_1m_tokens": { "input": 2.5, "output": 10.0 }, - "allowed_roles": ["research"] - }, - { - "id": "gpt-4o-mini-search-preview", - "swe_score": 0.3, - "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, - "allowed_roles": ["research"] - } - ], - "google": [ - { - "id": "gemini-2.5-pro-preview-05-06", - "swe_score": 0.638, - "cost_per_1m_tokens": null, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048000 - }, - { - "id": "gemini-2.5-pro-preview-03-25", - "swe_score": 0.638, - "cost_per_1m_tokens": null, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048000 - }, - { - "id": "gemini-2.5-flash-preview-04-17", - "swe_score": 0, - "cost_per_1m_tokens": null, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048000 - }, - { - "id": "gemini-2.0-flash", - "swe_score": 0.754, - "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048000 - }, - { - "id": "gemini-2.0-flash-lite", - "swe_score": 0, - "cost_per_1m_tokens": null, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048000 - } - ], - "perplexity": [ - { - "id": "sonar-pro", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 3, "output": 15 }, - "allowed_roles": ["research"], - "max_tokens": 8700 - }, - { - "id": "sonar", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 1, "output": 1 }, - "allowed_roles": ["research"], - "max_tokens": 8700 - }, - { - "id": "deep-research", - "swe_score": 0.211, - "cost_per_1m_tokens": { "input": 2, "output": 8 }, - "allowed_roles": ["research"], - "max_tokens": 8700 - }, - { - "id": "sonar-reasoning-pro", - "swe_score": 0.211, - "cost_per_1m_tokens": { "input": 2, "output": 8 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 8700 - }, - { - "id": "sonar-reasoning", - "swe_score": 0.211, - "cost_per_1m_tokens": { "input": 1, "output": 5 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 8700 - } - ], - "xai": [ - { - "id": "grok-3", - "name": "Grok 3", - "swe_score": null, - "cost_per_1m_tokens": { "input": 3, "output": 15 }, - "allowed_roles": ["main", "fallback", "research"], - "max_tokens": 131072 - }, - { - "id": "grok-3-fast", - "name": "Grok 3 Fast", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 5, "output": 25 }, - "allowed_roles": ["main", "fallback", "research"], - "max_tokens": 131072 - } - ], - "ollama": [ - { - "id": "devstral:latest", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "qwen3:latest", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "qwen3:14b", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "qwen3:32b", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "mistral-small3.1:latest", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "llama3.3:latest", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - }, - { - "id": "phi4:latest", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"] - } - ], - "openrouter": [ - { - "id": "google/gemini-2.5-flash-preview-05-20", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048576 - }, - { - "id": "google/gemini-2.5-flash-preview-05-20:thinking", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.15, "output": 3.5 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048576 - }, - { - "id": "google/gemini-2.5-pro-exp-03-25", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "deepseek/deepseek-chat-v3-0324:free", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 163840 - }, - { - "id": "deepseek/deepseek-chat-v3-0324", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.27, "output": 1.1 }, - "allowed_roles": ["main"], - "max_tokens": 64000 - }, - { - "id": "openai/gpt-4.1", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 2, "output": 8 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "openai/gpt-4.1-mini", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.4, "output": 1.6 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "openai/gpt-4.1-nano", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.1, "output": 0.4 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "openai/o3", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 10, "output": 40 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 200000 - }, - { - "id": "openai/codex-mini", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 1.5, "output": 6 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 100000 - }, - { - "id": "openai/gpt-4o-mini", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 100000 - }, - { - "id": "openai/o4-mini", - "swe_score": 0.45, - "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 100000 - }, - { - "id": "openai/o4-mini-high", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 100000 - }, - { - "id": "openai/o1-pro", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 150, "output": 600 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 100000 - }, - { - "id": "meta-llama/llama-3.3-70b-instruct", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 120, "output": 600 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1048576 - }, - { - "id": "meta-llama/llama-4-maverick", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.18, "output": 0.6 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "meta-llama/llama-4-scout", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.08, "output": 0.3 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "qwen/qwen-max", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 1.6, "output": 6.4 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 32768 - }, - { - "id": "qwen/qwen-turbo", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.05, "output": 0.2 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 1000000 - }, - { - "id": "qwen/qwen3-235b-a22b", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.14, "output": 2 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 24000 - }, - { - "id": "mistralai/mistral-small-3.1-24b-instruct:free", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 96000 - }, - { - "id": "mistralai/mistral-small-3.1-24b-instruct", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.1, "output": 0.3 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 128000 - }, - { - "id": "mistralai/devstral-small", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.1, "output": 0.3 }, - "allowed_roles": ["main"], - "max_tokens": 110000 - }, - { - "id": "mistralai/mistral-nemo", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0.03, "output": 0.07 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 100000 - }, - { - "id": "thudm/glm-4-32b:free", - "swe_score": 0, - "cost_per_1m_tokens": { "input": 0, "output": 0 }, - "allowed_roles": ["main", "fallback"], - "max_tokens": 32768 - } - ] + "anthropic": [ + { + "id": "claude-sonnet-4-20250514", + "swe_score": 0.727, + "cost_per_1m_tokens": { "input": 3.0, "output": 15.0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 64000 + }, + { + "id": "claude-opus-4-20250514", + "swe_score": 0.725, + "cost_per_1m_tokens": { "input": 15.0, "output": 75.0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 32000 + }, + { + "id": "claude-3-7-sonnet-20250219", + "swe_score": 0.623, + "cost_per_1m_tokens": { "input": 3.0, "output": 15.0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 120000 + }, + { + "id": "claude-3-5-sonnet-20241022", + "swe_score": 0.49, + "cost_per_1m_tokens": { "input": 3.0, "output": 15.0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 64000 + } + ], + "openai": [ + { + "id": "gpt-4o", + "swe_score": 0.332, + "cost_per_1m_tokens": { "input": 2.5, "output": 10.0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 16384 + }, + { + "id": "o1", + "swe_score": 0.489, + "cost_per_1m_tokens": { "input": 15.0, "output": 60.0 }, + "allowed_roles": ["main"] + }, + { + "id": "o3", + "swe_score": 0.5, + "cost_per_1m_tokens": { "input": 10.0, "output": 40.0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "o3-mini", + "swe_score": 0.493, + "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, + "allowed_roles": ["main"], + "max_tokens": 100000 + }, + { + "id": "o4-mini", + "swe_score": 0.45, + "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "o1-mini", + "swe_score": 0.4, + "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, + "allowed_roles": ["main"] + }, + { + "id": "o1-pro", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 150.0, "output": 600.0 }, + "allowed_roles": ["main"] + }, + { + "id": "gpt-4-5-preview", + "swe_score": 0.38, + "cost_per_1m_tokens": { "input": 75.0, "output": 150.0 }, + "allowed_roles": ["main"] + }, + { + "id": "gpt-4-1-mini", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.4, "output": 1.6 }, + "allowed_roles": ["main"] + }, + { + "id": "gpt-4-1-nano", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.1, "output": 0.4 }, + "allowed_roles": ["main"] + }, + { + "id": "gpt-4o-mini", + "swe_score": 0.3, + "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, + "allowed_roles": ["main"] + }, + { + "id": "gpt-4o-search-preview", + "swe_score": 0.33, + "cost_per_1m_tokens": { "input": 2.5, "output": 10.0 }, + "allowed_roles": ["research"] + }, + { + "id": "gpt-4o-mini-search-preview", + "swe_score": 0.3, + "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, + "allowed_roles": ["research"] + } + ], + "google": [ + { + "id": "gemini-2.5-pro-preview-05-06", + "swe_score": 0.638, + "cost_per_1m_tokens": null, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048000 + }, + { + "id": "gemini-2.5-pro-preview-03-25", + "swe_score": 0.638, + "cost_per_1m_tokens": null, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048000 + }, + { + "id": "gemini-2.5-flash-preview-04-17", + "swe_score": 0, + "cost_per_1m_tokens": null, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048000 + }, + { + "id": "gemini-2.0-flash", + "swe_score": 0.754, + "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048000 + }, + { + "id": "gemini-2.0-flash-lite", + "swe_score": 0, + "cost_per_1m_tokens": null, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048000 + } + ], + "perplexity": [ + { + "id": "sonar-pro", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 3, "output": 15 }, + "allowed_roles": ["main", "research"], + "max_tokens": 8700 + }, + { + "id": "sonar", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 1, "output": 1 }, + "allowed_roles": ["research"], + "max_tokens": 8700 + }, + { + "id": "deep-research", + "swe_score": 0.211, + "cost_per_1m_tokens": { "input": 2, "output": 8 }, + "allowed_roles": ["research"], + "max_tokens": 8700 + }, + { + "id": "sonar-reasoning-pro", + "swe_score": 0.211, + "cost_per_1m_tokens": { "input": 2, "output": 8 }, + "allowed_roles": ["main", "research", "fallback"], + "max_tokens": 8700 + }, + { + "id": "sonar-reasoning", + "swe_score": 0.211, + "cost_per_1m_tokens": { "input": 1, "output": 5 }, + "allowed_roles": ["main", "research", "fallback"], + "max_tokens": 8700 + } + ], + "xai": [ + { + "id": "grok-3", + "name": "Grok 3", + "swe_score": null, + "cost_per_1m_tokens": { "input": 3, "output": 15 }, + "allowed_roles": ["main", "fallback", "research"], + "max_tokens": 131072 + }, + { + "id": "grok-3-fast", + "name": "Grok 3 Fast", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 5, "output": 25 }, + "allowed_roles": ["main", "fallback", "research"], + "max_tokens": 131072 + } + ], + "ollama": [ + { + "id": "devstral:latest", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "qwen3:latest", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "qwen3:14b", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "qwen3:32b", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "mistral-small3.1:latest", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "llama3.3:latest", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + }, + { + "id": "phi4:latest", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"] + } + ], + "openrouter": [ + { + "id": "google/gemini-2.5-flash-preview-05-20", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048576 + }, + { + "id": "google/gemini-2.5-flash-preview-05-20:thinking", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.15, "output": 3.5 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048576 + }, + { + "id": "google/gemini-2.5-pro-exp-03-25", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "deepseek/deepseek-chat-v3-0324:free", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 163840 + }, + { + "id": "deepseek/deepseek-chat-v3-0324", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.27, "output": 1.1 }, + "allowed_roles": ["main"], + "max_tokens": 64000 + }, + { + "id": "openai/gpt-4.1", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 2, "output": 8 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "openai/gpt-4.1-mini", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.4, "output": 1.6 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "openai/gpt-4.1-nano", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.1, "output": 0.4 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "openai/o3", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 10, "output": 40 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 200000 + }, + { + "id": "openai/codex-mini", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 1.5, "output": 6 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 100000 + }, + { + "id": "openai/gpt-4o-mini", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.15, "output": 0.6 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 100000 + }, + { + "id": "openai/o4-mini", + "swe_score": 0.45, + "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 100000 + }, + { + "id": "openai/o4-mini-high", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 1.1, "output": 4.4 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 100000 + }, + { + "id": "openai/o1-pro", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 150, "output": 600 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 100000 + }, + { + "id": "meta-llama/llama-3.3-70b-instruct", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 120, "output": 600 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1048576 + }, + { + "id": "meta-llama/llama-4-maverick", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.18, "output": 0.6 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "meta-llama/llama-4-scout", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.08, "output": 0.3 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "qwen/qwen-max", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 1.6, "output": 6.4 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 32768 + }, + { + "id": "qwen/qwen-turbo", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.05, "output": 0.2 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 1000000 + }, + { + "id": "qwen/qwen3-235b-a22b", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.14, "output": 2 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 24000 + }, + { + "id": "mistralai/mistral-small-3.1-24b-instruct:free", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 96000 + }, + { + "id": "mistralai/mistral-small-3.1-24b-instruct", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.1, "output": 0.3 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 128000 + }, + { + "id": "mistralai/devstral-small", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.1, "output": 0.3 }, + "allowed_roles": ["main"], + "max_tokens": 110000 + }, + { + "id": "mistralai/mistral-nemo", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0.03, "output": 0.07 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 100000 + }, + { + "id": "thudm/glm-4-32b:free", + "swe_score": 0, + "cost_per_1m_tokens": { "input": 0, "output": 0 }, + "allowed_roles": ["main", "fallback"], + "max_tokens": 32768 + } + ] } diff --git a/src/ai-providers/base-provider.js b/src/ai-providers/base-provider.js index 46732502..b96561d7 100644 --- a/src/ai-providers/base-provider.js +++ b/src/ai-providers/base-provider.js @@ -1,214 +1,214 @@ -import { generateText, streamText, generateObject } from 'ai'; -import { log } from '../../scripts/modules/index.js'; +import { generateText, streamText, generateObject } from "ai"; +import { log } from "../../scripts/modules/index.js"; /** * Base class for all AI providers */ export class BaseAIProvider { - constructor() { - if (this.constructor === BaseAIProvider) { - throw new Error('BaseAIProvider cannot be instantiated directly'); - } + constructor() { + if (this.constructor === BaseAIProvider) { + throw new Error("BaseAIProvider cannot be instantiated directly"); + } - // Each provider must set their name - this.name = this.constructor.name; - } + // Each provider must set their name + this.name = this.constructor.name; + } - /** - * Validates authentication parameters - can be overridden by providers - * @param {object} params - Parameters to validate - */ - validateAuth(params) { - // Default: require API key (most providers need this) - if (!params.apiKey) { - throw new Error(`${this.name} API key is required`); - } - } + /** + * Validates authentication parameters - can be overridden by providers + * @param {object} params - Parameters to validate + */ + validateAuth(params) { + // Default: require API key (most providers need this) + if (!params.apiKey) { + throw new Error(`${this.name} API key is required`); + } + } - /** - * Validates common parameters across all methods - * @param {object} params - Parameters to validate - */ - validateParams(params) { - // Validate authentication (can be overridden by providers) - this.validateAuth(params); + /** + * Validates common parameters across all methods + * @param {object} params - Parameters to validate + */ + validateParams(params) { + // Validate authentication (can be overridden by providers) + this.validateAuth(params); - // Validate required model ID - if (!params.modelId) { - throw new Error(`${this.name} Model ID is required`); - } + // Validate required model ID + if (!params.modelId) { + throw new Error(`${this.name} Model ID is required`); + } - // Validate optional parameters - this.validateOptionalParams(params); - } + // Validate optional parameters + this.validateOptionalParams(params); + } - /** - * Validates optional parameters like temperature and maxTokens - * @param {object} params - Parameters to validate - */ - validateOptionalParams(params) { - if ( - params.temperature !== undefined && - (params.temperature < 0 || params.temperature > 1) - ) { - throw new Error('Temperature must be between 0 and 1'); - } - if (params.maxTokens !== undefined && params.maxTokens <= 0) { - throw new Error('maxTokens must be greater than 0'); - } - } + /** + * Validates optional parameters like temperature and maxTokens + * @param {object} params - Parameters to validate + */ + validateOptionalParams(params) { + if ( + params.temperature !== undefined && + (params.temperature < 0 || params.temperature > 1) + ) { + throw new Error("Temperature must be between 0 and 1"); + } + if (params.maxTokens !== undefined && params.maxTokens <= 0) { + throw new Error("maxTokens must be greater than 0"); + } + } - /** - * Validates message array structure - */ - validateMessages(messages) { - if (!messages || !Array.isArray(messages) || messages.length === 0) { - throw new Error('Invalid or empty messages array provided'); - } + /** + * Validates message array structure + */ + validateMessages(messages) { + if (!messages || !Array.isArray(messages) || messages.length === 0) { + throw new Error("Invalid or empty messages array provided"); + } - for (const msg of messages) { - if (!msg.role || !msg.content) { - throw new Error( - 'Invalid message format. Each message must have role and content' - ); - } - } - } + for (const msg of messages) { + if (!msg.role || !msg.content) { + throw new Error( + "Invalid message format. Each message must have role and content" + ); + } + } + } - /** - * Common error handler - */ - handleError(operation, error) { - const errorMessage = error.message || 'Unknown error occurred'; - log('error', `${this.name} ${operation} failed: ${errorMessage}`, { - error - }); - throw new Error( - `${this.name} API error during ${operation}: ${errorMessage}` - ); - } + /** + * Common error handler + */ + handleError(operation, error) { + const errorMessage = error.message || "Unknown error occurred"; + log("error", `${this.name} ${operation} failed: ${errorMessage}`, { + error, + }); + throw new Error( + `${this.name} API error during ${operation}: ${errorMessage}` + ); + } - /** - * Creates and returns a client instance for the provider - * @abstract - */ - getClient(params) { - throw new Error('getClient must be implemented by provider'); - } + /** + * Creates and returns a client instance for the provider + * @abstract + */ + getClient(params) { + throw new Error("getClient must be implemented by provider"); + } - /** - * Generates text using the provider's model - */ - async generateText(params) { - try { - this.validateParams(params); - this.validateMessages(params.messages); + /** + * Generates text using the provider's model + */ + async generateText(params) { + try { + this.validateParams(params); + this.validateMessages(params.messages); - log( - 'debug', - `Generating ${this.name} text with model: ${params.modelId}` - ); + log( + "debug", + `Generating ${this.name} text with model: ${params.modelId}` + ); - const client = this.getClient(params); - const result = await generateText({ - model: client(params.modelId), - messages: params.messages, - maxTokens: params.maxTokens, - temperature: params.temperature - }); + const client = this.getClient(params); + const result = await generateText({ + model: client(params.modelId), + messages: params.messages, + maxTokens: params.maxTokens, + temperature: params.temperature, + }); - log( - 'debug', - `${this.name} generateText completed successfully for model: ${params.modelId}` - ); + log( + "debug", + `${this.name} generateText completed successfully for model: ${params.modelId}` + ); - return { - text: result.text, - usage: { - inputTokens: result.usage?.promptTokens, - outputTokens: result.usage?.completionTokens, - totalTokens: result.usage?.totalTokens - } - }; - } catch (error) { - this.handleError('text generation', error); - } - } + return { + text: result.text, + usage: { + inputTokens: result.usage?.promptTokens, + outputTokens: result.usage?.completionTokens, + totalTokens: result.usage?.totalTokens, + }, + }; + } catch (error) { + this.handleError("text generation", error); + } + } - /** - * Streams text using the provider's model - */ - async streamText(params) { - try { - this.validateParams(params); - this.validateMessages(params.messages); + /** + * Streams text using the provider's model + */ + async streamText(params) { + try { + this.validateParams(params); + this.validateMessages(params.messages); - log('debug', `Streaming ${this.name} text with model: ${params.modelId}`); + log("debug", `Streaming ${this.name} text with model: ${params.modelId}`); - const client = this.getClient(params); - const stream = await streamText({ - model: client(params.modelId), - messages: params.messages, - maxTokens: params.maxTokens, - temperature: params.temperature - }); + const client = this.getClient(params); + const stream = await streamText({ + model: client(params.modelId), + messages: params.messages, + maxTokens: params.maxTokens, + temperature: params.temperature, + }); - log( - 'debug', - `${this.name} streamText initiated successfully for model: ${params.modelId}` - ); + log( + "debug", + `${this.name} streamText initiated successfully for model: ${params.modelId}` + ); - return stream; - } catch (error) { - this.handleError('text streaming', error); - } - } + return stream; + } catch (error) { + this.handleError("text streaming", error); + } + } - /** - * Generates a structured object using the provider's model - */ - async generateObject(params) { - try { - this.validateParams(params); - this.validateMessages(params.messages); + /** + * Generates a structured object using the provider's model + */ + async generateObject(params) { + try { + this.validateParams(params); + this.validateMessages(params.messages); - if (!params.schema) { - throw new Error('Schema is required for object generation'); - } - if (!params.objectName) { - throw new Error('Object name is required for object generation'); - } + if (!params.schema) { + throw new Error("Schema is required for object generation"); + } + if (!params.objectName) { + throw new Error("Object name is required for object generation"); + } - log( - 'debug', - `Generating ${this.name} object ('${params.objectName}') with model: ${params.modelId}` - ); + log( + "debug", + `Generating ${this.name} object ('${params.objectName}') with model: ${params.modelId}` + ); - const client = this.getClient(params); - const result = await generateObject({ - model: client(params.modelId), - messages: params.messages, - schema: params.schema, - mode: 'tool', - maxTokens: params.maxTokens, - temperature: params.temperature - }); + const client = this.getClient(params); + const result = await generateObject({ + model: client(params.modelId), + messages: params.messages, + schema: params.schema, + mode: "auto", + maxTokens: params.maxTokens, + temperature: params.temperature, + }); - log( - 'debug', - `${this.name} generateObject completed successfully for model: ${params.modelId}` - ); + log( + "debug", + `${this.name} generateObject completed successfully for model: ${params.modelId}` + ); - return { - object: result.object, - usage: { - inputTokens: result.usage?.promptTokens, - outputTokens: result.usage?.completionTokens, - totalTokens: result.usage?.totalTokens - } - }; - } catch (error) { - this.handleError('object generation', error); - } - } + return { + object: result.object, + usage: { + inputTokens: result.usage?.promptTokens, + outputTokens: result.usage?.completionTokens, + totalTokens: result.usage?.totalTokens, + }, + }; + } catch (error) { + this.handleError("object generation", error); + } + } }