Skip to content

Commit 5f8a1c4

Browse files
committed
feat: implement todo list management tool for task tracking
- Add manage_todo_list tool with full CRUD operations (add, complete, list, clear_completed, clear_all) - Integrate tool into existing architecture following established patterns - Add persistent storage in Task class with todoList and nextTodoId properties - Include comprehensive tool description with examples and parameter validation - Add tool to always available tools for consistent access across modes - Update test snapshots to include new tool in system prompts - Fix ESLint warnings by adding braces around case blocks with lexical declarations Resolves #5181
1 parent 3a8ba27 commit 5f8a1c4

20 files changed

+865
-0
lines changed

packages/types/src/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const toolNames = [
3333
"new_task",
3434
"fetch_instructions",
3535
"codebase_search",
36+
"manage_todo_list",
3637
] as const
3738

3839
export const toolNamesSchema = z.enum(toolNames)

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { askFollowupQuestionTool } from "../tools/askFollowupQuestionTool"
2424
import { switchModeTool } from "../tools/switchModeTool"
2525
import { attemptCompletionTool } from "../tools/attemptCompletionTool"
2626
import { newTaskTool } from "../tools/newTaskTool"
27+
import { manageTodoListTool } from "../tools/manageTodoListTool"
2728

2829
import { checkpointSave } from "../checkpoints"
2930

@@ -211,6 +212,10 @@ export async function presentAssistantMessage(cline: Task) {
211212
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
212213
return `[${block.name} in ${modeName} mode: '${message}']`
213214
}
215+
case "manage_todo_list":
216+
return `[${block.name} for '${block.params.todo_action}']`
217+
default:
218+
return `[${block.name}]`
214219
}
215220
}
216221

