Skip to content

Commit e5b319a

Browse files
MayDay-wpfNyxJae
authored andcommitted
feat(todo): Support for batch task addition feature
1 parent c618260 commit e5b319a

2 files changed

Lines changed: 63 additions & 17 deletions

File tree

source/api/systemPrompt.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,35 @@ PLACEHOLDER_FOR_WORKFLOW_SECTION
135135
136136
**Available TODO tools:**
137137
- **todo-get**: Get current session's TODO list
138-
- **todo-add**: Add new tasks to existing TODO list
138+
- **todo-add**: Add one or multiple new tasks to existing TODO list (supports batch adding)
139139
- **todo-update**: Update task status or content
140140
- **todo-delete**: Remove tasks from TODO list
141141
142142
**When to use:** Multi-file changes, features, refactoring, bug fixes touching 2+ files
143143
**Skip only:** Single-file trivial edits (1-2 lines)
144144
145+
**RECOMMENDED WORKFLOW - Plan Before Execute:**
146+
- **Before starting programming tasks**: Use todo-add to create a task list first (supports batch adding multiple tasks at once)
147+
- **While executing**: Update task status with todo-update as you complete each step
148+
- **Benefits**: Clear task structure, trackable progress, prevents missing requirements
149+
145150
**CRITICAL - PARALLEL CALLS ONLY:** ALWAYS call TODO tools WITH action tools in same function call block
146-
- CORRECT: todo-get + filesystem-read | todo-update + filesystem-edit
151+
- CORRECT: todo-get + filesystem-read | todo-update + filesystem-edit | todo-add + filesystem-read
147152
- FORBIDDEN: NEVER call TODO tools alone then wait for result
148153
149-
**Lifecycle:** New session → empty TODO auto-created | Add tasks → todo-add | Update progress → todo-update | Remove tasks → todo-delete
154+
**Lifecycle:** Receive task → Add TODO items (todo-add) → Execute & update progress (todo-update) → Clean up completed items (todo-delete)
155+
156+
**todo-add supports both single and batch adding:**
157+
- Single task: Pass a string for 'content' parameter
158+
- Multiple tasks: Pass an array of strings for 'content' to add multiple tasks at once
159+
- Example single: todo-add(content="Task 1")
160+
- Example batch: todo-add(content=["Task 1", "Task 2", "Task 3"])
161+
- This avoids redundant tool calls when adding multiple tasks
150162
151163
**Best practice:**
152164
- Always check current TODO status with todo-get before making changes
153165
- **Keep TODO clean**: Proactively delete obsolete, redundant, or overly detailed completed subtasks to maintain clarity and focus on current work
166+
- Use batch adding when you have multiple tasks to add at once to reduce tool call overhead
154167
155168
## Available Tools
156169

source/mcp/todo.ts

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ Example: todo-update(task1, completed) + filesystem-edit(task2) → Update while
330330
},
331331
{
332332
name: 'todo-add',
333-
description: `Add new task to existing TODO list when requirements expand.
333+
description: `Add one or multiple new tasks to existing TODO list when requirements expand.
334334
335335
MANDATORY RULE - PARALLEL CALLS ONLY:
336336
NEVER call todo-add alone! MUST call with other tools in the SAME function call block.
@@ -342,19 +342,34 @@ USE WHEN:
342342
- You discover additional necessary steps
343343
- Breaking down a complex task into subtasks
344344
345+
SUPPORTS BOTH:
346+
- Single task: Pass a string for 'content'
347+
- Multiple tasks: Pass an array of strings for 'content' to batch add tasks efficiently
348+
345349
TODO will be automatically created for each session.`,
346350
inputSchema: {
347351
type: 'object',
348352
properties: {
349353
content: {
350-
type: 'string',
354+
oneOf: [
355+
{
356+
type: 'string',
357+
description: 'Single TODO item description',
358+
},
359+
{
360+
type: 'array',
361+
items: {type: 'string'},
362+
description:
363+
'Multiple TODO item descriptions for batch adding',
364+
},
365+
],
351366
description:
352-
'TODO item description - must be specific, actionable, and technically precise',
367+
'TODO item description(s) - must be specific, actionable, and technically precise. Can be a single string or an array of strings.',
353368
},
354369
parentId: {
355370
type: 'string',
356371
description:
357-
'Parent TODO ID to create a subtask (optional). Get valid IDs from todo-get.',
372+
'Parent TODO ID to create a subtask (optional). Get valid IDs from todo-get. When adding multiple tasks, all will be added under the same parent.',
358373
},
359374
},
360375
required: ['content'],
@@ -455,19 +470,37 @@ Proactively delete obsolete, redundant, or overly detailed completed subtasks to
455470

456471
case 'add': {
457472
const {content, parentId} = args as {
458-
content: string;
473+
content: string | string[];
459474
parentId?: string;
460475
};
461476

462-
const result = await this.addTodoItem(sessionId, content, parentId);
463-
return {
464-
content: [
465-
{
466-
type: 'text',
467-
text: JSON.stringify(result, null, 2),
468-
},
469-
],
470-
};
477+
// 支持批量添加或单个添加
478+
if (Array.isArray(content)) {
479+
// 批量添加多个TODO项
480+
let currentList = await this.getTodoList(sessionId);
481+
for (const item of content) {
482+
currentList = await this.addTodoItem(sessionId, item, parentId);
483+
}
484+
return {
485+
content: [
486+
{
487+
type: 'text',
488+
text: JSON.stringify(currentList, null, 2),
489+
},
490+
],
491+
};
492+
} else {
493+
// 单个添加
494+
const result = await this.addTodoItem(sessionId, content, parentId);
495+
return {
496+
content: [
497+
{
498+
type: 'text',
499+
text: JSON.stringify(result, null, 2),
500+
},
501+
],
502+
};
503+
}
471504
}
472505

473506
case 'delete': {

0 commit comments

Comments
 (0)