Files
stack/packages/cli/src/tui/commands/parse.ts
Jason Woltje 48c9f57f69
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
feat(cli): TUI slash command parsing + local commands (P8-009)
- Add parseSlashCommand() with regex-based parser for /cmd [args] format
- Add CommandRegistry with local-only commands (help, stop, cost, status, clear) and gateway manifest support
- Add short alias resolution: /n→new, /m→model, /t→thinking, /a→agent, /s→status, /h→help, /pref→preferences
- Add executeHelp() and executeStatus() local command handlers
- Extend Message.role union with 'system' for in-TUI system messages
- Handle commands:manifest socket event to update registry from gateway
- Wire InputBar to intercept /commands before sending to socket
- Render system messages as dimmed ⚙ prefix without avatar chrome
- Expose addSystemMessage() and socketRef from useSocket hook

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 20:55:10 -05:00

12 lines
312 B
TypeScript

import type { ParsedCommand } from '@mosaic/types';
export function parseSlashCommand(input: string): ParsedCommand | null {
const match = input.match(/^\/([a-z][a-z0-9:_-]*)\s*(.*)?$/i);
if (!match) return null;
return {
command: match[1]!,
args: match[2]?.trim() || null,
raw: input,
};
}