Add next task to set status for mcp server (#558)
This commit is contained in:
6
.changeset/twenty-plums-act.md
Normal file
6
.changeset/twenty-plums-act.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'task-master-ai': minor
|
||||
---
|
||||
|
||||
Add next task to set task status response
|
||||
Status: DONE
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
disableSilentMode,
|
||||
isSilentMode
|
||||
} from '../../../../scripts/modules/utils.js';
|
||||
|
||||
import { nextTaskDirect } from './next-task.js';
|
||||
/**
|
||||
* Direct function wrapper for setTaskStatus with error handling.
|
||||
*
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
*/
|
||||
export async function setTaskStatusDirect(args, log) {
|
||||
// Destructure expected args, including the resolved tasksJsonPath
|
||||
const { tasksJsonPath, id, status } = args;
|
||||
const { tasksJsonPath, id, status, complexityReportPath } = args;
|
||||
try {
|
||||
log.info(`Setting task status with args: ${JSON.stringify(args)}`);
|
||||
|
||||
@@ -85,6 +85,39 @@ export async function setTaskStatusDirect(args, log) {
|
||||
},
|
||||
fromCache: false // This operation always modifies state and should never be cached
|
||||
};
|
||||
|
||||
// If the task was completed, attempt to fetch the next task
|
||||
if (result.data.status === 'done') {
|
||||
try {
|
||||
log.info(`Attempting to fetch next task for task ${taskId}`);
|
||||
const nextResult = await nextTaskDirect(
|
||||
{
|
||||
tasksJsonPath: tasksJsonPath,
|
||||
reportPath: complexityReportPath
|
||||
},
|
||||
log
|
||||
);
|
||||
|
||||
if (nextResult.success) {
|
||||
log.info(
|
||||
`Successfully retrieved next task: ${nextResult.data.nextTask}`
|
||||
);
|
||||
result.data = {
|
||||
...result.data,
|
||||
nextTask: nextResult.data.nextTask,
|
||||
isNextSubtask: nextResult.data.isSubtask,
|
||||
nextSteps: nextResult.data.nextSteps
|
||||
};
|
||||
} else {
|
||||
log.warn(
|
||||
`Failed to retrieve next task: ${nextResult.error?.message || 'Unknown error'}`
|
||||
);
|
||||
}
|
||||
} catch (nextErr) {
|
||||
log.error(`Error retrieving next task: ${nextErr.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
log.error(`Error setting task status: ${error.message}`);
|
||||
|
||||
@@ -9,8 +9,14 @@ import {
|
||||
createErrorResponse,
|
||||
withNormalizedProjectRoot
|
||||
} from './utils.js';
|
||||
import { setTaskStatusDirect } from '../core/task-master-core.js';
|
||||
import { findTasksJsonPath } from '../core/utils/path-utils.js';
|
||||
import {
|
||||
setTaskStatusDirect,
|
||||
nextTaskDirect
|
||||
} from '../core/task-master-core.js';
|
||||
import {
|
||||
findTasksJsonPath,
|
||||
findComplexityReportPath
|
||||
} from '../core/utils/path-utils.js';
|
||||
import { TASK_STATUS_OPTIONS } from '../../../src/constants/task-status.js';
|
||||
|
||||
/**
|
||||
@@ -33,6 +39,12 @@ export function registerSetTaskStatusTool(server) {
|
||||
"New status to set (e.g., 'pending', 'done', 'in-progress', 'review', 'deferred', 'cancelled'."
|
||||
),
|
||||
file: z.string().optional().describe('Absolute path to the tasks file'),
|
||||
complexityReport: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
'Path to the complexity report file (relative to project root or absolute)'
|
||||
),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe('The directory of the project. Must be an absolute path.')
|
||||
@@ -55,11 +67,23 @@ export function registerSetTaskStatusTool(server) {
|
||||
);
|
||||
}
|
||||
|
||||
let complexityReportPath;
|
||||
try {
|
||||
complexityReportPath = findComplexityReportPath(
|
||||
args.projectRoot,
|
||||
args.complexityReport,
|
||||
log
|
||||
);
|
||||
} catch (error) {
|
||||
log.error(`Error finding complexity report: ${error.message}`);
|
||||
}
|
||||
|
||||
const result = await setTaskStatusDirect(
|
||||
{
|
||||
tasksJsonPath: tasksJsonPath,
|
||||
id: args.id,
|
||||
status: args.status
|
||||
status: args.status,
|
||||
complexityReportPath
|
||||
},
|
||||
log
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user