MCPcopy
hub / github.com/claude-code-best/claude-code / findHighestTaskIdFromFiles

Function findHighestTaskIdFromFiles

src/utils/tasks.ts:246–265  ·  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

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