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."