split_tasks
Split complex tasks into manageable subtasks with defined dependencies, priorities, and structured updates. Ideal for streamlining workflows and adapting plans dynamically.
Instructions
Decompose complex tasks into independent subtasks, establishing dependencies and priorities.
updateMode
append: Keep existing tasks and add new ones
overwrite: Delete unfinished tasks, keep completed ones
selective: Intelligently match and update existing tasks based on name
clearAllTasks: Clear all tasks and create a backup (preferred mode)
Key Requirements
Provide concise pseudocode: Only provide high-level logic flow and key steps, avoid complete code
Consolidate when necessary: Simple modifications can be integrated with other tasks to avoid excessive task count
Submit in batches: If there are too many tasks, use the "split_tasks" tool with parameters not exceeding 5000 characters
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| globalAnalysisResult | No | Global analysis result: complete analysis result from reflect_task, applicable to the common parts of all tasks | |
| tasks | Yes | Structured task list, each task should be atomic and have a clear completion standard, avoid overly simple tasks, simple modifications can be integrated with other tasks, avoid too many tasks | |
| updateMode | Yes | Task update mode selection: 'append' (preserve all existing tasks and add new tasks), 'overwrite' (clear all unfinished tasks and completely replace, preserve completed tasks), 'selective' (intelligent update: match and update existing tasks by name, preserve tasks not in the list, recommended for minor task adjustments), 'clearAllTasks' (clear all tasks and create a backup). Default is 'clearAllTasks' mode, only use other modes when the user requests changes or modifications to the plan content |
Implementation Reference
- src/tools/taskTools.ts:296-438 (handler)Main execution logic for the split_tasks tool. Validates input, checks for duplicate task names, processes tasks according to updateMode (clearAllTasks, append, overwrite, selective), calls batchCreateOrUpdateTasks from taskModel, generates a prompt with getSplitTasksPrompt, and returns structured content with ephemeral task creation results.export async function splitTasks({ updateMode, tasks, globalAnalysisResult, }: z.infer<typeof splitTasksSchema>) { try { // Check if there are duplicate names in the tasks const nameSet = new Set(); for (const task of tasks) { if (nameSet.has(task.name)) { return { content: [ { type: "text" as const, text: "Duplicate task names exist in the tasks parameter, please ensure that each task name is unique", }, ], }; } nameSet.add(task.name); } // Process tasks based on different update modes let message = ""; let actionSuccess = true; let backupFile = null; let createdTasks: Task[] = []; let allTasks: Task[] = []; // Convert task data to the format required for batchCreateOrUpdateTasks const convertedTasks = tasks.map((task) => ({ name: task.name, description: task.description, notes: task.notes, dependencies: task.dependencies, implementationGuide: task.implementationGuide, verificationCriteria: task.verificationCriteria, relatedFiles: task.relatedFiles?.map((file) => ({ path: file.path, type: file.type as RelatedFileType, description: file.description, lineStart: file.lineStart, lineEnd: file.lineEnd, })), })); // Process clearAllTasks mode if (updateMode === "clearAllTasks") { const clearResult = await modelClearAllTasks(); if (clearResult.success) { message = clearResult.message; backupFile = clearResult.backupFile; try { // Clear tasks and then create new tasks createdTasks = await batchCreateOrUpdateTasks( convertedTasks, "append", globalAnalysisResult ); message += `\nSuccessfully created ${createdTasks.length} new tasks.`; } catch (error) { actionSuccess = false; message += `\nError occurred when creating new tasks: ${ error instanceof Error ? error.message : String(error) }`; } } else { actionSuccess = false; message = clearResult.message; } } else { // For other modes, directly use batchCreateOrUpdateTasks try { createdTasks = await batchCreateOrUpdateTasks( convertedTasks, updateMode, globalAnalysisResult ); // Generate messages based on different update modes switch (updateMode) { case "append": message = `Successfully appended ${createdTasks.length} new tasks.`; break; case "overwrite": message = `Successfully cleared unfinished tasks and created ${createdTasks.length} new tasks.`; break; case "selective": message = `Successfully selectively updated/created ${createdTasks.length} tasks.`; break; } } catch (error) { actionSuccess = false; message = `Task creation failed: ${ error instanceof Error ? error.message : String(error) }`; } } // Get all tasks for displaying dependency relationships try { allTasks = await getAllTasks(); } catch (error) { allTasks = [...createdTasks]; // If retrieval fails, use just created tasks } // Use prompt generator to get the final prompt const prompt = getSplitTasksPrompt({ updateMode, createdTasks, allTasks, }); return { content: [ { type: "text" as const, text: prompt, }, ], ephemeral: { taskCreationResult: { success: actionSuccess, message, backupFilePath: backupFile, }, }, }; } catch (error) { return { content: [ { type: "text" as const, text: "Error occurred when executing task splitting: " + (error instanceof Error ? error.message : String(error)), }, ], }; } }
- src/tools/taskTools.ts:204-294 (schema)Zod schema defining the input structure for split_tasks tool, including updateMode enum, array of tasks with name, description, implementationGuide, dependencies, notes, relatedFiles, verificationCriteria, and optional globalAnalysisResult. Used for validation in index.ts.export const splitTasksSchema = z.object({ updateMode: z .enum(["append", "overwrite", "selective", "clearAllTasks"]) .describe( "Task update mode selection: 'append' (preserve all existing tasks and add new tasks), 'overwrite' (clear all unfinished tasks and completely replace, preserve completed tasks), 'selective' (intelligent update: match and update existing tasks by name, preserve tasks not in the list, recommended for minor task adjustments), 'clearAllTasks' (clear all tasks and create a backup).\nDefault is 'clearAllTasks' mode, only use other modes when the user requests changes or modifications to the plan content" ), tasks: z .array( z.object({ name: z .string() .max(100, { message: "Task name too long, please limit to 100 characters", }) .describe("Brief and clear task name, should be able to express the purpose of the task"), description: z .string() .min(10, { message: "Task description too short, please provide more detailed content to ensure understanding", }) .describe("Detailed task description, including implementation points, technical details and acceptance standards"), implementationGuide: z .string() .describe( "Specific implementation method and steps for this task, please refer to previous analysis results and provide simplified pseudocode" ), dependencies: z .array(z.string()) .optional() .describe( "List of previous task IDs or task names this task depends on, supports two referencing methods, name referencing is more intuitive, and is a string array" ), notes: z .string() .optional() .describe("Supplementary notes, special processing requirements or implementation suggestions (optional)"), relatedFiles: z .array( z.object({ path: z .string() .min(1, { message: "File path cannot be empty", }) .describe("File path, can be a path relative to the project root directory or an absolute path"), type: z .nativeEnum(RelatedFileType) .describe( "File type (TO_MODIFY: to be modified, REFERENCE: reference material, CREATE: to be created, DEPENDENCY: dependency file, OTHER: other)" ), description: z .string() .min(1, { message: "File description cannot be empty", }) .describe("File description, used to explain the purpose and content of the file"), lineStart: z .number() .int() .positive() .optional() .describe("Starting line of the relevant code block (optional)"), lineEnd: z .number() .int() .positive() .optional() .describe("Ending line of the relevant code block (optional)"), }) ) .optional() .describe( "List of files related to the task, used to record code files, reference materials, files to be created, etc. related to the task (optional)" ), verificationCriteria: z .string() .optional() .describe("Verification criteria and inspection methods for this specific task"), }) ) .min(1, { message: "Please provide at least one task", }) .describe( "Structured task list, each task should be atomic and have a clear completion standard, avoid overly simple tasks, simple modifications can be integrated with other tasks, avoid too many tasks" ), globalAnalysisResult: z .string() .optional() .describe("Global analysis result: complete analysis result from reflect_task, applicable to the common parts of all tasks"), });
- src/index.ts:420-431 (registration)Dispatch logic in CallToolRequestSchema handler: parses arguments with splitTasksSchema and calls splitTasks handler function.case "split_tasks": parsedArgs = await splitTasksSchema.safeParseAsync( request.params.arguments ); if (!parsedArgs.success) { throw new Error( `Invalid arguments for tool ${request.params.name}: ${parsedArgs.error.message}` ); } result = await splitTasks(parsedArgs.data); return result;
- src/index.ts:249-254 (registration)Tool registration in ListToolsRequestSchema handler: defines name 'split_tasks', loads description from markdown template, converts splitTasksSchema to JSON schema for MCP protocol.name: "split_tasks", description: loadPromptFromTemplate( "toolsDescription/splitTasks.md" ), inputSchema: zodToJsonSchema(splitTasksSchema), },
- Prompt generator function getSplitTasksPrompt used by the handler to format the response prompt showing created/updated tasks and dependencies.export function getSplitTasksPrompt(params: SplitTasksPromptParams): string {