Add a few more read-only operations (#25)

This commit is contained in:
Matt Rubens
2024-11-29 12:35:33 -05:00
committed by GitHub
parent 178fd3ac34
commit 6fed90805a
4 changed files with 30 additions and 5 deletions

View File

@@ -693,7 +693,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
const lastMessage = messages.at(-1)
if (lastMessage?.type === "ask" && lastMessage.text) {
const tool = JSON.parse(lastMessage.text)
return ["readFile", "listFiles", "searchFiles"].includes(tool.tool)
return ["readFile", "listFiles", "listFilesTopLevel", "listFilesRecursive", "listCodeDefinitionNames", "searchFiles"].includes(tool.tool)
}
return false
}

View File

@@ -125,6 +125,31 @@ describe('ChatView', () => {
})
})
it('should auto-approve all file listing tool types when alwaysAllowReadOnly is true', () => {
const fileListingTools = [
'readFile', 'listFiles', 'listFilesTopLevel',
'listFilesRecursive', 'listCodeDefinitionNames', 'searchFiles'
]
fileListingTools.forEach(tool => {
jest.clearAllMocks()
mockState.clineMessages = [
{
type: 'ask',
ask: 'tool',
text: JSON.stringify({ tool }),
ts: Date.now(),
}
]
renderChatView()
expect(vscode.postMessage).toHaveBeenCalledWith({
type: 'askResponse',
askResponse: 'yesButtonClicked'
})
})
})
it('should auto-approve write tool actions when alwaysAllowWrite is true', () => {
mockState.clineMessages = [
{