feat: implement set-status MCP command and update changeset

This commit is contained in:
Eyal Toledano
2025-03-31 02:19:53 -04:00
parent 3cb0a89ef7
commit f1cdb33819
6 changed files with 104 additions and 27 deletions

View File

@@ -0,0 +1,83 @@
/**
* set-task-status.js
* Direct function implementation for setting task status
*/
import { setTaskStatus } from '../../../../scripts/modules/task-manager.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
/**
* Direct function wrapper for setTaskStatus with error handling.
*
* @param {Object} args - Command arguments containing id, status and file path options.
* @param {Object} log - Logger object.
* @returns {Promise<Object>} - Result object with success status and data/error information.
*/
export async function setTaskStatusDirect(args, log) {
try {
log.info(`Setting task status with args: ${JSON.stringify(args)}`);
// Check required parameters
if (!args.id) {
const errorMessage = 'No task ID specified. Please provide a task ID to update.';
log.error(errorMessage);
return {
success: false,
error: { code: 'MISSING_TASK_ID', message: errorMessage },
fromCache: false
};
}
if (!args.status) {
const errorMessage = 'No status specified. Please provide a new status value.';
log.error(errorMessage);
return {
success: false,
error: { code: 'MISSING_STATUS', message: errorMessage },
fromCache: false
};
}
// Get tasks file path
let tasksPath;
try {
tasksPath = findTasksJsonPath(args, log);
} catch (error) {
log.error(`Error finding tasks file: ${error.message}`);
return {
success: false,
error: { code: 'TASKS_FILE_ERROR', message: error.message },
fromCache: false
};
}
// Execute core setTaskStatus function
// We need to handle the arguments correctly - this function expects tasksPath, taskIdInput, newStatus
const taskId = args.id;
const newStatus = args.status;
log.info(`Setting task ${taskId} status to "${newStatus}"`);
// Execute the setTaskStatus function with source=mcp to avoid console output
await setTaskStatus(tasksPath, taskId, newStatus);
// Return success data
return {
success: true,
data: {
message: `Successfully updated task ${taskId} status to "${newStatus}"`,
taskId,
status: newStatus,
tasksPath
},
fromCache: false // This operation always modifies state and should never be cached
};
} catch (error) {
log.error(`Error setting task status: ${error.message}`);
return {
success: false,
error: { code: 'SET_STATUS_ERROR', message: error.message || 'Unknown error setting task status' },
fromCache: false
};
}
}

View File

@@ -12,6 +12,7 @@ import { updateTasksDirect } from './direct-functions/update-tasks.js';
import { updateTaskByIdDirect } from './direct-functions/update-task-by-id.js';
import { updateSubtaskByIdDirect } from './direct-functions/update-subtask-by-id.js';
import { generateTaskFilesDirect } from './direct-functions/generate-task-files.js';
import { setTaskStatusDirect } from './direct-functions/set-task-status.js';
// Re-export utility functions
export { findTasksJsonPath } from './utils/path-utils.js';
@@ -25,6 +26,7 @@ export {
updateTaskByIdDirect,
updateSubtaskByIdDirect,
generateTaskFilesDirect,
setTaskStatusDirect,
};
/**
@@ -39,5 +41,6 @@ export const directFunctions = {
updateTask: updateTaskByIdDirect,
updateSubtask: updateSubtaskByIdDirect,
generate: generateTaskFilesDirect,
setStatus: setTaskStatusDirect,
// Add more functions as we implement them
};