diff --git a/install.sh b/install.sh index 71ce85d..a1ce7c2 100755 --- a/install.sh +++ b/install.sh @@ -474,6 +474,38 @@ perform_update_only() { local PLUGIN_DST="$hermes_dir/plugins/platforms/rocketchat" mkdir -p "$PLUGIN_DST" + # GUARD 1: Syntax-Check VOR Deployment + echo "🔍 Running syntax check on Python files..." + while read -r pyfile; do + if ! python3 -m py_compile "$pyfile" 2>/dev/null; then + echo "❌ Syntax error in $pyfile" + echo "Deployment aborted due to syntax errors" + return 1 + fi + done < <(find "$script_dir/plugin" -name "*.py" -type f) + echo "✅ All Python files passed syntax check" + + # GUARD 2: Vollständigkeits-Check + echo "🔍 Running completeness check..." + local missing_files=() + while read -r src; do + rel="${src#$script_dir/plugin/}" + dst="$PLUGIN_DST/$rel" + if [ ! -f "$dst" ]; then + missing_files+=("$rel") + fi + done < <(find "$script_dir/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc') + + if [ ${#missing_files[@]} -gt 0 ]; then + echo "❌ Missing files detected:" + for file in "${missing_files[@]}"; do + echo " - $file" + done + echo "Deployment aborted due to missing files" + return 1 + fi + echo "✅ All files present in destination" + if [ -d "$script_dir/plugin" ]; then while read -r src; do rel="${src#$script_dir/plugin/}" @@ -489,14 +521,16 @@ perform_update_only() { return 1 fi + # GUARD 3: Pycache-Löschung NACH Deployment + echo "🧹 Cleaning up pycache files..." + find "$PLUGIN_DST" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true + find "$PLUGIN_DST" -name '*.pyc' -delete 2>/dev/null || true + msg cache_cleared + # NOTE: room-map.json is MACHINE-SPECIFIC — never deployed # by --update-only. It is created by the RC-Skill onboarding # flow after gateway start. See RC-Skill: "Room Topic Discipline" - # 4. Clear stale __pycache__ - find "$PLUGIN_DST" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true - msg cache_cleared - # 5. Restart gateway (mit State-Cleanup gegen Discovery-Bug + Auto-Resume-Loop) msg restarting systemctl --user daemon-reload 2>/dev/null || true @@ -720,6 +754,17 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PLUGIN_DST="$HERMES_DIR/plugins/platforms/rocketchat" mkdir -p "$PLUGIN_DST" +# GUARD 1: Syntax-Check VOR Deployment +echo "🔍 Running syntax check on Python files..." +while read -r pyfile; do + if ! python3 -m py_compile "$pyfile" 2>/dev/null; then + echo "❌ Syntax error in $pyfile" + echo "Deployment aborted due to syntax errors" + exit 1 + fi +done < <(find "$SCRIPT_DIR/plugin" -name "*.py" -type f) +echo "✅ All Python files passed syntax check" + # Rekursiv kopieren (inkl. Submodule wie archivar/), __pycache__ ausschließen if [ -d "$SCRIPT_DIR/plugin" ]; then # Lösche vorherige Dateien NICHT — das könnte andere Submodule zerstören @@ -734,6 +779,33 @@ if [ -d "$SCRIPT_DIR/plugin" ]; then msg copied "$copied_count" fi +# GUARD 2: Vollständigkeits-Check +echo "🔍 Running completeness check..." +missing_files=() +while read -r src; do + rel="${src#$SCRIPT_DIR/plugin/}" + dst="$PLUGIN_DST/$rel" + if [ ! -f "$dst" ]; then + missing_files+=("$rel") + fi +done < <(find "$SCRIPT_DIR/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc') + +if [ ${#missing_files[@]} -gt 0 ]; then + echo "❌ Missing files detected:" + for file in "${missing_files[@]}"; do + echo " - $file" + done + echo "Deployment aborted due to missing files" + exit 1 +fi +echo "✅ All files present in destination" + +# GUARD 3: Pycache-Löschung NACH Deployment +echo "🧹 Cleaning up pycache files..." +find "$PLUGIN_DST" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true +find "$PLUGIN_DST" -name '*.pyc' -delete 2>/dev/null || true +msg cache_cleared + # ─── Fix #9: Provision minimal config.yaml + .env ────────── # Only when hermes has NO config yet (fresh install, no setup run) HERMES_HOME="$HOME/.hermes"