@@ -504,6 +509,9 @@ export async function presentAssistantMessage(cline: Task) {
504509
case "new_task":
505510
await newTaskTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
506511
break
512+
case "manage_todo_list":
513+
await manageTodoListTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
514+
break
507515
case "attempt_completion":
508516
await attemptCompletionTool(
509517
cline,

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,54 @@ Example:
353353
</new_task>
354354

355355

356+
## manage_todo_list
357+
Description: Manage a todo list to track progress during complex task execution. This tool helps ensure no steps are missed by maintaining a persistent list of tasks and their completion status. Use this tool to add items, mark them as complete, view the current list, or clear completed items.
358+
Parameters:
359+
- todo_action: (required) The action to perform. Valid values are:
360+
- "add": Add a new item to the todo list
361+
- "complete": Mark an item as completed
362+
- "list": Display the current todo list with completion status
363+
- "clear_completed": Remove all completed items from the list
364+
- "clear_all": Clear the entire todo list
365+
- todo_item: (required for "add" action) The description of the todo item to add
366+
- item_id: (required for "complete" action) The ID of the item to mark as completed
367+
368+
Usage:
369+
<manage_todo_list>
370+
<todo_action>action_name</todo_action>
371+
<todo_item>item description (for add action)</todo_item>
372+
<item_id>item_id (for complete action)</item_id>
373+
</manage_todo_list>
374+
375+
Examples:
376+
377+
1. Add a new todo item:
378+
<manage_todo_list>
379+
<todo_action>add</todo_action>
380+
<todo_item>Create user authentication system</todo_item>
381+
</manage_todo_list>
382+
383+
2. Mark an item as completed:
384+
<manage_todo_list>
385+
<todo_action>complete</todo_action>
386+
<item_id>1</item_id>
387+
</manage_todo_list>
388+
389+
3. View the current todo list:
390+
<manage_todo_list>
391+
<todo_action>list</todo_action>
392+
</manage_todo_list>
393+
394+
4. Clear completed items:
395+
<manage_todo_list>
396+
<todo_action>clear_completed</todo_action>
397+
</manage_todo_list>
398+
399+
5. Clear all items:
400+
<manage_todo_list>
401+
<todo_action>clear_all</todo_action>
402+
</manage_todo_list>
403+
356404
# Tool Use Guidelines
357405

358406
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,54 @@ Example:
250250
</new_task>
251251

252252

253+
## manage_todo_list
254+
Description: Manage a todo list to track progress during complex task execution. This tool helps ensure no steps are missed by maintaining a persistent list of tasks and their completion status. Use this tool to add items, mark them as complete, view the current list, or clear completed items.
255+
Parameters:
256+
- todo_action: (required) The action to perform. Valid values are:
257+
- "add": Add a new item to the todo list
258+
- "complete": Mark an item as completed
259+
- "list": Display the current todo list with completion status
260+
- "clear_completed": Remove all completed items from the list
261+
- "clear_all": Clear the entire todo list
262+
- todo_item: (required for "add" action) The description of the todo item to add
263+
- item_id: (required for "complete" action) The ID of the item to mark as completed
264+
265+
Usage:
266+
<manage_todo_list>
267+
<todo_action>action_name</todo_action>
268+
<todo_item>item description (for add action)</todo_item>
269+
<item_id>item_id (for complete action)</item_id>
270+
</manage_todo_list>
271+
272+
Examples:
273+
274+
1. Add a new todo item:
275+
<manage_todo_list>
276+
<todo_action>add</todo_action>
277+
<todo_item>Create user authentication system</todo_item>
278+
</manage_todo_list>
279+
280+
2. Mark an item as completed:
281+
<manage_todo_list>
282+
<todo_action>complete</todo_action>
283+
<item_id>1</item_id>
284+
</manage_todo_list>
285+
286+
3. View the current todo list:
287+
<manage_todo_list>
288+
<todo_action>list</todo_action>
289+
</manage_todo_list>
290+
291+
4. Clear completed items:
292+
<manage_todo_list>
293+
<todo_action>clear_completed</todo_action>
294+
</manage_todo_list>
295+
296+
5. Clear all items:
297+
<manage_todo_list>
298+
<todo_action>clear_all</todo_action>
299+
</manage_todo_list>
300+
253301
# Tool Use Guidelines
254302

255303
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,54 @@ Example:
424424
</new_task>
425425

426426

427+
## manage_todo_list
428+
Description: Manage a todo list to track progress during complex task execution. This tool helps ensure no steps are missed by maintaining a persistent list of tasks and their completion status. Use this tool to add items, mark them as complete, view the current list, or clear completed items.
429+
Parameters:
430+
- todo_action: (required) The action to perform. Valid values are:
431+
- "add": Add a new item to the todo list
432+
- "complete": Mark an item as completed
433+
- "list": Display the current todo list with completion status
434+
- "clear_completed": Remove all completed items from the list
435+
- "clear_all": Clear the entire todo list
436+
- todo_item: (required for "add" action) The description of the todo item to add
437+
- item_id: (required for "complete" action) The ID of the item to mark as completed
438+
439+
Usage:
440+
<manage_todo_list>
441+
<todo_action>action_name</todo_action>
442+
<todo_item>item description (for add action)</todo_item>
443+
<item_id>item_id (for complete action)</item_id>
444+
</manage_todo_list>
445+
446+
Examples:
447+
448+
1. Add a new todo item:
449+
<manage_todo_list>
450+
<todo_action>add</todo_action>
451+
<todo_item>Create user authentication system</todo_item>
452+
</manage_todo_list>
453+
454+
2. Mark an item as completed:
455+
<manage_todo_list>
456+
<todo_action>complete</todo_action>
457+
<item_id>1</item_id>
458+
</manage_todo_list>
459+
460+
3. View the current todo list:
461+
<manage_todo_list>
462+
<todo_action>list</todo_action>
463+
</manage_todo_list>
464+
465+
4. Clear completed items:
466+
<manage_todo_list>
467+
<todo_action>clear_completed</todo_action>
468+
</manage_todo_list>
469+
470+
5. Clear all items:
471+
<manage_todo_list>
472+
<todo_action>clear_all</todo_action>
473+
</manage_todo_list>
474+
427475
# Tool Use Guidelines
428476

429477
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,54 @@ Example:
424424
</new_task>
425425

426426

427+
## manage_todo_list
428+
Description: Manage a todo list to track progress during complex task execution. This tool helps ensure no steps are missed by maintaining a persistent list of tasks and their completion status. Use this tool to add items, mark them as complete, view the current list, or clear completed items.
429+
Parameters:
430+
- todo_action: (required) The action to perform. Valid values are:
431+
- "add": Add a new item to the todo list
432+
- "complete": Mark an item as completed
433+
- "list": Display the current todo list with completion status
434+
- "clear_completed": Remove all completed items from the list
435+
- "clear_all": Clear the entire todo list
436+
- todo_item: (required for "add" action) The description of the todo item to add
437+
- item_id: (required for "complete" action) The ID of the item to mark as completed
438+
439+
Usage:
440+
<manage_todo_list>
441+
<todo_action>action_name</todo_action>
442+
<todo_item>item description (for add action)</todo_item>
443+
<item_id>item_id (for complete action)</item_id>
444+
</manage_todo_list>
445+
446+
Examples:
447+
448+
1. Add a new todo item:
449+
<manage_todo_list>
450+
<todo_action>add</todo_action>
451+
<todo_item>Create user authentication system</todo_item>
452+
</manage_todo_list>
453+
454+
2. Mark an item as completed:
455+
<manage_todo_list>
456+
<todo_action>complete</todo_action>
457+
<item_id>1</item_id>
458+
</manage_todo_list>
459+
460+
3. View the current todo list:
461+
<manage_todo_list>
462+
<todo_action>list</todo_action>
463+
</manage_todo_list>
464+
465+
4. Clear completed items:
466+
<manage_todo_list>
467+
<todo_action>clear_completed</todo_action>
468+
</manage_todo_list>
469+
470+
5. Clear all items:
471+
<manage_todo_list>
472+
<todo_action>clear_all</todo_action>
473+
</manage_todo_list>
474+
427475
# Tool Use Guidelines
428476

429477
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,54 @@ Example:
380380
</new_task>
381381

382382

383+
## manage_todo_list
384+
Description: Manage a todo list to track progress during complex task execution. This tool helps ensure no steps are missed by maintaining a persistent list of tasks and their completion status. Use this tool to add items, mark them as complete, view the current list, or clear completed items.
385+
Parameters:
386+
- todo_action: (required) The action to perform. Valid values are:
387+
- "add": Add a new item to the todo list
388+
- "complete": Mark an item as completed
389+
- "list": Display the current todo list with completion status
390+
- "clear_completed": Remove all completed items from the list
391+
- "clear_all": Clear the entire todo list
392+
- todo_item: (required for "add" action) The description of the todo item to add
393+
- item_id: (required for "complete" action) The ID of the item to mark as completed
394+
395+
Usage:
396+
<manage_todo_list>
397+
<todo_action>action_name</todo_action>
398+
<todo_item>item description (for add action)</todo_item>
399+
<item_id>item_id (for complete action)</item_id>
400+
</manage_todo_list>
401+
402+
Examples:
403+
404+
1. Add a new todo item:
405+
<manage_todo_list>
406+
<todo_action>add</todo_action>
407+
<todo_item>Create user authentication system</todo_item>
408+
</manage_todo_list>
409+
410+
2. Mark an item as completed:
411+
<manage_todo_list>
412+
<todo_action>complete</todo_action>
413+
<item_id>1</item_id>
414+
</manage_todo_list>
415+
416+
3. View the current todo list:
417+
<manage_todo_list>
418+
<todo_action>list</todo_action>
419+
</manage_todo_list>
420+
421+
4. Clear completed items:
422+
<manage_todo_list>
423+
<todo_action>clear_completed</todo_action>
424+
</manage_todo_list>
425+
426+
5. Clear all items:
427+
<manage_todo_list>
428+
<todo_action>clear_all</todo_action>
429+
</manage_todo_list>
430+
383431
# Tool Use Guidelines
384432

385433
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,54 @@ Example:
375375
</new_task>
376376

377377

378+
## manage_todo_list
379+
Description: Manage a todo list to track progress during complex task execution. This tool helps ensure no steps are missed by maintaining a persistent list of tasks and their completion status. Use this tool to add items, mark them as complete, view the current list, or clear completed items.
380+
Parameters:
381+
- todo_action: (required) The action to perform. Valid values are:
382+
- "add": Add a new item to the todo list
383+
- "complete": Mark an item as completed
384+
- "list": Display the current todo list with completion status
385+
- "clear_completed": Remove all completed items from the list
386+
- "clear_all": Clear the entire todo list
387+
- todo_item: (required for "add" action) The description of the todo item to add
388+
- item_id: (required for "complete" action) The ID of the item to mark as completed
389+
390+
Usage:
391+
<manage_todo_list>
392+
<todo_action>action_name</todo_action>
393+
<todo_item>item description (for add action)</todo_item>
394+
<item_id>item_id (for complete action)</item_id>
395+
</manage_todo_list>
396+
397+
Examples:
398+
399+
1. Add a new todo item:
400+
<manage_todo_list>
401+
<todo_action>add</todo_action>
402+
<todo_item>Create user authentication system</todo_item>
403+
</manage_todo_list>
404+
405+
2. Mark an item as completed:
406+
<manage_todo_list>
407+
<todo_action>complete</todo_action>
408+
<item_id>1</item_id>
409+
</manage_todo_list>
410+
411+
3. View the current todo list:
412+
<manage_todo_list>
413+
<todo_action>list</todo_action>
414+
</manage_todo_list>
415+
416+
4. Clear completed items:
417+
<manage_todo_list>
418+
<todo_action>clear_completed</todo_action>
419+
</manage_todo_list>
420+
421+
5. Clear all items:
422+
<manage_todo_list>
423+
<todo_action>clear_all</todo_action>
424+
</manage_todo_list>
425+
378426
# Tool Use Guidelines
379427

380428
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

0 commit comments

Comments
 (0)