fix(hilfe): vollständigen Hilfetext über zwei Teile ausgeben statt kürzen
Andreas' Entscheidung: lieber den vollständigen Hilfetext über zwei
Textblöcke ausgeben, als eine unvollständige Seite. Der progressive
Kürzungs-Fix (f74d206) schnitt Subcommand-Details weg (::keywords
review/status, ::butler mode-Optionen) — nicht akzeptabel.
- build_help_text() gibt wieder den vollständigen, ungekürzten Text zurück
- progressiven Kürzungs-Fix (Stufe 1-3) entfernt
- room_map_summary-Kürzungs-Fix (P1) beibehalten (optionale Sektion)
- NEU: build_help_text_parts() teilt bei > 4500 Zeichen in zwei Teile:
Teil 1 = Core + Standard + RC-Befehle, Teil 2 = Natürliche Sprache +
Status + Tipp
- adapter.py: _post_help_text() postet beide Teile nacheinander; alle
Aufrufer (::hilfe, ::commands, natürliche Hilfe, unbekannter Befehl,
Command-Question, Onboarding-Review) umgestellt
- Tests: test_build_help_text_full (alle Subcommands), test_build_help_text_split
(zwei Teile < 4500), test_build_help_text_split_single_part_when_short
This commit is contained in:
@@ -236,24 +236,17 @@ class InlineCommandRegistry:
|
||||
# ── Help-Text-Generator ─────────────────────────────────────────────────
|
||||
|
||||
|
||||
def build_help_text(
|
||||
def _build_help_sections(
|
||||
registry: InlineCommandRegistry,
|
||||
room_map_summary: str = "",
|
||||
presence_enabled: Optional[bool] = None,
|
||||
current_status: str = "online",
|
||||
plugin_version: str = "",
|
||||
) -> str:
|
||||
"""Baut die Hilfeseite mit ::-Befehlen und natürlichen Sprach-Befehlen.
|
||||
|
||||
Args:
|
||||
registry: Die InlineCommandRegistry mit allen registrierten Befehlen.
|
||||
room_map_summary: Optionale Raum-Map-Übersicht für den Status-Teil.
|
||||
presence_enabled: Ob die PresenceEngine aktiv ist (None = nicht verfügbar).
|
||||
current_status: Aktueller Presence-Status ('online', 'away', 'busy').
|
||||
plugin_version: Plugin-Version (z.B. "9.2 (1d31d2c)").
|
||||
) -> Dict[str, List[str]]:
|
||||
"""Baut die Hilfeseiten-Sektionen als Dict von Zeilen-Listen.
|
||||
|
||||
Returns:
|
||||
Formatierte Hilfeseite als Markdown-String.
|
||||
Dict mit den Keys: header, core, standard, rc, natural, status, footer.
|
||||
"""
|
||||
header = [
|
||||
"## 🤖 Rocket.Chat Plugin — Hilfe",
|
||||
@@ -398,16 +391,18 @@ def build_help_text(
|
||||
"Moderatorenrechte in den Themenräumen haben.",
|
||||
]
|
||||
|
||||
lines = header + core_lines + standard_lines + rc_lines + natural_lines + status_lines + footer
|
||||
result = "\n".join(lines)
|
||||
|
||||
# P1-Fix: Rocket.Chat hat ein Payload-Limit von ~5000 Zeichen.
|
||||
# Wenn der Hilfe-Text > 4000 Zeichen ist, lasse die room_map_summary
|
||||
# weg und ersetze sie durch einen kurzen Hinweis. Die Ersetzung erfolgt
|
||||
# direkt in status_lines, damit sie auch bei den P1b-Kürzungen
|
||||
# (Stufe 1/2) erhalten bleibt.
|
||||
# direkt in status_lines, damit sie auch bei der Zwei-Teil-Aufteilung
|
||||
# erhalten bleibt. (Die room_map_summary ist eine optionale Sektion,
|
||||
# keine Befehlsliste — das Kürzen ist hier akzeptabel.)
|
||||
MAX_HELP_LENGTH = 4000
|
||||
if len(result) > MAX_HELP_LENGTH and room_map_summary:
|
||||
full_lines = (
|
||||
header + core_lines + standard_lines + rc_lines
|
||||
+ natural_lines + status_lines + footer
|
||||
)
|
||||
if len("\n".join(full_lines)) > MAX_HELP_LENGTH and room_map_summary:
|
||||
for i, line in enumerate(status_lines):
|
||||
if line == room_map_summary:
|
||||
status_lines[i] = (
|
||||
@@ -415,73 +410,100 @@ def build_help_text(
|
||||
"(> 4000 Zeichen). `::status` für Details."
|
||||
)
|
||||
break
|
||||
lines = header + core_lines + standard_lines + rc_lines + natural_lines + status_lines + footer
|
||||
result = "\n".join(lines)
|
||||
|
||||
# P1b-Fix: Die Hilfe-Seite ist durch Subcommand-Ergänzungen auch OHNE
|
||||
# room_map_summary über das Payload-Limit gewachsen. Der P1-Fix greift
|
||||
# nur, wenn room_map_summary gesetzt ist. Zweiter Check: wenn der Text
|
||||
# IMMER NOCH > 4500 Zeichen ist (nah am ~5000-Limit), kürze die
|
||||
# entbehrlichsten Sektionen progressiv — zuerst die natürlichen
|
||||
# Sprach-Befehle (Sektion 3), dann die Standard-Hermes-Befehle
|
||||
# (Sektion 1) auf eine kompakte Liste. Core-Befehle, RC-Plugin-Befehle,
|
||||
# Status-Farben und Plugin-Status bleiben erhalten.
|
||||
MAX_SAFE_LENGTH = 4500
|
||||
# Kompakte Varianten der entbehrlichsten Sektionen — werden nur bei
|
||||
# Überschreitung des Limits verwendet.
|
||||
compact_natural = [
|
||||
"### 🗣️ Natürliche Sprach-Befehle",
|
||||
"",
|
||||
"Du kannst auch natürlich sprechen: 'Lass uns in #Raum wechseln', "
|
||||
"'Das gehört in den Plugin-Raum', 'Ich brauche Hilfe', '::status'.",
|
||||
"",
|
||||
]
|
||||
compact_standard = ["### 🔷 Standard-Hermes-Befehle (:: als Variante)", ""]
|
||||
for cmd in standard_cmds:
|
||||
compact_standard.append(f"- `::{cmd['name']}` — {cmd['help_text']}")
|
||||
compact_standard.append("")
|
||||
compact_rc = ["### 🔶 RC-Plugin-spezifische Befehle", ""]
|
||||
compact_rc.append("Diese Befehle steuern das Rocket.Chat-Plugin direkt:")
|
||||
compact_rc.append("")
|
||||
for cmd in rc_cmds:
|
||||
compact_rc.append(f"- `::{cmd['name']}` — {cmd['help_text']}")
|
||||
compact_rc.append("")
|
||||
compact_rc.append(
|
||||
"**Butler-Routing-Modus:** cognitive (Vorschlag+Bestätigung), "
|
||||
"strict (automatisch), off (deaktiviert) — einstellbar über `::onboarding`"
|
||||
return {
|
||||
"header": header,
|
||||
"core": core_lines,
|
||||
"standard": standard_lines,
|
||||
"rc": rc_lines,
|
||||
"natural": natural_lines,
|
||||
"status": status_lines,
|
||||
"footer": footer,
|
||||
}
|
||||
|
||||
|
||||
def build_help_text(
|
||||
registry: InlineCommandRegistry,
|
||||
room_map_summary: str = "",
|
||||
presence_enabled: Optional[bool] = None,
|
||||
current_status: str = "online",
|
||||
plugin_version: str = "",
|
||||
) -> str:
|
||||
"""Baut die vollständige Hilfeseite mit ::-Befehlen und natürlichen Sprach-Befehlen.
|
||||
|
||||
Der Text wird NICHT gekürzt — alle Subcommands bleiben erhalten.
|
||||
Nur die optionale room_map_summary wird bei Überschreitung des
|
||||
Payload-Limits weggelassen (P1-Fix).
|
||||
|
||||
Args:
|
||||
registry: Die InlineCommandRegistry mit allen registrierten Befehlen.
|
||||
room_map_summary: Optionale Raum-Map-Übersicht für den Status-Teil.
|
||||
presence_enabled: Ob die PresenceEngine aktiv ist (None = nicht verfügbar).
|
||||
current_status: Aktueller Presence-Status ('online', 'away', 'busy').
|
||||
plugin_version: Plugin-Version (z.B. "9.2 (1d31d2c)").
|
||||
|
||||
Returns:
|
||||
Formatierte Hilfeseite als Markdown-String (vollständig, ungekürzt).
|
||||
"""
|
||||
s = _build_help_sections(
|
||||
registry,
|
||||
room_map_summary=room_map_summary,
|
||||
presence_enabled=presence_enabled,
|
||||
current_status=current_status,
|
||||
plugin_version=plugin_version,
|
||||
)
|
||||
compact_rc.append("")
|
||||
lines = (
|
||||
s["header"] + s["core"] + s["standard"] + s["rc"]
|
||||
+ s["natural"] + s["status"] + s["footer"]
|
||||
)
|
||||
return "\n".join(lines)
|
||||
|
||||
if len(result) > MAX_SAFE_LENGTH:
|
||||
# Stufe 1: Natürliche Sprach-Befehle auf eine Zeile kürzen
|
||||
lines = (
|
||||
header + core_lines + standard_lines + rc_lines
|
||||
+ compact_natural + status_lines + footer
|
||||
)
|
||||
result = "\n".join(lines)
|
||||
|
||||
if len(result) > MAX_SAFE_LENGTH:
|
||||
# Stufe 2: Standard-Hermes-Befehle auf kompakte Liste kürzen
|
||||
# (nur Befehlsnamen, keine Subcommands, keine Einleitung)
|
||||
lines = (
|
||||
header + core_lines + compact_standard + rc_lines
|
||||
+ compact_natural + status_lines + footer
|
||||
)
|
||||
result = "\n".join(lines)
|
||||
def build_help_text_parts(
|
||||
registry: InlineCommandRegistry,
|
||||
room_map_summary: str = "",
|
||||
presence_enabled: Optional[bool] = None,
|
||||
current_status: str = "online",
|
||||
plugin_version: str = "",
|
||||
) -> List[str]:
|
||||
"""Baut die Hilfeseite als Liste von 1-2 Teilen, jeder < 4500 Zeichen.
|
||||
|
||||
if len(result) > MAX_SAFE_LENGTH:
|
||||
# Stufe 3: RC-Plugin-Befehle behalten, aber Subcommand-Details
|
||||
# weglassen (nur Befehlsname + help_text). Die Befehle selbst
|
||||
# bleiben vollständig erhalten — nur die ausführlichen
|
||||
# Subcommand-Aufzählungen (z.B. ::reasoning mit 9 Einträgen,
|
||||
# ::onboarding mit 6) werden entfernt.
|
||||
lines = (
|
||||
header + core_lines + compact_standard + compact_rc
|
||||
+ compact_natural + status_lines + footer
|
||||
)
|
||||
result = "\n".join(lines)
|
||||
Andreas' Entscheidung: lieber den vollständigen Hilfetext über zwei
|
||||
Textblöcke ausgeben, als eine unvollständige Seite. Wenn der vollständige
|
||||
Text > 4500 Zeichen ist, wird er in zwei Teile aufgeteilt:
|
||||
|
||||
return result
|
||||
- Teil 1: Core-Befehle + Standard-Hermes-Befehle + RC-Plugin-Befehle
|
||||
- Teil 2: Natürliche Sprach-Befehle + Status-Farben + Plugin-Status + Tipp
|
||||
|
||||
Args:
|
||||
registry: Die InlineCommandRegistry mit allen registrierten Befehlen.
|
||||
room_map_summary: Optionale Raum-Map-Übersicht für den Status-Teil.
|
||||
presence_enabled: Ob die PresenceEngine aktiv ist (None = nicht verfügbar).
|
||||
current_status: Aktueller Presence-Status ('online', 'away', 'busy').
|
||||
plugin_version: Plugin-Version (z.B. "9.2 (1d31d2c)").
|
||||
|
||||
Returns:
|
||||
Liste mit 1 Element (vollständiger Text, wenn <= 4500 Zeichen)
|
||||
oder 2 Elementen (Teil 1 und Teil 2, wenn > 4500 Zeichen).
|
||||
"""
|
||||
s = _build_help_sections(
|
||||
registry,
|
||||
room_map_summary=room_map_summary,
|
||||
presence_enabled=presence_enabled,
|
||||
current_status=current_status,
|
||||
plugin_version=plugin_version,
|
||||
)
|
||||
part1 = "\n".join(s["header"] + s["core"] + s["standard"] + s["rc"])
|
||||
part2 = "\n".join(s["natural"] + s["status"] + s["footer"])
|
||||
full = "\n".join(
|
||||
s["header"] + s["core"] + s["standard"] + s["rc"]
|
||||
+ s["natural"] + s["status"] + s["footer"]
|
||||
)
|
||||
|
||||
MAX_SAFE_LENGTH = 4500
|
||||
if len(full) <= MAX_SAFE_LENGTH:
|
||||
return [full]
|
||||
return [part1, part2]
|
||||
|
||||
|
||||
def build_status_text(
|
||||
|
||||
Reference in New Issue
Block a user