diff --git a/scripts/modules/commands.js b/scripts/modules/commands.js index d5b46bb4..7a5494f5 100644 --- a/scripts/modules/commands.js +++ b/scripts/modules/commands.js @@ -129,26 +129,26 @@ function registerCommands(programInstance) { console.log( boxen( chalk.white.bold('Parse PRD Help') + - '\n\n' + - chalk.cyan('Usage:') + - '\n' + - ` task-master parse-prd [options]\n\n` + - chalk.cyan('Options:') + - '\n' + - ' -i, --input Path to the PRD file (alternative to positional argument)\n' + - ' -o, --output Output file path (default: "tasks/tasks.json")\n' + - ' -n, --num-tasks Number of tasks to generate (default: 10)\n' + - ' -f, --force Skip confirmation when overwriting existing tasks\n\n' + - chalk.cyan('Example:') + - '\n' + - ' task-master parse-prd requirements.txt --num-tasks 15\n' + - ' task-master parse-prd --input=requirements.txt\n' + - ' task-master parse-prd --force\n\n' + - chalk.yellow('Note: This command will:') + - '\n' + - ' 1. Look for a PRD file at scripts/prd.txt by default\n' + - ' 2. Use the file specified by --input or positional argument if provided\n' + - ' 3. Generate tasks from the PRD and overwrite any existing tasks.json file', + '\n\n' + + chalk.cyan('Usage:') + + '\n' + + ` task-master parse-prd [options]\n\n` + + chalk.cyan('Options:') + + '\n' + + ' -i, --input Path to the PRD file (alternative to positional argument)\n' + + ' -o, --output Output file path (default: "tasks/tasks.json")\n' + + ' -n, --num-tasks Number of tasks to generate (default: 10)\n' + + ' -f, --force Skip confirmation when overwriting existing tasks\n\n' + + chalk.cyan('Example:') + + '\n' + + ' task-master parse-prd requirements.txt --num-tasks 15\n' + + ' task-master parse-prd --input=requirements.txt\n' + + ' task-master parse-prd --force\n\n' + + chalk.yellow('Note: This command will:') + + '\n' + + ' 1. Look for a PRD file at scripts/prd.txt by default\n' + + ' 2. Use the file specified by --input or positional argument if provided\n' + + ' 3. Generate tasks from the PRD and overwrite any existing tasks.json file', { padding: 1, borderColor: 'blue', borderStyle: 'round' } ) ); @@ -1132,25 +1132,25 @@ function registerCommands(programInstance) { chalk.white.bold( `Subtask ${parentId}.${subtask.id} Added Successfully` ) + - '\n\n' + - chalk.white(`Title: ${subtask.title}`) + - '\n' + - chalk.white(`Status: ${getStatusWithColor(subtask.status)}`) + - '\n' + - (dependencies.length > 0 - ? chalk.white(`Dependencies: ${dependencies.join(', ')}`) + - '\n' - : '') + - '\n' + - chalk.white.bold('Next Steps:') + - '\n' + - chalk.cyan( - `1. Run ${chalk.yellow(`task-master show ${parentId}`)} to see the parent task with all subtasks` - ) + - '\n' + - chalk.cyan( - `2. Run ${chalk.yellow(`task-master set-status --id=${parentId}.${subtask.id} --status=in-progress`)} to start working on it` - ), + '\n\n' + + chalk.white(`Title: ${subtask.title}`) + + '\n' + + chalk.white(`Status: ${getStatusWithColor(subtask.status)}`) + + '\n' + + (dependencies.length > 0 + ? chalk.white(`Dependencies: ${dependencies.join(', ')}`) + + '\n' + : '') + + '\n' + + chalk.white.bold('Next Steps:') + + '\n' + + chalk.cyan( + `1. Run ${chalk.yellow(`task-master show ${parentId}`)} to see the parent task with all subtasks` + ) + + '\n' + + chalk.cyan( + `2. Run ${chalk.yellow(`task-master set-status --id=${parentId}.${subtask.id} --status=in-progress`)} to start working on it` + ), { padding: 1, borderColor: 'green', @@ -1166,19 +1166,19 @@ function registerCommands(programInstance) { console.log( boxen( chalk.white.bold('Usage Examples:') + - '\n\n' + - chalk.white('Convert existing task to subtask:') + - '\n' + - chalk.yellow( - ` task-master add-subtask --parent=5 --task-id=8` - ) + - '\n\n' + - chalk.white('Create new subtask:') + - '\n' + - chalk.yellow( - ` task-master add-subtask --parent=5 --title="Implement login UI" --description="Create the login form"` - ) + - '\n\n', + '\n\n' + + chalk.white('Convert existing task to subtask:') + + '\n' + + chalk.yellow( + ` task-master add-subtask --parent=5 --task-id=8` + ) + + '\n\n' + + chalk.white('Create new subtask:') + + '\n' + + chalk.yellow( + ` task-master add-subtask --parent=5 --title="Implement login UI" --description="Create the login form"` + ) + + '\n\n', { padding: 1, borderColor: 'blue', borderStyle: 'round' } ) ); @@ -1200,25 +1200,25 @@ function registerCommands(programInstance) { console.log( boxen( chalk.white.bold('Add Subtask Command Help') + - '\n\n' + - chalk.cyan('Usage:') + - '\n' + - ` task-master add-subtask --parent= [options]\n\n` + - chalk.cyan('Options:') + - '\n' + - ' -p, --parent Parent task ID (required)\n' + - ' -i, --task-id Existing task ID to convert to subtask\n' + - ' -t, --title Title for the new subtask\n' + - ' -d, --description <text> Description for the new subtask\n' + - ' --details <text> Implementation details for the new subtask\n' + - ' --dependencies <ids> Comma-separated list of dependency IDs\n' + - ' -s, --status <status> Status for the new subtask (default: "pending")\n' + - ' -f, --file <file> Path to the tasks file (default: "tasks/tasks.json")\n' + - ' --skip-generate Skip regenerating task files\n\n' + - chalk.cyan('Examples:') + - '\n' + - ' task-master add-subtask --parent=5 --task-id=8\n' + - ' task-master add-subtask -p 5 -t "Implement login UI" -d "Create the login form"', + '\n\n' + + chalk.cyan('Usage:') + + '\n' + + ` task-master add-subtask --parent=<id> [options]\n\n` + + chalk.cyan('Options:') + + '\n' + + ' -p, --parent <id> Parent task ID (required)\n' + + ' -i, --task-id <id> Existing task ID to convert to subtask\n' + + ' -t, --title <title> Title for the new subtask\n' + + ' -d, --description <text> Description for the new subtask\n' + + ' --details <text> Implementation details for the new subtask\n' + + ' --dependencies <ids> Comma-separated list of dependency IDs\n' + + ' -s, --status <status> Status for the new subtask (default: "pending")\n' + + ' -f, --file <file> Path to the tasks file (default: "tasks/tasks.json")\n' + + ' --skip-generate Skip regenerating task files\n\n' + + chalk.cyan('Examples:') + + '\n' + + ' task-master add-subtask --parent=5 --task-id=8\n' + + ' task-master add-subtask -p 5 -t "Implement login UI" -d "Create the login form"', { padding: 1, borderColor: 'blue', borderStyle: 'round' } ) ); @@ -1291,24 +1291,24 @@ function registerCommands(programInstance) { chalk.white.bold( `Subtask ${subtaskId} Converted to Task #${result.id}` ) + - '\n\n' + - chalk.white(`Title: ${result.title}`) + - '\n' + - chalk.white(`Status: ${getStatusWithColor(result.status)}`) + - '\n' + - chalk.white( - `Dependencies: ${result.dependencies.join(', ')}` - ) + - '\n\n' + - chalk.white.bold('Next Steps:') + - '\n' + - chalk.cyan( - `1. Run ${chalk.yellow(`task-master show ${result.id}`)} to see details of the new task` - ) + - '\n' + - chalk.cyan( - `2. Run ${chalk.yellow(`task-master set-status --id=${result.id} --status=in-progress`)} to start working on it` - ), + '\n\n' + + chalk.white(`Title: ${result.title}`) + + '\n' + + chalk.white(`Status: ${getStatusWithColor(result.status)}`) + + '\n' + + chalk.white( + `Dependencies: ${result.dependencies.join(', ')}` + ) + + '\n\n' + + chalk.white.bold('Next Steps:') + + '\n' + + chalk.cyan( + `1. Run ${chalk.yellow(`task-master show ${result.id}`)} to see details of the new task` + ) + + '\n' + + chalk.cyan( + `2. Run ${chalk.yellow(`task-master set-status --id=${result.id} --status=in-progress`)} to start working on it` + ), { padding: 1, borderColor: 'green', @@ -1322,8 +1322,8 @@ function registerCommands(programInstance) { console.log( boxen( chalk.white.bold(`Subtask ${subtaskId} Removed`) + - '\n\n' + - chalk.white('The subtask has been successfully deleted.'), + '\n\n' + + chalk.white('The subtask has been successfully deleted.'), { padding: 1, borderColor: 'green', @@ -1351,21 +1351,21 @@ function registerCommands(programInstance) { console.log( boxen( chalk.white.bold('Remove Subtask Command Help') + - '\n\n' + - chalk.cyan('Usage:') + - '\n' + - ` task-master remove-subtask --id=<parentId.subtaskId> [options]\n\n` + - chalk.cyan('Options:') + - '\n' + - ' -i, --id <id> Subtask ID(s) to remove in format "parentId.subtaskId" (can be comma-separated, required)\n' + - ' -c, --convert Convert the subtask to a standalone task instead of deleting it\n' + - ' -f, --file <file> Path to the tasks file (default: "tasks/tasks.json")\n' + - ' --skip-generate Skip regenerating task files\n\n' + - chalk.cyan('Examples:') + - '\n' + - ' task-master remove-subtask --id=5.2\n' + - ' task-master remove-subtask --id=5.2,6.3,7.1\n' + - ' task-master remove-subtask --id=5.2 --convert', + '\n\n' + + chalk.cyan('Usage:') + + '\n' + + ` task-master remove-subtask --id=<parentId.subtaskId> [options]\n\n` + + chalk.cyan('Options:') + + '\n' + + ' -i, --id <id> Subtask ID(s) to remove in format "parentId.subtaskId" (can be comma-separated, required)\n' + + ' -c, --convert Convert the subtask to a standalone task instead of deleting it\n' + + ' -f, --file <file> Path to the tasks file (default: "tasks/tasks.json")\n' + + ' --skip-generate Skip regenerating task files\n\n' + + chalk.cyan('Examples:') + + '\n' + + ' task-master remove-subtask --id=5.2\n' + + ' task-master remove-subtask --id=5.2,6.3,7.1\n' + + ' task-master remove-subtask --id=5.2 --convert', { padding: 1, borderColor: 'blue', borderStyle: 'round' } ) ); @@ -1404,12 +1404,18 @@ function registerCommands(programInstance) { } // Split task IDs if comma-separated - const taskIdArray = taskIds.split(',').map(id => id.trim()); + const taskIdArray = taskIds.split(',').map((id) => id.trim()); // Validate all task IDs exist before proceeding - const invalidTasks = taskIdArray.filter(id => !taskExists(data.tasks, id)); + const invalidTasks = taskIdArray.filter( + (id) => !taskExists(data.tasks, id) + ); if (invalidTasks.length > 0) { - console.error(chalk.red(`Error: The following tasks were not found: ${invalidTasks.join(', ')}`)); + console.error( + chalk.red( + `Error: The following tasks were not found: ${invalidTasks.join(', ')}` + ) + ); process.exit(1); } @@ -1452,7 +1458,8 @@ function registerCommands(programInstance) { // Show if other tasks depend on it const dependentTasks = data.tasks.filter( (t) => - t.dependencies && t.dependencies.includes(parseInt(taskId, 10)) + t.dependencies && + t.dependencies.includes(parseInt(taskId, 10)) ); if (dependentTasks.length > 0) { @@ -1461,7 +1468,9 @@ function registerCommands(programInstance) { `⚠️ Warning: ${dependentTasks.length} other tasks depend on this task!` ) ); - console.log(chalk.yellow('These dependencies will be removed:')); + console.log( + chalk.yellow('These dependencies will be removed:') + ); dependentTasks.forEach((t) => { console.log(chalk.yellow(` - Task ${t.id}: ${t.title}`)); }); @@ -1504,8 +1513,8 @@ function registerCommands(programInstance) { stopLoadingIndicator(indicator); // Display results - const successfulRemovals = results.filter(r => r.success); - const failedRemovals = results.filter(r => !r.success); + const successfulRemovals = results.filter((r) => r.success); + const failedRemovals = results.filter((r) => !r.success); if (successfulRemovals.length > 0) { console.log( @@ -1513,10 +1522,14 @@ function registerCommands(programInstance) { chalk.green( `Successfully removed ${successfulRemovals.length} task${successfulRemovals.length > 1 ? 's' : ''}` ) + - '\n\n' + - successfulRemovals.map(r => - chalk.white(`✓ ${r.taskId.includes('.') ? 'Subtask' : 'Task'} ${r.taskId}`) - ).join('\n'), + '\n\n' + + successfulRemovals + .map((r) => + chalk.white( + `✓ ${r.taskId.includes('.') ? 'Subtask' : 'Task'} ${r.taskId}` + ) + ) + .join('\n'), { padding: 1, borderColor: 'green', @@ -1533,10 +1546,10 @@ function registerCommands(programInstance) { chalk.red( `Failed to remove ${failedRemovals.length} task${failedRemovals.length > 1 ? 's' : ''}` ) + - '\n\n' + - failedRemovals.map(r => - chalk.white(`✗ ${r.taskId}: ${r.error}`) - ).join('\n'), + '\n\n' + + failedRemovals + .map((r) => chalk.white(`✗ ${r.taskId}: ${r.error}`)) + .join('\n'), { padding: 1, borderColor: 'red', @@ -1761,7 +1774,7 @@ function compareVersions(v1, v2) { function displayUpgradeNotification(currentVersion, latestVersion) { const message = boxen( `${chalk.blue.bold('Update Available!')} ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)}\n\n` + - `Run ${chalk.cyan('npm i task-master-ai@latest -g')} to update to the latest version with new features and bug fixes.`, + `Run ${chalk.cyan('npm i task-master-ai@latest -g')} to update to the latest version with new features and bug fixes.`, { padding: 1, margin: { top: 1, bottom: 1 },