114 lines
2.8 KiB
Bash
Executable File
114 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# hediff.sh - Hermes Environment Debug Helper
|
|
# Quick utility to verify common debugging scenarios
|
|
|
|
set -euo pipefail
|
|
|
|
# Color codes for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Create test directory and file
|
|
TEST_DIR="/tmp/hediff_test_$$"
|
|
TEST_FILE="$TEST_DIR/test_result.txt"
|
|
|
|
create_test_environment() {
|
|
mkdir -p "$TEST_DIR"
|
|
|
|
{
|
|
echo "=== Test Environment Diagnostic ==="
|
|
echo "Process ID: $$"
|
|
echo "Timestamp: $(date -Iseconds)"
|
|
echo "User: $(whoami)"
|
|
echo "Working Directory: $(pwd)"
|
|
echo "Temp Directory: ${TMPDIR:-/tmp}"
|
|
echo "Hermes Scratch: /root/.hermes/profiles/spark/cache/scratch"
|
|
} > "$TEST_FILE"
|
|
}
|
|
|
|
verify_file_operation() {
|
|
local filepath="$1"
|
|
|
|
if [[ -f "$filepath" ]] && [[ -s "$filepath" ]]; then
|
|
echo -e "${GREEN}✓ File created successfully: $filepath${NC}"
|
|
echo "File size: $(wc -c < "$filepath") bytes"
|
|
echo "Line count: $(wc -l < "$filepath") lines"
|
|
return 0
|
|
else
|
|
echo -e "${RED}✗ File creation failed: $filepath${NC}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
verify_directory_structure() {
|
|
local basedir="$1"
|
|
|
|
local required_dirs=(
|
|
"/root/.hermes/profiles/spark"
|
|
"/root/.hermes/wizard-outputs/spark"
|
|
"$basedir"
|
|
)
|
|
|
|
for dir in "${required_dirs[@]}"; do
|
|
if [[ -d "$dir" ]]; then
|
|
echo -e "${GREEN}✓ Directory exists: $dir${NC}"
|
|
else
|
|
echo -e "${YELLOW}✗ Directory missing: $dir${NC}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
verify_tool_access() {
|
|
echo "Testing tool access..."
|
|
|
|
# Test Python availability
|
|
if command -v python3 &> /dev/null; then
|
|
echo -e "${GREEN}✓ Python3 available: $(python3 --version)${NC}"
|
|
else
|
|
echo -e "${RED}✗ Python3 not found${NC}"
|
|
fi
|
|
|
|
# Test hermes-tools import (if available)
|
|
if python3 -c "import hermes_tools" 2>/dev/null; then
|
|
echo -e "${GREEN}✓ hermes_tools module accessible${NC}"
|
|
else
|
|
echo -e "${YELLOW}○ hermes_tools module not in current Python environment${NC}"
|
|
fi
|
|
}
|
|
|
|
cleanup() {
|
|
if [[ -d "$TEST_DIR" ]]; then
|
|
rm -rf "$TEST_DIR"
|
|
echo "Cleaned up test directory: $TEST_DIR"
|
|
fi
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
echo "=== Hermes Environment Debug Helper ==="
|
|
echo ""
|
|
|
|
echo "Testing file operations..."
|
|
create_test_environment
|
|
verify_file_operation "$TEST_FILE"
|
|
echo ""
|
|
|
|
if [[ "${1:-}" != "--no-dirs" ]]; then
|
|
echo "Checking directory structure..."
|
|
verify_directory_structure "$TEST_DIR"
|
|
echo ""
|
|
fi
|
|
|
|
verify_tool_access
|
|
echo ""
|
|
|
|
cleanup
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Debug check complete.${NC}"
|
|
}
|
|
|
|
# Run with any arguments passed to main
|
|
main "$@" |