asdf
Squash the current repository state back into one baseline commit while preserving the README reframing and repository contents. Constraint: User explicitly requested a single squashed commit with subject "asdf" Confidence: high Scope-risk: broad Reversibility: clean Directive: This commit intentionally rewrites published history; coordinate before future force-pushes Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr Not-tested: Fresh clone verification after push
This commit is contained in:
commit
d2542c9a62
60
src/utils/slashCommandParsing.ts
Normal file
60
src/utils/slashCommandParsing.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Centralized utilities for parsing slash commands
|
||||
*/
|
||||
|
||||
export type ParsedSlashCommand = {
|
||||
commandName: string
|
||||
args: string
|
||||
isMcp: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a slash command input string into its component parts
|
||||
*
|
||||
* @param input - The raw input string (should start with '/')
|
||||
* @returns Parsed command name, args, and MCP flag, or null if invalid
|
||||
*
|
||||
* @example
|
||||
* parseSlashCommand('/search foo bar')
|
||||
* // => { commandName: 'search', args: 'foo bar', isMcp: false }
|
||||
*
|
||||
* @example
|
||||
* parseSlashCommand('/mcp:tool (MCP) arg1 arg2')
|
||||
* // => { commandName: 'mcp:tool (MCP)', args: 'arg1 arg2', isMcp: true }
|
||||
*/
|
||||
export function parseSlashCommand(input: string): ParsedSlashCommand | null {
|
||||
const trimmedInput = input.trim()
|
||||
|
||||
// Check if input starts with '/'
|
||||
if (!trimmedInput.startsWith('/')) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Remove the leading '/' and split by spaces
|
||||
const withoutSlash = trimmedInput.slice(1)
|
||||
const words = withoutSlash.split(' ')
|
||||
|
||||
if (!words[0]) {
|
||||
return null
|
||||
}
|
||||
|
||||
let commandName = words[0]
|
||||
let isMcp = false
|
||||
let argsStartIndex = 1
|
||||
|
||||
// Check for MCP commands (second word is '(MCP)')
|
||||
if (words.length > 1 && words[1] === '(MCP)') {
|
||||
commandName = commandName + ' (MCP)'
|
||||
isMcp = true
|
||||
argsStartIndex = 2
|
||||
}
|
||||
|
||||
// Extract arguments (everything after command name)
|
||||
const args = words.slice(argsStartIndex).join(' ')
|
||||
|
||||
return {
|
||||
commandName,
|
||||
args,
|
||||
isMcp,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user