This commit completes the major refactoring initiative (Task 61) to migrate all AI-interacting task management functions to the unified service layer (`ai-services-unified.js`) and standardized configuration (`config-manager.js`).
Key Changes:
1. **Refactor `update-task-by-id` & `update-subtask-by-id`:**
* Replaced direct AI client logic and config fetching with calls to `generateTextService`.
* Preserved original prompt logic while ensuring JSON output format is requested.
* Implemented robust manual JSON parsing and Zod validation for text-based AI responses.
* Corrected logger implementation (`logFn`/`isMCP`/`report` pattern) for both CLI and MCP contexts.
* Ensured correct passing of `session` context to the unified service.
* Refactored associated direct function wrappers (`updateTaskByIdDirect`, `updateSubtaskByIdDirect`) to remove AI client initialization and call core logic appropriately.
2. **CLI Environment Loading:**
* Added `dotenv.config()` to `scripts/dev.js` to ensure consistent loading of the `.env` file for CLI operations.
3. **Obsolete Code Removal:**
* Deleted unused helper files:
* `scripts/modules/task-manager/get-subtasks-from-ai.js`
* `scripts/modules/task-manager/generate-subtask-prompt.js`
* `scripts/modules/ai-services.js`
* `scripts/modules/ai-client-factory.js`
* `mcp-server/src/core/utils/ai-client-utils.js`
* Removed corresponding imports/exports from `scripts/modules/task-manager.js` and `mcp-server/src/core/task-master-core.js`.
4. **Verification:**
* Successfully tested `update-task` and `update-subtask` via both CLI and MCP after refactoring.
5. **Task Management:**
* Marked subtasks 61.38, 61.39, 61.40, 61.41, and 61.33 as 'done'.
* Includes other task content/status updates as reflected in the diff.
This completes the migration of core AI features to the new architecture, enhancing maintainability and flexibility.
Simplified the Task Master CLI by organizing code into modules within the directory.
**Why:**
- **Better Organization:** Code is now grouped by function (AI, commands, dependencies, tasks, UI, utilities).
- **Easier to Maintain:** Smaller modules are simpler to update and fix.
- **Scalable:** New features can be added more easily in a structured way.
**What Changed:**
- Moved code from single _____ _ __ __ _
|_ _|_ _ ___| | __ | \/ | __ _ ___| |_ ___ _ __
| |/ _` / __| |/ / | |\/| |/ _` / __| __/ _ \ '__|
| | (_| \__ \ < | | | | (_| \__ \ || __/ |
|_|\__,_|___/_|\_\ |_| |_|\__,_|___/\__\___|_|
by https://x.com/eyaltoledano
╭────────────────────────────────────────────╮
│ │
│ Version: 0.9.16 Project: Task Master │
│ │
╰────────────────────────────────────────────╯
╭─────────────────────╮
│ │
│ Task Master CLI │
│ │
╰─────────────────────╯
╭───────────────────╮
│ Task Generation │
╰───────────────────╯
parse-prd --input=<file.txt> [--tasks=10] Generate tasks from a PRD document
generate Create individual task files from tasks…
╭───────────────────╮
│ Task Management │
╰───────────────────╯
list [--status=<status>] [--with-subtas… List all tasks with their status
set-status --id=<id> --status=<status> Update task status (done, pending, etc.)
update --from=<id> --prompt="<context>" Update tasks based on new requirements
add-task --prompt="<text>" [--dependencies=… Add a new task using AI
add-dependency --id=<id> --depends-on=<id> Add a dependency to a task
remove-dependency --id=<id> --depends-on=<id> Remove a dependency from a task
╭──────────────────────────╮
│ Task Analysis & Detail │
╰──────────────────────────╯
analyze-complexity [--research] [--threshold=5] Analyze tasks and generate expansion re…
complexity-report [--file=<path>] Display the complexity analysis report
expand --id=<id> [--num=5] [--research] [… Break down tasks into detailed subtasks
expand --all [--force] [--research] Expand all pending tasks with subtasks
clear-subtasks --id=<id> Remove subtasks from specified tasks
╭─────────────────────────────╮
│ Task Navigation & Viewing │
╰─────────────────────────────╯
next Show the next task to work on based on …
show <id> Display detailed information about a sp…
╭─────────────────────────╮
│ Dependency Management │
╰─────────────────────────╯
validate-dependenci… Identify invalid dependencies without f…
fix-dependencies Fix invalid dependencies automatically
╭─────────────────────────╮
│ Environment Variables │
╰─────────────────────────╯
ANTHROPIC_API_KEY Your Anthropic API key Required
MODEL Claude model to use Default: claude-3-7-sonn…
MAX_TOKENS Maximum tokens for responses Default: 4000
TEMPERATURE Temperature for model responses Default: 0.7
PERPLEXITY_API_KEY Perplexity API key for research Optional
PERPLEXITY_MODEL Perplexity model to use Default: sonar-small-onl…
DEBUG Enable debug logging Default: false
LOG_LEVEL Console output level (debug,info,warn,error) Default: info
DEFAULT_SUBTASKS Default number of subtasks to generate Default: 3
DEFAULT_PRIORITY Default task priority Default: medium
PROJECT_NAME Project name displayed in UI Default: Task Master file into these new modules:
- : AI interactions (Claude, Perplexity)
- : CLI command definitions (Commander.js)
- : Task dependency handling
- : Core task operations (create, list, update, etc.)
- : User interface elements (display, formatting)
- : Utility functions and configuration
- : Exports all modules
- Replaced direct use of _____ _ __ __ _
|_ _|_ _ ___| | __ | \/ | __ _ ___| |_ ___ _ __
| |/ _` / __| |/ / | |\/| |/ _` / __| __/ _ \ '__|
| | (_| \__ \ < | | | | (_| \__ \ || __/ |
|_|\__,_|___/_|\_\ |_| |_|\__,_|___/\__\___|_|
by https://x.com/eyaltoledano
╭────────────────────────────────────────────╮
│ │
│ Version: 0.9.16 Project: Task Master │
│ │
╰────────────────────────────────────────────╯
╭─────────────────────╮
│ │
│ Task Master CLI │
│ │
╰─────────────────────╯
╭───────────────────╮
│ Task Generation │
╰───────────────────╯
parse-prd --input=<file.txt> [--tasks=10] Generate tasks from a PRD document
generate Create individual task files from tasks…
╭───────────────────╮
│ Task Management │
╰───────────────────╯
list [--status=<status>] [--with-subtas… List all tasks with their status
set-status --id=<id> --status=<status> Update task status (done, pending, etc.)
update --from=<id> --prompt="<context>" Update tasks based on new requirements
add-task --prompt="<text>" [--dependencies=… Add a new task using AI
add-dependency --id=<id> --depends-on=<id> Add a dependency to a task
remove-dependency --id=<id> --depends-on=<id> Remove a dependency from a task
╭──────────────────────────╮
│ Task Analysis & Detail │
╰──────────────────────────╯
analyze-complexity [--research] [--threshold=5] Analyze tasks and generate expansion re…
complexity-report [--file=<path>] Display the complexity analysis report
expand --id=<id> [--num=5] [--research] [… Break down tasks into detailed subtasks
expand --all [--force] [--research] Expand all pending tasks with subtasks
clear-subtasks --id=<id> Remove subtasks from specified tasks
╭─────────────────────────────╮
│ Task Navigation & Viewing │
╰─────────────────────────────╯
next Show the next task to work on based on …
show <id> Display detailed information about a sp…
╭─────────────────────────╮
│ Dependency Management │
╰─────────────────────────╯
validate-dependenci… Identify invalid dependencies without f…
fix-dependencies Fix invalid dependencies automatically
╭─────────────────────────╮
│ Environment Variables │
╰─────────────────────────╯
ANTHROPIC_API_KEY Your Anthropic API key Required
MODEL Claude model to use Default: claude-3-7-sonn…
MAX_TOKENS Maximum tokens for responses Default: 4000
TEMPERATURE Temperature for model responses Default: 0.7
PERPLEXITY_API_KEY Perplexity API key for research Optional
PERPLEXITY_MODEL Perplexity model to use Default: sonar-small-onl…
DEBUG Enable debug logging Default: false
LOG_LEVEL Console output level (debug,info,warn,error) Default: info
DEFAULT_SUBTASKS Default number of subtasks to generate Default: 3
DEFAULT_PRIORITY Default task priority Default: medium
PROJECT_NAME Project name displayed in UI Default: Task Master with the global command (see ).
- Updated documentation () to reflect the new command.
**Benefits:**
Code is now cleaner, easier to work with, and ready for future growth.
Use the command (or ) to run the CLI. See for command details.
- Implemented and commands:
- Added validation to prevent circular and duplicate dependencies.
- Ensured proper error handling for invalid task IDs.
- Updated task files (tasks.json and individual task files) after changes.
- Enhanced the command to provide a detailed view of tasks:
- Displayed dependencies with status (using color-coded output).
- Included comprehensive task information (description, details, etc.).
- Updated documentation: README, scripts/README.md, and dev_workflow.mdc.
- Prepared package for publishing (version bump).
This commit resolves several issues with the task expansion system to
ensure higher quality subtasks and better synchronization:
1. Task File Generation
- Add automatic regeneration of task files after expanding tasks
- Ensure individual task text files stay in sync with tasks.json
- Avoids manual regeneration steps after task expansion
2. Perplexity API Integration
- Fix 'researchPrompt is not defined' error in Perplexity integration
- Add specialized research-oriented prompt template
- Improve system message for better context and instruction
- Better fallback to Claude when Perplexity unavailable
3. Subtask Parsing Improvements
- Enhance regex pattern to handle more formatting variations
- Implement multiple parsing strategies for different response formats:
* Improved section detection with flexible headings
* Added support for numbered and bulleted lists
* Implemented heuristic-based title and description extraction
- Create more meaningful dummy subtasks with relevant titles and descriptions
instead of generic placeholders
- Ensure minimal descriptions are always provided
4. Quality Verification and Retry System
- Add post-expansion verification to identify low-quality subtask sets
- Detect tasks with too many generic/placeholder subtasks
- Implement interactive retry mechanism with enhanced prompts
- Use adjusted settings for retries (research mode, subtask count)
- Clear existing subtasks before retry to prevent duplicates
- Provide detailed reporting of verification and retry process
These changes significantly improve the quality of generated subtasks
and reduce the need for manual intervention when subtask generation
produces suboptimal results.
- Add loading indicator with spinner animation during API calls
- Implement retry logic with exponential backoff (1s, 2s, 4s)
- Add dynamic task count adjustment when API calls fail
- Improve error handling with detailed error messages
- Add interactive user options when all retries are exhausted
- Optimize token allocation based on PRD size
- Add comprehensive validation of API responses
- Improve error recovery strategies for various failure scenarios
- Update parsePRD function to properly handle errors from callClaude
This commit includes several important improvements:
1. Add support for updating multiple tasks at once with comma-separated IDs
- Modify setTaskStatus to handle lists like id=1,1.1,1.2
- Fix subtask handling to properly update subtask statuses
- Add in-progress as a valid status option
2. Fix initialization script issues
- Add debugging information to help diagnose npx execution problems
- Improve error handling and readline interface management
- Remove conditional check that prevented script from running in some environments
- Add troubleshooting section to README.md
3. Improve package preparation
- Make scripts executable during package preparation
- Update version to 1.0.7
These changes make the package more robust and user-friendly, particularly
for first-time users and those managing complex task hierarchies.
- Update to ES modules syntax throughout the codebase
- Add fileURLToPath and dirname imports to handle __dirname in ES modules
- Upgrade Anthropic SDK from 0.10.0 to 0.39.0
- Fix JSON parsing to handle responses wrapped in Markdown code blocks
- Improve documentation with clearer installation instructions
- Add important notes about ES modules and SDK requirements
- Update environment examples with API key format and model recommendations
- Include index.js in package files list
- Bump version to 1.0.2