#!/bin/bash # Check Spec Completeness Script # Shows detailed TODO items and missing sections set -o pipefail SPEC_FILE="${1:-.}" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Color codes RED='\033[0;31m' YELLOW='\033[1;33m' GREEN='\033[0;32m' BLUE='\033[0;34m' GRAY='\033[0;37m' NC='\033[0m' if [ ! -f "$SPEC_FILE" ]; then echo -e "${RED}✗ Error: File not found: $SPEC_FILE${NC}" exit 1 fi # Extract and display all TODO items show_todos() { echo -e "${BLUE}📝 TODO ITEMS (Incomplete):${NC}" echo "================================" echo "" local todo_count=0 local line_num=0 while IFS= read -r line; do ((line_num++)) if [[ $line =~ TODO|FIXME ]]; then ((todo_count++)) # Extract TODO content if [[ $line =~ \[TODO:(.*)\] ]]; then echo -e "${YELLOW}[$todo_count]${NC} Line $line_num: ${BASH_REMATCH[1]}" elif [[ $line =~ TODO:(.*) ]]; then echo -e "${YELLOW}[$todo_count]${NC} Line $line_num: ${BASH_REMATCH[1]}" else # Clean up the line for display clean_line=$(echo "$line" | sed 's/^[[:space:]]*//' | sed 's/^$//') echo -e "${YELLOW}[$todo_count]${NC} Line $line_num: $clean_line" fi fi done < "$SPEC_FILE" if [ $todo_count -eq 0 ]; then echo -e "${GREEN}✓ No TODO items found!${NC}" else echo "" echo -e "Total TODOs: ${RED}$todo_count${NC}" fi echo "" } # Show missing sections show_missing_sections() { echo -e "${BLUE}📋 SECTION ANALYSIS:${NC}" echo "================================" echo "" local found_sections=() local all_possible_sections=( "Description" "Overview" "Executive Summary" "Problem Statement" "Goals & Success Criteria" "Business Value" "Stakeholders" "User Stories" "Acceptance Criteria" "Proposed Solution" "Architecture" "Implementation Plan" "Risk & Mitigation" "Security Considerations" "Testing Strategy" "Rollout & Deployment Strategy" "Dependencies & Assumptions" "References" "Related Resources" ) for section in "${all_possible_sections[@]}"; do if grep -qE "^## $section" "$SPEC_FILE"; then found_sections+=("$section") fi done echo -e "${GREEN}✓ Found Sections (${#found_sections[@]}):${NC}" for section in "${found_sections[@]}"; do echo " ✓ $section" done echo "" } # Show file statistics show_statistics() { echo -e "${BLUE}📊 FILE STATISTICS:${NC}" echo "================================" echo "" local total_lines=$(wc -l < "$SPEC_FILE") local blank_lines blank_lines=$(grep -c '^[[:space:]]*$' "$SPEC_FILE" 2>/dev/null) blank_lines=${blank_lines:-0} local code_lines code_lines=$(grep -c '```' "$SPEC_FILE" 2>/dev/null) code_lines=${code_lines:-0} local comment_lines comment_lines=$(grep -c '