MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getTask

Function getTask

source code/utils/tasks.ts:312–352  ·  view source on GitHub ↗
(
  taskListId: string,
  taskId: string,
)

Source from the content-addressed store, hash-verified

310}
311
312export async function getTask(
313 taskListId: string,
314 taskId: string,
315): Promise<Task | null> {
316 const path = getTaskPath(taskListId, taskId)
317 try {
318 const content = await readFile(path, 'utf-8')
319 const data = jsonParse(content) as { status?: string }
320
321 // TEMPORARY: Migrate old status names for existing sessions (ant-only)
322 if (process.env.USER_TYPE === 'ant') {
323 if (data.status === 'open') data.status = 'pending'
324 else if (data.status === 'resolved') data.status = 'completed'
325 // Migrate development task statuses to in_progress
326 else if (
327 data.status &&
328 ['planning', 'implementing', 'reviewing', 'verifying'].includes(
329 data.status,
330 )
331 ) {
332 data.status = 'in_progress'
333 }
334 }
335 const parsed = TaskSchema().safeParse(data)
336 if (!parsed.success) {
337 logForDebugging(
338 `[Tasks] Task ${taskId} failed schema validation: ${parsed.error.message}`,
339 )
340 return null
341 }
342 return parsed.data
343 } catch (e) {
344 const code = getErrnoCode(e)
345 if (code === 'ENOENT') {
346 return null
347 }
348 logForDebugging(`[Tasks] Failed to read task ${taskId}: ${errorMessage(e)}`)
349 logError(e)
350 return null
351 }
352}
353
354// Internal: no lock. Callers already holding a lock on taskPath must use this
355// to avoid deadlock (claimTask, deleteTask cascade, etc.).

Callers 7

callFunction · 0.85
callFunction · 0.85
updateTaskUnsafeFunction · 0.85
updateTaskFunction · 0.85
listTasksFunction · 0.85
blockTaskFunction · 0.85
claimTaskFunction · 0.85

Calls 7

getTaskPathFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85
logForDebuggingFunction · 0.85
getErrnoCodeFunction · 0.85
errorMessageFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected