#!/bin/bash # Process "todo [task]" patterns in a text string # If found: add to Tududi and output status # If not found: exit silently with code 0 set -euo pipefail input_text="${1:-}" dry_run="${2:-false}" if [ -z "$input_text" ]; then exit 0 fi # Detect todo pattern using Node script detect_script="$(dirname "$0")/detect-todo.js" task_name=$(node "$detect_script" "$input_text" 2>/dev/null) || exit 0 # If we get here, task_name was found if [ "$dry_run" == "true" ]; then echo "🎯 Would add task: $task_name" exit 0 fi # Add to Tududi API_URL="${TUDUDI_API_URL:-https://todo.dilain.com/api/v1}" API_KEY="${TUDUDI_API_KEY:-}" if [ -z "$API_KEY" ]; then echo "⚠️ TUDUDI_API_KEY not set, skipping task capture" exit 0 fi response=$(curl -s -X POST \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "{\"name\":\"$task_name\"}" \ "$API_URL/task") task_uid=$(echo "$response" | jq -r '.uid // empty' 2>/dev/null) || task_uid="" if [ -n "$task_uid" ]; then echo "✅ Added to Tududi: $task_name" exit 0 else echo "⚠️ Failed to add task: $task_name" exit 1 fi