Clean, minimal autocomplete for slash commands.
| 28 | |
| 29 | |
| 30 | class CleanCommandCompleter(Completer): |
| 31 | """Clean, minimal autocomplete for slash commands.""" |
| 32 | |
| 33 | COMMANDS = [ |
| 34 | # Essential Commands Only |
| 35 | ("/models", "list or switch AI models"), |
| 36 | ("/setkey", "set or update OpenRouter API key"), |
| 37 | ("/gpu", "show GPU status"), |
| 38 | ("/setup", "configure compiler paths"), |
| 39 | ("/compilers", "show compiler configuration"), |
| 40 | ("/clear", "clear conversation history"), |
| 41 | ("/help", "show help menu"), |
| 42 | ("/quit", "exit RightNow CLI"), |
| 43 | ] |
| 44 | |
| 45 | def get_completions(self, document, complete_event): |
| 46 | text = document.text_before_cursor |
| 47 | |
| 48 | if text.startswith('/'): |
| 49 | command_text = text[1:].lower() |
| 50 | |
| 51 | for cmd, desc in self.COMMANDS: |
| 52 | cmd_without_slash = cmd[1:] |
| 53 | |
| 54 | if cmd_without_slash.startswith(command_text): |
| 55 | display = f"{cmd:<12} {desc}" |
| 56 | |
| 57 | yield Completion( |
| 58 | text=cmd_without_slash, |
| 59 | start_position=-len(command_text), |
| 60 | display=display, |
| 61 | ) |
| 62 | |
| 63 | |
| 64 | def _ensure_cursor_visible(): |