mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 15:31:27 +00:00
Make shell output consistent. (#4469)
This commit is contained in:
parent
4dbd9f30b6
commit
f650be2c3a
4 changed files with 78 additions and 19 deletions
|
|
@ -10,6 +10,7 @@ import { useShellCommandProcessor } from './shellCommandProcessor';
|
|||
import { Config, GeminiClient } from '@google/gemini-cli-core';
|
||||
import * as fs from 'fs';
|
||||
import EventEmitter from 'events';
|
||||
import { ToolCallStatus } from '../types';
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('child_process');
|
||||
|
|
@ -104,8 +105,15 @@ describe('useShellCommandProcessor', () => {
|
|||
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
expect(addItemToHistoryMock.mock.calls[1][0]).toEqual({
|
||||
type: 'info',
|
||||
text: 'file1.txt\nfile2.txt',
|
||||
type: 'tool_group',
|
||||
tools: [
|
||||
expect.objectContaining({
|
||||
name: 'Shell Command',
|
||||
description: 'ls -l',
|
||||
status: ToolCallStatus.Success,
|
||||
resultDisplay: 'file1.txt\nfile2.txt',
|
||||
}),
|
||||
],
|
||||
});
|
||||
expect(geminiClientMock.addHistory).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
|
@ -140,8 +148,16 @@ describe('useShellCommandProcessor', () => {
|
|||
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
expect(addItemToHistoryMock.mock.calls[1][0]).toEqual({
|
||||
type: 'info',
|
||||
text: '[Command produced binary output, which is not shown.]',
|
||||
type: 'tool_group',
|
||||
tools: [
|
||||
expect.objectContaining({
|
||||
name: 'Shell Command',
|
||||
description: 'cat myimage.png',
|
||||
status: ToolCallStatus.Success,
|
||||
resultDisplay:
|
||||
'[Command produced binary output, which is not shown.]',
|
||||
}),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -172,8 +188,15 @@ describe('useShellCommandProcessor', () => {
|
|||
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
expect(addItemToHistoryMock.mock.calls[1][0]).toEqual({
|
||||
type: 'error',
|
||||
text: 'Command exited with code 127.\ncommand not found',
|
||||
type: 'tool_group',
|
||||
tools: [
|
||||
expect.objectContaining({
|
||||
name: 'Shell Command',
|
||||
description: 'a-bad-command',
|
||||
status: ToolCallStatus.Error,
|
||||
resultDisplay: 'Command exited with code 127.\ncommand not found',
|
||||
}),
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue