Files
waggle-os/packages/cli/src/commands.ts
shumeiko.it 697517d378 refactor(cli): run local mode only (P1.1)
Team mode is not part of the community edition (ADR-0003), so the CLI
no longer detects or switches to it.

- Remove the mode detector, the --local and --team flags, the Clerk
  browser login (/login, /logout, /whoami) and /mode.
- Remove the /admin command and its team-server REST client.
- The welcome banner drops the Mode line.
- The installed-REPL test starts plain `waggle` and checks that the team
  commands are gone.
2026-10-24 17:35:48 +02:00

46 lines
1.3 KiB
TypeScript

/**
* 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<string, string> = {
model: '/model <name> — 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',
};