From 8001de46c71e4587ace559bbd6ad077fb4cb398d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 24 Feb 2026 07:24:02 +0000 Subject: [PATCH] Add !clear command and simplify !reset confirmation message Both !clear and !reset now respond with "Conversation memory cleared." Co-Authored-By: Claude Opus 4.6 --- meshai/commands/clear.py | 17 +++++++++++++++++ meshai/commands/dispatcher.py | 2 ++ meshai/commands/reset.py | 5 +---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 meshai/commands/clear.py diff --git a/meshai/commands/clear.py b/meshai/commands/clear.py new file mode 100644 index 0000000..be64cff --- /dev/null +++ b/meshai/commands/clear.py @@ -0,0 +1,17 @@ +"""Clear command handler (alias for !reset).""" + +from .base import CommandContext, CommandHandler + + +class ClearCommand(CommandHandler): + """Clear conversation history and summary.""" + + name = "clear" + description = "Clear your chat history" + usage = "!clear" + + async def execute(self, args: str, context: CommandContext) -> str: + """Clear conversation history and summary for the sender.""" + await context.history.clear_history(context.sender_id) + await context.history.clear_summary(context.sender_id) + return "Conversation memory cleared." diff --git a/meshai/commands/dispatcher.py b/meshai/commands/dispatcher.py index 4c03215..7f770f6 100644 --- a/meshai/commands/dispatcher.py +++ b/meshai/commands/dispatcher.py @@ -169,6 +169,7 @@ def create_dispatcher( Returns: Configured CommandDispatcher """ + from .clear import ClearCommand from .help import HelpCommand from .ping import PingCommand from .reset import ResetCommand @@ -178,6 +179,7 @@ def create_dispatcher( dispatcher = CommandDispatcher(prefix=prefix, disabled_commands=disabled_commands) # Register all built-in commands + dispatcher.register(ClearCommand()) dispatcher.register(HelpCommand(dispatcher)) dispatcher.register(PingCommand()) dispatcher.register(ResetCommand()) diff --git a/meshai/commands/reset.py b/meshai/commands/reset.py index e8e171f..36796ce 100644 --- a/meshai/commands/reset.py +++ b/meshai/commands/reset.py @@ -17,7 +17,4 @@ class ResetCommand(CommandHandler): # Also clear the conversation summary await context.history.clear_summary(context.sender_id) - if deleted > 0: - return f"Cleared {deleted} messages from history" - else: - return "No history to clear" + return "Conversation memory cleared."