fix(cli): add model guard and explicit tools:[] for /btw command

Explicitly pass tools:[] to generateContent to prevent tool invocation
in side questions. Add model undefined guard for defensive safety.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Shaojin Wen 2026-03-14 16:44:13 +08:00
parent d285c4409a
commit ed9a4edc40
2 changed files with 32 additions and 2 deletions

View file

@ -87,6 +87,28 @@ describe('btwCommand', () => {
});
});
it('should return error when model is not configured', async () => {
const noModelContext = createMockCommandContext({
services: {
config: {
getGeminiClient: () => ({
getHistory: mockGetHistory,
generateContent: mockGenerateContent,
}),
getModel: () => '',
},
},
});
const result = await btwCommand.action!(noModelContext, 'test question');
expect(result).toEqual({
type: 'message',
messageType: 'error',
content: 'No model configured.',
});
});
describe('interactive mode', () => {
it('should set pending item and add completed item on success', async () => {
mockGenerateContent.mockResolvedValue({
@ -149,7 +171,7 @@ describe('btwCommand', () => {
],
},
],
{},
{ tools: [] },
expect.any(AbortSignal),
'test-model',
);