diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap
index 632273dea0..347b1abeaf 100644
--- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap
+++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap
@@ -354,11 +354,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -367,6 +374,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap
index 09b6b04348..4c7986b27e 100644
--- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap
+++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap
@@ -251,11 +251,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -264,6 +271,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap
index 632273dea0..347b1abeaf 100644
--- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap
+++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap
@@ -354,11 +354,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -367,6 +374,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap
index 7ca32b80a1..dcf10902be 100644
--- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap
+++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap
@@ -403,11 +403,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -416,6 +423,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap
index 7dce6219f3..b832a7569b 100644
--- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap
+++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap
@@ -359,11 +359,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -372,6 +379,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap
index 632273dea0..347b1abeaf 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap
@@ -354,11 +354,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -367,6 +374,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap
index 419049609e..93c9438bfe 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap
@@ -407,11 +407,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -420,6 +427,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap
index 632273dea0..347b1abeaf 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap
@@ -354,11 +354,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -367,6 +374,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap
index 4390b95519..8087ec392e 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap
@@ -442,11 +442,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -455,6 +462,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap
index 632273dea0..347b1abeaf 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap
@@ -354,11 +354,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -367,6 +374,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap
index 191816f180..285984d92c 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap
@@ -407,11 +407,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -420,6 +427,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap
index 7ca32b80a1..dcf10902be 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap
@@ -403,11 +403,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -416,6 +423,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap
index 632273dea0..347b1abeaf 100644
--- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap
+++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap
@@ -354,11 +354,18 @@ Description: This will let you create a new task instance in the chosen mode usi
Parameters:
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
- message: (required) The initial user message or instructions for this new task.
+- todos: (optional) A markdown checklist of todo items to initialize the new task with. Use the same format as update_todo_list.
Usage:
your-mode-slug-here
Your initial instructions here
+
+[ ] First todo item
+[ ] Second todo item
+[x] Completed todo item
+[-] In progress todo item
+
Example:
@@ -367,6 +374,19 @@ Example:
Implement a new feature for the application.
+Example with todos:
+
+code
+Implement user authentication
+
+[ ] Set up authentication middleware
+[ ] Create login endpoint
+[ ] Create logout endpoint
+[ ] Add session management
+[ ] Write tests for authentication
+
+
+
## update_todo_list
diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts
index c7e43db184..5a8efee963 100644
--- a/src/core/task/Task.ts
+++ b/src/core/task/Task.ts
@@ -92,6 +92,7 @@ import { ApiMessage } from "../task-persistence/apiMessages"
import { getMessagesSinceLastSummary, summarizeConversation } from "../condense"
import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning"
import { restoreTodoListForTask } from "../tools/updateTodoListTool"
+import { parseMarkdownChecklist } from "../../shared/todoParser"
// Constants
const MAX_EXPONENTIAL_BACKOFF_SECONDS = 600 // 10 minutes
@@ -1970,35 +1971,11 @@ export class Task extends EventEmitter {
return
}
- this.todoList = []
-
if (!todosMarkdown) {
+ this.todoList = []
return
}
- const lines = todosMarkdown
- .split(/\r?\n/)
- .map((l) => l.trim())
- .filter(Boolean)
-
- for (const line of lines) {
- const match = line.match(/^\[\s*([ xX\-~])\s*\]\s+(.+)$/)
- if (!match) continue
-
- let status: "pending" | "in_progress" | "completed" = "pending"
- if (match[1] === "x" || match[1] === "X") status = "completed"
- else if (match[1] === "-" || match[1] === "~") status = "in_progress"
-
- const id = crypto
- .createHash("md5")
- .update(match[2] + status)
- .digest("hex")
-
- this.todoList.push({
- id,
- content: match[2],
- status,
- })
- }
+ this.todoList = parseMarkdownChecklist(todosMarkdown)
}
}
diff --git a/src/core/tools/updateTodoListTool.ts b/src/core/tools/updateTodoListTool.ts
index cbb90338d3..d403ed9ce0 100644
--- a/src/core/tools/updateTodoListTool.ts
+++ b/src/core/tools/updateTodoListTool.ts
@@ -6,6 +6,7 @@ import cloneDeep from "clone-deep"
import crypto from "crypto"
import { TodoItem, TodoStatus, todoStatusSchema } from "@roo-code/types"
import { getLatestTodo } from "../../shared/todo"
+import { parseMarkdownChecklist } from "../../shared/todoParser"
let approvedTodoList: TodoItem[] | undefined = undefined
@@ -100,32 +101,6 @@ function normalizeStatus(status: string | undefined): TodoStatus {
return "pending"
}
-function parseMarkdownChecklist(md: string): TodoItem[] {
- if (typeof md !== "string") return []
- const lines = md
- .split(/\r?\n/)
- .map((l) => l.trim())
- .filter(Boolean)
- const todos: TodoItem[] = []
- for (const line of lines) {
- const match = line.match(/^\[\s*([ xX\-~])\s*\]\s+(.+)$/)
- if (!match) continue
- let status: TodoStatus = "pending"
- if (match[1] === "x" || match[1] === "X") status = "completed"
- else if (match[1] === "-" || match[1] === "~") status = "in_progress"
- const id = crypto
- .createHash("md5")
- .update(match[2] + status)
- .digest("hex")
- todos.push({
- id,
- content: match[2],
- status,
- })
- }
- return todos
-}
-
export function setPendingTodoList(todos: TodoItem[]) {
approvedTodoList = todos
}
diff --git a/src/shared/todoParser.ts b/src/shared/todoParser.ts
new file mode 100644
index 0000000000..2e6fdf35fd
--- /dev/null
+++ b/src/shared/todoParser.ts
@@ -0,0 +1,45 @@
+import crypto from "crypto"
+import { TodoItem, TodoStatus } from "@roo-code/types"
+
+/**
+ * Parse a markdown checklist into TodoItem array.
+ * Supports the following formats:
+ * - [ ] for pending items
+ * - [x] or [X] for completed items
+ * - [-] or [~] for in-progress items
+ *
+ * @param md Markdown checklist string
+ * @returns Array of TodoItem objects
+ */
+export function parseMarkdownChecklist(md: string): TodoItem[] {
+ if (typeof md !== "string") return []
+
+ const lines = md
+ .split(/\r?\n/)
+ .map((l) => l.trim())
+ .filter(Boolean)
+
+ const todos: TodoItem[] = []
+
+ for (const line of lines) {
+ const match = line.match(/^\[\s*([ xX\-~])\s*\]\s+(.+)$/)
+ if (!match) continue
+
+ let status: TodoStatus = "pending"
+ if (match[1] === "x" || match[1] === "X") status = "completed"
+ else if (match[1] === "-" || match[1] === "~") status = "in_progress"
+
+ const id = crypto
+ .createHash("md5")
+ .update(match[2] + status)
+ .digest("hex")
+
+ todos.push({
+ id,
+ content: match[2],
+ status,
+ })
+ }
+
+ return todos
+}