feat: sync PROVIDER_NAMES with config schema and update README docs
Extract MODEL_PROVIDERS const from config schema as single source of truth for provider names. PROVIDER_NAMES in TUI commands now imports from schema instead of maintaining a hardcoded list. Adds tests verifying sync. Updates README TUI Commands section with /model hot-swap documentation, supported providers, and runtime model switching examples.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseCommand, getHelpText } from './commands.js';
|
||||
import { parseCommand, getHelpText, getCommandCompletions, PROVIDER_NAMES } from './commands.js';
|
||||
import { MODEL_PROVIDERS } from '../../config/index.js';
|
||||
|
||||
describe('parseCommand', () => {
|
||||
it('parses /quit command', () => {
|
||||
@@ -130,3 +131,33 @@ describe('/pair command', () => {
|
||||
expect(parseCommand('/pair revoke telegram 12345')).toEqual({ type: 'pair', action: 'revoke', args: 'telegram 12345' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('PROVIDER_NAMES', () => {
|
||||
it('matches all providers from the config schema', () => {
|
||||
expect(PROVIDER_NAMES).toEqual(MODEL_PROVIDERS);
|
||||
});
|
||||
|
||||
it('includes zhipuai, openrouter, and xai', () => {
|
||||
expect(PROVIDER_NAMES).toContain('zhipuai');
|
||||
expect(PROVIDER_NAMES).toContain('openrouter');
|
||||
expect(PROVIDER_NAMES).toContain('xai');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCommandCompletions', () => {
|
||||
it('suggests all providers when typing /model default with partial provider', () => {
|
||||
// Typing any character after the tier triggers provider suggestions
|
||||
const completions = getCommandCompletions('/model default a');
|
||||
expect(completions).toContain('/model default anthropic');
|
||||
});
|
||||
|
||||
it('filters provider suggestions by partial input', () => {
|
||||
const completions = getCommandCompletions('/model default zh');
|
||||
expect(completions).toEqual(['/model default zhipuai']);
|
||||
});
|
||||
|
||||
it('completes xai provider', () => {
|
||||
const completions = getCommandCompletions('/model fast x');
|
||||
expect(completions).toEqual(['/model fast xai']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user