Slash Commands
Relevant source files
The following files were used as context for generating this wiki page:
Slash commands are a core interactive feature of QQcode, providing users with a concise syntax to execute meta-actions, modify configurations, and manage sessions during an interactive chat. These commands are prefixed with the forward-slash (/) character and are distinct from natural language prompts or direct shell command execution (which uses the ! prefix).
Sources: README.md:104-106, README.md:124-125
Architecture and Discovery
The slash command system is integrated into the CLI's Textual-based TUI and programmatic entry points. It utilizes a dedicated controller and completer logic to handle user input in real-time.
Slash Command Controller
The SlashCommandController manages the lifecycle of a slash command interaction, including determining if the current input is a command, managing suggestions, and applying completions.
can_handle: Checks if the input text starts with/.on_text_changed: Triggers theCommandCompleterto fetch matching commands and updates the UI view.on_key: Handles keyboard events such asTab(for selection),Enter(for submission), andUp/Down(for navigation).
Sources: vibe/cli/autocompletion/slash_command.py:11-82
Component Relationship
The following diagram illustrates how slash commands are processed within the CLI autocompletion framework.
This flow ensures that suggestions are updated dynamically as the user types after a / prefix.
Sources: vibe/cli/autocompletion/slash_command.py:24-60
Autocompletion Logic
The system provides visual feedback through a popup widget that lists available commands and their descriptions.
Suggestion Management
Suggestions are limited to a maximum of 5 items to maintain UI clarity. The controller tracks a _selected_index to allow users to navigate through the list using arrow keys.
| Feature | Logic Description |
|---|---|
| Trigger | Input must start with / |
| Max Suggestions | 5 items |
| Navigation | Circular cycling using Up/Down arrows |
| Selection | Tab replaces input; Enter replaces input and submits |
Sources: vibe/cli/autocompletion/slash_command.py:9-70
Interaction Flow
The sequence of autocompleting a slash command involves the UI, the controller, and the underlying completion engine.
Implementation Examples
Slash commands are tested to ensure they integrate correctly with the Textual application state and the terminal's command history.
User Interaction Test
The following test logic confirms that typing a partial command triggers the popup and allows for selection.
@pytest.mark.asyncio
async def test_popup_appears_with_matching_suggestions(vibe_app: VibeApp) -> None:
async with vibe_app.run_test() as pilot:
popup = vibe_app.query_one(CompletionPopup)
await pilot.press(*"/sum")
assert popup.styles.display == "block"
assert "/summarize" in str(popup.render())
Sources: tests/autocompletion/test_ui_chat_autocompletion.py:33-46
Common Meta-Actions
While specific command implementations reside in the core agent logic, the UI identifies several standard commands:
/configor/cfg: Manage application settings./stats: View session or model statistics./status: Check current agent or project status./help: Display available commands and usage instructions.
Sources: tests/autocompletion/test_ui_chat_autocompletion.py:65-95
Conclusion
Slash commands provide a high-efficiency alternative to natural language for administrative and meta-tasks within QQcode. By integrating a dedicated SlashCommandController with real-time autocompletion, the system ensures that users can discover and execute configuration changes or session management tasks with minimal friction.