#!/bin/bash
cd ~/firefrost-work/firefrost-operations-manual

# Update the executor to wait and display results automatically
cat > automation/auto-wait-and-check.sh << 'AUTOWAIT'
#!/bin/bash
# Helper script: Queue task, wait, and display results
# Usage: ./auto-wait-and-check.sh <task-file>

TASK_FILE=$1
TASK_NAME=$(basename "$TASK_FILE" .sh)

# Queue the task
cp "$TASK_FILE" automation/queue/
chmod +x "automation/queue/$TASK_NAME.sh"

# Wait for execution (daemon polls every 10s, add buffer)
echo "Task queued: $TASK_NAME"
echo "Waiting for execution..."
sleep 20

# Display results
if [ -f "automation/results/${TASK_NAME}_result.txt" ]; then
    cat "automation/results/${TASK_NAME}_result.txt"
else
    echo "No results yet. Task may still be running or failed."
fi
AUTOWAIT

chmod +x automation/auto-wait-and-check.sh

# Document the improvement
cat >> automation/USAGE.md << 'IMPROVEMENT'

## Improved Workflow (Feb 9, 2026)

**Old way (3 commands):**
1. Queue task
2. Sleep 20
3. Cat results

**New way (consolidated into task creation):**
Claude provides ONE block that includes:
- Task creation
- Queueing (chmod +x)
- Auto-wait (sleep 20)
- Auto-display (cat results)

Michael pastes ONCE, sees results automatically.
IMPROVEMENT

git add -A
git commit -m "Improve automation workflow: consolidate wait + results into single paste"
git push

echo "Automation workflow improved!"
