#!/usr/bin/env bash # Real-time dashboard for lint-fixer progress LOG_FILE="/tmp/lint-fixer.log" PROGRESS_FILE="scripts/lint-fixer/PROGRESS.md" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" # Colors GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' BOLD='\033[1m' RESET='\033[0m' # Function to get current branch (lint-fixes branch if running) get_lint_branch() { git branch --list 'lint-fixes/*' --sort=-committerdate | head -1 | sed 's/^[* ]*//' } # Function to calculate stats calculate_stats() { local branch="$1" local base_commit="9dd606ea" # The commit we started from if [ -z "$branch" ]; then echo "0|0|0|0" return fi # Get commit count local commits=$(git log --oneline "${base_commit}..${branch}" 2>/dev/null | wc -l | tr -d ' ') # Get line changes (additions and deletions) local stats=$(git diff --shortstat "${base_commit}..${branch}" 2>/dev/null) local insertions=0 local deletions=0 if [ -n "$stats" ]; then insertions=$(echo "$stats" | grep -o '[0-9]* insertion' | grep -o '[0-9]*' || echo "0") deletions=$(echo "$stats" | grep -o '[0-9]* deletion' | grep -o '[0-9]*' || echo "0") fi # Get files changed local files=$(git diff --name-only "${base_commit}..${branch}" 2>/dev/null | grep -v 'PROGRESS.md\|\.gitignore' | wc -l | tr -d ' ') echo "${commits}|${insertions}|${deletions}|${files}" } # Function to get current activity from log get_current_activity() { if [ ! -f "$LOG_FILE" ]; then echo "Not running" return fi # Get last few lines and find current package/status local last_lines=$(tail -50 "$LOG_FILE" 2>/dev/null) # Check if it's currently calling AI if echo "$last_lines" | grep -q "Calling AI model..."; then local pkg=$(echo "$last_lines" | grep "Package: " | tail -1 | sed 's/.*Package: \(.*\) (.*/\1/') local linter=$(echo "$last_lines" | grep "โ†’ Running" | tail -1 | sed 's/.*Running \([^ ]*\).*/\1/') echo "๐Ÿค– AI fixing ${linter} in ${pkg}" return fi # Check if testing if echo "$last_lines" | grep -q "Testing changes..."; then local pkg=$(echo "$last_lines" | grep "Package: " | tail -1 | sed 's/.*Package: \(.*\) (.*/\1/') echo "๐Ÿงช Testing fixes in ${pkg}" return fi # Check if scanning if echo "$last_lines" | grep -q "Scanning for lint warnings..."; then echo "๐Ÿ” Scanning for lint warnings..." return fi # Check if building if echo "$last_lines" | grep -q "Building"; then echo "๐Ÿ”จ Building code..." return fi # Check if completed if echo "$last_lines" | tail -5 | grep -q "Lint Fixer Complete"; then echo "โœ… COMPLETED" return fi # Default echo "โณ Processing..." } # Function to parse package results from log get_package_results() { if [ ! -f "$LOG_FILE" ]; then echo "0|0|0" return fi local passed=$(grep -c "โœ“ Tests passed" "$LOG_FILE" 2>/dev/null || echo "0") local failed=$(grep -c "โœ— Tests failed" "$LOG_FILE" 2>/dev/null || echo "0") local ai_completed=$(grep -c "โœ“ AI completed successfully" "$LOG_FILE" 2>/dev/null || echo "0") echo "${passed}|${failed}|${ai_completed}" } # Function to get package queue status get_queue_status() { if [ ! -f "$LOG_FILE" ]; then echo "0|0" return fi # Find the "Found N packages" line local total=$(grep "Found .* packages with warnings:" "$LOG_FILE" 2>/dev/null | head -1 | grep -o '[0-9]*' | head -1 || echo "0") # Count completed packages (those with โ”โ”โ” header that have been processed) local completed=$(grep -c "Package: internal/" "$LOG_FILE" 2>/dev/null || echo "0") # Adjust completed count (each package gets 2 passes: errcheck + dupl) # So completed packages = lines / 2, but be conservative completed=$((completed > 0 ? (completed + 1) / 2 : 0)) echo "${completed}|${total}" } # Function to get current package name get_current_package() { if [ ! -f "$LOG_FILE" ]; then echo "-" return fi grep "Package: " "$LOG_FILE" 2>/dev/null | tail -1 | sed 's/.*Package: \(.*\) (.*/\1/' || echo "-" } # Function to get elapsed time get_elapsed_time() { local branch="$1" if [ -z "$branch" ]; then echo "0s" return fi # Get first commit time on this branch local start_time=$(git log --reverse --format=%ct "${branch}" 2>/dev/null | head -1) if [ -z "$start_time" ]; then echo "0s" return fi local now=$(date +%s) local elapsed=$((now - start_time)) if [ $elapsed -ge 3600 ]; then echo "$((elapsed / 3600))h $((elapsed % 3600 / 60))m" elif [ $elapsed -ge 60 ]; then echo "$((elapsed / 60))m $((elapsed % 60))s" else echo "${elapsed}s" fi } # Function to check if process is running is_running() { pgrep -f 'lint-fixer/run.sh' >/dev/null 2>&1 } # Main display loop while true; do clear # Get current lint-fixes branch BRANCH=$(get_lint_branch) # Calculate stats IFS='|' read -r COMMITS INSERTIONS DELETIONS FILES <<< "$(calculate_stats "$BRANCH")" # Get results IFS='|' read -r PASSED FAILED AI_CALLS <<< "$(get_package_results)" # Get queue status IFS='|' read -r COMPLETED TOTAL <<< "$(get_queue_status)" # Get current activity ACTIVITY=$(get_current_activity) # Get current package CURRENT_PKG=$(get_current_package) # Get elapsed time ELAPSED=$(get_elapsed_time "$BRANCH") # Check if running if is_running; then STATUS="${GREEN}โ— RUNNING${RESET}" else STATUS="${RED}โ—‹ STOPPED${RESET}" fi # Display header echo -e "${BOLD}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—${RESET}" echo -e "${BOLD}โ•‘ Pulse Lint Fixer โ€” Live Dashboard โ•‘${RESET}" echo -e "${BOLD}โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ${RESET}" echo -e "${BOLD}โ•‘${RESET} Status: $STATUS" echo -e "${BOLD}โ•‘${RESET} Model: ${CYAN}MiniMax M2.5${RESET}" echo -e "${BOLD}โ•‘${RESET} Branch: ${YELLOW}${BRANCH:-none}${RESET}" echo -e "${BOLD}โ•‘${RESET} Elapsed: ${ELAPSED}" echo -e "${BOLD}โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${RESET}" echo "" # Current activity echo -e "${BOLD}Current Activity:${RESET}" echo -e " $ACTIVITY" echo "" # Progress echo -e "${BOLD}Package Progress:${RESET}" if [ "$TOTAL" -gt 0 ]; then local pct=$((COMPLETED * 100 / TOTAL)) local bar_width=40 local filled=$((pct * bar_width / 100)) local empty=$((bar_width - filled)) echo -n " [" for ((i=0; i