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,
|
disableSilentMode,
|
||||||
isSilentMode
|
isSilentMode
|
||||||
} from '../../../../scripts/modules/utils.js';
|
} from '../../../../scripts/modules/utils.js';
|
||||||
|
import { nextTaskDirect } from './next-task.js';
|
||||||
/**
|
/**
|
||||||
* Direct function wrapper for setTaskStatus with error handling.
|
* Direct function wrapper for setTaskStatus with error handling.
|
||||||
*
|
*
|
||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
*/
|
*/
|
||||||
export async function setTaskStatusDirect(args, log) {
|
export async function setTaskStatusDirect(args, log) {
|
||||||
// Destructure expected args, including the resolved tasksJsonPath
|
// Destructure expected args, including the resolved tasksJsonPath
|
||||||
const { tasksJsonPath, id, status } = args;
|
const { tasksJsonPath, id, status, complexityReportPath } = args;
|
||||||
try {
|
try {
|
||||||
log.info(`Setting task status with args: ${JSON.stringify(args)}`);
|
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
|
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;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`Error setting task status: ${error.message}`);
|
log.error(`Error setting task status: ${error.message}`);
|
||||||
|
|||||||
@@ -9,8 +9,14 @@ import {
|
|||||||
createErrorResponse,
|
createErrorResponse,
|
||||||
withNormalizedProjectRoot
|
withNormalizedProjectRoot
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
import { setTaskStatusDirect } from '../core/task-master-core.js';
|
import {
|
||||||
import { findTasksJsonPath } from '../core/utils/path-utils.js';
|
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';
|
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'."
|
"New status to set (e.g., 'pending', 'done', 'in-progress', 'review', 'deferred', 'cancelled'."
|
||||||
),
|
),
|
||||||
file: z.string().optional().describe('Absolute path to the tasks file'),
|
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
|
projectRoot: z
|
||||||
.string()
|
.string()
|
||||||
.describe('The directory of the project. Must be an absolute path.')
|
.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(
|
const result = await setTaskStatusDirect(
|
||||||
{
|
{
|
||||||
tasksJsonPath: tasksJsonPath,
|
tasksJsonPath: tasksJsonPath,
|
||||||
id: args.id,
|
id: args.id,
|
||||||
status: args.status
|
status: args.status,
|
||||||
|
complexityReportPath
|
||||||
},
|
},
|
||||||
log
|
log
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user