This commit introduces a comprehensive set of skipped tests to both and . These skipped tests serve as a blueprint for future test implementation, outlining the necessary test cases for currently untested functionalities.
- Ensures sync with bin/ folder by adding -r/--research to the command
- Fixes an issue that improperly parsed command line args
- Ensures confirmation card on dependency add/remove
- Properly formats some sub-task dependencies
**Potentially addressed issues:**
While primarily focused on adding test coverage, this commit also implicitly addresses potential issues by:
- **Improving error handling coverage:** The addition of skipped tests for error scenarios in functions like , , , and highlights areas where error handling needs to be robustly tested and potentially improved in the codebase.
- **Enhancing dependency validation:** Skipped tests for include validation of dependencies, prompting a review of the dependency validation logic and ensuring its correctness.
- **Standardizing test coverage:** By creating a clear roadmap for testing all functions, this commit contributes to a more standardized and complete test suite, reducing the likelihood of undiscovered bugs in the future.
**task-manager.test.js:**
- Added skipped test blocks for the following functions:
- : Includes tests for handling valid JSON responses, malformed JSON, missing tasks in responses, Perplexity AI research integration, Claude fallback, and parallel task processing.
- : Covers tests for updating tasks based on context, handling Claude streaming, Perplexity AI integration, scenarios with no tasks to update, and error handling during updates.
- : Includes tests for generating task files from , formatting dependencies with status indicators, handling tasks without subtasks, empty task arrays, and dependency validation before file generation.
- : Covers tests for updating task status, subtask status using dot notation, updating multiple tasks, automatic subtask status updates, parent task update suggestions, and handling non-existent task IDs.
- : Includes tests for updating regular and subtask statuses, handling parent tasks without subtasks, and non-existent subtask IDs.
- : Covers tests for displaying all tasks, filtering by status, displaying subtasks, showing completion statistics, identifying the next task, and handling empty task arrays.
- : Includes tests for generating subtasks, using complexity reports for subtask counts, Perplexity AI integration, appending subtasks, skipping completed tasks, and error handling during subtask generation.
- : Covers tests for expanding all pending tasks, sorting by complexity, skipping tasks with existing subtasks (unless forced), using task-specific parameters from complexity reports, handling empty task arrays, and error handling for individual tasks.
- : Includes tests for clearing subtasks from specific and multiple tasks, handling tasks without subtasks, non-existent task IDs, and regenerating task files after clearing subtasks.
- : Covers tests for adding new tasks using AI, handling Claude streaming, validating dependencies, handling malformed AI responses, and using existing task context for generation.
**utils.test.js:**
- Added skipped test blocks for the following functions:
- : Tests for logging messages according to log levels and filtering messages below configured levels.
- : Tests for reading and parsing valid JSON files, handling file not found errors, and invalid JSON formats.
- : Tests for writing JSON data to files and handling file write errors.
- : Tests for escaping double quotes in prompts and handling prompts without special characters.
- : Tests for reading and parsing complexity reports, handling missing report files, and custom report paths.
- : Tests for finding tasks in reports by ID, handling non-existent task IDs, and invalid report structures.
- : Tests for verifying existing task and subtask IDs, handling non-existent IDs, and invalid inputs.
- : Tests for formatting numeric and string task IDs and preserving dot notation for subtasks.
- : Tests for detecting simple and complex cycles in dependency graphs, handling acyclic graphs, and empty dependency maps.
These skipped tests provide a clear roadmap for future test development, ensuring comprehensive coverage for core functionalities in both modules. They document the intended behavior of each function and outline various scenarios, including happy paths, edge cases, and error conditions, thereby improving the overall test strategy and maintainability of the Task Master CLI.
91 lines
4.9 KiB
Plaintext
91 lines
4.9 KiB
Plaintext
# Task ID: 21
|
|
# Title: Refactor dev.js into Modular Components
|
|
# Status: done
|
|
# Dependencies: 3, 16, 17
|
|
# Priority: high
|
|
# Description: Restructure the monolithic dev.js file into separate modular components to improve code maintainability, readability, and testability while preserving all existing functionality.
|
|
# Details:
|
|
This task involves breaking down the current dev.js file into logical modules with clear responsibilities:
|
|
|
|
1. Create the following module files:
|
|
- commands.js: Handle all CLI command definitions and execution logic
|
|
- ai-services.js: Encapsulate all AI service interactions (OpenAI, etc.)
|
|
- task-manager.js: Manage task operations (create, read, update, delete)
|
|
- ui.js: Handle all console output formatting, colors, and user interaction
|
|
- utils.js: Contain helper functions, utilities, and shared code
|
|
|
|
2. Refactor dev.js to serve as the entry point that:
|
|
- Imports and initializes all modules
|
|
- Handles command-line argument parsing
|
|
- Sets up the execution environment
|
|
- Orchestrates the flow between modules
|
|
|
|
3. Ensure proper dependency injection between modules to avoid circular dependencies
|
|
|
|
4. Maintain consistent error handling across modules
|
|
|
|
5. Update import/export statements throughout the codebase
|
|
|
|
6. Document each module with clear JSDoc comments explaining purpose and usage
|
|
|
|
7. Ensure configuration and logging systems are properly integrated into each module
|
|
|
|
The refactoring should not change any existing functionality - this is purely a code organization task.
|
|
|
|
# Test Strategy:
|
|
Testing should verify that functionality remains identical after refactoring:
|
|
|
|
1. Automated Testing:
|
|
- Create unit tests for each new module to verify individual functionality
|
|
- Implement integration tests that verify modules work together correctly
|
|
- Test each command to ensure it works exactly as before
|
|
|
|
2. Manual Testing:
|
|
- Execute all existing CLI commands and verify outputs match pre-refactoring behavior
|
|
- Test edge cases like error handling and invalid inputs
|
|
- Verify that configuration options still work as expected
|
|
|
|
3. Code Quality Verification:
|
|
- Run linting tools to ensure code quality standards are maintained
|
|
- Check for any circular dependencies between modules
|
|
- Verify that each module has a single, clear responsibility
|
|
|
|
4. Performance Testing:
|
|
- Compare execution time before and after refactoring to ensure no performance regression
|
|
|
|
5. Documentation Check:
|
|
- Verify that each module has proper documentation
|
|
- Ensure README is updated if necessary to reflect architectural changes
|
|
|
|
# Subtasks:
|
|
## 1. Analyze Current dev.js Structure and Plan Module Boundaries [done]
|
|
### Dependencies: None
|
|
### Description: Perform a comprehensive analysis of the existing dev.js file to identify logical boundaries for the new modules. Create a detailed mapping document that outlines which functions, variables, and code blocks will move to which module files. Identify shared dependencies, potential circular references, and determine the appropriate interfaces between modules.
|
|
### Details:
|
|
|
|
|
|
## 2. Create Core Module Structure and Entry Point Refactoring [done]
|
|
### Dependencies: 21.1
|
|
### 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.
|
|
### Details:
|
|
|
|
|
|
## 3. Implement Core Module Functionality with Dependency Injection [done]
|
|
### Dependencies: 21.2
|
|
### 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.
|
|
### Details:
|
|
|
|
|
|
## 4. Implement Error Handling and Complete Module Migration [done]
|
|
### Dependencies: 21.3
|
|
### 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.
|
|
### Details:
|
|
|
|
|
|
## 5. Test, Document, and Finalize Modular Structure [done]
|
|
### Dependencies: 21.4
|
|
### 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.
|
|
### Details:
|
|
|
|
|