Install
Install with PiG
pig install npm:@smallbatchcode/pi-slash-command-guardInstall with Pi
pi install npm:@smallbatchcode/pi-slash-command-guardPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.1.3 (README.md). PiG does not review it.
Slash Command Guard
Prevents mistyped or unknown slash commands from being sent as normal user messages.
Does not interfere with custom slash commands registered by extensions. It also does not interfere with prompt slash commands, or skill slash commands.
What it does
When a user submits a message that starts with /, this extension checks whether the slash command is known to pi. If the command is unknown, the message is blocked and an error notification is shown.
If the unknown command is close to a known command, the notification includes a hint:
Unknown slash command "/quti". Did you mean "/quit"?
If no close match is found, it shows:
Unknown slash command "/whatever".
The extension does not rewrite or resubmit the user's input.
Why?
If you never start a message to the agent with a slash, you've probably had the experience of attempting a slash command, hitting enter quickly, and then realizing you just sent /treee to the agent, furiously aborting, and then going back up the session tree so /treee doesn't sit in your session context (or using pi-wtf). This simply prevents you from sending a bad slash command to the agent, and attempts to help tell you what you meant to type.
Related
This pairs well with my pi-wtf. Slash Command Guard catches mistyped slash commands before they are sent; pi-wtf can help recover and revise prompts after they have already been submitted.
Install
Local checkout:
pi install /path/to/pi-extensions/extensions/slash-command-guard
NPM:
pi install npm:@smallbatchcode/pi-slash-command-guard
Development
npm install
npm run typecheck
npm run check:builtins