Clear the terminal screen.
| 17 | |
| 18 | |
| 19 | class ClearCommand(UnifiedCommand): |
| 20 | """Clear the terminal screen.""" |
| 21 | |
| 22 | @property |
| 23 | def name(self) -> str: |
| 24 | return "clear" |
| 25 | |
| 26 | @property |
| 27 | def aliases(self) -> list[str]: |
| 28 | return [] |
| 29 | |
| 30 | @property |
| 31 | def description(self) -> str: |
| 32 | return "Clear the terminal screen" |
| 33 | |
| 34 | @property |
| 35 | def help_text(self) -> str: |
| 36 | return """ |
| 37 | Clear the terminal screen. |
| 38 | |
| 39 | Usage: |
| 40 | /clear - Clear screen (chat mode) |
| 41 | clear - Clear screen (interactive mode) |
| 42 | |
| 43 | Aliases: cls |
| 44 | """ |
| 45 | |
| 46 | @property |
| 47 | def modes(self) -> CommandMode: |
| 48 | """Clear is only for chat and interactive modes.""" |
| 49 | return CommandMode.CHAT | CommandMode.INTERACTIVE |
| 50 | |
| 51 | @property |
| 52 | def requires_context(self) -> bool: |
| 53 | """Clear doesn't need tool manager context.""" |
| 54 | return False |
| 55 | |
| 56 | async def execute(self, **kwargs) -> CommandResult: |
| 57 | """Execute the clear command.""" |
| 58 | # Import needed modules |
| 59 | from chuk_term.ui import clear_screen, display_chat_banner |
| 60 | from mcp_cli.context import get_context |
| 61 | from mcp_cli.model_management import ModelManager |
| 62 | |
| 63 | # Clear the screen first |
| 64 | clear_screen() |
| 65 | |
| 66 | # Try to get context for banner information |
| 67 | provider = None |
| 68 | model = None |
| 69 | additional_info = {} |
| 70 | |
| 71 | try: |
| 72 | context = get_context() |
| 73 | if context: |
| 74 | # Get provider and model from context's model_manager |
| 75 | if hasattr(context, "model_manager") and context.model_manager: |
| 76 | provider = context.model_manager.get_active_provider() |
no outgoing calls