3 Commits

Author SHA1 Message Date
Bernd (Hermes) b4ba67e80b feat: ::hilfe um Core-Befehle ergänzt (continue, /reset, /compress)
- inline_commands.py: Sektion 0 'Core-Befehle' in build_help_text()
- docs/Archivar-Funktionsbeschreibung-v8.5.md: Section 6.0 Core-Befehle
- test_r5_inline_commands.py: Assertions für Core-Befehle
2026-07-25 19:12:42 +02:00
Bernd (Hermes) 7457dc81a9 fix(install.sh): --update-only kopiert an korrekten pipx-venv-Pfad + Cleanup
Root Cause: install.sh --update-only kopierte Plugin-Dateien nach
~/.hermes/plugins/rocketchat/, aber der Gateway lädt Plugins aus dem
pipx-venv site-packages/plugins/platforms/rocketchat/.

Änderungen:
- systemd drop-in PYTHONPATH: hardcoded python3.13 → dynamisch via
  find_site_packages() mit Fallback
- deploy_plugin() + --update-only: alte tools.py löschen
  (wurde zu rc_tools.py umbenannt, verhindert Shadowing)
- --update-only: stale ~/.hermes/plugins/rocketchat/ bereinigen
  (alter falscher Pfad aus früheren Versionen)
- Tests: restart_gateway-Funktion statt literal systemctl-String
- Neue Tests: tools.py-Cleanup, stale-Pfad-Cleanup, kein hardcoded
  python3.13

