#!/bin/bash # CTO AI Delegation - Progress Dashboard Generator # Analyzes git history and worklog files to create visual progress dashboard set -e # Configuration DASHBOARD_DIR="docs/dashboard" OUTPUT_FILE="$DASHBOARD_DIR/index.html" DATA_FILE="$DASHBOARD_DIR/metrics.json" # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${BLUE}๐Ÿ”ง CTO AI Delegation - Progress Dashboard Generator${NC}" echo "=================================================" # Validate git repository if [ ! -d ".git" ]; then echo "โŒ Error: Not in a git repository" exit 1 fi # Create dashboard directory mkdir -p "$DASHBOARD_DIR" # Collect metrics collect_metrics() { echo "๐Ÿ“Š Collecting project metrics..." # Git metrics local total_commits=$(git rev-list --all --count 2>/dev/null || echo "0") local total_branches=$(git branch -a | grep -v HEAD | wc -l) local feature_branches=$(git branch | grep -c "feature/" || echo "0") local last_commit_date=$(git log -1 --format="%cd" --date=short 2>/dev/null || echo "N/A") local repo_age_days=$(git log --reverse --format="%cd" --date=short | head -1 | xargs -I {} date -d {} +%s 2>/dev/null | xargs -I {} echo $(($(date +%s) - {}) / 86400)) || echo "0") # Milestone metrics local total_tags=$(git tag | wc -l) local recent_tags=$(git tag --sort=-creatordate | head -5 | tr '\n' ',' | sed 's/,$//') # Integration metrics local integration_commits=$(git log --oneline INTEGRATION-WIP 2>/dev/null | grep -c "Auto-Integration" || echo "0") local bootstrap_complete=$(git tag | grep -c "bootstrap" || echo "0") # Worklog analysis local worklog_entries=$(grep -c "SESSION:" docs/WORKLOG-LLM.md 2>/dev/null || echo "0") local current_status=$(grep "STATUS:" docs/WORKLOG-LLM.md 2>/dev/null | head -1 | cut -d':' -f2 | xargs || echo "Unknown") # Health score calculation (0-100) local health_score=0 [ "$bootstrap_complete" -gt 0 ] && health_score=$((health_score + 25)) [ "$total_commits" -gt 5 ] && health_score=$((health_score + 25)) [ "$feature_branches" -gt 0 ] && health_score=$((health_score + 25)) [ "$integration_commits" -gt 0 ] && health_score=$((health_score + 25)) # Generate JSON data cat > "$DATA_FILE" << EOF { "generated": "$(date -u '+%Y-%m-%d %H:%M:%S UTC')", "project": { "health_score": $health_score, "status": "$current_status", "repository_age_days": $repo_age_days }, "git_metrics": { "total_commits": $total_commits, "total_branches": $total_branches, "feature_branches": $feature_branches, "last_commit_date": "$last_commit_date" }, "milestones": { "total_tags": $total_tags, "recent_tags": "$recent_tags", "bootstrap_complete": $bootstrap_complete }, "integration": { "auto_integrations": $integration_commits, "integration_rate": $(( integration_commits > 0 ? (integration_commits * 100) / total_commits : 0 )) }, "activity": { "worklog_entries": $worklog_entries, "avg_commits_per_day": $(( repo_age_days > 0 ? total_commits / repo_age_days : 0 )) } } EOF echo "โœ… Metrics collected and saved to $DATA_FILE" } # Generate HTML dashboard generate_dashboard() { echo "๐ŸŽจ Generating HTML dashboard..." # Read metrics local health_score=$(grep -o '"health_score": [0-9]*' "$DATA_FILE" | cut -d':' -f2 | xargs) local total_commits=$(grep -o '"total_commits": [0-9]*' "$DATA_FILE" | cut -d':' -f2 | xargs) local feature_branches=$(grep -o '"feature_branches": [0-9]*' "$DATA_FILE" | cut -d':' -f2 | xargs) local total_tags=$(grep -o '"total_tags": [0-9]*' "$DATA_FILE" | cut -d':' -f2 | xargs) local integration_rate=$(grep -o '"integration_rate": [0-9]*' "$DATA_FILE" | cut -d':' -f2 | xargs) local last_commit=$(grep -o '"last_commit_date": "[^"]*"' "$DATA_FILE" | cut -d'"' -f4) local status=$(grep -o '"status": "[^"]*"' "$DATA_FILE" | cut -d'"' -f4) # Health score color local health_color="red" [ "$health_score" -gt 50 ] && health_color="orange" [ "$health_score" -gt 75 ] && health_color="green" # Generate HTML cat > "$OUTPUT_FILE" << EOF CTO AI Delegation - Progress Dashboard

๐Ÿค– CTO AI Delegation Dashboard

Real-time progress tracking for AI development sessions

๐Ÿ“Š Project Health

$health_score%
Overall Health Score
$status
Current Status
$total_commits
Total Commits
$feature_branches
Feature Branches
$total_tags
Milestones Tagged
$integration_rate%
Integration Success Rate

๐Ÿ“… Recent Activity

Last Commit: $last_commit

Integration Status: $([ "$integration_rate" -gt 80 ] && echo "โœ… Excellent" || echo "โš ๏ธ Needs Attention")

AI Agent Activity: $([ "$total_commits" -gt 0 ] && echo "Active" || echo "Inactive")

๐ŸŽฏ Quick Actions

Dashboard generated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')
๐Ÿค– CTO AI Delegation Framework - Automatic Progress Tracking
EOF echo "โœ… Dashboard generated: $OUTPUT_FILE" } # Main execution main() { local mode="${1:-full}" case "$mode" in "--quick-update"|"--auto-update") echo "๐Ÿ”„ Quick dashboard update..." collect_metrics generate_dashboard ;; "--full-report"|"--full") echo "๐Ÿ“‹ Full dashboard report generation..." collect_metrics generate_dashboard ;; "--check-sources") echo "๐Ÿ” Checking data sources..." [ -f "docs/WORKLOG-LLM.md" ] && echo "โœ… WORKLOG-LLM.md found" || echo "โš ๏ธ WORKLOG-LLM.md missing" [ -f "docs/CURRENTWORK-LLM.md" ] && echo "โœ… CURRENTWORK-LLM.md found" || echo "โš ๏ธ CURRENTWORK-LLM.md missing" [ -d ".git" ] && echo "โœ… Git repository found" || echo "โŒ Git repository missing" ;; "--validate-metrics") echo "๐Ÿงช Validating metrics..." collect_metrics echo "๐Ÿ“Š Metrics validation complete" ;; *) collect_metrics generate_dashboard ;; esac echo "" echo -e "${GREEN}๐ŸŽฏ Progress Dashboard Ready!${NC}" echo -e "๐Ÿ“ Dashboard: $OUTPUT_FILE" echo -e "๐Ÿ“Š Metrics: $DATA_FILE" echo "" echo -e "${YELLOW}๐Ÿ’ก View dashboard:${NC}" echo -e " Open $OUTPUT_FILE in your browser" echo -e " Or run: open $OUTPUT_FILE" } # Execute main function main "$@"