Skip to content

Commit eaee2fc

Browse files
committed
add todos
1 parent ad201cc commit eaee2fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1362
-3
lines changed

packages/types/src/global-settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const globalSettingsSchema = z.object({
4747
alwaysAllowExecute: z.boolean().optional(),
4848
alwaysAllowFollowupQuestions: z.boolean().optional(),
4949
followupAutoApproveTimeoutMs: z.number().optional(),
50+
alwaysAllowUpdateTodoList: z.boolean().optional(),
5051
allowedCommands: z.array(z.string()).optional(),
5152
allowedMaxRequests: z.number().nullish(),
5253
autoCondenseContext: z.boolean().optional(),
@@ -195,6 +196,7 @@ export const EVALS_SETTINGS: RooCodeSettings = {
195196
alwaysAllowSubtasks: true,
196197
alwaysAllowExecute: true,
197198
alwaysAllowFollowupQuestions: true,
199+
alwaysAllowUpdateTodoList: true,
198200
followupAutoApproveTimeoutMs: 0,
199201
allowedCommands: ["*"],
200202

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export * from "./terminal.js"
2020
export * from "./tool.js"
2121
export * from "./type-fu.js"
2222
export * from "./vscode.js"
23+
export * from "./todo.js"

packages/types/src/message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const clineSays = [
106106
"condense_context",
107107
"condense_context_error",
108108
"codebase_search_result",
109+
"user_edit_todos",
109110
] as const
110111

111112
export const clineSaySchema = z.enum(clineSays)

packages/types/src/todo.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { z } from "zod"
2+
3+
/**
4+
* TodoStatus
5+
*/
6+
export const todoStatusSchema = z.enum(["pending", "in_progress", "completed", "cancelled"] as const)
7+
8+
export type TodoStatus = z.infer<typeof todoStatusSchema>
9+
10+
/**
11+
* TodoItem
12+
*/
13+
export const todoItemSchema = z.object({
14+
id: z.string().optional(),
15+
content: z.string(),
16+
status: todoStatusSchema,
17+
})
18+
19+
export type TodoItem = z.infer<typeof todoItemSchema>

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+
"update_todo_list",
3637
] as const
3738

3839
export const toolNamesSchema = z.enum(toolNames)

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { attemptCompletionTool } from "../tools/attemptCompletionTool"
2626
import { newTaskTool } from "../tools/newTaskTool"
2727

2828
import { checkpointSave } from "../checkpoints"
29+
import { updateTodoListTool } from "../tools/updateTodoListTool"
2930

3031
import { formatResponse } from "../prompts/responses"
3132
import { validateToolUse } from "../tools/validateToolUse"
@@ -211,6 +212,8 @@ export async function presentAssistantMessage(cline: Task) {
211212
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
212213
return `[${block.name} in ${modeName} mode: '${message}']`
213214
}
215+
default:
216+
return `[${block.name}]`
214217
}
215218
}
216219

@@ -410,6 +413,9 @@ export async function presentAssistantMessage(cline: Task) {
410413
case "write_to_file":
411414
await writeToFileTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
412415
break
416+
case "update_todo_list":
417+
await updateTodoListTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
418+
break
413419
case "apply_diff": {
414420
// Get the provider and state to check experiment settings
415421
const provider = cline.providerRef.deref()

src/core/environment/getEnvironmentDetails.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { arePathsEqual } from "../../utils/path"
1818
import { formatResponse } from "../prompts/responses"
1919

2020
import { Task } from "../task/Task"
21+
import { formatReminderSection } from "./reminder"
2122

2223
export async function getEnvironmentDetails(cline: Task, includeFileDetails: boolean = false) {
2324
let details = ""
@@ -273,5 +274,6 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
273274
}
274275
}
275276

276-
return `<environment_details>\n${details.trim()}\n</environment_details>`
277+
const reminderSection = formatReminderSection(cline.todoList)
278+
return `<environment_details>\n${details.trim()}\n${reminderSection}\n</environment_details>`
277279
}

src/core/environment/reminder.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { TodoItem } from "@roo-code/types"
2+
3+
/**
4+
* Format the reminders section as a markdown block in English, with basic instructions.
5+
*/
6+
export function formatReminderSection(todoList?: TodoItem[]): string {
7+
if (!todoList || todoList.length === 0) {
8+
return ""
9+
}
10+
const statusMap: Record<string, string> = {
11+
pending: "Pending",
12+
in_progress: "In Progress",
13+
completed: "Completed",
14+
}
15+
const lines: string[] = [
16+
"====",
17+
"",
18+
"REMINDERS",
19+
"",
20+
"Below is your current list of reminders for this task. Keep them updated as you progress.",
21+
"",
22+
]
23+
24+
lines.push("| # | Content | Status |")
25+
lines.push("|---|---------|--------|")
26+
todoList.forEach((item, idx) => {
27+
const escapedContent = item.content.replace(/\\/g, "\\\\").replace(/\|/g, "\\|")
28+
lines.push(`| ${idx + 1} | ${escapedContent} | ${statusMap[item.status] || item.status} |`)
29+
})
30+
lines.push("")
31+
32+
lines.push(
33+
"",
34+
"IMPORTANT: When task status changes, remember to call the `update_todo_list` tool to update your progress.",
35+
"",
36+
)
37+
return lines.join("\n")
38+
}

src/core/prompts/system.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from "vscode"
22
import * as os from "os"
33

4-
import type { ModeConfig, PromptComponent, CustomModePrompts } from "@roo-code/types"
4+
import type { ModeConfig, PromptComponent, CustomModePrompts, TodoItem } from "@roo-code/types"
55

66
import { Mode, modes, defaultModeSlug, getModeBySlug, getGroupName, getModeSelection } from "../../shared/modes"
77
import { DiffStrategy } from "../../shared/tools"
@@ -44,6 +44,7 @@ async function generatePrompt(
4444
rooIgnoreInstructions?: string,
4545
partialReadsEnabled?: boolean,
4646
settings?: Record<string, any>,
47+
todoList?: TodoItem[],
4748
): Promise<string> {
4849
if (!context) {
4950
throw new Error("Extension context is required for generating system prompt")
@@ -122,6 +123,7 @@ export const SYSTEM_PROMPT = async (
122123
rooIgnoreInstructions?: string,
123124
partialReadsEnabled?: boolean,
124125
settings?: Record<string, any>,
126+
todoList?: TodoItem[],
125127
): Promise<string> => {
126128
if (!context) {
127129
throw new Error("Extension context is required for generating system prompt")
@@ -195,5 +197,6 @@ ${customInstructions}`
195197
rooIgnoreInstructions,
196198
partialReadsEnabled,
197199
settings,
200+
todoList,
198201
)
199202
}

src/core/prompts/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { getAccessMcpResourceDescription } from "./access-mcp-resource"
2222
import { getSwitchModeDescription } from "./switch-mode"
2323
import { getNewTaskDescription } from "./new-task"
2424
import { getCodebaseSearchDescription } from "./codebase-search"
25+
import { getUpdateTodoListDescription } from "./update-todo-list"
2526
import { CodeIndexManager } from "../../../services/code-index/manager"
2627

2728
// Map of tool names to their description functions
@@ -45,6 +46,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
4546
search_and_replace: (args) => getSearchAndReplaceDescription(args),
4647
apply_diff: (args) =>
4748
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
49+
update_todo_list: (args) => getUpdateTodoListDescription(args),
4850
}
4951

5052
export function getToolDescriptionsForMode(

0 commit comments

Comments
 (0)