Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b4ba67e80b | |||
| 7457dc81a9 | |||
| 0d6837e341 |
@@ -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
@@ -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
|
||||
|
||||
+22
-21
@@ -2349,27 +2349,28 @@ 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":
|
||||
try:
|
||||
prefix = f"*(Auftrag von @{username}, hierher kopiert)*\n"
|
||||
target_copy_id = await self._post_message_with_retry(
|
||||
move_req["target_room"],
|
||||
prefix + move_req["text"],
|
||||
)
|
||||
if target_copy_id:
|
||||
self._recent_auto_routes[room_id]["target_message_id"] = target_copy_id
|
||||
routing_counter.increment('confirm_move_copied')
|
||||
logger.info(
|
||||
"[rocketchat] FIX 1: confirm_move copy → %s, "
|
||||
"target_msg_id=%s",
|
||||
move_req.get("target_name", "?")[:20],
|
||||
target_copy_id or "N/A",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"[rocketchat] FIX 1: confirm_move copy failed — %s", e
|
||||
)
|
||||
# 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(
|
||||
move_req["target_room"],
|
||||
prefix + move_req["text"],
|
||||
)
|
||||
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",
|
||||
move_req.get("target_name", "?")[:20],
|
||||
target_copy_id or "N/A",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"[rocketchat] FIX 1: confirm_move copy failed — %s", e
|
||||
)
|
||||
elif choice in ("2", "2️⃣", "generell", "generell hier bleiben", "stay_here"):
|
||||
# 2️⃣ Generell hier bleiben → Antwort im Ursprungsraum + Sticky-Eintrag
|
||||
# P0-B: Thematischer Sticky (v7) — Thema aus Match-Ergebnis extrahieren
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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]}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user