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