Roo-Code/src/shared/todo.ts
axb 7645aad435
add todo tool (#5182)
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
2025-07-07 14:07:39 -04:00

23 lines
560 B
TypeScript

import { ClineMessage } from "@roo-code/types"
export function getLatestTodo(clineMessages: ClineMessage[]) {
const todos = clineMessages
.filter(
(msg) =>
(msg.type === "ask" && msg.ask === "tool") || (msg.type === "say" && msg.say === "user_edit_todos"),
)
.map((msg) => {
try {
return JSON.parse(msg.text ?? "{}")
} catch {
return null
}
})
.filter((item) => item && item.tool === "updateTodoList" && Array.isArray(item.todos))
.map((item) => item.todos)
.pop()
if (todos) {
return todos
} else {
return []
}
}