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

Function resetTaskList

src/utils/tasks.ts:148–189  ·  view source on GitHub ↗
(taskListId: string)

Source from the content-addressed store, hash-verified

146 * Uses file locking to prevent race conditions when multiple Claudes run in parallel.
147 */
148export async function resetTaskList(taskListId: string): Promise<void> {
149 const dir = getTasksDir(taskListId)
150 const lockPath = await ensureTaskListLockFile(taskListId)
151
152 let release: (() => Promise<void>) | undefined
153 try {
154 // Acquire exclusive lock on the task list
155 release = await lockfile.lock(lockPath, LOCK_OPTIONS)
156
157 // Find the current highest ID and save it to the high water mark file
158 const currentHighest = await findHighestTaskIdFromFiles(taskListId)
159 if (currentHighest > 0) {
160 const existingMark = await readHighWaterMark(taskListId)
161 if (currentHighest > existingMark) {
162 await writeHighWaterMark(taskListId, currentHighest)
163 }
164 }
165
166 // Delete all task files
167 let files: string[]
168 try {
169 files = await readdir(dir)
170 } catch {
171 files = []
172 }
173 for (const file of files) {
174 if (file.endsWith('.json') && !file.startsWith('.')) {
175 const filePath = join(dir, file)
176 try {
177 await unlink(filePath)
178 } catch {
179 // Ignore errors, file may already be deleted
180 }
181 }
182 }
183 notifyTasksUpdated()
184 } finally {
185 if (release) {
186 await release()
187 }
188 }
189}
190
191/**
192 * Gets the task list ID based on the current context.

Callers 3

callFunction · 0.85
#onHideTimerFiredMethod · 0.85

Calls 9

getTasksDirFunction · 0.85
ensureTaskListLockFileFunction · 0.85
readHighWaterMarkFunction · 0.85
writeHighWaterMarkFunction · 0.85
readdirFunction · 0.85
unlinkFunction · 0.85
notifyTasksUpdatedFunction · 0.85
releaseFunction · 0.50

Tested by

no test coverage detected