MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / deleteTask

Function deleteTask

src/utils/tasks.ts:393–441  ·  view source on GitHub ↗
(
  taskListId: string,
  taskId: string,
)

Source from the content-addressed store, hash-verified

391}
392
393export async function deleteTask(
394 taskListId: string,
395 taskId: string,
396): Promise<boolean> {
397 const path = getTaskPath(taskListId, taskId)
398
399 try {
400 // Update high water mark before deleting to prevent ID reuse
401 const numericId = parseInt(taskId, 10)
402 if (!isNaN(numericId)) {
403 const currentMark = await readHighWaterMark(taskListId)
404 if (numericId > currentMark) {
405 await writeHighWaterMark(taskListId, numericId)
406 }
407 }
408
409 // Delete the task file
410 try {
411 await unlink(path)
412 } catch (e) {
413 const code = getErrnoCode(e)
414 if (code === 'ENOENT') {
415 return false
416 }
417 throw e
418 }
419
420 // Remove references to this task from other tasks
421 const allTasks = await listTasks(taskListId)
422 for (const task of allTasks) {
423 const newBlocks = task.blocks.filter(id => id !== taskId)
424 const newBlockedBy = task.blockedBy.filter(id => id !== taskId)
425 if (
426 newBlocks.length !== task.blocks.length ||
427 newBlockedBy.length !== task.blockedBy.length
428 ) {
429 await updateTask(taskListId, task.id, {
430 blocks: newBlocks,
431 blockedBy: newBlockedBy,
432 })
433 }
434 }
435
436 notifyTasksUpdated()
437 return true
438 } catch {
439 return false
440 }
441}
442
443export async function listTasks(taskListId: string): Promise<Task[]> {
444 const dir = getTasksDir(taskListId)

Callers 3

tasks.test.tsFile · 0.90
callFunction · 0.85
callFunction · 0.85

Calls 8

getTaskPathFunction · 0.85
readHighWaterMarkFunction · 0.85
writeHighWaterMarkFunction · 0.85
unlinkFunction · 0.85
getErrnoCodeFunction · 0.85
listTasksFunction · 0.85
updateTaskFunction · 0.85
notifyTasksUpdatedFunction · 0.85

Tested by

no test coverage detected