Slash Commands Registry
Relevant source files
The following files were used as context for generating this wiki page:
The Slash Commands Registry is a centralized system within the plugsuits project responsible for managing and executing user-facing commands that start with a forward slash (/). This registry allows developers to define custom interactions that bypass the standard LLM reasoning loop, providing direct control over agent configuration, UI state, and specialized operations.
The registry is primarily utilized by the Interactive Terminal UI (TUI) to handle commands like /model for switching LLMs or /help for listing available actions. It supports command aliases, argument parsing, and can be integrated with a skill loader to resolve commands based on external skill definitions.
Sources: packages/harness/README.md, AGENTS.md:46, README.md:68-80
Architecture and Core Logic
The registry functions as a global mapping of command names to their respective execution logic. It is architecturally decoupled from the specific runtime (TUI or Headless), allowing it to be configured with different command sets depending on the package.
Command Definition and Registration
A command is defined as an object containing a unique name, a description, optional aliases, and an asynchronous execute function. This function receives a CommandContext which includes the parsed arguments and returns a CommandResult.
The diagram above illustrates how a user input string is parsed and resolved to a specific command implementation via the registry.
Sources: packages/harness/README.md, AGENTS.md:46
Data Structures
| Structure | Type | Description |
|---|---|---|
Command | Interface | Defines name, description, aliases[], and execute function. |
CommandContext | Interface | Contains args (string array) passed to the command. |
CommandResult | Interface | Contains success (boolean) and message (string). |
SkillCommandResult | Interface | Extends CommandResult with a content field for skill-based prompts. |
Sources: packages/harness/README.md
Key Registry Functions
The registry provides several utility functions to manage the lifecycle of a command from registration to execution.
registerCommand(command: Command): Adds a new command or updates an existing one in the global map.executeCommand(input: string): The main entry point for processing slash commands. It handles the initial parsing (splitting the name from the arguments) and then looks up the implementation.parseCommand(input: string): Splits a string like"/model gpt-4o"into the namemodeland an arguments array["gpt-4o"].resolveRegisteredCommandName(name: string): Resolves a provided alias (e.g.,m) to its canonical name (e.g.,model) if it exists in the registry.
Sources: packages/harness/README.md, AGENTS.md:46
Integration with Skill Loaders
The registry can be extended to handle "Skill Commands"—commands that are not hardcoded but loaded dynamically from a filesystem or repository. This is facilitated by the configureCommandRegistry function.
The sequence diagram shows how the registry falls back to a skill loader when a command is not explicitly registered.
Sources: packages/harness/README.md, packages/cea/src/AGENTS.md:38
Built-in Commands in @ai-sdk-tool/cea
The Code Editing Agent (CEA) package implements a standard set of slash commands for its TUI entrypoint.
| Command | Alias | Description |
|---|---|---|
/help | - | Displays all registered commands and their descriptions. |
/clear | - | Clears the current conversation history. |
/model | /m | Switches the active AI model/provider. |
/reasoning | - | Toggles the LLM's reasoning mode if supported. |
/translate | - | Toggles automatic translation mode. |
/quit | - | Exits the interactive session. |
Sources: README.md:71-79, packages/cea/src/AGENTS.md:38
Implementation Example
The following snippet demonstrates how a command is registered and utilized within the harness.
// Registering a model-switching command
registerCommand({
name: "model",
description: "Switch the active model",
aliases: ["m"],
execute: async ({ args }) => {
const newModel = args[0];
return { success: true, message: `Switched to ${newModel}` };
},
});
// Executing the command from a UI input
if (isCommand("/m claude-3-5-sonnet")) {
const result = await executeCommand("/m claude-3-5-sonnet");
console.log(result?.message); // => "Switched to claude-3-5-sonnet"
}
Sources: packages/harness/README.md
The Slash Commands Registry ensures that the user interface remains responsive and configurable, providing a standardized way to interact with the agent's underlying mechanics without polluting the natural language conversation flow.