mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
rename tools
This commit is contained in:
parent
c1ffca04a7
commit
2aae01f3b6
7 changed files with 106 additions and 106 deletions
|
|
@ -34,7 +34,7 @@
|
|||
// // const result = await new Promise((res, rej) => {
|
||||
// // sendLLMMessage({
|
||||
// // messages,
|
||||
// // tools: ['grep_search'],
|
||||
// // tools: ['search_files'],
|
||||
// // onFinalMessage: ({ result: r, }) => {
|
||||
// // res(r)
|
||||
// // },
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
// // const result = new Promise((res, rej) => {
|
||||
// // sendLLMMessage({
|
||||
// // messages,
|
||||
// // tools: ['grep_search'],
|
||||
// // tools: ['search_files'],
|
||||
// // onResult: (r) => {
|
||||
// // res(r)
|
||||
// // }
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
|||
this._setStreamState(threadId, { isRunning: 'tool' }, 'merge')
|
||||
let interrupted = false
|
||||
try {
|
||||
if (toolName === 'edit') { this._addToolEditCheckpoint({ threadId, uri: (toolParams as ToolCallParams['edit']).uri }) }
|
||||
if (toolName === 'edit_file') { this._addToolEditCheckpoint({ threadId, uri: (toolParams as ToolCallParams['edit_file']).uri }) }
|
||||
|
||||
const { result, interruptTool } = await this._toolsService.callTool[toolName](toolParams as any)
|
||||
this._currentlyRunningToolInterruptor[threadId] = () => {
|
||||
|
|
@ -1198,7 +1198,7 @@ We only need to do it for files that were edited since `from`, ie files between
|
|||
// else search codebase for `target`
|
||||
let uris: URI[] = []
|
||||
try {
|
||||
const { result } = await this._toolsService.callTool['pathname_search']({ queryStr: target, pageNumber: 0 })
|
||||
const { result } = await this._toolsService.callTool['search_pathnames_only']({ queryStr: target, pageNumber: 0 })
|
||||
uris = result.uris
|
||||
} catch (e) {
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export const computeDirectoryTree1Deep = async (
|
|||
fileService: IFileService,
|
||||
rootURI: URI,
|
||||
pageNumber: number = 1,
|
||||
): Promise<ToolResultType['list_dir']> => {
|
||||
): Promise<ToolResultType['ls_dir']> => {
|
||||
const stat = await fileService.resolve(rootURI, { resolveMetadata: false });
|
||||
if (!stat.isDirectory) {
|
||||
return { children: null, hasNextPage: false, hasPrevPage: false, itemsRemaining: 0 };
|
||||
|
|
@ -99,7 +99,7 @@ export const computeDirectoryTree1Deep = async (
|
|||
};
|
||||
};
|
||||
|
||||
export const stringifyDirectoryTree1Deep = (params: ToolCallParams['list_dir'], result: ToolResultType['list_dir']): string => {
|
||||
export const stringifyDirectoryTree1Deep = (params: ToolCallParams['ls_dir'], result: ToolResultType['ls_dir']): string => {
|
||||
if (!result.children) {
|
||||
return `Error: ${params.rootURI} is not a directory`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1178,23 +1178,23 @@ const loadingTitleWrapper = (item: React.ReactNode) => {
|
|||
}
|
||||
const folderFileStr = (isFolder: boolean) => isFolder ? 'folder' : 'file'
|
||||
const titleOfToolName = {
|
||||
'read_file': { done: 'Read file', proposed: 'Read file', running: loadingTitleWrapper('Reading file') },
|
||||
'list_dir': { done: 'Inspected folder', proposed: 'Inspect folder', running: loadingTitleWrapper('Inspecting folder') },
|
||||
'list_dir_recursive': { done: 'Inspected folder', proposed: 'Inspect folder', running: loadingTitleWrapper('Inspecting folder') },
|
||||
'pathname_search': { done: 'Searched by file name', proposed: 'Search by file name', running: loadingTitleWrapper('Searching by file name') },
|
||||
'grep_search': { done: 'Searched', proposed: 'Search', running: loadingTitleWrapper('Searching') },
|
||||
'create_uri': {
|
||||
'view_file_contents': { done: 'Read file', proposed: 'Read file', running: loadingTitleWrapper('Reading file') },
|
||||
'ls_dir': { done: 'Inspected folder', proposed: 'Inspect folder', running: loadingTitleWrapper('Inspecting folder') },
|
||||
'get_dir_structure': { done: 'Inspected folder', proposed: 'Inspect folder', running: loadingTitleWrapper('Inspecting folder') },
|
||||
'search_pathnames_only': { done: 'Searched by file name', proposed: 'Search by file name', running: loadingTitleWrapper('Searching by file name') },
|
||||
'search_files': { done: 'Searched', proposed: 'Search', running: loadingTitleWrapper('Searching') },
|
||||
'create_file_or_folder': {
|
||||
done: (isFolder: boolean) => `Created ${folderFileStr(isFolder)}`,
|
||||
proposed: (isFolder: boolean | null) => isFolder === null ? 'Create URI' : `Create ${folderFileStr(isFolder)}`,
|
||||
running: (isFolder: boolean) => loadingTitleWrapper(`Creating ${folderFileStr(isFolder)}`)
|
||||
},
|
||||
'delete_uri': {
|
||||
'delete_file_or_folder': {
|
||||
done: (isFolder: boolean) => `Deleted ${folderFileStr(isFolder)}`,
|
||||
proposed: (isFolder: boolean | null) => isFolder === null ? 'Delete URI' : `Delete ${folderFileStr(isFolder)}`,
|
||||
running: (isFolder: boolean) => loadingTitleWrapper(`Deleting ${folderFileStr(isFolder)}`)
|
||||
},
|
||||
'edit': { done: `Edited file`, proposed: 'Edit file', running: loadingTitleWrapper('Editing file') },
|
||||
'terminal_command': { done: `Ran terminal`, proposed: 'Run terminal', running: loadingTitleWrapper('Running terminal') }
|
||||
'edit_file': { done: `Edited file`, proposed: 'Edit file', running: loadingTitleWrapper('Editing file') },
|
||||
'run_terminal_command': { done: `Ran terminal`, proposed: 'Run terminal', running: loadingTitleWrapper('Running terminal') }
|
||||
} as const satisfies Record<ToolName, { done: any, proposed: any, running: any }>
|
||||
|
||||
|
||||
|
|
@ -1205,29 +1205,29 @@ const toolNameToDesc = (toolName: ToolName, _toolParams: ToolCallParams[ToolName
|
|||
return '';
|
||||
}
|
||||
|
||||
if (toolName === 'read_file') {
|
||||
const toolParams = _toolParams as ToolCallParams['read_file']
|
||||
if (toolName === 'view_file_contents') {
|
||||
const toolParams = _toolParams as ToolCallParams['view_file_contents']
|
||||
return getBasename(toolParams.uri.fsPath);
|
||||
} else if (toolName === 'list_dir') {
|
||||
const toolParams = _toolParams as ToolCallParams['list_dir']
|
||||
} else if (toolName === 'ls_dir') {
|
||||
const toolParams = _toolParams as ToolCallParams['ls_dir']
|
||||
return `${getFolderName(toolParams.rootURI.fsPath)}`;
|
||||
} else if (toolName === 'pathname_search') {
|
||||
const toolParams = _toolParams as ToolCallParams['pathname_search']
|
||||
} else if (toolName === 'search_pathnames_only') {
|
||||
const toolParams = _toolParams as ToolCallParams['search_pathnames_only']
|
||||
return `"${toolParams.queryStr}"`;
|
||||
} else if (toolName === 'grep_search') {
|
||||
const toolParams = _toolParams as ToolCallParams['grep_search']
|
||||
} else if (toolName === 'search_files') {
|
||||
const toolParams = _toolParams as ToolCallParams['search_files']
|
||||
return `"${toolParams.queryStr}"`;
|
||||
} else if (toolName === 'create_uri') {
|
||||
const toolParams = _toolParams as ToolCallParams['create_uri']
|
||||
} else if (toolName === 'create_file_or_folder') {
|
||||
const toolParams = _toolParams as ToolCallParams['create_file_or_folder']
|
||||
return toolParams.isFolder ? getFolderName(toolParams.uri.fsPath) : getBasename(toolParams.uri.fsPath);
|
||||
} else if (toolName === 'delete_uri') {
|
||||
const toolParams = _toolParams as ToolCallParams['delete_uri']
|
||||
} else if (toolName === 'delete_file_or_folder') {
|
||||
const toolParams = _toolParams as ToolCallParams['delete_file_or_folder']
|
||||
return toolParams.isFolder ? getFolderName(toolParams.uri.fsPath) : getBasename(toolParams.uri.fsPath);
|
||||
} else if (toolName === 'edit') {
|
||||
const toolParams = _toolParams as ToolCallParams['edit']
|
||||
} else if (toolName === 'edit_file') {
|
||||
const toolParams = _toolParams as ToolCallParams['edit_file']
|
||||
return getBasename(toolParams.uri.fsPath);
|
||||
} else if (toolName === 'terminal_command') {
|
||||
const toolParams = _toolParams as ToolCallParams['terminal_command']
|
||||
} else if (toolName === 'run_terminal_command') {
|
||||
const toolParams = _toolParams as ToolCallParams['run_terminal_command']
|
||||
return `"${toolParams.command}"`;
|
||||
} else {
|
||||
return ''
|
||||
|
|
@ -1373,7 +1373,7 @@ type ToolComponent<T extends ToolName,> = {
|
|||
}
|
||||
|
||||
const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
||||
'read_file': {
|
||||
'view_file_contents': {
|
||||
requestWrapper: null,
|
||||
resultWrapper: ({ toolMessage }) => {
|
||||
const accessor = useAccessor()
|
||||
|
|
@ -1409,7 +1409,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
return <ToolHeaderWrapper {...componentParams} />
|
||||
},
|
||||
},
|
||||
'list_dir_recursive': {
|
||||
'get_dir_structure': {
|
||||
requestWrapper: null,
|
||||
resultWrapper: ({ toolMessage }) => {
|
||||
const accessor = useAccessor()
|
||||
|
|
@ -1450,7 +1450,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
|
||||
}
|
||||
},
|
||||
'list_dir': {
|
||||
'ls_dir': {
|
||||
requestWrapper: null,
|
||||
resultWrapper: ({ toolMessage }) => {
|
||||
const accessor = useAccessor()
|
||||
|
|
@ -1497,7 +1497,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
return <ToolHeaderWrapper {...componentParams} />
|
||||
}
|
||||
},
|
||||
'pathname_search': {
|
||||
'search_pathnames_only': {
|
||||
requestWrapper: null,
|
||||
resultWrapper: ({ toolMessage }) => {
|
||||
const accessor = useAccessor()
|
||||
|
|
@ -1540,7 +1540,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
return <ToolHeaderWrapper {...componentParams} />
|
||||
}
|
||||
},
|
||||
'grep_search': {
|
||||
'search_files': {
|
||||
requestWrapper: null,
|
||||
resultWrapper: ({ toolMessage }) => {
|
||||
const accessor = useAccessor()
|
||||
|
|
@ -1585,7 +1585,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
|
||||
// ---
|
||||
|
||||
'create_uri': {
|
||||
'create_file_or_folder': {
|
||||
requestWrapper: ({ toolRequest, toolRequestState }) => {
|
||||
const accessor = useAccessor()
|
||||
const commandService = accessor.get('ICommandService')
|
||||
|
|
@ -1633,7 +1633,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
return <ToolHeaderWrapper {...componentParams} />
|
||||
}
|
||||
},
|
||||
'delete_uri': {
|
||||
'delete_file_or_folder': {
|
||||
requestWrapper: ({ toolRequest, toolRequestState }) => {
|
||||
const accessor = useAccessor()
|
||||
const commandService = accessor.get('ICommandService')
|
||||
|
|
@ -1683,7 +1683,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
return <ToolHeaderWrapper {...componentParams} />
|
||||
}
|
||||
},
|
||||
'edit': {
|
||||
'edit_file': {
|
||||
requestWrapper: ({ toolRequest, messageIdx, toolRequestState, threadId }) => {
|
||||
const accessor = useAccessor()
|
||||
const isError = false
|
||||
|
|
@ -1771,7 +1771,7 @@ const toolNameToComponent: { [T in ToolName]: ToolComponent<T> } = {
|
|||
return <ToolHeaderWrapper {...componentParams} />
|
||||
}
|
||||
},
|
||||
'terminal_command': {
|
||||
'run_terminal_command': {
|
||||
requestWrapper: ({ toolRequest, toolRequestState }) => {
|
||||
const accessor = useAccessor()
|
||||
const commandService = accessor.get('ICommandService')
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export class ToolsService implements IToolsService {
|
|||
const queryBuilder = instantiationService.createInstance(QueryBuilder);
|
||||
|
||||
this.validateParams = {
|
||||
read_file: async (params: string) => {
|
||||
view_file_contents: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { uri: uriStr, pageNumber: pageNumberUnknown } = o
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ export class ToolsService implements IToolsService {
|
|||
|
||||
return { uri, pageNumber }
|
||||
},
|
||||
list_dir: async (params: string) => {
|
||||
ls_dir: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { uri: uriStr, pageNumber: pageNumberUnknown } = o
|
||||
|
||||
|
|
@ -156,13 +156,13 @@ export class ToolsService implements IToolsService {
|
|||
const pageNumber = validatePageNum(pageNumberUnknown)
|
||||
return { rootURI: uri, pageNumber }
|
||||
},
|
||||
list_dir_recursive: async (params: string) => {
|
||||
get_dir_structure: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { uri: uriStr, } = o
|
||||
const uri = validateURI(uriStr)
|
||||
return { rootURI: uri }
|
||||
},
|
||||
pathname_search: async (params: string) => {
|
||||
search_pathnames_only: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { query: queryUnknown, pageNumber: pageNumberUnknown } = o
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ export class ToolsService implements IToolsService {
|
|||
return { queryStr, pageNumber }
|
||||
|
||||
},
|
||||
grep_search: async (params: string) => {
|
||||
search_files: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { query: queryUnknown, pageNumber: pageNumberUnknown } = o
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ export class ToolsService implements IToolsService {
|
|||
|
||||
// ---
|
||||
|
||||
create_uri: async (params: string) => {
|
||||
create_file_or_folder: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { uri: uriUnknown } = o
|
||||
const uri = validateURI(uriUnknown)
|
||||
|
|
@ -193,7 +193,7 @@ export class ToolsService implements IToolsService {
|
|||
return { uri, isFolder }
|
||||
},
|
||||
|
||||
delete_uri: async (params: string) => {
|
||||
delete_file_or_folder: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { uri: uriUnknown, params: paramsStr } = o
|
||||
const uri = validateURI(uriUnknown)
|
||||
|
|
@ -203,7 +203,7 @@ export class ToolsService implements IToolsService {
|
|||
return { uri, isRecursive, isFolder }
|
||||
},
|
||||
|
||||
edit: async (params: string) => {
|
||||
edit_file: async (params: string) => {
|
||||
const o = validateJSON(params)
|
||||
const { uri: uriStr, changeDescription: changeDescriptionUnknown } = o
|
||||
const uri = validateURI(uriStr)
|
||||
|
|
@ -211,7 +211,7 @@ export class ToolsService implements IToolsService {
|
|||
return { uri, changeDescription }
|
||||
},
|
||||
|
||||
terminal_command: async (s: string) => {
|
||||
run_terminal_command: async (s: string) => {
|
||||
const o = validateJSON(s)
|
||||
const { command: commandUnknown, terminalId: terminalIdUnknown, waitForCompletion: waitForCompletionUnknown } = o
|
||||
const command = validateStr('command', commandUnknown)
|
||||
|
|
@ -224,7 +224,7 @@ export class ToolsService implements IToolsService {
|
|||
|
||||
|
||||
this.callTool = {
|
||||
read_file: async ({ uri, pageNumber }) => {
|
||||
view_file_contents: async ({ uri, pageNumber }) => {
|
||||
await voidModelService.initializeModel(uri)
|
||||
const { model } = await voidModelService.getModelSafe(uri)
|
||||
if (model === null) { throw new Error(`Contents were empty. There may have been an error, or the file may not exist.`) }
|
||||
|
|
@ -238,19 +238,19 @@ export class ToolsService implements IToolsService {
|
|||
return { result: { fileContents, hasNextPage } }
|
||||
},
|
||||
|
||||
list_dir: async ({ rootURI, pageNumber }) => {
|
||||
ls_dir: async ({ rootURI, pageNumber }) => {
|
||||
const dirResult = await computeDirectoryTree1Deep(fileService, rootURI, pageNumber)
|
||||
return { result: dirResult }
|
||||
},
|
||||
|
||||
list_dir_recursive: async ({ rootURI }) => {
|
||||
get_dir_structure: async ({ rootURI }) => {
|
||||
const result = await this.directoryStrService.getDirectoryStrTool(rootURI)
|
||||
let str = result.str
|
||||
if (result.wasCutOff) str += '\n(Result was truncated)'
|
||||
return { result: { str } }
|
||||
},
|
||||
|
||||
pathname_search: async ({ queryStr, pageNumber }) => {
|
||||
search_pathnames_only: async ({ queryStr, pageNumber }) => {
|
||||
const query = queryBuilder.file(workspaceContextService.getWorkspace().folders.map(f => f.uri), {
|
||||
filePattern: queryStr,
|
||||
})
|
||||
|
|
@ -266,7 +266,7 @@ export class ToolsService implements IToolsService {
|
|||
return { result: { uris, hasNextPage } }
|
||||
},
|
||||
|
||||
grep_search: async ({ queryStr, pageNumber }) => {
|
||||
search_files: async ({ queryStr, pageNumber }) => {
|
||||
const query = queryBuilder.text({
|
||||
pattern: queryStr,
|
||||
isRegExp: true,
|
||||
|
|
@ -286,7 +286,7 @@ export class ToolsService implements IToolsService {
|
|||
|
||||
// ---
|
||||
|
||||
create_uri: async ({ uri, isFolder }) => {
|
||||
create_file_or_folder: async ({ uri, isFolder }) => {
|
||||
if (isFolder)
|
||||
await fileService.createFolder(uri)
|
||||
else {
|
||||
|
|
@ -295,12 +295,12 @@ export class ToolsService implements IToolsService {
|
|||
return { result: {} }
|
||||
},
|
||||
|
||||
delete_uri: async ({ uri, isRecursive }) => {
|
||||
delete_file_or_folder: async ({ uri, isRecursive }) => {
|
||||
await fileService.del(uri, { recursive: isRecursive })
|
||||
return { result: {} }
|
||||
},
|
||||
|
||||
edit: async ({ uri, changeDescription }) => {
|
||||
edit_file: async ({ uri, changeDescription }) => {
|
||||
await voidModelService.initializeModel(uri)
|
||||
if (this.commandBarService.getStreamState(uri) === 'streaming') {
|
||||
throw new Error(`The Apply model was already running. This can happen if two agents try editing the same file at the same time. Please try again in a moment.`)
|
||||
|
|
@ -322,7 +322,7 @@ export class ToolsService implements IToolsService {
|
|||
}
|
||||
return { result: applyDonePromise, interruptTool }
|
||||
},
|
||||
terminal_command: async ({ command, proposedTerminalId, waitForCompletion }) => {
|
||||
run_terminal_command: async ({ command, proposedTerminalId, waitForCompletion }) => {
|
||||
const { terminalId, didCreateTerminal, result, resolveReason } = await this.terminalToolService.runCommand(command, proposedTerminalId, waitForCompletion)
|
||||
return { result: { terminalId, didCreateTerminal, result, resolveReason } }
|
||||
},
|
||||
|
|
@ -333,33 +333,33 @@ export class ToolsService implements IToolsService {
|
|||
|
||||
// given to the LLM after the call
|
||||
this.stringOfResult = {
|
||||
read_file: (params, result) => {
|
||||
view_file_contents: (params, result) => {
|
||||
return result.fileContents + nextPageStr(result.hasNextPage)
|
||||
},
|
||||
list_dir: (params, result) => {
|
||||
ls_dir: (params, result) => {
|
||||
const dirTreeStr = stringifyDirectoryTree1Deep(params, result)
|
||||
return dirTreeStr // + nextPageStr(result.hasNextPage) // already handles num results remaining
|
||||
},
|
||||
list_dir_recursive: (params, result) => {
|
||||
get_dir_structure: (params, result) => {
|
||||
return result.str
|
||||
},
|
||||
pathname_search: (params, result) => {
|
||||
search_pathnames_only: (params, result) => {
|
||||
return result.uris.map(uri => uri.fsPath).join('\n') + nextPageStr(result.hasNextPage)
|
||||
},
|
||||
grep_search: (params, result) => {
|
||||
search_files: (params, result) => {
|
||||
return result.uris.map(uri => uri.fsPath).join('\n') + nextPageStr(result.hasNextPage)
|
||||
},
|
||||
// ---
|
||||
create_uri: (params, result) => {
|
||||
create_file_or_folder: (params, result) => {
|
||||
return `URI ${params.uri.fsPath} successfully created.`
|
||||
},
|
||||
delete_uri: (params, result) => {
|
||||
delete_file_or_folder: (params, result) => {
|
||||
return `URI ${params.uri.fsPath} successfully deleted.`
|
||||
},
|
||||
edit: (params, result) => {
|
||||
edit_file: (params, result) => {
|
||||
return `Change successfully made to ${params.uri.fsPath}.`
|
||||
},
|
||||
terminal_command: (params, result) => {
|
||||
run_terminal_command: (params, result) => {
|
||||
|
||||
const {
|
||||
terminalId,
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ const uriParam = (object: string) => ({
|
|||
export const voidTools = {
|
||||
// --- context-gathering (read/search/list) ---
|
||||
|
||||
read_file: {
|
||||
name: 'read_file',
|
||||
view_file_contents: {
|
||||
name: 'view_file_contents',
|
||||
description: `Returns file contents of a given URI. ${paginationHelper.desc}`,
|
||||
params: {
|
||||
...uriParam('file'),
|
||||
|
|
@ -60,8 +60,8 @@ export const voidTools = {
|
|||
},
|
||||
},
|
||||
|
||||
list_dir: {
|
||||
name: 'list_dir',
|
||||
ls_dir: {
|
||||
name: 'ls_dir',
|
||||
description: `Returns all file names and folder names in a given folder. ${paginationHelper.desc}`,
|
||||
params: {
|
||||
...uriParam('folder'),
|
||||
|
|
@ -69,16 +69,16 @@ export const voidTools = {
|
|||
},
|
||||
},
|
||||
|
||||
list_dir_recursive: {
|
||||
name: 'list_dir_recursive',
|
||||
description: `Returns a tree diagram of all the files and folders in the URI. If results are large, the given string will be truncated (this will be indicated). If truncated, you should use this tool on a more specific folder, or just use list_dir which supports pagination but is not recursive.`,
|
||||
get_dir_structure: {
|
||||
name: 'get_dir_structure',
|
||||
description: `Returns a tree diagram of all the files and folders in the URI. If results are large, the given string will be truncated (this will be indicated). If truncated, you should use this tool on a more specific folder, or just use ls_dir which supports pagination but is not recursive.`,
|
||||
params: {
|
||||
...uriParam('folder')
|
||||
}
|
||||
},
|
||||
|
||||
pathname_search: {
|
||||
name: 'pathname_search',
|
||||
search_pathnames_only: {
|
||||
name: 'search_pathnames_only',
|
||||
description: `Returns all pathnames that match a given \`find\`-style query (searches ONLY file names). You should use this when looking for a file with a specific name or path. ${paginationHelper.desc}`,
|
||||
params: {
|
||||
query: { type: 'string', description: undefined },
|
||||
|
|
@ -86,9 +86,9 @@ export const voidTools = {
|
|||
},
|
||||
},
|
||||
|
||||
grep_search: {
|
||||
name: 'grep_search',
|
||||
description: `Returns all pathnames that match a given \`grep\`-style query (searches ONLY file contents). The query can be any regex. This is often followed by the \`read_file\` tool to view the full file contents of results. ${paginationHelper.desc}`,
|
||||
search_files: {
|
||||
name: 'search_files',
|
||||
description: `Returns all pathnames that match a given \`grep\`-style query (searches ONLY file contents). The query can be any regex. This is often followed by the \`view_file_contents\` tool to view the full file contents of results. ${paginationHelper.desc}`,
|
||||
params: {
|
||||
query: { type: 'string', description: undefined },
|
||||
...paginationHelper.param,
|
||||
|
|
@ -97,16 +97,16 @@ export const voidTools = {
|
|||
|
||||
// --- editing (create/delete) ---
|
||||
|
||||
create_uri: {
|
||||
name: 'create_uri',
|
||||
create_file_or_folder: {
|
||||
name: 'create_file_or_folder',
|
||||
description: `Create a file or folder at the given path. To create a folder, ensure the path ends with a trailing slash. Fails gracefully if the file already exists. Missing ancestors in the path will be recursively created automatically.`,
|
||||
params: {
|
||||
...uriParam('file or folder'),
|
||||
},
|
||||
},
|
||||
|
||||
delete_uri: {
|
||||
name: 'delete_uri',
|
||||
delete_file_or_folder: {
|
||||
name: 'delete_file_or_folder',
|
||||
description: `Delete a file or folder at the given path. Fails gracefully if the file or folder does not exist.`,
|
||||
params: {
|
||||
...uriParam('file or folder'),
|
||||
|
|
@ -114,8 +114,8 @@ export const voidTools = {
|
|||
},
|
||||
},
|
||||
|
||||
edit: { // APPLY TOOL
|
||||
name: 'edit',
|
||||
edit_file: { // APPLY TOOL
|
||||
name: 'edit_file',
|
||||
description: `Edits the contents of a file, given the file's URI and a description. Fails gracefully if the file does not exist.`,
|
||||
params: {
|
||||
...uriParam('file'),
|
||||
|
|
@ -130,8 +130,8 @@ Here's an example of a good description:\n${editToolDescription}.`
|
|||
},
|
||||
},
|
||||
|
||||
terminal_command: {
|
||||
name: 'terminal_command',
|
||||
run_terminal_command: {
|
||||
name: 'run_terminal_command',
|
||||
description: `Executes a terminal command.`,
|
||||
params: {
|
||||
command: { type: 'string', description: 'The terminal command to execute. Typically you should pipe to cat to avoid pagination.' },
|
||||
|
|
|
|||
|
|
@ -36,34 +36,34 @@ export const isAToolName = (toolName: string): toolName is ToolName => {
|
|||
}
|
||||
|
||||
|
||||
const toolNamesWithApproval = ['create_uri', 'delete_uri', 'edit', 'terminal_command'] as const satisfies readonly ToolName[]
|
||||
const toolNamesWithApproval = ['create_file_or_folder', 'delete_file_or_folder', 'edit_file', 'run_terminal_command'] as const satisfies readonly ToolName[]
|
||||
export type ToolNameWithApproval = typeof toolNamesWithApproval[number]
|
||||
export const toolNamesThatRequireApproval = new Set<ToolName>(toolNamesWithApproval)
|
||||
|
||||
export type ToolCallParams = {
|
||||
'read_file': { uri: URI, pageNumber: number },
|
||||
'list_dir': { rootURI: URI, pageNumber: number },
|
||||
'list_dir_recursive': { rootURI: URI },
|
||||
'pathname_search': { queryStr: string, pageNumber: number },
|
||||
'grep_search': { queryStr: string, pageNumber: number },
|
||||
'view_file_contents': { uri: URI, pageNumber: number },
|
||||
'ls_dir': { rootURI: URI, pageNumber: number },
|
||||
'get_dir_structure': { rootURI: URI },
|
||||
'search_pathnames_only': { queryStr: string, pageNumber: number },
|
||||
'search_files': { queryStr: string, pageNumber: number },
|
||||
// ---
|
||||
'edit': { uri: URI, changeDescription: string },
|
||||
'create_uri': { uri: URI, isFolder: boolean },
|
||||
'delete_uri': { uri: URI, isRecursive: boolean, isFolder: boolean },
|
||||
'terminal_command': { command: string, proposedTerminalId: string, waitForCompletion: boolean },
|
||||
'edit_file': { uri: URI, changeDescription: string },
|
||||
'create_file_or_folder': { uri: URI, isFolder: boolean },
|
||||
'delete_file_or_folder': { uri: URI, isRecursive: boolean, isFolder: boolean },
|
||||
'run_terminal_command': { command: string, proposedTerminalId: string, waitForCompletion: boolean },
|
||||
}
|
||||
|
||||
|
||||
export type ToolResultType = {
|
||||
'read_file': { fileContents: string, hasNextPage: boolean },
|
||||
'list_dir': { children: ShallowDirectoryItem[] | null, hasNextPage: boolean, hasPrevPage: boolean, itemsRemaining: number },
|
||||
'list_dir_recursive': { str: string, },
|
||||
'pathname_search': { uris: URI[], hasNextPage: boolean },
|
||||
'grep_search': { uris: URI[], hasNextPage: boolean },
|
||||
'view_file_contents': { fileContents: string, hasNextPage: boolean },
|
||||
'ls_dir': { children: ShallowDirectoryItem[] | null, hasNextPage: boolean, hasPrevPage: boolean, itemsRemaining: number },
|
||||
'get_dir_structure': { str: string, },
|
||||
'search_pathnames_only': { uris: URI[], hasNextPage: boolean },
|
||||
'search_files': { uris: URI[], hasNextPage: boolean },
|
||||
// ---
|
||||
'edit': Promise<void>,
|
||||
'create_uri': {},
|
||||
'delete_uri': {},
|
||||
'terminal_command': { terminalId: string, didCreateTerminal: boolean, result: string; resolveReason: TerminalResolveReason; },
|
||||
'edit_file': Promise<void>,
|
||||
'create_file_or_folder': {},
|
||||
'delete_file_or_folder': {},
|
||||
'run_terminal_command': { terminalId: string, didCreateTerminal: boolean, result: string; resolveReason: TerminalResolveReason; },
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue