MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / parseTodosFromToolInfo

Function parseTodosFromToolInfo

apps/cli/src/ui/utils/tools.ts:252–278  ·  view source on GitHub ↗
(toolInfo: Record<string, unknown>)

Source from the content-addressed store, hash-verified

250 * Handles both array format and markdown checklist string format
251 */
252export function parseTodosFromToolInfo(toolInfo: Record<string, unknown>): TodoItem[] | null {
253 // Try to get todos directly as an array
254 const todosArray = toolInfo.todos as unknown[] | undefined
255 if (Array.isArray(todosArray)) {
256 return todosArray
257 .map((item, index) => {
258 if (typeof item === "object" && item !== null) {
259 const todo = item as Record<string, unknown>
260 return {
261 id: (todo.id as string) || `todo-${index}`,
262 content: (todo.content as string) || "",
263 status: ((todo.status as string) || "pending") as TodoItem["status"],
264 }
265 }
266 return null
267 })
268 .filter((item): item is TodoItem => item !== null)
269 }
270
271 // Try to parse markdown checklist format from todos string
272 const todosString = toolInfo.todos as string | undefined
273 if (typeof todosString === "string") {
274 return parseMarkdownChecklist(todosString)
275 }
276
277 return null
278}
279
280/**
281 * Parse a markdown checklist string into TodoItem array

Callers 1

useMessageHandlersFunction · 0.85

Calls 1

parseMarkdownChecklistFunction · 0.70

Tested by

no test coverage detected