- 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>
12 lines
312 B
TypeScript
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,
|
|
};
|
|
}
|