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

Function parseMarkdownChecklist

src/core/tools/UpdateTodoListTool.ts:178–202  ·  view source on GitHub ↗
(md: string)

Source from the content-addressed store, hash-verified

176}
177
178export function parseMarkdownChecklist(md: string): TodoItem[] {
179 if (typeof md !== "string") return []
180 const lines = md
181 .split(/\r?\n/)
182 .map((l) => l.trim())
183 .filter(Boolean)
184 const todos: TodoItem[] = []
185 for (const line of lines) {
186 const match = line.match(/^(?:-\s*)?\[\s*([ xX\-~])\s*\]\s+(.+)$/)
187 if (!match) continue
188 let status: TodoStatus = "pending"
189 if (match[1] === "x" || match[1] === "X") status = "completed"
190 else if (match[1] === "-" || match[1] === "~") status = "in_progress"
191 const id = crypto
192 .createHash("md5")
193 .update(match[2] + status)
194 .digest("hex")
195 todos.push({
196 id,
197 content: match[2],
198 status,
199 })
200 }
201 return todos
202}
203
204export function setPendingTodoList(todos: TodoItem[]) {
205 approvedTodoList = todos

Callers 4

executeMethod · 0.90
executeMethod · 0.70
handlePartialMethod · 0.70

Calls 1

updateMethod · 0.65

Tested by

no test coverage detected