---
description: Display comprehensive status of all active workflow instances with visual progress
argument-hint: [instance-name]
---

# /eg:status

Shows all active workflow instances and their current status with enhanced visual progress tracking.

Input: `$ARGUMENTS`

## Step 1: Parse Arguments

Check if specific instance requested:
```
# Parse arguments to extract instance name (optional)
# If provided, show detailed status for that instance only
```

## Step 2: Check for Workflow Directory

Check if workflow directory exists:
```
!if [ -d ".eg" ]; then
  echo "🔍 Scanning workflows..."
else
  echo "❌ No workflows found. Start a workflow with:"
  echo "   • /eg:define <name> <requirements>"
  echo "   • /eg:architect <name> <description>"
  echo "   • /eg:debug <name> <issue>"
  exit 0
fi
```

## Step 3: Display Visual Progress Overview

Create enhanced visual summary with Unicode progress bars:

```
!echo "
╔══════════════════════════════════════════════════════════════════╗
║                  🚀 EG Workflow Status Dashboard                  ║
╚══════════════════════════════════════════════════════════════════╝"

# Count active workflows
!active_count=$(ls -d .eg/*/ 2>/dev/null | wc -l | tr -d ' ')
!echo "
Active Workflows: $active_count
═══════════════════════════════════════════════════════════════════"
```

## Step 4: Display Feature Development Workflows

Show feature workflows with detailed progress:

```
!echo ""
!echo "📦 FEATURE DEVELOPMENT"
!echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
!for dir in .eg/*/; do
  if [ -f "$dir/feature-definition.md" ]; then
    instance=$(basename "$dir")
    
    # Calculate phase progress
    def_done=0; arch_done=0; plan_done=0; impl_done=0; test_done=0
    [ -f "$dir/feature-definition.md" ] && def_done=1
    [ -f "$dir/architecture.md" ] && arch_done=1
    [ -f "$dir/plan.md" ] && plan_done=1
    
    # Calculate implementation progress from plan.md
    if [ -f "$dir/plan.md" ]; then
      total_tasks=$(grep -c "^- \[ \]" "$dir/plan.md" 2>/dev/null || echo 0)
      completed_tasks=$(grep -c "^- \[x\]" "$dir/plan.md" 2>/dev/null || echo 0)
      if [ $((total_tasks + completed_tasks)) -gt 0 ]; then
        impl_progress=$((completed_tasks * 100 / (total_tasks + completed_tasks)))
        impl_done=$((impl_progress / 25))  # Convert to 0-4 scale
      fi
    fi
    
    [ -f "$dir/test-results.md" ] && test_done=1
    
    # Generate progress bars
    echo ""
    echo "📂 $instance"
    
    # Definition phase
    if [ $def_done -eq 1 ]; then
      echo "  📋 Definition    ████████████ 100% ✅"
    else
      echo "  📋 Definition    ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Architecture phase  
    if [ $arch_done -eq 1 ]; then
      echo "  🏗️  Architecture  ████████████ 100% ✅"
    else
      echo "  🏗️  Architecture  ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Planning phase
    if [ $plan_done -eq 1 ]; then
      echo "  📝 Planning      ████████████ 100% ✅"
    else
      echo "  📝 Planning      ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Implementation phase with detailed progress
    if [ $plan_done -eq 1 ]; then
      # Create progress bar based on completion
      bar=""
      for i in $(seq 1 12); do
        if [ $i -le $((impl_progress * 12 / 100)) ]; then
          bar="${bar}█"
        else
          bar="${bar}░"
        fi
      done
      
      if [ $impl_progress -eq 100 ]; then
        echo "  ⚙️  Implementation $bar 100% ✅"
      else
        echo "  ⚙️  Implementation $bar  ${impl_progress}% 🔄"
      fi
      
      # Show task details
      echo "     Tasks: $completed_tasks/$((total_tasks + completed_tasks)) complete"
    else
      echo "  ⚙️  Implementation ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Testing phase
    if [ $test_done -eq 1 ]; then
      echo "  🧪 Testing       ████████████ 100% ✅"
    else
      echo "  🧪 Testing       ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Get last activity
    latest=$(find "$dir" -type f -name "*.md" -o -name "*.json" | xargs ls -t 2>/dev/null | head -1)
    if [ -n "$latest" ]; then
      last_update=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$latest" 2>/dev/null || date)
      echo "     Last activity: $last_update"
    fi
  fi
done

# If no feature workflows
!feature_count=$(find .eg -name "feature-definition.md" 2>/dev/null | wc -l | tr -d ' ')
![ "$feature_count" -eq 0 ] && echo "  (No active feature workflows)"
```

## Step 5: Display Bug Fix Workflows

Show bug fix workflows:

```
!echo ""
!echo "🐛 BUG FIXES"
!echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
!for dir in .eg/*/; do
  if [ -f "$dir/debug-analysis.md" ]; then
    instance=$(basename "$dir")
    
    # Calculate progress
    analysis_done=0; solution_done=0; test_done=0
    [ -f "$dir/debug-analysis.md" ] && analysis_done=1
    [ -f "$dir/solution.md" ] && solution_done=1
    [ -f "$dir/test-results.md" ] && test_done=1
    
    echo ""
    echo "🔧 $instance"
    
    # Analysis phase
    if [ $analysis_done -eq 1 ]; then
      echo "  🔍 Analysis      ████████████ 100% ✅"
    else
      echo "  🔍 Analysis      ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Solution phase
    if [ $solution_done -eq 1 ]; then
      echo "  💡 Solution      ████████████ 100% ✅"
    else
      echo "  💡 Solution      ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Testing phase
    if [ $test_done -eq 1 ]; then
      echo "  🧪 Verification  ████████████ 100% ✅"
    else
      echo "  🧪 Verification  ░░░░░░░░░░░░   0% ⏳"
    fi
  fi
done

# If no bug workflows
!bug_count=$(find .eg -name "debug-analysis.md" 2>/dev/null | wc -l | tr -d ' ')
![ "$bug_count" -eq 0 ] && echo "  (No active bug fixes)"
```

