fix: fixed next cli command handling
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
sanitizePrompt,
|
||||
findTaskById,
|
||||
readComplexityReport,
|
||||
findTaskInComplexityReport,
|
||||
addComplexityToTask,
|
||||
truncate,
|
||||
enableSilentMode,
|
||||
disableSilentMode,
|
||||
@@ -4543,7 +4543,7 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
|
||||
* @param {Object[]} tasks - The array of tasks
|
||||
* @returns {Object|null} The next task to work on or null if no eligible tasks
|
||||
*/
|
||||
function findNextTask(tasks) {
|
||||
function findNextTask(tasks, complexityReport = null) {
|
||||
// Get all completed task IDs
|
||||
const completedTaskIds = new Set(
|
||||
tasks
|
||||
@@ -4591,6 +4591,9 @@ function findNextTask(tasks) {
|
||||
return a.id - b.id; // Lower ID first
|
||||
})[0]; // Return the first (highest priority) task
|
||||
|
||||
// Add complexity to the task
|
||||
addComplexityToTask(nextTask, complexityReport);
|
||||
|
||||
return nextTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -686,7 +686,7 @@ async function displayNextTask(tasksPath, complexityReportPath = null) {
|
||||
const complexityReport = readComplexityReport(complexityReportPath);
|
||||
|
||||
// Find the next task
|
||||
const nextTask = findNextTask(data.tasks);
|
||||
const nextTask = findNextTask(data.tasks, complexityReport);
|
||||
|
||||
if (!nextTask) {
|
||||
console.log(
|
||||
@@ -759,6 +759,12 @@ async function displayNextTask(tasksPath, complexityReportPath = null) {
|
||||
complexityReport
|
||||
) // Pass complexityReport
|
||||
],
|
||||
[
|
||||
chalk.cyan.bold('Complexity:'),
|
||||
nextTask.complexityScore
|
||||
? getComplexityWithColor(nextTask.complexityScore)
|
||||
: chalk.gray('N/A')
|
||||
],
|
||||
[chalk.cyan.bold('Description:'), nextTask.description]
|
||||
);
|
||||
|
||||
|
||||
@@ -190,6 +190,15 @@ function findTaskInComplexityReport(report, taskId) {
|
||||
return report.complexityAnalysis.find((task) => task.taskId === taskId);
|
||||
}
|
||||
|
||||
function addComplexityToTask(task, complexityReport) {
|
||||
const taskId = task.isSubtask ? task.parentTask.id : task.id;
|
||||
|
||||
const taskAnalysis = findTaskInComplexityReport(complexityReport, taskId);
|
||||
if (taskAnalysis) {
|
||||
task.complexityScore = taskAnalysis.complexityScore;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a task exists in the tasks array
|
||||
* @param {Array} tasks - The tasks array
|
||||
@@ -279,20 +288,7 @@ function findTaskById(tasks, taskId, complexityReport = null) {
|
||||
|
||||
// If we found a task, check for complexity data
|
||||
if (taskResult && complexityReport) {
|
||||
if (complexityReport && complexityReport.complexityAnalysis) {
|
||||
// For a main task, look for a direct match
|
||||
const taskId = taskResult.isSubtask
|
||||
? taskResult.parentTask.id
|
||||
: taskResult.id;
|
||||
|
||||
const taskAnalysis = complexityReport.complexityAnalysis.find(
|
||||
(analysis) => analysis.taskId === taskId
|
||||
);
|
||||
|
||||
if (taskAnalysis) {
|
||||
taskResult.complexityScore = taskAnalysis.complexityScore;
|
||||
}
|
||||
}
|
||||
addComplexityToTask(taskResult, complexityReport);
|
||||
}
|
||||
|
||||
return taskResult;
|
||||
@@ -434,6 +430,7 @@ export {
|
||||
log,
|
||||
LOG_LEVELS,
|
||||
readComplexityReport,
|
||||
addComplexityToTask,
|
||||
readJSON,
|
||||
sanitizePrompt,
|
||||
taskExists,
|
||||
|
||||
Reference in New Issue
Block a user