From 29aafc7e4f5fd781b08500ad31509e2f5027ff1a Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Thu, 4 Dec 2025 05:12:27 -0800 Subject: [PATCH] fix: use task.filePath in aggregator update/archive/delete handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task files are named 'task-001 - title.md' not 'task-001.md'. The handlers were constructing incorrect filenames instead of using the filePath property stored when tasks are loaded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/aggregator/index.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/aggregator/index.ts b/src/aggregator/index.ts index 5deb268..cb64d1d 100644 --- a/src/aggregator/index.ts +++ b/src/aggregator/index.ts @@ -538,10 +538,11 @@ export class BacklogAggregator { return Response.json({ error: "Task not found" }, { status: 404 }); } - // Find the task file path - const tasksDir = join(projectPath, "backlog", "tasks"); - const taskFileName = `${taskId}.md`; - const taskFilePath = join(tasksDir, taskFileName); + // Use the stored file path from when the task was loaded + const taskFilePath = task.filePath; + if (!taskFilePath) { + return Response.json({ error: "Task file path not found" }, { status: 404 }); + } // Read the current task file let content: string; @@ -695,12 +696,15 @@ created_date: '${dateStr}' return Response.json({ error: "Task not found" }, { status: 404 }); } - // Find the task file path - const tasksDir = join(projectPath, "backlog", "tasks"); + // Use the stored file path from when the task was loaded + const taskFilePath = task.filePath; + if (!taskFilePath) { + return Response.json({ error: "Task file path not found" }, { status: 404 }); + } + + // Build archive path preserving the original filename const archiveDir = join(projectPath, "backlog", "archive", "tasks"); - const taskFileName = `${taskId}.md`; - const taskFilePath = join(tasksDir, taskFileName); - const archiveFilePath = join(archiveDir, taskFileName); + const archiveFilePath = join(archiveDir, basename(taskFilePath)); // Ensure archive directory exists try { @@ -754,10 +758,11 @@ created_date: '${dateStr}' return Response.json({ error: "Task not found" }, { status: 404 }); } - // Find the task file path - const tasksDir = join(projectPath, "backlog", "tasks"); - const taskFileName = `${taskId}.md`; - const taskFilePath = join(tasksDir, taskFileName); + // Use the stored file path from when the task was loaded + const taskFilePath = task.filePath; + if (!taskFilePath) { + return Response.json({ error: "Task file path not found" }, { status: 404 }); + } // Delete the file try {