fixes issue with perplexity model used by default (now sonar-pro in all cases). Fixes an issue preventing analyzeTaskComplexity to work as designed. Fixes an issue that prevented parse-prd from working. Stubs in the test for analyzeTaskComplexity to be done later.

This commit is contained in:
Eyal Toledano
2025-03-24 16:30:27 -04:00
parent f5bce3452e
commit 0c874f93e9
8 changed files with 200 additions and 114 deletions

View File

@@ -4,6 +4,7 @@ PERPLEXITY_API_KEY=pplx-abcde # For research (recommended but optional)
# Optional - defaults shown
MODEL=claude-3-7-sonnet-20250219 # Recommended models: claude-3-7-sonnet-20250219, claude-3-opus-20240229
PERPLEXITY_MODEL=sonar-pro # Make sure you have access to sonar-pro otherwise you can use sonar regular.
MAX_TOKENS=4000 # Maximum tokens for model responses
TEMPERATURE=0.7 # Temperature for model responses (0.0-1.0)
DEBUG=false # Enable debug logging (true/false)

View File

@@ -10,6 +10,7 @@ import { dirname, resolve } from 'path';
import { createRequire } from 'module';
import { spawn } from 'child_process';
import { Command } from 'commander';
import { displayHelp, displayBanner } from '../scripts/modules/ui.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -43,28 +44,17 @@ program
.description('Claude Task Master CLI')
.version(version)
.addHelpText('afterAll', () => {
// Add the same help output that dev.js uses
const child = spawn('node', [devScriptPath, '--help'], {
stdio: ['inherit', 'pipe', 'inherit'],
cwd: process.cwd()
});
let output = '';
child.stdout.on('data', (data) => {
output += data.toString();
});
child.on('close', () => {
// Only display the custom help text part, not the commander-generated part
const customHelpStart = output.indexOf('Task Master CLI');
if (customHelpStart > -1) {
console.log('\n' + output.substring(customHelpStart));
}
});
return ''; // Return empty string to prevent immediate display
// Use the same help display function as dev.js for consistency
displayHelp();
return ''; // Return empty string to prevent commander's default help
});
// Add custom help option to directly call our help display
program.helpOption('-h, --help', 'Display help information');
program.on('--help', () => {
displayHelp();
});
program
.command('init')
.description('Initialize a new project')
@@ -146,11 +136,12 @@ program
program
.command('parse-prd')
.description('Parse a PRD file and generate tasks')
.argument('<file>', 'Path to the PRD file')
.argument('[file]', 'Path to the PRD file')
.option('-o, --output <file>', 'Output file path', 'tasks/tasks.json')
.option('-n, --num-tasks <number>', 'Number of tasks to generate', '10')
.action((file, options) => {
const args = ['parse-prd', file];
const args = ['parse-prd'];
if (file) args.push(file);
if (options.output) args.push('--output', options.output);
if (options.numTasks) args.push('--num-tasks', options.numTasks);
runDevScript(args);
@@ -256,7 +247,7 @@ program
program
.command('show')
.description('Show details of a specific task by ID')
.description('Display detailed information about a specific task')
.argument('[id]', 'Task ID to show')
.option('-i, --id <id>', 'Task ID to show (alternative to argument)')
.option('-f, --file <file>', 'Path to the tasks file', 'tasks/tasks.json')
@@ -326,4 +317,11 @@ program
runDevScript(args);
});
program.parse(process.argv);
program.parse(process.argv);
// Show help if no command was provided (just 'task-master' with no args)
if (process.argv.length <= 2) {
displayBanner();
displayHelp();
process.exit(0);
}

View File

