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 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-02-24 07:24:02 +00:00
commit 8001de46c7
3 changed files with 20 additions and 4 deletions

17
meshai/commands/clear.py Normal file
View file

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

View file

@ -169,6 +169,7 @@ def create_dispatcher(
Returns: Returns:
Configured CommandDispatcher Configured CommandDispatcher
""" """
from .clear import ClearCommand
from .help import HelpCommand from .help import HelpCommand
from .ping import PingCommand from .ping import PingCommand
from .reset import ResetCommand from .reset import ResetCommand
@ -178,6 +179,7 @@ def create_dispatcher(
dispatcher = CommandDispatcher(prefix=prefix, disabled_commands=disabled_commands) dispatcher = CommandDispatcher(prefix=prefix, disabled_commands=disabled_commands)
# Register all built-in commands # Register all built-in commands
dispatcher.register(ClearCommand())
dispatcher.register(HelpCommand(dispatcher)) dispatcher.register(HelpCommand(dispatcher))
dispatcher.register(PingCommand()) dispatcher.register(PingCommand())
dispatcher.register(ResetCommand()) dispatcher.register(ResetCommand())

View file

@ -17,7 +17,4 @@ class ResetCommand(CommandHandler):
# Also clear the conversation summary # Also clear the conversation summary
await context.history.clear_summary(context.sender_id) await context.history.clear_summary(context.sender_id)
if deleted > 0: return "Conversation memory cleared."
return f"Cleared {deleted} messages from history"
else:
return "No history to clear"