mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 04:54:25 -07:00
feat(cli): Add /model command for interactive model selection (#8940)
Co-authored-by: Miguel Solorio <miguel.solorio07@gmail.com>
This commit is contained in:
@@ -59,6 +59,9 @@ vi.mock('../ui/commands/extensionsCommand.js', () => ({
|
||||
}));
|
||||
vi.mock('../ui/commands/helpCommand.js', () => ({ helpCommand: {} }));
|
||||
vi.mock('../ui/commands/memoryCommand.js', () => ({ memoryCommand: {} }));
|
||||
vi.mock('../ui/commands/modelCommand.js', () => ({
|
||||
modelCommand: { name: 'model' },
|
||||
}));
|
||||
vi.mock('../ui/commands/privacyCommand.js', () => ({ privacyCommand: {} }));
|
||||
vi.mock('../ui/commands/quitCommand.js', () => ({ quitCommand: {} }));
|
||||
vi.mock('../ui/commands/statsCommand.js', () => ({ statsCommand: {} }));
|
||||
@@ -81,6 +84,7 @@ describe('BuiltinCommandLoader', () => {
|
||||
vi.clearAllMocks();
|
||||
mockConfig = {
|
||||
getFolderTrust: vi.fn().mockReturnValue(true),
|
||||
getUseModelRouter: () => false,
|
||||
} as unknown as Config;
|
||||
|
||||
restoreCommandMock.mockReturnValue({
|
||||
@@ -150,4 +154,26 @@ describe('BuiltinCommandLoader', () => {
|
||||
const permissionsCmd = commands.find((c) => c.name === 'permissions');
|
||||
expect(permissionsCmd).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should include modelCommand when getUseModelRouter is true', async () => {
|
||||
const mockConfigWithModelRouter = {
|
||||
...mockConfig,
|
||||
getUseModelRouter: () => true,
|
||||
} as unknown as Config;
|
||||
const loader = new BuiltinCommandLoader(mockConfigWithModelRouter);
|
||||
const commands = await loader.loadCommands(new AbortController().signal);
|
||||
const modelCmd = commands.find((c) => c.name === 'model');
|
||||
expect(modelCmd).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not include modelCommand when getUseModelRouter is false', async () => {
|
||||
const mockConfigWithoutModelRouter = {
|
||||
...mockConfig,
|
||||
getUseModelRouter: () => false,
|
||||
} as unknown as Config;
|
||||
const loader = new BuiltinCommandLoader(mockConfigWithoutModelRouter);
|
||||
const commands = await loader.loadCommands(new AbortController().signal);
|
||||
const modelCmd = commands.find((c) => c.name === 'model');
|
||||
expect(modelCmd).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ideCommand } from '../ui/commands/ideCommand.js';
|
||||
import { initCommand } from '../ui/commands/initCommand.js';
|
||||
import { mcpCommand } from '../ui/commands/mcpCommand.js';
|
||||
import { memoryCommand } from '../ui/commands/memoryCommand.js';
|
||||
import { modelCommand } from '../ui/commands/modelCommand.js';
|
||||
import { permissionsCommand } from '../ui/commands/permissionsCommand.js';
|
||||
import { privacyCommand } from '../ui/commands/privacyCommand.js';
|
||||
import { quitCommand } from '../ui/commands/quitCommand.js';
|
||||
@@ -69,7 +70,8 @@ export class BuiltinCommandLoader implements ICommandLoader {
|
||||
initCommand,
|
||||
mcpCommand,
|
||||
memoryCommand,
|
||||
this.config?.getFolderTrust() ? permissionsCommand : null,
|
||||
...(this.config?.getUseModelRouter() ? [modelCommand] : []),
|
||||
...(this.config?.getFolderTrust() ? [permissionsCommand] : []),
|
||||
privacyCommand,
|
||||
quitCommand,
|
||||
restoreCommand(this.config),
|
||||
|
||||
Reference in New Issue
Block a user