@hasna/todos 0.9.19 → 0.9.20

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.
@@ -852,6 +852,17 @@ function checkCompletionGuard(task, agentId, db, configOverride) {
852
852
  }
853
853
  }
854
854
 
855
+ // src/db/audit.ts
856
+ init_database();
857
+ function logTaskChange(taskId, action, field, oldValue, newValue, agentId, db) {
858
+ const d = db || getDatabase();
859
+ const id = uuid();
860
+ const timestamp = now();
861
+ d.run(`INSERT INTO task_history (id, task_id, action, field, old_value, new_value, agent_id, created_at)
862
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [id, taskId, action, field || null, oldValue ?? null, newValue ?? null, agentId || null, timestamp]);
863
+ return { id, task_id: taskId, action, field: field || null, old_value: oldValue ?? null, new_value: newValue ?? null, agent_id: agentId || null, created_at: timestamp };
864
+ }
865
+
855
866
  // src/db/tasks.ts
856
867
  function rowToTask(row) {
857
868
  return {
@@ -1076,6 +1087,17 @@ function updateTask(id, input, db) {
1076
1087
  if (input.tags !== undefined) {
1077
1088
  replaceTaskTags(id, input.tags, d);
1078
1089
  }
1090
+ const agentId = task.assigned_to || task.agent_id || null;
1091
+ if (input.status !== undefined && input.status !== task.status)
1092
+ logTaskChange(id, "update", "status", task.status, input.status, agentId, d);
1093
+ if (input.priority !== undefined && input.priority !== task.priority)
1094
+ logTaskChange(id, "update", "priority", task.priority, input.priority, agentId, d);
1095
+ if (input.title !== undefined && input.title !== task.title)
1096
+ logTaskChange(id, "update", "title", task.title, input.title, agentId, d);
1097
+ if (input.assigned_to !== undefined && input.assigned_to !== task.assigned_to)
1098
+ logTaskChange(id, "update", "assigned_to", task.assigned_to, input.assigned_to, agentId, d);
1099
+ if (input.approved_by !== undefined)
1100
+ logTaskChange(id, "approve", "approved_by", null, input.approved_by, agentId, d);
1079
1101
  return getTask(id, d);
1080
1102
  }
1081
1103
  function deleteTask(id, db) {
@@ -1097,6 +1119,7 @@ function startTask(id, agentId, db) {
1097
1119
  throw new LockError(id, current.locked_by);
1098
1120
  }
1099
1121
  }
1122
+ logTaskChange(id, "start", "status", "pending", "in_progress", agentId, d);
1100
1123
  return getTask(id, d);
1101
1124
  }
1102
1125
  function completeTask(id, agentId, db) {
@@ -1111,6 +1134,7 @@ function completeTask(id, agentId, db) {
1111
1134
  const timestamp = now();
1112
1135
  d.run(`UPDATE tasks SET status = 'completed', locked_by = NULL, locked_at = NULL, completed_at = ?, version = version + 1, updated_at = ?
1113
1136
  WHERE id = ?`, [timestamp, timestamp, id]);
1137
+ logTaskChange(id, "complete", "status", task.status, "completed", agentId || null, d);
1114
1138
  return getTask(id, d);
1115
1139
  }
1116
1140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/todos",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "description": "Universal task management for AI coding agents - CLI + MCP server + interactive TUI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",