Slash command parse and dispatch
Overview
This flow covers how a user-typed string starting with / is parsed into a command name and arguments, then dispatched to the correct handler . It is triggered from the prompt input submission path after the base user-input processor detects a slash prefix .
Steps
- The user submits text from the prompt input component, which routes non-bash input into the base user-input processor . That processor normalizes images and content blocks before considering slash-command handling .
- For bridge-origin input the base processor calls
parseSlashCommandearly to decide whether the command is safe to run remotely, short-circuiting unsafe commands with a local stdout message . Otherwise it hands the raw string toprocessSlashCommand. processSlashCommandinvokesparseSlashCommand, which trims the input, verifies the leading/, splits on spaces, extractscommandName, detects an(MCP)marker, and joins the rest asargsinto aParsedSlashCommand. A null result makesprocessSlashCommandreturn a synthetic "Commands are in the form/command [args]" error .processSlashCommandthen checkshasCommand; if unknown it stats/commandNamevia the fs implementation to distinguish a file path from a typo, usinglooksLikeCommandas a character-class filter . Unknown-but-command-shaped input logstengu_input_slash_invalidand returns an "Unknown skill" message .- For a recognized command
processSlashCommanddelegates togetMessagesForSlashCommandwith the parsed name, args, andProcessUserInputContext. That function resolves theCommandobject viagetCommand, which callsfindCommandagainstcontext.options.commandsand throws aReferenceErrorlisting available commands if missing . - If the resolved command is a user-invocable prompt skill, usage is recorded before dispatch via the debounced tracker that persists through
saveGlobalConfig. Commands withuserInvocable === falseare rejected with a message telling the user to ask Claude to invoke the skill . getMessagesForSlashCommandthen switches oncommand.type:local-jsxcommands resolve via a Promise-wrapped JSX handler, while prompt commands withcontext === 'fork'path intoexecuteForkedSlashCommandwhich prepares a forked agent context and runs the sub-agent .- Back in
processSlashCommand, the returnedSlashCommandResultis used to logtengu_input_commandwith plugin telemetry fields and to assemble the finalProcessUserInputBaseResultmessages that feed the main query loop . - The
SkillToolpath reuses the same parsing/dispatch machinery by importingprocessPromptSlashCommandand callingfindCommand+recordSkillUsageitself when the model (not the user) invokes a skill .
State touched
Decisions
(none in whitelist)