UNPKG

task-master-neo-sdlc

Version:

Enhanced task management system with Neo SDLC agents and MCP tools for comprehensive, AI-driven software development lifecycle management.

102 lines (93 loc) 2.87 kB
/** * tools/setTaskStatus.js * Tool to set the status of a task */ import { z } from 'zod'; import { handleApiResult, createErrorResponse, getProjectRootFromSession } from './utils.js'; import { setTaskStatusDirect } from '../core/task-master-core.js'; import { findTasksJsonPath } from '../core/utils/path-utils.js'; /** * Register the setTaskStatus tool with the MCP server * @param {Object} server - FastMCP server instance */ export function registerSetTaskStatusTool(server) { server.addTool({ name: 'set_task_status', description: 'Set the status of one or more tasks or subtasks.', parameters: z.object({ id: z .string() .describe( "Task ID or subtask ID (e.g., '15', '15.2'). Can be comma-separated for multiple updates." ), status: z .string() .describe( "New status to set (e.g., 'pending', 'done', 'in-progress', 'review', 'deferred', 'cancelled'." ), file: z.string().optional().describe('Absolute path to the tasks file'), projectRoot: z .string() .describe('The directory of the project. Must be an absolute path.') }), execute: async (args, { log, session }) => { try { log.info(`Setting status of task(s) ${args.id} to: ${args.status}`); // Get project root from args or session const rootFolder = args.projectRoot || getProjectRootFromSession(session, log); // Ensure project root was determined if (!rootFolder) { return createErrorResponse( 'Could not determine project root. Please provide it explicitly or ensure your session contains valid root information.' ); } // Resolve the path to tasks.json let tasksJsonPath; try { tasksJsonPath = findTasksJsonPath( { projectRoot: rootFolder, file: args.file }, log ); } catch (error) { log.error(`Error finding tasks.json: ${error.message}`); return createErrorResponse( `Failed to find tasks.json: ${error.message}` ); } // Call the direct function with the resolved path const result = await setTaskStatusDirect( { // Pass the explicitly resolved path tasksJsonPath: tasksJsonPath, // Pass other relevant args id: args.id, status: args.status }, log ); // Log the result if (result.success) { log.info( `Successfully updated status for task(s) ${args.id} to "${args.status}": ${result.data.message}` ); } else { log.error( `Failed to update task status: ${result.error?.message || 'Unknown error'}` ); } // Format and return the result return handleApiResult(result, log, 'Error setting task status'); } catch (error) { log.error(`Error in setTaskStatus tool: ${error.message}`); return createErrorResponse( `Error setting task status: ${error.message}` ); } } }); }