4.6 KiB
4.6 KiB
Taskmaster Task Tracker
Automatically updates Taskmaster tasks with datetime stamps whenever they're created or status changed. This tool monitors the tasks.json file and adds timestamps to track task lifecycle events.
Features
- Automatic Timestamping: Adds timestamps for task creation and status changes
- File Monitoring: Watches for changes in the tasks.json file
- Backup System: Creates backups before making changes
- Logging: Comprehensive logging to track all activities
- Safe Operation: Only adds timestamps, never modifies existing data
Timestamp Fields Added
The tracker adds the following timestamp fields to tasks:
created_at: ISO 8601 timestamp when the task was first detectedupdated_at: ISO 8601 timestamp when the task was last modifiedstatus_changed_to_X: ISO 8601 timestamp when status changed to X (e.g.,status_changed_to_done)
Usage
Quick Start
# Run once to process current tasks
./scripts/tm_tracker.sh --once
# Watch for changes continuously (5-second interval)
./scripts/tm_tracker.sh --watch
# Watch with custom interval (10 seconds)
./scripts/tm_tracker.sh --watch --interval 10
Python Script Direct Usage
# Run once
python scripts/taskmaster_tracker.py
# Watch continuously
python scripts/taskmaster_tracker.py --watch
# Watch with custom interval
python scripts/taskmaster_tracker.py --watch --interval 10
Files and Directories
scripts/taskmaster_tracker.py: Main Python scriptscripts/tm_tracker.sh: Shell wrapper script.taskmaster/backups/: Directory containing task backupslogs/taskmaster_tracker.log: Log file with all tracker activities
How It Works
- File Monitoring: Uses MD5 hashing to detect changes in
tasks.json - Task Detection: Compares current tasks with previously known tasks
- Timestamp Addition: Adds appropriate timestamps for new tasks and status changes
- Backup Creation: Creates timestamped backups before making changes
- Logging: Logs all activities for debugging and audit purposes
Example Output
When a new task is created:
{
"id": 11,
"title": "New Task",
"status": "pending",
"created_at": "2024-01-15T10:30:00.123456+00:00",
"updated_at": "2024-01-15T10:30:00.123456+00:00"
}
When a task status changes:
{
"id": 11,
"title": "New Task",
"status": "done",
"created_at": "2024-01-15T10:30:00.123456+00:00",
"updated_at": "2024-01-15T14:45:00.789012+00:00",
"status_changed_to_done": "2024-01-15T14:45:00.789012+00:00"
}
Logging
The tracker logs all activities to logs/taskmaster_tracker.log with timestamps:
2024-01-15 10:30:00,123 - INFO - New task detected: 11 - New Task
2024-01-15 10:30:00,124 - INFO - Added created_at to task 11: 2024-01-15T10:30:00.123456+00:00
2024-01-15 14:45:00,789 - INFO - Status change detected for task 11: pending -> done
2024-01-15 14:45:00,790 - INFO - Added status_changed_to_done to task 11: 2024-01-15T14:45:00.789012+00:00
Safety Features
- Backup System: Always creates backups before modifying tasks
- Non-Destructive: Only adds new fields, never modifies existing data
- Error Handling: Graceful handling of file errors and JSON parsing issues
- Cleanup: Automatically removes old backups (keeps last 10)
Integration with Taskmaster
The tracker works seamlessly with Taskmaster:
- No Conflicts: Only adds timestamp fields, doesn't interfere with Taskmaster operations
- Automatic Detection: Detects changes made by Taskmaster CLI or MCP tools
- Backup Safety: Creates backups before any modifications
- Logging: Provides audit trail for all task changes
Troubleshooting
Common Issues
- Permission Errors: Ensure the script has read/write permissions
- File Not Found: Check that
.taskmaster/tasks/tasks.jsonexists - JSON Errors: The tracker will log JSON parsing errors and continue
- Backup Directory: Automatically creates backup directory if it doesn't exist
Debug Mode
To see more detailed logging, modify the logging level in the Python script:
logging.basicConfig(level=logging.DEBUG, ...)
Development
The tracker is designed to be:
- Lightweight: Minimal resource usage
- Reliable: Comprehensive error handling
- Safe: Non-destructive operations only
- Extensible: Easy to add new timestamp types
Future Enhancements
Potential improvements:
- Webhook notifications for task changes
- Integration with external time tracking tools
- Custom timestamp field configurations
- Database storage for change history
- Email notifications for status changes