/** * Slash command parser for the Waggle CLI REPL. */ export interface SlashCommand { name: string; args: string; } /** * Parse a user input line as a slash command. * Returns null if the input is not a slash command. * * Examples: * "/model gpt-4o" → { name: "model", args: "gpt-4o" } * "/exit" → { name: "exit", args: "" } * "hello" → null */ export function parseCommand(input: string): SlashCommand | null { const trimmed = input.trim(); if (!trimmed.startsWith('/')) return null; const spaceIdx = trimmed.indexOf(' '); if (spaceIdx === -1) { return { name: trimmed.slice(1), args: '' }; } return { name: trimmed.slice(1, spaceIdx), args: trimmed.slice(spaceIdx + 1).trim(), }; } /** Help text for each supported slash command. */ export const COMMANDS: Record = { model: '/model — Switch to a different model', models: '/models — List all available models', exit: '/exit — Quit the REPL', clear: '/clear — Clear conversation history', help: '/help — Show this help message', identity: '/identity — Show agent identity', cost: '/cost — Show token usage and estimated cost', plan: '/plan — Show current execution plan', git: '/git — Show git status for workspace', };