Solves merge conflicts with origin/next.

This commit is contained in:
Eyal Toledano
2025-05-16 18:15:11 -04:00
21 changed files with 566 additions and 124 deletions

View File

@@ -17,7 +17,11 @@ import {
isSilentMode
} from './utils.js';
import fs from 'fs';
import { findNextTask, analyzeTaskComplexity } from './task-manager.js';
import {
findNextTask,
analyzeTaskComplexity,
readComplexityReport
} from './task-manager.js';
import { getProjectName, getDefaultSubtasks } from './config-manager.js';
import { TASK_STATUS_OPTIONS } from '../../src/constants/task-status.js';
import { getTaskMasterVersion } from '../../src/utils/getVersion.js';
@@ -264,12 +268,14 @@ function getStatusWithColor(status, forTable = false) {
* @param {Array} dependencies - Array of dependency IDs
* @param {Array} allTasks - Array of all tasks
* @param {boolean} forConsole - Whether the output is for console display
* @param {Object|null} complexityReport - Optional pre-loaded complexity report
* @returns {string} Formatted dependencies string
*/
function formatDependenciesWithStatus(
dependencies,
allTasks,
forConsole = false
forConsole = false,
complexityReport = null // Add complexityReport parameter
) {
if (
!dependencies ||
@@ -333,7 +339,11 @@ function formatDependenciesWithStatus(
typeof depId === 'string' ? parseInt(depId, 10) : depId;
// Look up the task using the numeric ID
const depTaskResult = findTaskById(allTasks, numericDepId);
const depTaskResult = findTaskById(
allTasks,
numericDepId,
complexityReport
);
const depTask = depTaskResult.task; // Access the task object from the result
if (!depTask) {
@@ -752,7 +762,7 @@ function truncateString(str, maxLength) {
* Display the next task to work on
* @param {string} tasksPath - Path to the tasks.json file
*/
async function displayNextTask(tasksPath) {
async function displayNextTask(tasksPath, complexityReportPath = null) {
displayBanner();
// Read the tasks file
@@ -762,8 +772,11 @@ async function displayNextTask(tasksPath) {
process.exit(1);
}
// Read complexity report once
const complexityReport = readComplexityReport(complexityReportPath);
// Find the next task
const nextTask = findNextTask(data.tasks);
const nextTask = findNextTask(data.tasks, complexityReport);
if (!nextTask) {
console.log(
@@ -824,7 +837,18 @@ async function displayNextTask(tasksPath) {
],
[
chalk.cyan.bold('Dependencies:'),
formatDependenciesWithStatus(nextTask.dependencies, data.tasks, true)
formatDependenciesWithStatus(
nextTask.dependencies,
data.tasks,
true,
complexityReport
)
],
[
chalk.cyan.bold('Complexity:'),
nextTask.complexityScore
? getComplexityWithColor(nextTask.complexityScore)
: chalk.gray('N/A')
],
[chalk.cyan.bold('Description:'), nextTask.description]
);
@@ -1005,7 +1029,12 @@ async function displayNextTask(tasksPath) {
* @param {string|number} taskId - The ID of the task to display
* @param {string} [statusFilter] - Optional status to filter subtasks by
*/
async function displayTaskById(tasksPath, taskId, statusFilter = null) {
async function displayTaskById(
tasksPath,
taskId,
complexityReportPath = null,
statusFilter = null
) {
displayBanner();
// Read the tasks file
@@ -1015,11 +1044,15 @@ async function displayTaskById(tasksPath, taskId, statusFilter = null) {
process.exit(1);
}
// Read complexity report once
const complexityReport = readComplexityReport(complexityReportPath);
// Find the task by ID, applying the status filter if provided
// Returns { task, originalSubtaskCount, originalSubtasks }
const { task, originalSubtaskCount, originalSubtasks } = findTaskById(
data.tasks,
taskId,
complexityReport,
statusFilter
);
@@ -1074,6 +1107,12 @@ async function displayTaskById(tasksPath, taskId, statusFilter = null) {
chalk.cyan.bold('Status:'),
getStatusWithColor(task.status || 'pending', true)
],
[
chalk.cyan.bold('Complexity:'),
task.complexityScore
? getComplexityWithColor(task.complexityScore)
: chalk.gray('N/A')
],
[
chalk.cyan.bold('Description:'),
task.description || 'No description provided.'
@@ -1152,7 +1191,18 @@ async function displayTaskById(tasksPath, taskId, statusFilter = null) {
[chalk.cyan.bold('Priority:'), priorityColor(task.priority || 'medium')],
[
chalk.cyan.bold('Dependencies:'),
formatDependenciesWithStatus(task.dependencies, data.tasks, true)
formatDependenciesWithStatus(
task.dependencies,
data.tasks,
true,
complexityReport
)
],
[
chalk.cyan.bold('Complexity:'),
task.complexityScore
? getComplexityWithColor(task.complexityScore)
: chalk.gray('N/A')
],
[chalk.cyan.bold('Description:'), task.description]
);