mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-22 21:31:08 -05:00
Prettier backfill
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getAccessMcpResourceDescription(args: ToolArgs): string | undefined {
|
||||
if (!args.mcpHub) {
|
||||
return undefined;
|
||||
}
|
||||
return `## access_mcp_resource
|
||||
if (!args.mcpHub) {
|
||||
return undefined
|
||||
}
|
||||
return `## access_mcp_resource
|
||||
Description: Request to access a resource provided by a connected MCP server. Resources represent data sources that can be used as context, such as files, API responses, or system information.
|
||||
Parameters:
|
||||
- server_name: (required) The name of the MCP server providing the resource
|
||||
@@ -21,4 +21,4 @@ Example: Requesting to access an MCP resource
|
||||
<server_name>weather-server</server_name>
|
||||
<uri>weather://san-francisco/current</uri>
|
||||
</access_mcp_resource>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export function getAskFollowupQuestionDescription(): string {
|
||||
return `## ask_followup_question
|
||||
return `## ask_followup_question
|
||||
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
|
||||
Parameters:
|
||||
- question: (required) The question to ask the user. This should be a clear, specific question that addresses the information you need.
|
||||
@@ -12,4 +12,4 @@ Example: Requesting to ask the user for the path to the frontend-config.json fil
|
||||
<ask_followup_question>
|
||||
<question>What is the path to the frontend-config.json file?</question>
|
||||
</ask_followup_question>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export function getAttemptCompletionDescription(): string {
|
||||
return `## attempt_completion
|
||||
return `## attempt_completion
|
||||
Description: After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user. Optionally you may provide a CLI command to showcase the result of your work. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again.
|
||||
IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in <thinking></thinking> tags if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool.
|
||||
Parameters:
|
||||
@@ -20,4 +20,4 @@ I've updated the CSS
|
||||
</result>
|
||||
<command>open index.html</command>
|
||||
</attempt_completion>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getBrowserActionDescription(args: ToolArgs): string | undefined {
|
||||
if (!args.supportsComputerUse) {
|
||||
return undefined;
|
||||
}
|
||||
return `## browser_action
|
||||
if (!args.supportsComputerUse) {
|
||||
return undefined
|
||||
}
|
||||
return `## browser_action
|
||||
Description: Request to interact with a Puppeteer-controlled browser. Every action, except \`close\`, will be responded to with a screenshot of the browser's current state, along with any new console logs. You may only perform one browser action per message, and wait for the user's response including a screenshot and logs to determine the next action.
|
||||
- The sequence of actions **must always start with** launching the browser at a URL, and **must always end with** closing the browser. If you need to visit a new URL that is not possible to navigate to from the current webpage, you must first close the browser, then launch again at the new URL.
|
||||
- While the browser is active, only the \`browser_action\` tool can be used. No other tools should be called during this time. You may proceed to use other tools only after closing the browser. For example if you run into an error and need to fix a file, you must close the browser, then use other tools to make the necessary changes, then re-launch the browser to verify the result.
|
||||
@@ -49,4 +49,4 @@ Example: Requesting to click on the element at coordinates 450,300
|
||||
<action>click</action>
|
||||
<coordinate>450,300</coordinate>
|
||||
</browser_action>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getExecuteCommandDescription(args: ToolArgs): string | undefined {
|
||||
return `## execute_command
|
||||
return `## execute_command
|
||||
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: ${args.cwd}
|
||||
Parameters:
|
||||
- command: (required) The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.
|
||||
@@ -14,4 +14,4 @@ Example: Requesting to execute npm run dev
|
||||
<execute_command>
|
||||
<command>npm run dev</command>
|
||||
</execute_command>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,80 @@
|
||||
import { getExecuteCommandDescription } from './execute-command'
|
||||
import { getReadFileDescription } from './read-file'
|
||||
import { getWriteToFileDescription } from './write-to-file'
|
||||
import { getSearchFilesDescription } from './search-files'
|
||||
import { getListFilesDescription } from './list-files'
|
||||
import { getListCodeDefinitionNamesDescription } from './list-code-definition-names'
|
||||
import { getBrowserActionDescription } from './browser-action'
|
||||
import { getAskFollowupQuestionDescription } from './ask-followup-question'
|
||||
import { getAttemptCompletionDescription } from './attempt-completion'
|
||||
import { getUseMcpToolDescription } from './use-mcp-tool'
|
||||
import { getAccessMcpResourceDescription } from './access-mcp-resource'
|
||||
import { DiffStrategy } from '../../diff/DiffStrategy'
|
||||
import { McpHub } from '../../../services/mcp/McpHub'
|
||||
import { Mode, ToolName, getModeConfig, isToolAllowedForMode } from '../../../shared/modes'
|
||||
import { ToolArgs } from './types'
|
||||
import { getExecuteCommandDescription } from "./execute-command"
|
||||
import { getReadFileDescription } from "./read-file"
|
||||
import { getWriteToFileDescription } from "./write-to-file"
|
||||
import { getSearchFilesDescription } from "./search-files"
|
||||
import { getListFilesDescription } from "./list-files"
|
||||
import { getListCodeDefinitionNamesDescription } from "./list-code-definition-names"
|
||||
import { getBrowserActionDescription } from "./browser-action"
|
||||
import { getAskFollowupQuestionDescription } from "./ask-followup-question"
|
||||
import { getAttemptCompletionDescription } from "./attempt-completion"
|
||||
import { getUseMcpToolDescription } from "./use-mcp-tool"
|
||||
import { getAccessMcpResourceDescription } from "./access-mcp-resource"
|
||||
import { DiffStrategy } from "../../diff/DiffStrategy"
|
||||
import { McpHub } from "../../../services/mcp/McpHub"
|
||||
import { Mode, ToolName, getModeConfig, isToolAllowedForMode } from "../../../shared/modes"
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
// Map of tool names to their description functions
|
||||
const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined> = {
|
||||
'execute_command': args => getExecuteCommandDescription(args),
|
||||
'read_file': args => getReadFileDescription(args),
|
||||
'write_to_file': args => getWriteToFileDescription(args),
|
||||
'search_files': args => getSearchFilesDescription(args),
|
||||
'list_files': args => getListFilesDescription(args),
|
||||
'list_code_definition_names': args => getListCodeDefinitionNamesDescription(args),
|
||||
'browser_action': args => getBrowserActionDescription(args),
|
||||
'ask_followup_question': () => getAskFollowupQuestionDescription(),
|
||||
'attempt_completion': () => getAttemptCompletionDescription(),
|
||||
'use_mcp_tool': args => getUseMcpToolDescription(args),
|
||||
'access_mcp_resource': args => getAccessMcpResourceDescription(args),
|
||||
'apply_diff': args => args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : ''
|
||||
};
|
||||
execute_command: (args) => getExecuteCommandDescription(args),
|
||||
read_file: (args) => getReadFileDescription(args),
|
||||
write_to_file: (args) => getWriteToFileDescription(args),
|
||||
search_files: (args) => getSearchFilesDescription(args),
|
||||
list_files: (args) => getListFilesDescription(args),
|
||||
list_code_definition_names: (args) => getListCodeDefinitionNamesDescription(args),
|
||||
browser_action: (args) => getBrowserActionDescription(args),
|
||||
ask_followup_question: () => getAskFollowupQuestionDescription(),
|
||||
attempt_completion: () => getAttemptCompletionDescription(),
|
||||
use_mcp_tool: (args) => getUseMcpToolDescription(args),
|
||||
access_mcp_resource: (args) => getAccessMcpResourceDescription(args),
|
||||
apply_diff: (args) =>
|
||||
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
|
||||
}
|
||||
|
||||
export function getToolDescriptionsForMode(
|
||||
mode: Mode,
|
||||
cwd: string,
|
||||
supportsComputerUse: boolean,
|
||||
diffStrategy?: DiffStrategy,
|
||||
browserViewportSize?: string,
|
||||
mcpHub?: McpHub
|
||||
mode: Mode,
|
||||
cwd: string,
|
||||
supportsComputerUse: boolean,
|
||||
diffStrategy?: DiffStrategy,
|
||||
browserViewportSize?: string,
|
||||
mcpHub?: McpHub,
|
||||
): string {
|
||||
const config = getModeConfig(mode);
|
||||
const args: ToolArgs = {
|
||||
cwd,
|
||||
supportsComputerUse,
|
||||
diffStrategy,
|
||||
browserViewportSize,
|
||||
mcpHub
|
||||
};
|
||||
const config = getModeConfig(mode)
|
||||
const args: ToolArgs = {
|
||||
cwd,
|
||||
supportsComputerUse,
|
||||
diffStrategy,
|
||||
browserViewportSize,
|
||||
mcpHub,
|
||||
}
|
||||
|
||||
// Map tool descriptions in the exact order specified in the mode's tools array
|
||||
const descriptions = config.tools.map(([toolName, toolOptions]) => {
|
||||
const descriptionFn = toolDescriptionMap[toolName];
|
||||
if (!descriptionFn || !isToolAllowedForMode(toolName as ToolName, mode)) {
|
||||
return undefined;
|
||||
}
|
||||
// Map tool descriptions in the exact order specified in the mode's tools array
|
||||
const descriptions = config.tools.map(([toolName, toolOptions]) => {
|
||||
const descriptionFn = toolDescriptionMap[toolName]
|
||||
if (!descriptionFn || !isToolAllowedForMode(toolName as ToolName, mode)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return descriptionFn({
|
||||
...args,
|
||||
toolOptions
|
||||
});
|
||||
});
|
||||
return descriptionFn({
|
||||
...args,
|
||||
toolOptions,
|
||||
})
|
||||
})
|
||||
|
||||
return `# Tools\n\n${descriptions.filter(Boolean).join('\n\n')}`;
|
||||
return `# Tools\n\n${descriptions.filter(Boolean).join("\n\n")}`
|
||||
}
|
||||
|
||||
// Export individual description functions for backward compatibility
|
||||
export {
|
||||
getExecuteCommandDescription,
|
||||
getReadFileDescription,
|
||||
getWriteToFileDescription,
|
||||
getSearchFilesDescription,
|
||||
getListFilesDescription,
|
||||
getListCodeDefinitionNamesDescription,
|
||||
getBrowserActionDescription,
|
||||
getAskFollowupQuestionDescription,
|
||||
getAttemptCompletionDescription,
|
||||
getUseMcpToolDescription,
|
||||
getAccessMcpResourceDescription
|
||||
}
|
||||
getExecuteCommandDescription,
|
||||
getReadFileDescription,
|
||||
getWriteToFileDescription,
|
||||
getSearchFilesDescription,
|
||||
getListFilesDescription,
|
||||
getListCodeDefinitionNamesDescription,
|
||||
getBrowserActionDescription,
|
||||
getAskFollowupQuestionDescription,
|
||||
getAttemptCompletionDescription,
|
||||
getUseMcpToolDescription,
|
||||
getAccessMcpResourceDescription,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getListCodeDefinitionNamesDescription(args: ToolArgs): string {
|
||||
return `## list_code_definition_names
|
||||
return `## list_code_definition_names
|
||||
Description: Request to list definition names (classes, functions, methods, etc.) used in source code files at the top level of the specified directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.
|
||||
Parameters:
|
||||
- path: (required) The path of the directory (relative to the current working directory ${args.cwd}) to list top level source code definitions for.
|
||||
@@ -14,4 +14,4 @@ Example: Requesting to list all top level source code definitions in the current
|
||||
<list_code_definition_names>
|
||||
<path>.</path>
|
||||
</list_code_definition_names>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getListFilesDescription(args: ToolArgs): string {
|
||||
return `## list_files
|
||||
return `## list_files
|
||||
Description: Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.
|
||||
Parameters:
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory ${args.cwd})
|
||||
@@ -17,4 +17,4 @@ Example: Requesting to list all files in the current directory
|
||||
<path>.</path>
|
||||
<recursive>false</recursive>
|
||||
</list_files>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getReadFileDescription(args: ToolArgs): string {
|
||||
return `## read_file
|
||||
return `## read_file
|
||||
Description: Request to read the contents of a file at the specified path. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. The output includes line numbers prefixed to each line (e.g. "1 | const x = 1"), making it easier to reference specific lines when creating diffs or discussing code. Automatically extracts raw text from PDF and DOCX files. May not be suitable for other types of binary files, as it returns the raw content as a string.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory ${args.cwd})
|
||||
@@ -14,4 +14,4 @@ Example: Requesting to read frontend-config.json
|
||||
<read_file>
|
||||
<path>frontend-config.json</path>
|
||||
</read_file>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getSearchFilesDescription(args: ToolArgs): string {
|
||||
return `## search_files
|
||||
return `## search_files
|
||||
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
|
||||
Parameters:
|
||||
- path: (required) The path of the directory to search in (relative to the current working directory ${args.cwd}). This directory will be recursively searched.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { DiffStrategy } from '../../diff/DiffStrategy'
|
||||
import { McpHub } from '../../../services/mcp/McpHub'
|
||||
import { DiffStrategy } from "../../diff/DiffStrategy"
|
||||
import { McpHub } from "../../../services/mcp/McpHub"
|
||||
|
||||
export type ToolArgs = {
|
||||
cwd: string;
|
||||
supportsComputerUse: boolean;
|
||||
diffStrategy?: DiffStrategy;
|
||||
browserViewportSize?: string;
|
||||
mcpHub?: McpHub;
|
||||
toolOptions?: any;
|
||||
};
|
||||
cwd: string
|
||||
supportsComputerUse: boolean
|
||||
diffStrategy?: DiffStrategy
|
||||
browserViewportSize?: string
|
||||
mcpHub?: McpHub
|
||||
toolOptions?: any
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getUseMcpToolDescription(args: ToolArgs): string | undefined {
|
||||
if (!args.mcpHub) {
|
||||
return undefined;
|
||||
}
|
||||
return `## use_mcp_tool
|
||||
if (!args.mcpHub) {
|
||||
return undefined
|
||||
}
|
||||
return `## use_mcp_tool
|
||||
Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters.
|
||||
Parameters:
|
||||
- server_name: (required) The name of the MCP server providing the tool
|
||||
@@ -34,4 +34,4 @@ Example: Requesting to use an MCP tool
|
||||
}
|
||||
</arguments>
|
||||
</use_mcp_tool>`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ToolArgs } from './types';
|
||||
import { ToolArgs } from "./types"
|
||||
|
||||
export function getWriteToFileDescription(args: ToolArgs): string {
|
||||
return `## write_to_file
|
||||
return `## write_to_file
|
||||
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to write to (relative to the current working directory ${args.cwd})
|
||||
|
||||
Reference in New Issue
Block a user