MCPcopy Create free account
hub / github.com/Noumena-Network/code / taskListHandler

Function taskListHandler

src/cli/handlers/ant.ts:745–791  ·  view source on GitHub ↗
(
  opts: TaskFilterOptions = {},
)

Source from the content-addressed store, hash-verified

743}
744
745export async function taskListHandler(
746 opts: TaskFilterOptions = {},
747): Promise<void> {
748 try {
749 const taskListId = normalizeTaskListId(opts.list)
750 let tasks = await listTasks(taskListId)
751 tasks = tasks.sort((a, b) => {
752 const aNum = Number.parseInt(a.id, 10)
753 const bNum = Number.parseInt(b.id, 10)
754 if (!Number.isNaN(aNum) && !Number.isNaN(bNum)) {
755 return aNum - bNum
756 }
757 return a.id.localeCompare(b.id)
758 })
759
760 if (opts.pending) {
761 tasks = tasks.filter(task => task.status === 'pending')
762 }
763
764 if (opts.json) {
765 writeJson({
766 taskListId,
767 tasks,
768 })
769 await gracefulShutdown(0)
770 return
771 }
772
773 if (tasks.length === 0) {
774 writeToStdout(`No tasks found in ${taskListId}.\n`)
775 await gracefulShutdown(0)
776 return
777 }
778
779 writeToStdout(`Task list: ${taskListId}\n`)
780 for (const task of tasks) {
781 writeToStdout(`${formatTaskSummary(task)}\n`)
782 if (task.description) {
783 writeToStdout(` ${task.description}\n`)
784 }
785 }
786 await gracefulShutdown(0)
787 } catch (error) {
788 writeToStderr(`Failed to list tasks: ${errorMessage(error)}\n`)
789 await gracefulShutdown(1)
790 }
791}
792
793export async function taskGetHandler(
794 id: string,

Callers 1

runFunction · 0.85

Calls 8

normalizeTaskListIdFunction · 0.85
listTasksFunction · 0.85
writeJsonFunction · 0.85
gracefulShutdownFunction · 0.85
writeToStdoutFunction · 0.85
formatTaskSummaryFunction · 0.85
writeToStderrFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected