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

Function findHighestTaskIdFromFiles

source code/utils/tasks.ts:248–267  ·  view source on GitHub ↗

* Finds the highest task ID from existing task files (not including high water mark).

(taskListId: string)

Source from the content-addressed store, hash-verified

246 * Finds the highest task ID from existing task files (not including high water mark).
247 */
248async function findHighestTaskIdFromFiles(taskListId: string): Promise<number> {
249 const dir = getTasksDir(taskListId)
250 let files: string[]
251 try {
252 files = await readdir(dir)
253 } catch {
254 return 0
255 }
256 let highest = 0
257 for (const file of files) {
258 if (!file.endsWith('.json')) {
259 continue
260 }
261 const taskId = parseInt(file.replace('.json', ''), 10)
262 if (!isNaN(taskId) && taskId > highest) {
263 highest = taskId
264 }
265 }
266 return highest
267}
268
269/**
270 * Finds the highest task ID ever assigned, considering both existing files

Callers 2

resetTaskListFunction · 0.85
findHighestTaskIdFunction · 0.85

Calls 2

getTasksDirFunction · 0.85
readdirFunction · 0.85

Tested by

no test coverage detected