claude-task-viewer 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/server.js CHANGED
@@ -22,6 +22,9 @@ let sessionMetadataCache = {};
22
22
  let lastMetadataRefresh = 0;
23
23
  const METADATA_CACHE_TTL = 10000; // 10 seconds
24
24
 
25
+ // Parse JSON bodies
26
+ app.use(express.json());
27
+
25
28
  // Serve static files
26
29
  app.use(express.static(path.join(__dirname, 'public')));
27
30
 
@@ -292,6 +295,39 @@ app.get('/api/tasks/all', async (req, res) => {
292
295
  }
293
296
  });
294
297
 
298
+ // API: Add note to a task
299
+ app.post('/api/tasks/:sessionId/:taskId/note', async (req, res) => {
300
+ try {
301
+ const { sessionId, taskId } = req.params;
302
+ const { note } = req.body;
303
+
304
+ if (!note || !note.trim()) {
305
+ return res.status(400).json({ error: 'Note cannot be empty' });
306
+ }
307
+
308
+ const taskPath = path.join(TASKS_DIR, sessionId, `${taskId}.json`);
309
+
310
+ if (!existsSync(taskPath)) {
311
+ return res.status(404).json({ error: 'Task not found' });
312
+ }
313
+
314
+ // Read current task
315
+ const task = JSON.parse(await fs.readFile(taskPath, 'utf8'));
316
+
317
+ // Append note to description
318
+ const noteBlock = `\n\n---\n\n#### [Note added by user]\n\n${note.trim()}`;
319
+ task.description = (task.description || '') + noteBlock;
320
+
321
+ // Write updated task
322
+ await fs.writeFile(taskPath, JSON.stringify(task, null, 2));
323
+
324
+ res.json({ success: true, task });
325
+ } catch (error) {
326
+ console.error('Error adding note:', error);
327
+ res.status(500).json({ error: 'Failed to add note' });
328
+ }
329
+ });
330
+
295
331
  // SSE endpoint for live updates
296
332
  app.get('/api/events', (req, res) => {
297
333
  res.setHeader('Content-Type', 'text/event-stream');