feat: V8.5 — FAKT-Speicherort-Dialog beim Onboarding (4 Optionen, Pfad-Validierung, strategy-aware doc_store)
This commit is contained in:
+227
-10
@@ -1519,6 +1519,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
or (is_operator_room and self._onboarding_state.get("current_room_index", -1) >= 0) # v2 Interview läuft
|
||||
or (is_operator_room and self._onboarding_state.get("phase") == "butler_mode") # Fix C v7: Butler-Mode Phase
|
||||
or (is_operator_room and self._onboarding_state.get("phase") == "catch_all_change") # Catch-All Phase
|
||||
or (is_operator_room and self._onboarding_state.get("phase") == "fakt_store") # Thema 3: FAKT-Speicherort Phase
|
||||
or (is_operator_room and "=" in stripped) # v1 Legacy: Name = Thema
|
||||
or (is_operator_room and stripped.startswith("#")) # v1 Legacy: #Name = Thema
|
||||
or (is_operator_room and stripped.lower().startswith("raum:")) # v1 Legacy: Raum: Name = Thema
|
||||
@@ -2942,19 +2943,222 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
)
|
||||
logger.info("[rocketchat] Fix C v7: Butler-Mode gesetzt auf '%s' (Text)", mode)
|
||||
|
||||
# Onboarding abschließen
|
||||
# Thema 3: FAKT-Speicherort-Dialog statt direktem Abschluss
|
||||
self._onboarding_state = {
|
||||
"phase": "fakt_store",
|
||||
"operator_room_id": operator_room_id,
|
||||
}
|
||||
if self.archivar is not None:
|
||||
self.archivar._stats["onboarding_active"] = False
|
||||
self.archivar._state.clear_onboarding_state()
|
||||
self._onboarding_state = {}
|
||||
# FIX E: Raum-Map Summary nach Onboarding aktualisieren
|
||||
self._room_map_summary = self._build_room_map_summary()
|
||||
if self._room_map_summary:
|
||||
logger.info("[rocketchat] FIX E: Raum-Map Summary nach Onboarding aktualisiert (%d Räume)",
|
||||
len(self._room_map_summary.splitlines()) - 1)
|
||||
logger.info("[rocketchat] Onboarding v2 vollständig abgeschlossen (mit Butler-Mode)")
|
||||
self.archivar._state.set_onboarding_state(self._onboarding_state)
|
||||
|
||||
# FAKT-Speicherort-Frage senden
|
||||
_build = self._get_build_custom_buttons()
|
||||
fakt_text = (
|
||||
"📁 **FAKT-Speicherort** — Wo soll ich Fakten (deine Notizen) ablegen?\n\n"
|
||||
"1️⃣ **Standard** — `.hermes/wissenssammlung` in deinem Home-Verzeichnis\n"
|
||||
"2️⃣ **Neuer Ort** — Du gibst einen Pfad an, ich lege das Verzeichnis an\n"
|
||||
"3️⃣ **Bestehender Ort** — Du gibst einen Pfad an, ich verweise darauf\n"
|
||||
"4️⃣ **Keine Sammlung** — FAKT-Nachrichten werden nicht persistiert\n\n"
|
||||
"👉 Klicke auf einen Button oder antworte mit 1–4:"
|
||||
)
|
||||
fakt_buttons = _build(
|
||||
["1️⃣ Standard", "2️⃣ Neuer Ort", "3️⃣ Bestehender Ort", "4️⃣ Keine Sammlung"],
|
||||
prefix="FAKT",
|
||||
style="primary",
|
||||
)
|
||||
fakt_attachments = [{
|
||||
"color": "#1d74f5",
|
||||
"title": "FAKT-Speicherort wählen",
|
||||
"actions": fakt_buttons,
|
||||
}]
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id, fakt_text, attachments=fakt_attachments
|
||||
)
|
||||
logger.info("[rocketchat] Thema 3: FAKT-Speicherort-Frage gesendet")
|
||||
return
|
||||
|
||||
# ── Thema 3: FAKT-Speicherort-Dialog ─────────────────────────────
|
||||
if state.get("phase") == "fakt_store":
|
||||
single_line = text.strip()
|
||||
fakt_sub_phase = state.get("fakt_sub_phase", "")
|
||||
|
||||
# Sub-Phase: User gibt Pfad ein (für Option 2 oder 3)
|
||||
if fakt_sub_phase in ("new_path", "existing_path"):
|
||||
from plugin.archivar.onboarding import (
|
||||
validate_fact_store_path,
|
||||
create_and_verify_fact_store,
|
||||
verify_existing_fact_store,
|
||||
)
|
||||
from datetime import datetime, timezone
|
||||
|
||||
validation = validate_fact_store_path(single_line)
|
||||
if not validation["valid"]:
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
f"❌ {validation['error']}\n\nBitte gib einen gültigen absoluten Pfad ein:"
|
||||
)
|
||||
return
|
||||
|
||||
norm_path = validation["normalized_path"]
|
||||
|
||||
if fakt_sub_phase == "new_path":
|
||||
result = create_and_verify_fact_store(norm_path)
|
||||
else:
|
||||
result = verify_existing_fact_store(norm_path)
|
||||
|
||||
if not result["success"]:
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
f"❌ {result['error']}\n\nBitte versuche einen anderen Pfad:"
|
||||
)
|
||||
return
|
||||
|
||||
# Erfolg: Persistiere in room-map.json
|
||||
strategy = "manual"
|
||||
now_iso = datetime.now(timezone.utc).isoformat()
|
||||
self.archivar._room_map.set_fact_store_strategy(strategy)
|
||||
self.archivar._room_map.set_fact_store_created_at(now_iso)
|
||||
from archivar.room_map import RoomMap
|
||||
from archivar.config import ROOM_MAP_PATH
|
||||
from pathlib import Path as PathLib
|
||||
RoomMap.save(self.archivar._room_map, PathLib(ROOM_MAP_PATH))
|
||||
self.archivar._room_map.reload()
|
||||
|
||||
# Aktualisiere doc_store mit neuem Pfad
|
||||
if self.archivar._doc_store is not None:
|
||||
self.archivar._doc_store.set_base_dir(PathLib(norm_path))
|
||||
else:
|
||||
from plugin.archivar.doc_store import DocumentationStore
|
||||
self.archivar._doc_store = DocumentationStore(base_dir=PathLib(norm_path))
|
||||
|
||||
logger.info(
|
||||
"[rocketchat] FAKT-Store: strategy='manual', path=%s, created_at=%s",
|
||||
norm_path, now_iso,
|
||||
)
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
f"✅ FAKT-Speicherort: `{norm_path}`\n"
|
||||
f"Strategie: {'Neues Verzeichnis angelegt' if fakt_sub_phase == 'new_path' else 'Bestehendes Verzeichnis referenziert'}\n"
|
||||
f"Änderbar mit `::setfakt`."
|
||||
)
|
||||
|
||||
# Onboarding abschließen
|
||||
await self._complete_onboarding(operator_room_id)
|
||||
return
|
||||
|
||||
# Haupt-Phase: Button-Klick oder Text-Antwort
|
||||
if single_line.startswith("FAKT::"):
|
||||
_, choice = single_line.split("::", 1)
|
||||
choice = choice.strip()
|
||||
else:
|
||||
choice = single_line
|
||||
|
||||
from plugin.archivar.onboarding import (
|
||||
validate_fact_store_path,
|
||||
create_and_verify_fact_store,
|
||||
get_default_fact_store_path,
|
||||
)
|
||||
from datetime import datetime, timezone
|
||||
|
||||
# Option 1: Standard
|
||||
if "Standard" in choice or "1️⃣" in choice or choice == "1":
|
||||
default_path = get_default_fact_store_path()
|
||||
result = create_and_verify_fact_store(default_path)
|
||||
if not result["success"]:
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
f"❌ Standard-Pfad konnte nicht erstellt werden: {result['error']}"
|
||||
)
|
||||
return
|
||||
|
||||
strategy = "auto"
|
||||
now_iso = datetime.now(timezone.utc).isoformat()
|
||||
self.archivar._room_map.set_fact_store_strategy(strategy)
|
||||
self.archivar._room_map.set_fact_store_created_at(now_iso)
|
||||
from archivar.room_map import RoomMap
|
||||
from archivar.config import ROOM_MAP_PATH
|
||||
from pathlib import Path as PathLib
|
||||
RoomMap.save(self.archivar._room_map, PathLib(ROOM_MAP_PATH))
|
||||
self.archivar._room_map.reload()
|
||||
|
||||
# Aktualisiere doc_store
|
||||
if self.archivar._doc_store is not None:
|
||||
self.archivar._doc_store.set_base_dir(PathLib(default_path))
|
||||
else:
|
||||
from plugin.archivar.doc_store import DocumentationStore
|
||||
self.archivar._doc_store = DocumentationStore(base_dir=PathLib(default_path))
|
||||
|
||||
logger.info(
|
||||
"[rocketchat] FAKT-Store: strategy='auto', path=%s, created_at=%s",
|
||||
default_path, now_iso,
|
||||
)
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
f"✅ FAKT-Speicherort: `{default_path}` (Standard)\n"
|
||||
f"Änderbar mit `::setfakt`."
|
||||
)
|
||||
await self._complete_onboarding(operator_room_id)
|
||||
return
|
||||
|
||||
# Option 2: Neuer Ort
|
||||
elif "Neuer Ort" in choice or "2️⃣" in choice or choice == "2":
|
||||
self._onboarding_state["fakt_sub_phase"] = "new_path"
|
||||
if self.archivar is not None:
|
||||
self.archivar._state.set_onboarding_state(self._onboarding_state)
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
"📁 Bitte gib den absoluten Pfad für den neuen FAKT-Speicherort ein "
|
||||
"(z.B. `/home/bernd/meine-notizen`):"
|
||||
)
|
||||
return
|
||||
|
||||
# Option 3: Bestehender Ort
|
||||
elif "Bestehender Ort" in choice or "3️⃣" in choice or choice == "3":
|
||||
self._onboarding_state["fakt_sub_phase"] = "existing_path"
|
||||
if self.archivar is not None:
|
||||
self.archivar._state.set_onboarding_state(self._onboarding_state)
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
"📁 Bitte gib den absoluten Pfad zum bestehenden FAKT-Speicherort ein "
|
||||
"(z.B. `/data/Wissensdatenbank`):"
|
||||
)
|
||||
return
|
||||
|
||||
# Option 4: Keine Sammlung
|
||||
elif "Keine Sammlung" in choice or "4️⃣" in choice or choice == "4":
|
||||
strategy = "none"
|
||||
now_iso = datetime.now(timezone.utc).isoformat()
|
||||
self.archivar._room_map.set_fact_store_strategy(strategy)
|
||||
self.archivar._room_map.set_fact_store_created_at(now_iso)
|
||||
from archivar.room_map import RoomMap
|
||||
from archivar.config import ROOM_MAP_PATH
|
||||
from pathlib import Path as PathLib
|
||||
RoomMap.save(self.archivar._room_map, PathLib(ROOM_MAP_PATH))
|
||||
self.archivar._room_map.reload()
|
||||
|
||||
# Deaktiviere doc_store
|
||||
self.archivar._doc_store = None
|
||||
|
||||
logger.info(
|
||||
"[rocketchat] FAKT-Store: strategy='none', created_at=%s",
|
||||
now_iso,
|
||||
)
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
"✅ FAKT-Speicherort: **Keine Wissensammlung**\n"
|
||||
"FAKT-Nachrichten werden im Chat beantwortet, aber nicht persistiert.\n"
|
||||
"Änderbar mit `::setfakt`."
|
||||
)
|
||||
await self._complete_onboarding(operator_room_id)
|
||||
return
|
||||
|
||||
else:
|
||||
await self._post_message_with_retry(
|
||||
operator_room_id,
|
||||
"❌ Bitte wähle eine Option: 1 (Standard), 2 (Neuer Ort), 3 (Bestehender Ort) oder 4 (Keine Sammlung)."
|
||||
)
|
||||
return
|
||||
|
||||
# ── V8.4.2: Keyword-Konflikt-Auflösung ──────────────────────────
|
||||
conflict_phase = state.get("conflict_phase", "")
|
||||
if conflict_phase in ("keywords_100", "keywords_context"):
|
||||
@@ -3644,6 +3848,19 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
await self._post_message_with_retry(operator_room_id, "\n".join(lines), attachments=attachments)
|
||||
logger.info("[rocketchat] Onboarding v2 abgeschlossen: alle Räume eingerichtet")
|
||||
|
||||
async def _complete_onboarding(self, operator_room_id: str) -> None:
|
||||
"""Thema 3: Onboarding final abschließen (nach FAKT-Speicherort-Dialog)."""
|
||||
if self.archivar is not None:
|
||||
self.archivar._stats["onboarding_active"] = False
|
||||
self.archivar._state.clear_onboarding_state()
|
||||
self._onboarding_state = {}
|
||||
# FIX E: Raum-Map Summary nach Onboarding aktualisieren
|
||||
self._room_map_summary = self._build_room_map_summary()
|
||||
if self._room_map_summary:
|
||||
logger.info("[rocketchat] FIX E: Raum-Map Summary nach Onboarding aktualisiert (%d Räume)",
|
||||
len(self._room_map_summary.splitlines()) - 1)
|
||||
logger.info("[rocketchat] Onboarding v2 vollständig abgeschlossen (mit FAKT-Speicherort)")
|
||||
|
||||
@staticmethod
|
||||
def _derive_keywords(room_name: str, theme: str) -> list:
|
||||
"""Leitet Stichworte aus Raumname und Thema ab.
|
||||
|
||||
Reference in New Issue
Block a user