mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
25 lines
562 B
TypeScript
25 lines
562 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 []
|
|
}
|
|
}
|