## Step 6: Display Improvement Workflows

Show improvement workflows:

```
!echo ""
!echo "✨ IMPROVEMENTS"
!echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
!for dir in .eg/*/; do
  if [ -f "$dir/architecture.md" ] && [ ! -f "$dir/feature-definition.md" ]; then
    instance=$(basename "$dir")
    
    # Calculate progress
    arch_done=0; impl_done=0; test_done=0
    [ -f "$dir/architecture.md" ] && arch_done=1
    [ -f "$dir/progress.json" ] && impl_done=1
    [ -f "$dir/test-results.md" ] && test_done=1
    
    echo ""
    echo "🔨 $instance"
    
    # Architecture phase
    if [ $arch_done -eq 1 ]; then
      echo "  🏗️  Design        ████████████ 100% ✅"
    else
      echo "  🏗️  Design        ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Implementation phase
    if [ $impl_done -eq 1 ]; then
      echo "  ⚙️  Implementation ████████████ 100% ✅"
    else
      echo "  ⚙️  Implementation ░░░░░░░░░░░░   0% ⏳"
    fi
    
    # Testing phase
    if [ $test_done -eq 1 ]; then
      echo "  🧪 Testing       ████████████ 100% ✅"
    else
      echo "  🧪 Testing       ░░░░░░░░░░░░   0% ⏳"
    fi
  fi
done

# If no improvement workflows
!improvement_count=$(find .eg -type f -name "architecture.md" 2>/dev/null | while read f; do dirname "$f"; done | while read d; do [ ! -f "$d/feature-definition.md" ] && echo 1; done | wc -l | tr -d ' ')
![ "$improvement_count" -eq 0 ] && echo "  (No active improvements)"
```

## Step 7: Suggest Next Actions

Provide intelligent next action suggestions:

```
!echo ""
!echo "💡 NEXT ACTIONS"
!echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# Check for stalled workflows (>3 days inactive)
!stalled_found=0
!for dir in .eg/*/; do
  if [ -d "$dir" ]; then
    instance=$(basename "$dir")
    latest=$(find "$dir" -type f -name "*.md" -o -name "*.json" | xargs ls -t 2>/dev/null | head -1)
    if [ -n "$latest" ]; then
      age=$(( ($(date +%s) - $(stat -f %m "$latest" 2>/dev/null || echo 0)) / 86400 ))
      if [ $age -gt 3 ]; then
        [ $stalled_found -eq 0 ] && echo "" && echo "⚠️  Stalled Workflows (>3 days inactive):"
        stalled_found=1
        echo "   • $instance ($age days)"
      fi
    fi
  fi
done

# Suggest next commands for active workflows
!echo ""
!echo "▶️  Ready for Next Step:"
!suggested=0
!for dir in .eg/*/; do
  if [ -d "$dir" ]; then
    instance=$(basename "$dir")
    
    # Feature workflow suggestions
    if [ -f "$dir/feature-definition.md" ]; then
      if [ ! -f "$dir/architecture.md" ]; then
        echo "   → /eg:architect $instance"
        suggested=1
      elif [ ! -f "$dir/plan.md" ]; then
        echo "   → /eg:plan $instance"
        suggested=1
      elif [ -f "$dir/plan.md" ]; then
        # Check if there are uncompleted tasks
        uncompleted=$(grep -c "^- \[ \]" "$dir/plan.md" 2>/dev/null || echo 0)
        if [ $uncompleted -gt 0 ]; then
          echo "   → /eg:implement $instance"
          suggested=1
        elif [ ! -f "$dir/test-results.md" ]; then
          echo "   → /eg:test $instance"
          suggested=1
        fi
      fi
    fi
    
    # Bug fix workflow suggestions
    if [ -f "$dir/debug-analysis.md" ] && [ ! -f "$dir/solution.md" ]; then
      echo "   → /eg:fix $instance"
      suggested=1
    fi
    
    # Test suggestions
    if [ -f "$dir/solution.md" ] && [ ! -f "$dir/test-results.md" ]; then
      echo "   → /eg:test $instance"
      suggested=1
    fi
  fi
done

![ $suggested -eq 0 ] && echo "   (All workflows are up to date)"

!echo ""
!echo "═══════════════════════════════════════════════════════════════════"
```

## Step 8: Show Detailed Status for Specific Instance

If an instance name was provided, show detailed information:

```
# If specific instance requested, show detailed view
# This would include:
# - Full file listing
# - Detailed task breakdown if plan exists
# - Recent commits related to the instance
# - Any validation results
```

The enhanced status command now provides:
- Visual progress bars for each phase
- Percentage completion for implementations
- Task completion counts
- Intelligent next action suggestions
- Stalled workflow detection
- Clear categorization by workflow type