fix: Bugfix-Runde — Sub-Phase Dispatch, Keywords Buttons, abort Task-Kill, Message Splitting, ::multiroom .env, ::approve/::deny, Button-Nummern, Command-Help
This commit is contained in:
@@ -73,6 +73,86 @@ def is_natural_help_request(text: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
# ── UX-8: Command Question Detection ────────────────────────────────────
|
||||
|
||||
# Muster für Fragen über ::-Befehle: "Was macht ::curate?", "Wie geht ::onboarding?"
|
||||
# Diese werden VOR dem LLM-Dispatch abgefangen, damit der Agent nicht halluziniert.
|
||||
_COMMAND_QUESTION_PATTERNS = [
|
||||
"was macht ::",
|
||||
"was ist ::",
|
||||
"wie geht ::",
|
||||
"wie funktioniert ::",
|
||||
"erkläre ::",
|
||||
"was bedeutet ::",
|
||||
"wofür ist ::",
|
||||
"was kann ::",
|
||||
"hilfe zu ::",
|
||||
"help ::",
|
||||
"what does ::",
|
||||
"how to ::",
|
||||
]
|
||||
|
||||
|
||||
def extract_command_question(text: str) -> Optional[str]:
|
||||
"""Extrahiert den ::-Befehl aus einer Frage wie 'Was macht ::curate?'.
|
||||
|
||||
Args:
|
||||
text: Der Nachrichtentext.
|
||||
|
||||
Returns:
|
||||
Den Befehlsnamen (ohne ::) wenn eine Command-Frage erkannt wurde,
|
||||
sonst None.
|
||||
"""
|
||||
stripped = text.strip().lower()
|
||||
for pattern in _COMMAND_QUESTION_PATTERNS:
|
||||
if pattern in stripped:
|
||||
# Extrahiere den Befehl nach dem Pattern
|
||||
idx = stripped.find(pattern) + len(pattern)
|
||||
rest = stripped[idx:].strip()
|
||||
# Nimm das erste Wort (den Befehl)
|
||||
cmd = rest.split()[0] if rest else ""
|
||||
# Entferne Satzzeichen
|
||||
cmd = cmd.rstrip("?!.,;:")
|
||||
if cmd:
|
||||
return cmd
|
||||
return None
|
||||
|
||||
|
||||
def build_command_help(registry: InlineCommandRegistry, name: str) -> Optional[str]:
|
||||
"""Baut einen Hilfetext für einen einzelnen ::-Befehl.
|
||||
|
||||
Args:
|
||||
registry: Die InlineCommandRegistry.
|
||||
name: Der Befehlsname (ohne ::).
|
||||
|
||||
Returns:
|
||||
Formatierter Hilfetext oder None wenn der Befehl nicht existiert.
|
||||
"""
|
||||
cmd = registry._commands.get(name)
|
||||
if cmd is None:
|
||||
return None
|
||||
|
||||
lines = [
|
||||
f"## `::{name}`",
|
||||
"",
|
||||
f"**{cmd['help_text']}**",
|
||||
"",
|
||||
]
|
||||
if cmd.get("description"):
|
||||
lines.append(cmd["description"])
|
||||
lines.append("")
|
||||
|
||||
subcmds = cmd.get("subcommands", {})
|
||||
if subcmds:
|
||||
lines.append("**Subcommands:**")
|
||||
for sub_name, sub_desc in subcmds.items():
|
||||
lines.append(f"- `::{name} {sub_name}` — {sub_desc}")
|
||||
lines.append("")
|
||||
|
||||
lines.append(f"💡 `::hilfe` zeigt alle Befehle an.")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
# ── Inline-Command Registry ────────────────────────────────────────────
|
||||
|
||||
# Command-Handler-Signatur: async def handler(room_id: str, args: str) -> str
|
||||
|
||||
Reference in New Issue
Block a user