@@ -305,7 +305,7 @@ async function generateSubtasksWithPerplexity(task, numSubtasks = 3, nextSubtask
log('info', `Researching context for task ${task.id}: ${task.title}`);
const perplexityClient = getPerplexityClient();
const PERPLEXITY_MODEL = process.env.PERPLEXITY_MODEL || 'sonar-small-online';
const PERPLEXITY_MODEL = process.env.PERPLEXITY_MODEL || 'sonar-pro';
const researchLoadingIndicator = startLoadingIndicator('Researching best practices with Perplexity AI...');
// Formulate research query based on task
@@ -493,13 +493,13 @@ function parseSubtasksFromText(text, startId, expectedCount, parentTaskId) {
/**
* Generate a prompt for complexity analysis
* @param {Array} tasksData - Tasks data
* @param {Object} tasksData - Tasks data object containing tasks array
* @returns {string} Generated prompt
*/
function generateComplexityAnalysisPrompt(tasksData) {
return `Analyze the complexity of the following tasks and provide recommendations for subtask breakdown:
${tasksData.map(task => `
${tasksData.tasks.map(task => `
Task ID: ${task.id}
Title: ${task.title}
Description: ${task.description}

View File

@@ -52,10 +52,27 @@ function registerCommands(programInstance) {
programInstance
.command('parse-prd')
.description('Parse a PRD file and generate tasks')
.argument('<file>', 'Path to the PRD file')
.argument('[file]', 'Path to the PRD file')
.option('-o, --output <file>', 'Output file path', 'tasks/tasks.json')
.option('-n, --num-tasks <number>', 'Number of tasks to generate', '10')
.action(async (file, options) => {
if (!file) {
console.log(chalk.yellow('No PRD file specified.'));
console.log(boxen(
chalk.white.bold('Parse PRD Help') + '\n\n' +
chalk.cyan('Usage:') + '\n' +
` task-master parse-prd <prd-file.txt> [options]\n\n` +
chalk.cyan('Options:') + '\n' +
' -o, --output <file> Output file path (default: "tasks/tasks.json")\n' +
' -n, --num-tasks <number> Number of tasks to generate (default: 10)\n\n' +
chalk.cyan('Example:') + '\n' +
' task-master parse-prd requirements.txt --num-tasks 15\n\n' +
chalk.yellow('Note: This command will generate tasks from a PRD document and will overwrite any existing tasks.json file.'),
{ padding: 1, borderColor: 'blue', borderStyle: 'round' }
));
return;
}
const numTasks = parseInt(options.numTasks, 10);
const outputPath = options.output;

View File

@@ -207,7 +207,7 @@ The changes described in the prompt should be applied to ALL tasks in the list.`
log('info', 'Using Perplexity AI for research-backed task updates');
// Call Perplexity AI using format consistent with ai-services.js
const perplexityModel = process.env.PERPLEXITY_MODEL || 'sonar-small-online';
const perplexityModel = process.env.PERPLEXITY_MODEL || 'sonar-pro';
const result = await perplexity.chat.completions.create({
model: perplexityModel,
messages: [
@@ -1756,7 +1756,7 @@ Your response must be a clean JSON array only, following exactly this format:
DO NOT include any text before or after the JSON array. No explanations, no markdown formatting.`;
const result = await perplexity.chat.completions.create({
model: PERPLEXITY_MODEL,
model: process.env.PERPLEXITY_MODEL || 'sonar-pro',
messages: [
{
role: "system",
@@ -1767,8 +1767,8 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
content: researchPrompt
}
],
temperature: TEMPERATURE,
max_tokens: MAX_TOKENS,
temperature: CONFIG.temperature,
max_tokens: CONFIG.maxTokens,
});
// Extract the response text
@@ -1889,7 +1889,13 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
// 3. Replace single quotes with double quotes for property values
cleanedResponse = cleanedResponse.replace(/:(\s*)'([^']*)'(\s*[,}])/g, ':$1"$2"$3');
// 4. Add a special fallback option if we're still having issues
// 4. Fix unterminated strings - common with LLM responses
const untermStringPattern = /:(\s*)"([^"]*)(?=[,}])/g;
cleanedResponse = cleanedResponse.replace(untermStringPattern, ':$1"$2"');
// 5. Fix multi-line strings by replacing newlines
cleanedResponse = cleanedResponse.replace(/:(\s*)"([^"]*)\n([^"]*)"/g, ':$1"$2 $3"');
try {
complexityAnalysis = JSON.parse(cleanedResponse);
console.log(chalk.green("Successfully parsed JSON after fixing common issues"));
@@ -2006,7 +2012,7 @@ Your response must be a clean JSON array only, following exactly this format:
DO NOT include any text before or after the JSON array. No explanations, no markdown formatting.`;
const result = await perplexity.chat.completions.create({
model: PERPLEXITY_MODEL,
model: process.env.PERPLEXITY_MODEL || 'sonar-pro',
messages: [
{
role: "system",
@@ -2017,8 +2023,8 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
content: missingTasksResearchPrompt
}
],
temperature: TEMPERATURE,
max_tokens: MAX_TOKENS,
temperature: CONFIG.temperature,
max_tokens: CONFIG.maxTokens,
});
// Extract the response

View File

@@ -391,7 +391,7 @@ function displayHelp() {
`${chalk.dim('Optional')}${chalk.reset('')}`],
[`${chalk.yellow('PERPLEXITY_MODEL')}${chalk.reset('')}`,
`${chalk.white('Perplexity model to use')}${chalk.reset('')}`,
`${chalk.dim('Default: sonar-small-online')}${chalk.reset('')}`],
`${chalk.dim('Default: sonar-pro')}${chalk.reset('')}`],
[`${chalk.yellow('DEBUG')}${chalk.reset('')}`,
`${chalk.white('Enable debug logging')}${chalk.reset('')}`,
`${chalk.dim(`Default: ${CONFIG.debug}`)}${chalk.reset('')}`],

View File

@@ -1,171 +1,203 @@
{
"meta": {
"generatedAt": "2025-03-21T20:01:53.007Z",
"tasksAnalyzed": 20,
"generatedAt": "2025-03-24T20:01:35.986Z",
"tasksAnalyzed": 24,
"thresholdScore": 5,
"projectName": "Your Project Name",
"usedResearch": true
"usedResearch": false
},
"complexityAnalysis": [
{
"taskId": 1,
"taskTitle": "Implement Task Data Structure",
"complexityScore": 8,
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the task of creating the tasks.json structure into subtasks focusing on schema design, model creation, validation, file operations, and error handling.",
"reasoning": "This task involves multiple critical components including schema design, model creation, and file operations, each requiring detailed attention and validation."
"expansionPrompt": "Break down the implementation of the core tasks.json data structure into subtasks that cover schema design, model implementation, validation, file operations, and error handling. For each subtask, include specific technical requirements and acceptance criteria.",
"reasoning": "This task requires designing a foundational data structure that will be used throughout the system. It involves schema design, validation logic, and file system operations, which together represent moderate to high complexity. The task is critical as many other tasks depend on it."
},
{
"taskId": 2,
"taskTitle": "Develop Command Line Interface Foundation",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the CLI development into subtasks such as command parsing, help documentation, console output, logging system, and global options handling.",
"reasoning": "Creating a CLI involves several distinct functionalities that need to be implemented and integrated, each contributing to the overall complexity."
"complexityScore": 6,
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the CLI foundation implementation into subtasks covering Commander.js setup, help documentation creation, console output formatting, and global options handling. Each subtask should specify implementation details and how it integrates with the overall CLI structure.",
"reasoning": "Setting up the CLI foundation requires integrating Commander.js, implementing various command-line options, and establishing the output formatting system. The complexity is moderate as it involves creating the interface layer that users will interact with."
},
{
"taskId": 3,
"taskTitle": "Implement Basic Task Operations",
"complexityScore": 9,
"recommendedSubtasks": 6,
"expansionPrompt": "Break down the task operations into subtasks including listing, creating, updating, deleting, status changes, dependency management, and priority handling.",
"reasoning": "This task requires implementing a wide range of operations, each with its own logic and dependencies, increasing the complexity."
"complexityScore": 8,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the implementation of basic task operations into subtasks covering CRUD operations, status management, dependency handling, and priority management. Each subtask should detail the specific operations, validation requirements, and error cases to handle.",
"reasoning": "This task encompasses multiple operations (create, read, update, delete) along with status changes, dependency management, and priority handling. It represents high complexity due to the breadth of functionality and the need to ensure data integrity across operations."
},
{
"taskId": 4,
"taskTitle": "Create Task File Generation System",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the file generation system into subtasks such as template creation, file generation, synchronization, file naming, and update handling.",
"reasoning": "The task involves creating a system that generates and synchronizes files, requiring careful handling of templates and updates."
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the task file generation system into subtasks covering template creation, file generation logic, bi-directional synchronization, and file organization. Each subtask should specify the technical approach, edge cases to handle, and integration points with the task data structure.",
"reasoning": "Implementing file generation with bi-directional synchronization presents significant complexity due to the need to maintain consistency between individual files and the central tasks.json. The system must handle updates in either direction and resolve potential conflicts."
},
{
"taskId": 5,
"taskTitle": "Integrate Anthropic Claude API",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Break down the API integration into subtasks including authentication, prompt templates, response handling, error management, token tracking, and model configuration.",
"reasoning": "Integrating an external API involves multiple steps from authentication to response handling, each adding to the complexity."
"complexityScore": 6,
"recommendedSubtasks": 4,
"expansionPrompt": "Break down the Claude API integration into subtasks covering authentication setup, prompt template creation, response handling, and error management with retries. Each subtask should detail the specific implementation approach, including security considerations and performance optimizations.",
"reasoning": "Integrating with the Claude API involves setting up authentication, creating effective prompts, and handling responses and errors. The complexity is moderate, focusing on establishing a reliable connection to the external service with proper error handling and retry logic."
},
{
"taskId": 6,
"taskTitle": "Build PRD Parsing System",
"complexityScore": 9,
"recommendedSubtasks": 6,
"expansionPrompt": "Divide the PRD parsing system into subtasks such as file reading, prompt engineering, task conversion, dependency inference, priority assignment, and chunking.",
"reasoning": "Parsing PRDs and converting them into tasks requires handling various complexities including dependency inference and priority assignment."
"complexityScore": 8,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the PRD parsing system into subtasks covering file reading, prompt engineering, content-to-task conversion, dependency inference, priority assignment, and handling large documents. Each subtask should specify the AI interaction approach, data transformation steps, and validation requirements.",
"reasoning": "Parsing PRDs into structured tasks requires sophisticated prompt engineering and intelligent processing of unstructured text. The complexity is high due to the need to accurately extract tasks, infer dependencies, and handle potentially large documents with varying formats."
},
{
"taskId": 7,
"taskTitle": "Implement Task Expansion with Claude",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the task expansion into subtasks including prompt creation, workflow implementation, context-aware expansion, relationship management, subtask specification, and regeneration.",
"reasoning": "Expanding tasks into subtasks using AI involves creating prompts and managing relationships, adding to the complexity."
"recommendedSubtasks": 4,
"expansionPrompt": "Break down the task expansion functionality into subtasks covering prompt creation for subtask generation, expansion workflow implementation, parent-child relationship management, and regeneration mechanisms. Each subtask should detail the AI interaction patterns, data structures, and user experience considerations.",
"reasoning": "Task expansion involves complex AI interactions to generate meaningful subtasks and manage their relationships with parent tasks. The complexity comes from creating effective prompts that produce useful subtasks and implementing a smooth workflow for users to generate and refine these subtasks."
},
{
"taskId": 8,
"taskTitle": "Develop Implementation Drift Handling",
"complexityScore": 8,
"complexityScore": 9,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the drift handling into subtasks including task updates, rewriting, dependency chain updates, completed work preservation, and update analysis.",
"reasoning": "Handling implementation drift requires updating tasks and dependencies while preserving completed work, increasing complexity."
"expansionPrompt": "Divide the implementation drift handling into subtasks covering change detection, task rewriting based on new context, dependency chain updates, work preservation, and update suggestion analysis. Each subtask should specify the algorithms, heuristics, and AI prompts needed to effectively manage implementation changes.",
"reasoning": "This task involves the complex challenge of updating future tasks based on changes in implementation. It requires sophisticated analysis of completed work, understanding how it affects pending tasks, and intelligently updating those tasks while preserving dependencies. This represents high complexity due to the need for context-aware AI reasoning."
},
{
"taskId": 9,
"taskTitle": "Integrate Perplexity API",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the API integration into subtasks including authentication, prompt templates, response handling, fallback logic, quality comparison, and model selection.",
"reasoning": "Integrating another external API involves similar complexities as the Claude API integration, including authentication and response handling."
"complexityScore": 5,
"recommendedSubtasks": 3,
"expansionPrompt": "Break down the Perplexity API integration into subtasks covering authentication setup, research-oriented prompt creation, response handling, and fallback mechanisms. Each subtask should detail the implementation approach, integration with existing systems, and quality comparison metrics.",
"reasoning": "Similar to the Claude integration but slightly less complex, this task focuses on connecting to the Perplexity API for research capabilities. The complexity is moderate, involving API authentication, prompt templates, and response handling with fallback mechanisms to Claude."
},
{
"taskId": 10,
"taskTitle": "Create Research-Backed Subtask Generation",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Divide the research-backed generation into subtasks including prompt creation, context enrichment, domain knowledge incorporation, detailed generation, and reference inclusion.",
"reasoning": "Enhancing subtask generation with research requires handling domain-specific knowledge and context enrichment, adding complexity."
"complexityScore": 7,
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the research-backed subtask generation into subtasks covering domain-specific prompt creation, context enrichment from research, knowledge incorporation, and detailed subtask generation. Each subtask should specify the approach for leveraging research data and integrating it into the generation process.",
"reasoning": "This task builds on previous work to enhance subtask generation with research capabilities. The complexity comes from effectively incorporating research results into the generation process and creating domain-specific prompts that produce high-quality, detailed subtasks with best practices."
},
{
"taskId": 11,
"taskTitle": "Implement Batch Operations",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the batch operations into subtasks including status updates, subtask generation, task filtering, dependency management, prioritization, and command creation.",
"reasoning": "Implementing batch operations involves handling multiple tasks simultaneously, each with its own set of operations."
"complexityScore": 6,
"recommendedSubtasks": 4,
"expansionPrompt": "Break down the batch operations functionality into subtasks covering multi-task status updates, bulk subtask generation, task filtering/querying, and batch prioritization. Each subtask should detail the command interface, implementation approach, and performance considerations for handling multiple tasks.",
"reasoning": "Implementing batch operations requires extending existing functionality to work with multiple tasks simultaneously. The complexity is moderate, focusing on efficient processing of task sets, filtering capabilities, and maintaining data consistency across bulk operations."
},
{
"taskId": 12,
"taskTitle": "Develop Project Initialization System",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Divide the project initialization into subtasks including templating, setup wizard, environment configuration, directory structure, example tasks, and default configuration.",
"reasoning": "Creating a project initialization system involves setting up multiple components and configurations, increasing complexity."
"complexityScore": 6,
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the project initialization system into subtasks covering project templating, interactive setup wizard, environment configuration, directory structure creation, and example generation. Each subtask should specify the user interaction flow, template design, and integration with existing components.",
"reasoning": "Creating a project initialization system involves setting up templates, an interactive wizard, and generating initial files and directories. The complexity is moderate, focusing on providing a smooth setup experience for new projects with appropriate defaults and configuration."
},
{
"taskId": 13,
"taskTitle": "Create Cursor Rules Implementation",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the Cursor rules implementation into subtasks including documentation creation, rule implementation, directory setup, and integration documentation.",
"reasoning": "Implementing Cursor rules involves creating documentation and setting up directory structures, adding to the complexity."
"complexityScore": 5,
"recommendedSubtasks": 3,
"expansionPrompt": "Break down the Cursor rules implementation into subtasks covering documentation creation (dev_workflow.mdc, cursor_rules.mdc, self_improve.mdc), directory structure setup, and integration documentation. Each subtask should detail the specific content to include and how it enables effective AI interaction.",
"reasoning": "This task focuses on creating documentation and rules for Cursor AI integration. The complexity is moderate, involving the creation of structured documentation files that define how AI should interact with the system and setting up the appropriate directory structure."
},
{
"taskId": 14,
"taskTitle": "Develop Agent Workflow Guidelines",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the agent workflow guidelines into subtasks including task discovery, selection, implementation, verification, prioritization, and dependency handling.",
"reasoning": "Creating guidelines for AI agents involves defining workflows and handling dependencies, increasing complexity."
"complexityScore": 5,
"recommendedSubtasks": 3,
"expansionPrompt": "Divide the agent workflow guidelines into subtasks covering task discovery documentation, selection guidelines, implementation guidance, verification procedures, and prioritization rules. Each subtask should specify the specific guidance to provide and how it enables effective agent workflows.",
"reasoning": "Creating comprehensive guidelines for AI agents involves documenting workflows, selection criteria, and implementation guidance. The complexity is moderate, focusing on clear documentation that helps agents interact effectively with the task system."
},
{
"taskId": 15,
"taskTitle": "Implement Agent Command Integration",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Break down the agent command integration into subtasks including command syntax, example interactions, response patterns, context management, special flags, and output interpretation.",
"reasoning": "Integrating commands for AI agents involves handling syntax, responses, and context, adding to the complexity."
"taskTitle": "Optimize Agent Integration with Cursor and dev.js Commands",
"complexityScore": 6,
"recommendedSubtasks": 4,
"expansionPrompt": "Break down the agent integration optimization into subtasks covering existing pattern documentation, Cursor-dev.js command integration enhancement, workflow documentation improvement, and feature additions. Each subtask should specify the specific improvements to make and how they enhance agent interaction.",
"reasoning": "This task involves enhancing and documenting existing agent interaction patterns with Cursor and dev.js commands. The complexity is moderate, focusing on improving integration between different components and ensuring agents can effectively utilize the system's capabilities."
},
{
"taskId": 16,
"taskTitle": "Create Configuration Management System",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Divide the configuration management into subtasks including environment handling, .env support, validation, defaults, template creation, documentation, and API key security.",
"reasoning": "Implementing a robust configuration system involves handling environment variables, validation, and security, increasing complexity."
"complexityScore": 6,
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the configuration management system into subtasks covering environment variable handling, .env file support, configuration validation, defaults with overrides, and secure API key handling. Each subtask should specify the implementation approach, security considerations, and user experience for configuration.",
"reasoning": "Implementing robust configuration management involves handling environment variables, .env files, validation, and secure storage of sensitive information. The complexity is moderate, focusing on creating a flexible system that works across different environments with appropriate security measures."
},
{
"taskId": 17,
"taskTitle": "Implement Comprehensive Logging System",
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the logging system into subtasks including log levels, output destinations, command logging, API logging, error tracking, metrics, and file rotation.",
"reasoning": "Creating a logging system involves implementing multiple log levels and destinations, adding to the complexity."
"complexityScore": 5,
"recommendedSubtasks": 3,
"expansionPrompt": "Break down the logging system implementation into subtasks covering log level configuration, output destination management, specialized logging (commands, APIs, errors), and performance metrics. Each subtask should detail the implementation approach, configuration options, and integration with existing components.",
"reasoning": "Creating a comprehensive logging system involves implementing multiple log levels, configurable destinations, and specialized logging for different components. The complexity is moderate, focusing on providing useful information for debugging and monitoring while maintaining performance."
},
{
"taskId": 18,
"taskTitle": "Create Comprehensive User Documentation",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Divide the user documentation into subtasks including README creation, command reference, configuration guide, examples, troubleshooting, API documentation, and best practices.",
"reasoning": "Developing comprehensive documentation involves covering multiple aspects of the system, increasing complexity."
"complexityScore": 7,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the user documentation creation into subtasks covering README with installation instructions, command reference, configuration guide, example workflows, troubleshooting guides, and advanced usage. Each subtask should specify the content to include, format, and organization to ensure comprehensive coverage.",
"reasoning": "Creating comprehensive documentation requires covering installation, usage, configuration, examples, and troubleshooting across multiple components. The complexity is moderate to high due to the breadth of functionality to document and the need to make it accessible to different user levels."
},
{
"taskId": 19,
"taskTitle": "Implement Error Handling and Recovery",
"complexityScore": 8,
"recommendedSubtasks": 6,
"expansionPrompt": "Break down the implementation of error handling and recovery into 6 subtasks, focusing on different aspects like message formatting, API handling, file system recovery, data validation, command errors, and system state recovery. For each subtask, specify the key components to implement and any specific techniques or best practices to consider.",
"reasoning": "High complexity due to system-wide implementation, multiple error types, and recovery mechanisms. Requires careful design and integration across various system components."
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the error handling implementation into subtasks covering consistent error formatting, helpful error messages, API error handling with retries, file system error recovery, validation errors, and system state recovery. Each subtask should detail the specific error types to handle, recovery strategies, and user communication approach.",
"reasoning": "Implementing robust error handling across the entire system represents high complexity due to the variety of error types, the need for meaningful messages, and the implementation of recovery mechanisms. This task is critical for system reliability and user experience."
},
{
"taskId": 20,
"taskTitle": "Create Token Usage Tracking and Cost Management",
"complexityScore": 7,
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the token tracking and cost management into subtasks covering usage tracking implementation, configurable limits, reporting features, cost estimation, caching for optimization, and usage alerts. Each subtask should specify the implementation approach, data storage, and user interface for monitoring and managing usage.",
"reasoning": "Implementing token usage tracking involves monitoring API calls, calculating costs, implementing limits, and optimizing usage through caching. The complexity is moderate to high, focusing on providing users with visibility into their API consumption and tools to manage costs."
},
{
"taskId": 21,
"taskTitle": "Refactor dev.js into Modular Components",
"complexityScore": 8,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the token usage tracking and cost management system into 5 subtasks, covering usage tracking implementation, limit configuration, reporting and cost estimation, caching and optimization, and alert system development. For each subtask, outline the main features to implement and any key considerations for effective integration with the existing system.",
"reasoning": "Moderate to high complexity due to the need for accurate tracking, optimization strategies, and integration with existing API systems. Involves both data processing and user-facing features."
"expansionPrompt": "Break down the refactoring of dev.js into subtasks covering module design (commands.js, ai-services.js, task-manager.js, ui.js, utils.js), entry point restructuring, dependency management, error handling standardization, and documentation. Each subtask should detail the specific code to extract, interfaces to define, and integration points between modules.",
"reasoning": "Refactoring a monolithic file into modular components represents high complexity due to the need to identify appropriate boundaries, manage dependencies between modules, and ensure all functionality is preserved. This requires deep understanding of the existing codebase and careful restructuring."
},
{
"taskId": 22,
"taskTitle": "Create Comprehensive Test Suite for Task Master CLI",
"complexityScore": 9,
"recommendedSubtasks": 5,
"expansionPrompt": "Divide the test suite creation into subtasks covering unit test implementation, integration test development, end-to-end test creation, mocking setup, and CI integration. Each subtask should specify the testing approach, coverage goals, test data preparation, and specific functionality to test.",
"reasoning": "Developing a comprehensive test suite represents high complexity due to the need to cover unit, integration, and end-to-end tests across all functionality, implement appropriate mocking, and ensure good test coverage. This requires significant test engineering and understanding of the entire system."
},
{
"taskId": 23,
"taskTitle": "Implement MCP (Model Context Protocol) Server Functionality for Task Master",
"complexityScore": 9,
"recommendedSubtasks": 5,
"expansionPrompt": "Break down the MCP server implementation into subtasks covering core server module creation, endpoint implementation (/context, /models, /execute), context management system, authentication mechanisms, and performance optimization. Each subtask should detail the API design, data structures, and integration with existing Task Master functionality.",
"reasoning": "Implementing an MCP server represents high complexity due to the need to create a RESTful API with multiple endpoints, manage context data efficiently, handle authentication, and ensure compatibility with the MCP specification. This requires significant API design and server-side development work."
},
{
"taskId": 24,
"taskTitle": "Implement AI-Powered Test Generation Command",
"complexityScore": 7,
"recommendedSubtasks": 4,
"expansionPrompt": "Divide the test generation command implementation into subtasks covering command structure and parameter handling, task analysis logic, AI prompt construction, and test file generation. Each subtask should specify the implementation approach, AI interaction pattern, and output formatting requirements.",
"reasoning": "Creating an AI-powered test generation command involves analyzing tasks, constructing effective prompts, and generating well-formatted test files. The complexity is moderate to high, focusing on leveraging AI to produce useful tests based on task descriptions and subtasks."
}
]
}

View File

@@ -150,4 +150,36 @@ describe('Task Manager Module', () => {
expect(nextTask).toBeNull();
});
});
// Skipped tests for analyzeTaskComplexity
describe.skip('analyzeTaskComplexity function', () => {
// These tests are skipped because they require complex mocking
// but document what should be tested
test('should handle valid JSON response from LLM', async () => {
// This test would verify that:
// 1. The function properly calls the AI model
// 2. It correctly parses a valid JSON response
// 3. It generates a properly formatted complexity report
// 4. The report includes all analyzed tasks with their complexity scores
expect(true).toBe(true);
});
test('should handle and fix malformed JSON with unterminated strings', async () => {
// This test would verify that:
// 1. The function can handle JSON with unterminated strings
// 2. It applies regex fixes to repair the malformed JSON
// 3. It still produces a valid report despite receiving bad JSON
expect(true).toBe(true);
});
test('should handle missing tasks in the response', async () => {
// This test would verify that:
// 1. When the AI response is missing some tasks
// 2. The function detects the missing tasks
// 3. It attempts to analyze just those missing tasks
// 4. The final report includes all tasks that could be analyzed
expect(true).toBe(true);
});
});
});