feat: added complexity score handling to list tasks

This commit is contained in:
Shrey Paharia
2025-04-19 02:17:38 +05:30
parent 48a8d952bc
commit b98af1541e
2 changed files with 104 additions and 29 deletions

View File

@@ -4,11 +4,11 @@
*/
import { listTasks } from '../../../../scripts/modules/task-manager.js';
import { getCachedOrExecute } from '../../tools/utils.js';
import {
enableSilentMode,
disableSilentMode
disableSilentMode,
enableSilentMode
} from '../../../../scripts/modules/utils.js';
import { getCachedOrExecute } from '../../tools/utils.js';
/**
* Direct function wrapper for listTasks with error handling and caching.
@@ -19,7 +19,7 @@ import {
*/
export async function listTasksDirect(args, log) {
// Destructure the explicit tasksJsonPath from args
const { tasksJsonPath, status, withSubtasks } = args;
const { tasksJsonPath, reportPath, status, withSubtasks } = args;
if (!tasksJsonPath) {
log.error('listTasksDirect called without tasksJsonPath');
@@ -65,6 +65,21 @@ export async function listTasksDirect(args, log) {
}
};
}
// Add complexity scores to tasks if report exists
const complexityReport = readComplexityReport(reportPath);
if (complexityReport && complexityReport.complexityAnalysis) {
resultData.tasks = resultData.tasks.map((task) => {
const analysis = complexityReport.complexityAnalysis.find(
(a) => a.taskId === task.id
);
if (analysis) {
return { ...task, complexityScore: analysis.complexityScore };
}
return task;
});
}
log.info(
`Core listTasks function retrieved ${resultData.tasks.length} tasks`
);