143 tests passed, bash -n clean.
2026-07-25 17:43:39 +02:00
Bernd (Hermes) 0d6837e341 fix(P0): DM-Guard entfernt — confirm_move Copy-Schritt läuft jetzt auch bei DM-Origins
Rainer Analyse: adapter.py Z.2353 hatte 'if room_type != "d":' Guard
der den Copy-Schritt bei DM-Origins übersprang. Entfernt.
Telemetrie: confirm_move_dm_origin hinzugefügt.
2026-07-25 17:00:28 +02:00
6 changed files with 203 additions and 28 deletions
@@ -242,6 +242,16 @@ Whitespace-Validierung: Keywords mit internen Leerzeichen werden abgelehnt (`if
Rocket.Chat unterstützt kein `/`-Prefix; deshalb verwendet das Plugin `::` als alternatives Command-Präfix. Registriert in `adapter.py` (`self._inline_commands.register(...)`).
### 6.0 Core-Befehle (Hermes Core, immer verfügbar)
Diese Befehle werden direkt vom Hermes-Agenten verarbeitet — unabhängig vom Plugin:
| Befehl | Wirkung |
|----------------|-------------------------------------------------------------------------|
| `continue` | Agent fortsetzen nach leerer Antwort / Stream-Drop |
| `/reset` | Session zurücksetzen (Chat-Kontext löschen, frische Session). In RC: `::reset` |
| `/compress` | Kontext manuell komprimieren (Token sparen bei langen Sessions). In RC: `::compress` |
### 6.1 Standard-Hermes-Befehle
| Befehl | Wirkung |
+23 -1
View File
@@ -467,6 +467,12 @@ deploy_plugin() {
find "$dst" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
find "$dst" -name '*.pyc' -delete 2>/dev/null || true
# V8.6: Alte tools.py löschen (wurde zu rc_tools.py umbenannt, P3-Fix)
if [ -f "$dst/tools.py" ]; then
rm -f "$dst/tools.py"
log "Alte tools.py gelöscht (ersetzt durch rc_tools.py)"
fi
# plugin.yaml am richtigen Ort? Datei liegt in plugin/plugin.yaml
# → kopiert als $dst/plugin.yaml. Korrekt.
local count
@@ -907,11 +913,15 @@ install_gateway_service() {
local dropin_dir="$HOME/.config/systemd/user/hermes-gateway.service.d"
local dropin="$dropin_dir/env.conf"
mkdir -p "$dropin_dir"
# Dynamischen site-packages-Pfad ermitteln (nicht hardcoded python3.13)
local _sp
_sp="$(find_site_packages "$PIPX_VENV")"
[ -n "$_sp" ] || _sp="$PIPX_VENV/lib/python3.13/site-packages"
cat > "$dropin" <<EOF
[Service]
EnvironmentFile=%h/.config/hermes/rocketchat.env
EnvironmentFile=%h/.hermes/.env
Environment=PYTHONPATH=$PIPX_VENV/lib/python3.13/site-packages/plugins/platforms/rocketchat
Environment=PYTHONPATH=${_sp}/plugins/platforms/rocketchat
Environment=MULTIROOM_AGENT=$RC_MULTIROOM
Environment=OLLAMA_KEEP_ALIVE=$OLLAMA_KEEP_ALIVE
EOF
@@ -1446,6 +1456,18 @@ if $UPDATE_ONLY; then
find "$_update_dst" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find "$_update_dst" -name '*.pyc' -delete 2>/dev/null || true
ok "__pycache__ nach Deployment gelöscht"
# V8.6: Alte tools.py löschen (wurde zu rc_tools.py umbenannt, P3-Fix)
if [ -f "$_update_dst/tools.py" ]; then
rm -f "$_update_dst/tools.py"
log "Alte tools.py gelöscht (ersetzt durch rc_tools.py)"
fi
# V8.6: Stale ~/.hermes/plugins/rocketchat/ bereinigen (alter falscher Pfad)
if [ -d "$HOME/.hermes/plugins/rocketchat" ]; then
rm -rf "$HOME/.hermes/plugins/rocketchat"
log "Stale ~/.hermes/plugins/rocketchat/ gelöscht (alter falscher Pfad)"
fi
else
printf '%s[dry]%s find %s -type d -name __pycache__ -exec rm -rf {} +\n' "$C_YELLOW" "$C_RESET" "$_update_dst"
fi
+3 -2
View File
@@ -2349,8 +2349,7 @@ class RocketChatAdapter(BasePlatformAdapter):
)
# ── FIX 1 (P0): ISSUE 4 — Nachricht in Zielraum kopieren ──
# V8.1 hatte den Copy-Schritt fälschlich entfernt.
# DM-Aufträge werden NIE geroutet (DM-Guard).
if room_type != "d":
# P0-Fix: DM-Guard entfernt — Copy läuft jetzt auch bei DM-Origins.
try:
prefix = f"*(Auftrag von @{username}, hierher kopiert)*\n"
target_copy_id = await self._post_message_with_retry(
@@ -2360,6 +2359,8 @@ class RocketChatAdapter(BasePlatformAdapter):
if target_copy_id:
self._recent_auto_routes[room_id]["target_message_id"] = target_copy_id
routing_counter.increment('confirm_move_copied')
if room_type == "d":
routing_counter.increment('confirm_move_dm_origin')
logger.info(
"[rocketchat] FIX 1: confirm_move copy → %s, "
"target_msg_id=%s",
+25
View File
@@ -235,6 +235,31 @@ def build_help_text(
"",
]
# ── Sektion 0: Core-Befehle (Hermes Core, immer verfügbar) ────────
lines.append("### ⚙️ Core-Befehle")
lines.append("")
lines.append(
"Diese Befehle werden direkt vom Hermes-Agenten verarbeitet "
"und sind immer verfügbar — unabhängig vom Plugin:"
)
lines.append("")
lines.append(
"- **continue** — Agent fortsetzen nach leerer Antwort / Stream-Drop. "
"Einfach `continue` in den Chat schreiben, der Agent macht weiter."
)
lines.append(
"- **/reset** — Session zurücksetzen. "
"Löscht den gesamten Chat-Kontext und startet eine frische Session. "
"In Rocket.Chat als `::reset` nutzbar."
)
lines.append(
"- **/compress** — Kontext manuell komprimieren. "
"Verdichtet den Chat-Verlauf, um Token zu sparen und die "
"Antwortqualität bei langen Sessions zu erhalten. "
"In Rocket.Chat als `::compress` nutzbar."
)
lines.append("")
# ::-Befehle nach Kategorie gruppieren
by_category: Dict[str, List[Dict[str, Any]]] = {}
for name, cmd in registry.get_commands().items():
@@ -226,6 +226,10 @@ class TestBuildHelpText:
registry.register("sethome", dummy, "Setzt Heimatraum", category="Raum")
text = build_help_text(registry)
assert "Core-Befehle" in text
assert "continue" in text
assert "/reset" in text
assert "/compress" in text
assert "::hilfe" in text
assert "::status" in text
assert "::sethome" in text
@@ -254,6 +258,8 @@ class TestBuildHelpText:
registry = InlineCommandRegistry()
text = build_help_text(registry)
assert "Rocket.Chat Plugin" in text
assert "Core-Befehle" in text
assert "continue" in text
assert "Natürliche Sprach-Befehle" in text
+117 -6
View File
@@ -139,12 +139,13 @@ class TestUpdateOnlyServiceRestart:
"""Gateway-Dienst muss nach dem Update neu gestartet werden."""
def test_systemctl_restart_present(self):
"""systemctl --user restart hermes-gateway ist im --update-only Block."""
"""restart_gateway (oder systemctl restart) ist im --update-only Block."""
content = _read_install_sh()
update_section = _extract_update_only_section(content)
assert "systemctl --user restart hermes-gateway" in update_section, (
f"systemctl restart fehlt im --update-only Block:\n{update_section}"
# restart_gateway ist die Funktion, die systemctl --user restart kapselt
assert "restart_gateway" in update_section, (
f"restart_gateway fehlt im --update-only Block:\n{update_section}"
)
def test_no_restart_flag_respected(self):
@@ -158,15 +159,15 @@ class TestUpdateOnlyServiceRestart:
)
def test_restart_after_deploy(self):
"""systemctl restart kommt NACH deploy_plugin."""
"""restart_gateway kommt NACH deploy_plugin."""
content = _read_install_sh()
update_section = _extract_update_only_section(content)
deploy_pos = update_section.find("deploy_plugin")
restart_pos = update_section.find("systemctl --user restart hermes-gateway")
restart_pos = update_section.find("restart_gateway")
assert restart_pos > deploy_pos, (
f"restart ({restart_pos}) muss NACH deploy_plugin ({deploy_pos}) kommen"
f"restart_gateway ({restart_pos}) muss NACH deploy_plugin ({deploy_pos}) kommen"
)
@@ -361,3 +362,113 @@ class TestDeployPluginCacheCleanup:
assert "rm -rf" in func_body, (
f"deploy_plugin() nutzt kein rm -rf für __pycache__:\n{func_body[:500]}"
)
# ═══════════════════════════════════════════════════════════════════════════
# Test 8: tools.py Cleanup (V8.6: rename tools.py → rc_tools.py)
# ═══════════════════════════════════════════════════════════════════════════
class TestToolsPyCleanup:
"""Alte tools.py muss in deploy_plugin() und --update-only gelöscht werden."""
def test_deploy_plugin_removes_old_tools_py(self):
"""deploy_plugin() löscht alte tools.py."""
content = _read_install_sh()
match = re.search(
r'deploy_plugin\(\)\s*\{.*?(?=\n\}\n\n#)',
content,
re.DOTALL,
)
assert match, "deploy_plugin()-Funktion nicht gefunden"
func_body = match.group(0)
assert "tools.py" in func_body, (
f"deploy_plugin() enthält keine tools.py-Bereinigung:\n{func_body[:500]}"
)
assert "rc_tools.py" in func_body, (
f"deploy_plugin() erwähnt rc_tools.py nicht:\n{func_body[:500]}"
)
def test_update_only_removes_old_tools_py(self):
"""--update-only Block löscht alte tools.py."""
content = _read_install_sh()
update_section = _extract_update_only_section(content)
assert "tools.py" in update_section, (
f"--update-only Block enthält keine tools.py-Bereinigung:\n{update_section}"
)
assert "rc_tools.py" in update_section, (
f"--update-only Block erwähnt rc_tools.py nicht:\n{update_section}"
)
# ═══════════════════════════════════════════════════════════════════════════
# Test 9: Stale ~/.hermes/plugins/rocketchat/ Cleanup (V8.6)
# ═══════════════════════════════════════════════════════════════════════════
class TestStalePluginDirCleanup:
"""--update-only muss den alten falschen Pfad ~/.hermes/plugins/rocketchat/ bereinigen."""
def test_update_only_removes_stale_hermes_plugins_dir(self):
"""--update-only Block löscht ~/.hermes/plugins/rocketchat/."""
content = _read_install_sh()
update_section = _extract_update_only_section(content)
assert ".hermes/plugins/rocketchat" in update_section, (
f"--update-only Block bereinigt nicht ~/.hermes/plugins/rocketchat/:\n{update_section}"
)
assert "rm -rf" in update_section, (
f"--update-only Block nutzt kein rm -rf für stale Pfad:\n{update_section}"
)
# ═══════════════════════════════════════════════════════════════════════════
# Test 10: Kein hardcoded python3.13 (V8.6: dynamischer site-packages-Pfad)
# ═══════════════════════════════════════════════════════════════════════════
class TestNoHardcodedPythonVersion:
"""install.sh darf keinen hardcoded python3.13-Pfad enthalten."""
def test_no_hardcoded_python3_13_in_site_packages_path(self):
"""Kein 'python3.13/site-packages' als hartcodierter Pfad (außer Fallback/Dry-Run)."""
content = _read_install_sh()
# python3.13 darf nur in Kommentaren, Fallback-Strings, Dry-Run-Platzhaltern
# oder apt-Install vorkommen. Aber NICHT als hartcodierter site-packages-Pfad.
lines_with_python3_13 = [
line for line in content.split("\n")
if "python3.13" in line
]
for line in lines_with_python3_13:
if "site-packages" in line:
# Erlaubt: Fallback nach find_site_packages, Dry-Run-Platzhalter, Kommentare
ok = (
"find_site_packages" in line
or "||" in line
or "#" in line.strip()[:1]
or "<PIPX_VENV>" in line # Dry-Run-Platzhalter
)
assert ok, (
f"Hardcoded python3.13/site-packages ohne Fallback:\n {line.strip()}"
)
def test_find_site_packages_used_for_dropin(self):
"""systemd drop-in nutzt find_site_packages (nicht hardcoded python3.13)."""
content = _read_install_sh()
# Der drop-in-Block muss find_site_packages aufrufen
match = re.search(
r'install_gateway_service\(\).*?(?=\n\}\n\n#)',
content,
re.DOTALL,
)
assert match, "install_gateway_service()-Funktion nicht gefunden"
func_body = match.group(0)
assert "find_site_packages" in func_body, (
f"install_gateway_service() nutzt nicht find_site_packages:\n{func_body[:500]}"
)