198 lines
5.4 KiB
Bash
Executable File
198 lines
5.4 KiB
Bash
Executable File
#!/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/^<!--[[:space:]]*//' | sed 's/[[:space:]]*-->$//')
|
|
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 '<!--' "$SPEC_FILE" 2>/dev/null)
|
|
comment_lines=${comment_lines:-0}
|
|
local has_frontmatter
|
|
has_frontmatter=$(grep -c '^---$' "$SPEC_FILE" 2>/dev/null)
|
|
has_frontmatter=${has_frontmatter:-0}
|
|
|
|
echo "Total Lines: $total_lines"
|
|
echo "Blank Lines: $blank_lines"
|
|
echo "Code Blocks: $((code_lines / 2))"
|
|
echo "Comments: $((comment_lines / 2))"
|
|
frontmatter_status="No"
|
|
[ "$has_frontmatter" -gt 0 ] && frontmatter_status="Yes"
|
|
echo "Has YAML Frontmatter: $frontmatter_status"
|
|
echo ""
|
|
}
|
|
|
|
# Show completion percentage
|
|
show_completion() {
|
|
local completion=$(grep -c "^##" "$SPEC_FILE" || echo 0)
|
|
completion=$((completion * 100 / 15)) # Assume ~15 sections for full spec
|
|
[ $completion -gt 100 ] && completion=100
|
|
|
|
echo -e "${BLUE}📈 COMPLETION:${NC}"
|
|
echo "================================"
|
|
echo ""
|
|
|
|
# Simple progress bar
|
|
local filled=$((completion / 5))
|
|
local empty=$((20 - filled))
|
|
local bar=""
|
|
for i in $(seq 1 $filled); do bar+="█"; done
|
|
for i in $(seq 1 $empty); do bar+="░"; done
|
|
|
|
echo -n "Progress: [$bar] "
|
|
if [ $completion -lt 50 ]; then
|
|
echo -e "${RED}$completion%${NC}"
|
|
elif [ $completion -lt 80 ]; then
|
|
echo -e "${YELLOW}$completion%${NC}"
|
|
else
|
|
echo -e "${GREEN}$completion%${NC}"
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
# Show references/links
|
|
show_references() {
|
|
echo -e "${BLUE}🔗 EXTERNAL REFERENCES:${NC}"
|
|
echo "================================"
|
|
echo ""
|
|
|
|
local refs=$(grep -oE '\[([^\]]+)\]\(([^)]+)\)' "$SPEC_FILE" | cut -d'(' -f2 | tr -d ')' | sort -u || echo "")
|
|
|
|
if [ -z "$refs" ]; then
|
|
echo "No external references found"
|
|
else
|
|
echo "$refs" | while read -r ref; do
|
|
# Check if link is broken (relative and file doesn't exist)
|
|
if [[ ! "$ref" =~ ^http ]] && [ ! -f "$ref" ]; then
|
|
echo -e " ${YELLOW}⚠${NC} $ref (file not found)"
|
|
else
|
|
echo " ${GREEN}✓${NC} $ref"
|
|
fi
|
|
done
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
# Main
|
|
echo ""
|
|
echo -e "${BLUE}📋 SPEC COMPLETENESS ANALYSIS${NC}"
|
|
echo "========================================"
|
|
echo "File: $(basename "$SPEC_FILE")"
|
|
echo ""
|
|
|
|
show_todos
|
|
show_missing_sections
|
|
show_statistics
|
|
show_completion
|
|
show_references
|
|
|
|
echo -e "${GRAY}---${NC}"
|
|
echo "Run 'validate-spec.sh' for full validation"
|