-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_with_llx.sh
More file actions
executable file
·65 lines (58 loc) · 2.33 KB
/
validate_with_llx.sh
File metadata and controls
executable file
·65 lines (58 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Validate planfile examples using LLX
echo "Planfile Example Validation with LLX"
echo "====================================="
# Check if LLX is available
if ! command -v llx &> /dev/null; then
echo "⚠️ LLX not found. Install with: pip install llx"
echo " Falling back to basic validation"
LLX_AVAILABLE=false
else
echo "✅ LLX found"
LLX_AVAILABLE=true
fi
# Function to validate a file
validate_file() {
local file=$1
echo -e "\nValidating: $file"
if [ "$LLX_AVAILABLE" = true ]; then
# Use LLX for validation
case "${file##*.}" in
yaml|yml)
echo " YAML structure validation..."
python3 -c "import yaml; yaml.safe_load(open('$file'))" && echo " ✅ Valid YAML" || echo " ❌ Invalid YAML"
;;
py)
echo " Python syntax validation..."
python3 -m py_compile "$file" && echo " ✅ Valid Python" || echo " ❌ Invalid Python"
if [ "$LLX_AVAILABLE" = true ]; then
echo " Code complexity analysis..."
llx analyze "$file" 2>/dev/null || echo " ⚠️ Could not analyze with LLX"
fi
;;
json)
echo " JSON structure validation..."
python3 -c "import json; json.load(open('$file'))" && echo " ✅ Valid JSON" || echo " ❌ Invalid JSON"
;;
esac
else
# Basic validation
case "${file##*.}" in
yaml|yml)
python3 -c "import yaml; yaml.safe_load(open('$file'))" 2>/dev/null && echo " ✅ Valid YAML" || echo " ❌ Invalid YAML"
;;
py)
python3 -m py_compile "$file" 2>/dev/null && echo " ✅ Valid Python" || echo " ❌ Invalid Python"
;;
json)
python3 -c "import json; json.load(open('$file'))" 2>/dev/null && echo " ✅ Valid JSON" || echo " ❌ Invalid JSON"
;;
esac
fi
}
# Find and validate all generated files
echo "\nScanning for generated files..."
find . -type f \( -name "*.yaml" -o -name "*.yml" -o -name "*.py" -o -name "*.json" \) -not -path "./venv/*" -not -path "./.venv/*" | while read file; do
validate_file "$file"
done
echo "\nValidation complete!"