feat: add /backend command parsing

Add support for /backend command to show or switch local backend providers. Follows the same pattern as /model command with optional argument support.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
William Valentin
2026-02-05 13:35:10 -08:00
parent dbeaa78e2c
commit 465b4a0c3c
2 changed files with 20 additions and 0 deletions
+9
View File
@@ -35,6 +35,15 @@ describe('parseCommand', () => {
expect(parseCommand('/model opus')).toEqual({ type: 'model', name: 'opus' });
});
it('parses /backend command without argument', () => {
expect(parseCommand('/backend')).toEqual({ type: 'backend' });
});
it('parses /backend command with argument', () => {
expect(parseCommand('/backend llamacpp')).toEqual({ type: 'backend', provider: 'llamacpp' });
expect(parseCommand('/backend ollama')).toEqual({ type: 'backend', provider: 'ollama' });
});
it('parses /transfer command', () => {
expect(parseCommand('/transfer telegram')).toEqual({ type: 'transfer', target: 'telegram' });
});
+11
View File
@@ -5,6 +5,7 @@ export type Command =
| { type: 'status' }
| { type: 'fullscreen' }
| { type: 'model'; name?: string }
| { type: 'backend'; provider?: string }
| { type: 'transfer'; target: string }
| { type: 'message'; content: string };
@@ -46,6 +47,15 @@ export function parseCommand(input: string): Command | null {
return { type: 'model', name };
}
// Backend (with optional argument)
if (trimmed === '/backend') {
return { type: 'backend' };
}
if (trimmed.startsWith('/backend ')) {
const provider = trimmed.slice('/backend '.length).trim();
return { type: 'backend', provider };
}
// Transfer
if (trimmed.startsWith('/transfer ')) {
const target = trimmed.slice('/transfer '.length).trim();
@@ -61,6 +71,7 @@ export function getHelpText(): string {
Commands:
/help, /? Show this help
/model [name] Show or switch model (local, default, fast, complex)
/backend [provider] Show or switch local backend (ollama, llamacpp)
/reset, /clear Clear conversation history
/status Show session info and token usage
/fullscreen, /fs Switch to fullscreen mode