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
This commit is contained in:
Roo Code 2025-06-30 09:16:58 +00:00
parent 3a8ba27615
commit 5f8a1c426e
20 changed files with 865 additions and 0 deletions

View file

@ -33,6 +33,7 @@ export const toolNames = [
"new_task",
"fetch_instructions",
"codebase_search",
"manage_todo_list",
] as const
export const toolNamesSchema = z.enum(toolNames)

View file

@ -24,6 +24,7 @@ import { askFollowupQuestionTool } from "../tools/askFollowupQuestionTool"
import { switchModeTool } from "../tools/switchModeTool"
import { attemptCompletionTool } from "../tools/attemptCompletionTool"
import { newTaskTool } from "../tools/newTaskTool"
import { manageTodoListTool } from "../tools/manageTodoListTool"
import { checkpointSave } from "../checkpoints"
@ -211,6 +212,10 @@ export async function presentAssistantMessage(cline: Task) {
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
return `[${block.name} in ${modeName} mode: '${message}']`
}
case "manage_todo_list":
return `[${block.name} for '${block.params.todo_action}']`
default:
return `[${block.name}]`
}
}
@ -504,6 +509,9 @@ export async function presentAssistantMessage(cline: Task) {
case "new_task":
await newTaskTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
case "manage_todo_list":
await manageTodoListTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
case "attempt_completion":
await attemptCompletionTool(
cline,

View file

@ -353,6 +353,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -250,6 +250,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -424,6 +424,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -424,6 +424,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -380,6 +380,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -375,6 +375,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -428,6 +428,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -375,6 +375,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -463,6 +463,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -375,6 +375,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -428,6 +428,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -424,6 +424,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -375,6 +375,54 @@ Example:
</new_task>
## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>
# Tool Use Guidelines
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.

View file

@ -22,6 +22,7 @@ import { getAccessMcpResourceDescription } from "./access-mcp-resource"
import { getSwitchModeDescription } from "./switch-mode"
import { getNewTaskDescription } from "./new-task"
import { getCodebaseSearchDescription } from "./codebase-search"
import { getManageTodoListDescription } from "./manage-todo-list"
import { CodeIndexManager } from "../../../services/code-index/manager"
// Map of tool names to their description functions
@ -43,6 +44,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
new_task: (args) => getNewTaskDescription(args),
insert_content: (args) => getInsertContentDescription(args),
search_and_replace: (args) => getSearchAndReplaceDescription(args),
manage_todo_list: () => getManageTodoListDescription(),
apply_diff: (args) =>
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
}

View file

@ -0,0 +1,49 @@
export function getManageTodoListDescription(): string {
return `## manage_todo_list
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.
Parameters:
- todo_action: (required) The action to perform. Valid values are:
- "add": Add a new item to the todo list
- "complete": Mark an item as completed
- "list": Display the current todo list with completion status
- "clear_completed": Remove all completed items from the list
- "clear_all": Clear the entire todo list
- todo_item: (required for "add" action) The description of the todo item to add
- item_id: (required for "complete" action) The ID of the item to mark as completed
Usage:
<manage_todo_list>
<todo_action>action_name</todo_action>
<todo_item>item description (for add action)</todo_item>
<item_id>item_id (for complete action)</item_id>
</manage_todo_list>
Examples:
1. Add a new todo item:
<manage_todo_list>
<todo_action>add</todo_action>
<todo_item>Create user authentication system</todo_item>
</manage_todo_list>
2. Mark an item as completed:
<manage_todo_list>
<todo_action>complete</todo_action>
<item_id>1</item_id>
</manage_todo_list>
3. View the current todo list:
<manage_todo_list>
<todo_action>list</todo_action>
</manage_todo_list>
4. Clear completed items:
<manage_todo_list>
<todo_action>clear_completed</todo_action>
</manage_todo_list>
5. Clear all items:
<manage_todo_list>
<todo_action>clear_all</todo_action>
</manage_todo_list>`
}

View file

@ -184,6 +184,15 @@ export class Task extends EventEmitter<ClineEvents> {
consecutiveMistakeCountForApplyDiff: Map<string, number> = new Map()
toolUsage: ToolUsage = {}
// Todo List
todoList: Array<{
id: number
description: string
completed: boolean
createdAt: Date
}> = []
nextTodoId: number = 1
// Checkpoints
enableCheckpoints: boolean
checkpointService?: RepoPerTaskCheckpointService

View file

@ -0,0 +1,162 @@
import { Task } from "../task/Task"
import { ToolUse, AskApproval, HandleError, PushToolResult, RemoveClosingTag } from "../../shared/tools"
import { formatResponse } from "../prompts/responses"
interface TodoItem {
id: number
description: string
completed: boolean
createdAt: Date
}
export async function manageTodoListTool(
cline: Task,
block: ToolUse,
askApproval: AskApproval,
handleError: HandleError,
pushToolResult: PushToolResult,
removeClosingTag: RemoveClosingTag,
) {
const todoAction: string | undefined = block.params.todo_action
const todoItem: string | undefined = block.params.todo_item
const itemId: string | undefined = block.params.item_id
try {
if (block.partial) {
await cline
.ask(
"tool",
JSON.stringify({ tool: "manageTodoList", action: removeClosingTag("todo_action", todoAction) }),
block.partial,
)
.catch(() => {})
return
} else {
if (!todoAction) {
cline.consecutiveMistakeCount++
cline.recordToolError("manage_todo_list")
pushToolResult(await cline.sayAndCreateMissingParamError("manage_todo_list", "todo_action"))
return
}
cline.consecutiveMistakeCount = 0
// Get or initialize the todo list from task state
let todoList: TodoItem[] = cline.todoList || []
let nextId = cline.nextTodoId || 1
let result = ""
switch (todoAction) {
case "add": {
if (!todoItem) {
cline.consecutiveMistakeCount++
cline.recordToolError("manage_todo_list")
pushToolResult(await cline.sayAndCreateMissingParamError("manage_todo_list", "todo_item"))
return
}
const newItem: TodoItem = {
id: nextId,
description: todoItem,
completed: false,
createdAt: new Date(),
}
todoList.push(newItem)
cline.nextTodoId = nextId + 1
result = `Added todo item #${nextId}: "${todoItem}"`
break
}
case "complete": {
if (!itemId) {
cline.consecutiveMistakeCount++
cline.recordToolError("manage_todo_list")
pushToolResult(await cline.sayAndCreateMissingParamError("manage_todo_list", "item_id"))
return
}
const id = parseInt(itemId)
const item = todoList.find((item) => item.id === id)
if (!item) {
result = `Todo item #${id} not found`
} else if (item.completed) {
result = `Todo item #${id} is already completed`
} else {
item.completed = true
result = `Marked todo item #${id} as completed: "${item.description}"`
}
break
}
case "list": {
if (todoList.length === 0) {
result = "Todo list is empty"
} else {
const pendingItems = todoList.filter((item) => !item.completed)
const completedItems = todoList.filter((item) => item.completed)
result = "Current Todo List:\n\n"
if (pendingItems.length > 0) {
result += "📋 Pending Items:\n"
pendingItems.forEach((item) => {
result += ` ${item.id}. [ ] ${item.description}\n`
})
}
if (completedItems.length > 0) {
result += "\n✅ Completed Items:\n"
completedItems.forEach((item) => {
result += ` ${item.id}. [✓] ${item.description}\n`
})
}
result += `\nTotal: ${todoList.length} items (${pendingItems.length} pending, ${completedItems.length} completed)`
}
break
}
case "clear_completed": {
const completedCount = todoList.filter((item) => item.completed).length
todoList = todoList.filter((item) => !item.completed)
result = `Cleared ${completedCount} completed items from todo list`
break
}
case "clear_all": {
const totalCount = todoList.length
todoList = []
cline.nextTodoId = 1
result = `Cleared all ${totalCount} items from todo list`
break
}
default:
result = `Invalid todo_action: "${todoAction}". Valid actions are: add, complete, list, clear_completed, clear_all`
break
}
// Save the updated todo list back to the task
cline.todoList = todoList
const didApprove = await askApproval(
"tool",
JSON.stringify({
tool: "manageTodoList",
action: todoAction,
result: result,
}),
)
if (!didApprove) {
return
}
pushToolResult(result)
}
} catch (error) {
await handleError("managing todo list", error)
return
}
}

View file

@ -64,6 +64,9 @@ export const toolParamNames = [
"end_line",
"query",
"args",
"todo_action",
"todo_item",
"item_id",
] as const
export type ToolParamName = (typeof toolParamNames)[number]
@ -163,6 +166,11 @@ export interface SearchAndReplaceToolUse extends ToolUse {
Partial<Pick<Record<ToolParamName, string>, "use_regex" | "ignore_case" | "start_line" | "end_line">>
}
export interface ManageTodoListToolUse extends ToolUse {
name: "manage_todo_list"
params: Partial<Pick<Record<ToolParamName, string>, "todo_action" | "todo_item" | "item_id">>
}
// Define tool group configuration
export type ToolGroupConfig = {
tools: readonly string[]
@ -188,6 +196,7 @@ export const TOOL_DISPLAY_NAMES: Record<ToolName, string> = {
insert_content: "insert content",
search_and_replace: "search and replace",
codebase_search: "codebase search",
manage_todo_list: "manage todo list",
} as const
// Define available tool groups.
@ -226,6 +235,7 @@ export const ALWAYS_AVAILABLE_TOOLS: ToolName[] = [
"attempt_completion",
"switch_mode",
"new_task",
"manage_todo_list",
] as const
export type DiffResult =