feat: added handling for next-task in mcp

This commit is contained in:
Shrey Paharia
2025-04-24 00:17:19 +05:30
parent be8fe8092f
commit 8047ec756c
2 changed files with 33 additions and 6 deletions

View File

@@ -4,7 +4,10 @@
*/
import { findNextTask } from '../../../../scripts/modules/task-manager.js';
import { readJSON } from '../../../../scripts/modules/utils.js';
import {
readJSON,
readComplexityReport
} from '../../../../scripts/modules/utils.js';
import { getCachedOrExecute } from '../../tools/utils.js';
import {
enableSilentMode,
@@ -21,7 +24,7 @@ import {
*/
export async function nextTaskDirect(args, log) {
// Destructure expected args
const { tasksJsonPath } = args;
const { tasksJsonPath, reportPath } = args;
if (!tasksJsonPath) {
log.error('nextTaskDirect called without tasksJsonPath');
@@ -36,7 +39,7 @@ export async function nextTaskDirect(args, log) {
}
// Generate cache key using the provided task path
const cacheKey = `nextTask:${tasksJsonPath}`;
const cacheKey = `nextTask:${tasksJsonPath}:${reportPath}`;
// Define the action function to be executed on cache miss
const coreNextTaskAction = async () => {
@@ -59,8 +62,11 @@ export async function nextTaskDirect(args, log) {
};
}
// Read the complexity report
const complexityReport = readComplexityReport(reportPath);
// Find the next task
const nextTask = findNextTask(data.tasks);
const nextTask = findNextTask(data.tasks, complexityReport);
if (!nextTask) {
log.info(