mirror of
https://github.com/cline/cline.git
synced 2026-09-11 16:42:40 +08:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
097faf4527 | ||
|
|
2784df94cf | ||
|
|
8bda429f2f | ||
|
|
07d7506190 | ||
|
|
5b4789af39 | ||
|
|
8cd8d94f27 | ||
|
|
7de7ee7d73 | ||
|
|
e8e516bb52 | ||
|
|
eabdb4758c | ||
|
|
732bc0d73d | ||
|
|
b04aa829c5 | ||
|
|
1bda20fe01 | ||
|
|
ccb89e5108 | ||
|
|
1df5bcd4de | ||
|
|
8bae6e80d4 | ||
|
|
6dbbcbe016 | ||
|
|
19884ed548 | ||
|
|
431dae0439 | ||
|
|
fb173d665c | ||
|
|
52050bd12c | ||
|
|
4da2e302c9 | ||
|
|
3b3fc0cb65 |
+5
-5
@@ -28,7 +28,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -41,7 +41,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<read_file>
|
||||
@@ -52,7 +52,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -129,7 +129,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
|
||||
+5
-5
@@ -28,7 +28,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -41,7 +41,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<read_file>
|
||||
@@ -52,7 +52,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -129,7 +129,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
|
||||
+5
-5
@@ -25,7 +25,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -38,7 +38,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
Usage:
|
||||
<read_file>
|
||||
<path>File path here</path>
|
||||
@@ -47,7 +47,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
Usage:
|
||||
<write_to_file>
|
||||
@@ -105,7 +105,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
Usage:
|
||||
<list_files>
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
<path>Directory path here</path>
|
||||
|
||||
+5
-5
@@ -28,7 +28,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -41,7 +41,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<read_file>
|
||||
@@ -52,7 +52,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -129,7 +129,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
|
||||
@@ -28,7 +28,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -41,7 +41,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<read_file>
|
||||
@@ -52,7 +52,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -129,7 +129,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
|
||||
@@ -28,7 +28,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -41,7 +41,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<read_file>
|
||||
@@ -52,7 +52,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -129,7 +129,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
|
||||
+5
-5
@@ -25,7 +25,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -38,7 +38,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
Usage:
|
||||
<read_file>
|
||||
<path>File path here</path>
|
||||
@@ -47,7 +47,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
Usage:
|
||||
<write_to_file>
|
||||
@@ -105,7 +105,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
Usage:
|
||||
<list_files>
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
<path>Directory path here</path>
|
||||
|
||||
@@ -28,7 +28,7 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
|
||||
# Tools
|
||||
|
||||
## 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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: /test/project
|
||||
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.
|
||||
- requires_approval: (required) A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.
|
||||
@@ -41,7 +41,7 @@ Usage:
|
||||
## 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. 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. Do NOT use this tool to list the contents of a directory. Only use this tool on files.
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- path: (required) The path of the file to read (relative to the current working directory /test/project)
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<read_file>
|
||||
@@ -52,7 +52,7 @@ Usage:
|
||||
## write_to_file
|
||||
Description: Request to write 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 /test/project)
|
||||
- path: (required) The path of the file to write to (relative to the current working directory /test/project)
|
||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -116,7 +116,7 @@ Usage:
|
||||
## 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 /test/project)
|
||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/project)
|
||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
@@ -129,7 +129,7 @@ Usage:
|
||||
## 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 /test/project) to list top level source code definitions for.
|
||||
- path: (required) The path of the directory (relative to the current working directory /test/project) to list top level source code definitions for.
|
||||
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
|
||||
Usage:
|
||||
<list_code_definition_names>
|
||||
|
||||
@@ -18,6 +18,11 @@ export async function getToolUseToolsSection(variant: PromptVariant, context: Sy
|
||||
// (TODO tool is now dynamically added when focusChainEnabled is true)
|
||||
const shouldIncludeTaskProgress = focusChainEnabled
|
||||
|
||||
// Define multi-root hint based on feature flag
|
||||
const multiRootHint = context.isMultiRootEnabled
|
||||
? "Use @workspace:path syntax (e.g., @frontend:src/index.ts) to specify a workspace."
|
||||
: ""
|
||||
|
||||
return new TemplateEngine().resolve(template, context, {
|
||||
TASK_PROGRESS: shouldIncludeTaskProgress ? TASK_PROGRESS : "",
|
||||
FOCUS_CHAIN_ATTEMPT: shouldIncludeTaskProgress ? FOCUS_CHAIN_ATTEMPT : "",
|
||||
@@ -25,6 +30,7 @@ export async function getToolUseToolsSection(variant: PromptVariant, context: Sy
|
||||
BROWSER_VIEWPORT_WIDTH: context.browserSettings?.viewport?.width || 0,
|
||||
BROWSER_VIEWPORT_HEIGHT: context.browserSettings?.viewport?.height || 0,
|
||||
CWD: context.cwd,
|
||||
MULTI_ROOT_HINT: multiRootHint,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const generic: ClineToolSpec = {
|
||||
variant: ModelFamily.GENERIC,
|
||||
id: ClineDefaultTool.BASH,
|
||||
name: "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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: {{CWD}}`,
|
||||
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. For command chaining, use the appropriate chaining syntax for the user's shell. 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: {{CWD}} {{MULTI_ROOT_HINT}}`,
|
||||
parameters: [
|
||||
{
|
||||
name: "command",
|
||||
|
||||
@@ -15,7 +15,7 @@ const generic: ClineToolSpec = {
|
||||
{
|
||||
name: "path",
|
||||
required: true,
|
||||
instruction: `The path of the directory (relative to the current working directory {{CWD}}) to list top level source code definitions for.`,
|
||||
instruction: `The path of the directory (relative to the current working directory {{CWD}}) {{MULTI_ROOT_HINT}} to list top level source code definitions for.`,
|
||||
usage: "Directory path here",
|
||||
},
|
||||
TASK_PROGRESS_PARAMETER,
|
||||
|
||||
@@ -15,7 +15,8 @@ const generic: ClineToolSpec = {
|
||||
{
|
||||
name: "path",
|
||||
required: true,
|
||||
instruction: "The path of the directory to list contents for (relative to the current working directory {{CWD}})",
|
||||
instruction:
|
||||
"The path of the directory to list contents for (relative to the current working directory {{CWD}}) {{MULTI_ROOT_HINT}}",
|
||||
usage: "Directory path here",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ const generic: ClineToolSpec = {
|
||||
{
|
||||
name: "path",
|
||||
required: true,
|
||||
instruction: `The path of the file to read (relative to the current working directory {{CWD}})`,
|
||||
instruction: `The path of the file to read (relative to the current working directory {{CWD}}) {{MULTI_ROOT_HINT}}`,
|
||||
usage: "File path here",
|
||||
},
|
||||
TASK_PROGRESS_PARAMETER,
|
||||
|
||||
@@ -34,7 +34,7 @@ const generic: ClineToolSpec = {
|
||||
{
|
||||
name: "path",
|
||||
required: true,
|
||||
instruction: `The path of the file to write to (relative to the current working directory {{CWD}})`,
|
||||
instruction: `The path of the file to write to (relative to the current working directory {{CWD}}) {{MULTI_ROOT_HINT}}`,
|
||||
usage: "File path here",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { resolveWorkspacePath } from "@core/workspace"
|
||||
import { AutoApprovalSettings } from "@shared/AutoApprovalSettings"
|
||||
import { ClineDefaultTool } from "@shared/tools"
|
||||
import { getCwd, getDesktopDir, isLocatedInPath } from "@/utils/path"
|
||||
import { getCwd, getDesktopDir } from "@/utils/path"
|
||||
|
||||
export class AutoApprove {
|
||||
autoApprovalSettings: AutoApprovalSettings
|
||||
@@ -82,9 +82,30 @@ export class AutoApprove {
|
||||
|
||||
let isLocalRead: boolean = false
|
||||
if (autoApproveActionpath) {
|
||||
const cwd = await getCwd(getDesktopDir())
|
||||
const absolutePath = resolveWorkspacePath(cwd, autoApproveActionpath, "AutoApprove.shouldAutoApproveToolWithPath")
|
||||
isLocalRead = isLocatedInPath(cwd, absolutePath)
|
||||
// Import isLocatedInWorkspace inline to check against ALL workspace roots
|
||||
const { isLocatedInWorkspace } = await import("@/utils/path")
|
||||
const path = await import("path")
|
||||
|
||||
// If the path is already absolute, use it directly
|
||||
// Otherwise, resolve it relative to the primary workspace
|
||||
let absolutePath: string
|
||||
if (path.isAbsolute(autoApproveActionpath)) {
|
||||
// Path is already resolved by the tool handler
|
||||
absolutePath = autoApproveActionpath
|
||||
} else {
|
||||
// Fallback for legacy code paths that might still pass relative paths
|
||||
const cwd = await getCwd(getDesktopDir())
|
||||
absolutePath = resolveWorkspacePath(
|
||||
cwd,
|
||||
autoApproveActionpath,
|
||||
"AutoApprove.shouldAutoApproveToolWithPath",
|
||||
) as string
|
||||
}
|
||||
|
||||
// Check if the path is in ANY workspace root, not just the primary one
|
||||
// This fixes the multi-workspace bug where files in secondary workspaces
|
||||
// were incorrectly treated as external files
|
||||
isLocalRead = await isLocatedInWorkspace(absolutePath)
|
||||
} else {
|
||||
// If we do not get a path for some reason, default to a (safer) false return
|
||||
isLocalRead = false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ToolUse } from "@core/assistant-message"
|
||||
import { formatResponse } from "@core/prompts/responses"
|
||||
import { WorkspacePathAdapter } from "@core/workspace/WorkspacePathAdapter"
|
||||
import { showSystemNotification } from "@integrations/notifications"
|
||||
import { COMMAND_REQ_APP_STRING } from "@shared/combineCommandSequences"
|
||||
import { ClineAsk } from "@shared/ExtensionMessage"
|
||||
@@ -76,8 +77,37 @@ export class ExecuteCommandToolHandler implements IFullyManagedTool {
|
||||
command = fixModelHtmlEscaping(command)
|
||||
}
|
||||
|
||||
// Handle multi-workspace command execution
|
||||
let executionDir: string = config.cwd
|
||||
let actualCommand: string = command
|
||||
|
||||
if (config.isMultiRootEnabled && config.workspaceManager) {
|
||||
// Check if command has a workspace hint prefix
|
||||
// e.g., "@backend:npm install" or just "npm install"
|
||||
const commandMatch = command.match(/^@(\w+):(.+)$/)
|
||||
|
||||
if (commandMatch) {
|
||||
const workspaceHint = commandMatch[1]
|
||||
actualCommand = commandMatch[2].trim()
|
||||
|
||||
// Find the workspace root for this hint
|
||||
const adapter = new WorkspacePathAdapter({
|
||||
cwd: config.cwd,
|
||||
isMultiRootEnabled: true,
|
||||
workspaceManager: config.workspaceManager,
|
||||
})
|
||||
|
||||
// Resolve to get the workspace directory
|
||||
executionDir = adapter.resolvePath(".", workspaceHint)
|
||||
|
||||
// Update command to remove the workspace prefix for display
|
||||
command = actualCommand
|
||||
}
|
||||
// If no hint, use primary workspace (cwd)
|
||||
}
|
||||
|
||||
// Check clineignore validation for command
|
||||
const ignoredFileAttemptedToAccess = config.services.clineIgnoreController.validateCommand(command)
|
||||
const ignoredFileAttemptedToAccess = config.services.clineIgnoreController.validateCommand(actualCommand)
|
||||
if (ignoredFileAttemptedToAccess) {
|
||||
await config.callbacks.say("clineignore_error", ignoredFileAttemptedToAccess)
|
||||
return formatResponse.toolError(formatResponse.clineIgnoreError(ignoredFileAttemptedToAccess))
|
||||
@@ -95,21 +125,21 @@ export class ExecuteCommandToolHandler implements IFullyManagedTool {
|
||||
if ((!requiresApprovalPerLLM && autoApproveSafe) || (requiresApprovalPerLLM && autoApproveSafe && autoApproveAll)) {
|
||||
// Auto-approve flow
|
||||
await config.callbacks.removeLastPartialMessageIfExistsWithType("ask", "command")
|
||||
await config.callbacks.say("command", command, undefined, undefined, false)
|
||||
await config.callbacks.say("command", actualCommand, undefined, undefined, false)
|
||||
config.taskState.consecutiveAutoApprovedRequestsCount++
|
||||
didAutoApprove = true
|
||||
telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, true, true)
|
||||
} else {
|
||||
// Manual approval flow
|
||||
showNotificationForApprovalIfAutoApprovalEnabled(
|
||||
`Cline wants to execute a command: ${command}`,
|
||||
`Cline wants to execute a command: ${actualCommand}`,
|
||||
config.autoApprovalSettings.enabled,
|
||||
config.autoApprovalSettings.enableNotifications,
|
||||
)
|
||||
|
||||
const didApprove = await ToolResultUtils.askApprovalAndPushFeedback(
|
||||
"command",
|
||||
command + `${autoApproveSafe && requiresApprovalPerLLM ? COMMAND_REQ_APP_STRING : ""}`,
|
||||
actualCommand + `${autoApproveSafe && requiresApprovalPerLLM ? COMMAND_REQ_APP_STRING : ""}`,
|
||||
config,
|
||||
)
|
||||
if (!didApprove) {
|
||||
@@ -131,8 +161,15 @@ export class ExecuteCommandToolHandler implements IFullyManagedTool {
|
||||
}, 30_000)
|
||||
}
|
||||
|
||||
// Execute the command
|
||||
const [userRejected, result] = await config.callbacks.executeCommandTool(command, timeoutSeconds)
|
||||
// Execute the command in the correct directory
|
||||
// If executionDir is different from cwd, prepend cd command
|
||||
let finalCommand: string = actualCommand
|
||||
if (executionDir !== config.cwd) {
|
||||
// Use && to chain commands so they run in sequence
|
||||
finalCommand = `cd "${executionDir}" && ${actualCommand}`
|
||||
}
|
||||
|
||||
const [userRejected, result] = await config.callbacks.executeCommandTool(finalCommand, timeoutSeconds)
|
||||
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId)
|
||||
|
||||
@@ -58,14 +58,19 @@ export class ListCodeDefinitionNamesToolHandler implements IFullyManagedTool {
|
||||
}
|
||||
|
||||
config.taskState.consecutiveMistakeCount = 0
|
||||
const absolutePath = resolveWorkspacePath(config.cwd, relDirPath!, "ListCodeDefinitionNamesToolHandler.execute")
|
||||
|
||||
// Resolve the absolute path based on multi-workspace configuration
|
||||
const pathResult = resolveWorkspacePath(config, relDirPath!, "ListCodeDefinitionNamesToolHandler.execute")
|
||||
const { absolutePath, displayPath } =
|
||||
typeof pathResult === "string" ? { absolutePath: pathResult, displayPath: relDirPath! } : pathResult
|
||||
|
||||
// Execute the actual parse source code operation
|
||||
const result = await parseSourceCodeForDefinitionsTopLevel(absolutePath, config.services.clineIgnoreController)
|
||||
|
||||
// Handle approval flow
|
||||
const sharedMessageProps = {
|
||||
tool: "listCodeDefinitionNames",
|
||||
path: getReadablePath(config.cwd, relDirPath!),
|
||||
path: getReadablePath(config.cwd, displayPath),
|
||||
content: result,
|
||||
operationIsLocatedInWorkspace: await isLocatedInWorkspace(relDirPath!),
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ export class ListFilesToolHandler implements IFullyManagedTool {
|
||||
// Get config access for services
|
||||
const config = uiHelpers.getConfig()
|
||||
|
||||
// Resolve the absolute path for multi-workspace support
|
||||
const pathResult = resolveWorkspacePath(config, relPath || "", "ListFilesToolHandler.handlePartialBlock")
|
||||
const resolvedAbsolutePath = typeof pathResult === "string" ? pathResult : pathResult.absolutePath
|
||||
|
||||
// Create and show partial UI message
|
||||
const recursiveRaw = block.params.recursive
|
||||
const recursive = recursiveRaw?.toLowerCase() === "true"
|
||||
@@ -41,7 +45,8 @@ export class ListFilesToolHandler implements IFullyManagedTool {
|
||||
const partialMessage = JSON.stringify(sharedMessageProps)
|
||||
|
||||
// Handle auto-approval vs manual approval for partial
|
||||
if (await uiHelpers.shouldAutoApproveToolWithPath(block.name, relPath)) {
|
||||
// Pass the resolved absolute path for multi-workspace support
|
||||
if (await uiHelpers.shouldAutoApproveToolWithPath(block.name, resolvedAbsolutePath)) {
|
||||
await uiHelpers.removeLastPartialMessageIfExistsWithType("ask", "tool")
|
||||
await uiHelpers.say("tool", partialMessage, undefined, undefined, block.partial)
|
||||
} else {
|
||||
@@ -63,7 +68,11 @@ export class ListFilesToolHandler implements IFullyManagedTool {
|
||||
}
|
||||
|
||||
config.taskState.consecutiveMistakeCount = 0
|
||||
const absolutePath = resolveWorkspacePath(config.cwd, relDirPath!, "ListFilesToolHandler.execute")
|
||||
|
||||
// Resolve the absolute path based on multi-workspace configuration
|
||||
const pathResult = resolveWorkspacePath(config, relDirPath!, "ListFilesToolHandler.execute")
|
||||
const { absolutePath, displayPath } =
|
||||
typeof pathResult === "string" ? { absolutePath: pathResult, displayPath: relDirPath! } : pathResult
|
||||
|
||||
// Execute the actual list files operation
|
||||
const [files, didHitLimit] = await listFiles(absolutePath, recursive, 200)
|
||||
@@ -73,14 +82,15 @@ export class ListFilesToolHandler implements IFullyManagedTool {
|
||||
// Handle approval flow
|
||||
const sharedMessageProps = {
|
||||
tool: recursive ? "listFilesRecursive" : "listFilesTopLevel",
|
||||
path: getReadablePath(config.cwd, relDirPath!),
|
||||
path: getReadablePath(config.cwd, displayPath),
|
||||
content: result,
|
||||
operationIsLocatedInWorkspace: await isLocatedInWorkspace(relDirPath!),
|
||||
}
|
||||
|
||||
const completeMessage = JSON.stringify(sharedMessageProps)
|
||||
|
||||
if (await config.callbacks.shouldAutoApproveToolWithPath(block.name, relDirPath)) {
|
||||
// Pass the resolved absolute path for multi-workspace support
|
||||
if (await config.callbacks.shouldAutoApproveToolWithPath(block.name, absolutePath)) {
|
||||
// Auto-approval flow
|
||||
await config.callbacks.removeLastPartialMessageIfExistsWithType("ask", "tool")
|
||||
await config.callbacks.say("tool", completeMessage, undefined, undefined, false)
|
||||
|
||||
@@ -28,6 +28,10 @@ export class ReadFileToolHandler implements IFullyManagedTool {
|
||||
|
||||
const config = uiHelpers.getConfig()
|
||||
|
||||
// Resolve the absolute path for multi-workspace support
|
||||
const pathResult = resolveWorkspacePath(config, relPath || "", "ReadFileToolHandler.handlePartialBlock")
|
||||
const resolvedAbsolutePath = typeof pathResult === "string" ? pathResult : pathResult.absolutePath
|
||||
|
||||
// Create and show partial UI message
|
||||
const sharedMessageProps = {
|
||||
tool: "readFile",
|
||||
@@ -39,7 +43,8 @@ export class ReadFileToolHandler implements IFullyManagedTool {
|
||||
const partialMessage = JSON.stringify(sharedMessageProps)
|
||||
|
||||
// Handle auto-approval vs manual approval for partial
|
||||
if (await uiHelpers.shouldAutoApproveToolWithPath(block.name, relPath)) {
|
||||
// Pass the resolved absolute path for multi-workspace support
|
||||
if (await uiHelpers.shouldAutoApproveToolWithPath(block.name, resolvedAbsolutePath)) {
|
||||
await uiHelpers.removeLastPartialMessageIfExistsWithType("ask", "tool")
|
||||
await uiHelpers.say("tool", partialMessage, undefined, undefined, block.partial)
|
||||
} else {
|
||||
@@ -66,19 +71,24 @@ export class ReadFileToolHandler implements IFullyManagedTool {
|
||||
}
|
||||
|
||||
config.taskState.consecutiveMistakeCount = 0
|
||||
const absolutePath = resolveWorkspacePath(config.cwd, relPath!, "ReadFileToolHandler.execute")
|
||||
|
||||
// Resolve the absolute path based on multi-workspace configuration
|
||||
const pathResult = resolveWorkspacePath(config, relPath!, "ReadFileToolHandler.execute")
|
||||
const { absolutePath, displayPath } =
|
||||
typeof pathResult === "string" ? { absolutePath: pathResult, displayPath: relPath! } : pathResult
|
||||
|
||||
// Handle approval flow
|
||||
const sharedMessageProps = {
|
||||
tool: "readFile",
|
||||
path: getReadablePath(config.cwd, relPath!),
|
||||
path: getReadablePath(config.cwd, displayPath),
|
||||
content: absolutePath,
|
||||
operationIsLocatedInWorkspace: await isLocatedInWorkspace(relPath!),
|
||||
} satisfies ClineSayTool
|
||||
|
||||
const completeMessage = JSON.stringify(sharedMessageProps)
|
||||
|
||||
if (await config.callbacks.shouldAutoApproveToolWithPath(block.name, relPath)) {
|
||||
// Pass the resolved absolute path to AutoApprove, not the original relative path
|
||||
if (await config.callbacks.shouldAutoApproveToolWithPath(block.name, absolutePath)) {
|
||||
// Auto-approval flow
|
||||
await config.callbacks.removeLastPartialMessageIfExistsWithType("ask", "tool")
|
||||
await config.callbacks.say("tool", completeMessage, undefined, undefined, false)
|
||||
@@ -110,16 +120,16 @@ export class ReadFileToolHandler implements IFullyManagedTool {
|
||||
|
||||
// Execute the actual file read operation
|
||||
const supportsImages = config.api.getModel().info.supportsImages ?? false
|
||||
const result = await extractFileContent(absolutePath, supportsImages)
|
||||
const fileContent = await extractFileContent(absolutePath, supportsImages)
|
||||
|
||||
// Track file read operation
|
||||
await config.services.fileContextTracker.trackFileContext(relPath!, "read_tool")
|
||||
|
||||
// Handle image blocks separately - they need to be pushed to userMessageContent
|
||||
if (result.imageBlock) {
|
||||
config.taskState.userMessageContent.push(result.imageBlock)
|
||||
if (fileContent.imageBlock) {
|
||||
config.taskState.userMessageContent.push(fileContent.imageBlock)
|
||||
}
|
||||
|
||||
return result.text
|
||||
return fileContent.text
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,10 @@ export class SearchFilesToolHandler implements IFullyManagedTool {
|
||||
}
|
||||
|
||||
config.taskState.consecutiveMistakeCount = 0
|
||||
const absolutePath = resolveWorkspacePath(config.cwd, relDirPath!, "SearchFilesTool.execute")
|
||||
|
||||
// Resolve the absolute path based on multi-workspace configuration
|
||||
const pathResult = resolveWorkspacePath(config, relDirPath!, "SearchFilesTool.execute")
|
||||
const absolutePath = typeof pathResult === "string" ? pathResult : pathResult.absolutePath
|
||||
|
||||
// Execute the actual regex search operation
|
||||
const results = await regexSearchFiles(
|
||||
|
||||
@@ -60,7 +60,10 @@ export class WriteToFileToolHandler implements IFullyManagedTool {
|
||||
const partialMessage = JSON.stringify(sharedMessageProps)
|
||||
|
||||
// Handle auto-approval vs manual approval for partial
|
||||
if (await uiHelpers.shouldAutoApproveToolWithPath(block.name, relPath)) {
|
||||
// Pass the resolved absolute path for multi-workspace support
|
||||
const absolutePath = resolveWorkspacePath(config, relPath, "WriteToFileToolHandler.handlePartialBlock")
|
||||
const resolvedAbsolutePath = typeof absolutePath === "string" ? absolutePath : absolutePath.absolutePath
|
||||
if (await uiHelpers.shouldAutoApproveToolWithPath(block.name, resolvedAbsolutePath)) {
|
||||
await uiHelpers.removeLastPartialMessageIfExistsWithType("ask", "tool") // in case the user changes auto-approval settings mid stream
|
||||
await uiHelpers.say("tool", partialMessage, undefined, undefined, block.partial)
|
||||
} else {
|
||||
@@ -156,7 +159,10 @@ export class WriteToFileToolHandler implements IFullyManagedTool {
|
||||
// : undefined,
|
||||
} satisfies ClineSayTool)
|
||||
|
||||
if (await config.callbacks.shouldAutoApproveToolWithPath(block.name, relPath)) {
|
||||
// Pass the resolved absolute path for multi-workspace support
|
||||
const pathResult = resolveWorkspacePath(config, relPath, "WriteToFileToolHandler.execute")
|
||||
const resolvedAbsolutePath = typeof pathResult === "string" ? pathResult : pathResult.absolutePath
|
||||
if (await config.callbacks.shouldAutoApproveToolWithPath(block.name, resolvedAbsolutePath)) {
|
||||
// Auto-approval flow
|
||||
await config.callbacks.removeLastPartialMessageIfExistsWithType("ask", "tool")
|
||||
await config.callbacks.say("tool", completeMessage, undefined, undefined, false)
|
||||
@@ -297,14 +303,21 @@ export class WriteToFileToolHandler implements IFullyManagedTool {
|
||||
* or undefined if validation fails
|
||||
*/
|
||||
async validateAndPrepareFileOperation(config: TaskConfig, block: ToolUse, relPath: string, diff?: string, content?: string) {
|
||||
// Parse workspace hint and resolve path for multi-workspace support
|
||||
const pathResult = resolveWorkspacePath(config, relPath, "WriteToFileToolHandler.validateAndPrepareFileOperation")
|
||||
const { absolutePath, resolvedPath } =
|
||||
typeof pathResult === "string"
|
||||
? { absolutePath: pathResult, resolvedPath: relPath }
|
||||
: { absolutePath: pathResult.absolutePath, resolvedPath: pathResult.resolvedPath }
|
||||
|
||||
// Check clineignore access first
|
||||
const accessValidation = this.validator.checkClineIgnorePath(relPath)
|
||||
const accessValidation = this.validator.checkClineIgnorePath(resolvedPath)
|
||||
if (!accessValidation.ok) {
|
||||
// Show error and return early (full original behavior)
|
||||
await config.callbacks.say("clineignore_error", relPath)
|
||||
await config.callbacks.say("clineignore_error", resolvedPath)
|
||||
|
||||
// Push tool result and save checkpoint using existing utilities
|
||||
const errorResponse = formatResponse.toolError(formatResponse.clineIgnoreError(relPath))
|
||||
const errorResponse = formatResponse.toolError(formatResponse.clineIgnoreError(resolvedPath))
|
||||
ToolResultUtils.pushToolResult(
|
||||
errorResponse,
|
||||
block,
|
||||
@@ -324,11 +337,6 @@ export class WriteToFileToolHandler implements IFullyManagedTool {
|
||||
if (config.services.diffViewProvider.editType !== undefined) {
|
||||
fileExists = config.services.diffViewProvider.editType === "modify"
|
||||
} else {
|
||||
const absolutePath = resolveWorkspacePath(
|
||||
config.cwd,
|
||||
relPath,
|
||||
"WriteToFileToolHandler.validateAndPrepareFileOperation",
|
||||
)
|
||||
fileExists = await fileExistsAtPath(absolutePath)
|
||||
config.services.diffViewProvider.editType = fileExists ? "modify" : "create"
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export class WorkspacePathAdapter {
|
||||
resolvePath(relativePath: string, workspaceHint?: string): string {
|
||||
// Single-root mode (backward compatible)
|
||||
if (!this.config.isMultiRootEnabled || !this.config.workspaceManager) {
|
||||
return resolveWorkspacePath(this.config.cwd, relativePath, "WorkspacePathAdapter")
|
||||
return resolveWorkspacePath(this.config.cwd, relativePath, "WorkspacePathAdapter") as string
|
||||
}
|
||||
|
||||
// Multi-root mode
|
||||
@@ -73,7 +73,7 @@ export class WorkspacePathAdapter {
|
||||
|
||||
// Fallback to cwd if no roots (shouldn't happen, but defensive)
|
||||
console.warn(`[WorkspacePathAdapter] No workspace roots found, falling back to cwd`)
|
||||
return resolveWorkspacePath(this.config.cwd, relativePath, "WorkspacePathAdapter-fallback")
|
||||
return resolveWorkspacePath(this.config.cwd, relativePath, "WorkspacePathAdapter-fallback") as string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ export class WorkspacePathAdapter {
|
||||
getAllPossiblePaths(relativePath: string): string[] {
|
||||
// Single-root mode
|
||||
if (!this.config.isMultiRootEnabled || !this.config.workspaceManager) {
|
||||
return [resolveWorkspacePath(this.config.cwd, relativePath, "WorkspacePathAdapter-getAllPaths")]
|
||||
return [resolveWorkspacePath(this.config.cwd, relativePath, "WorkspacePathAdapter-getAllPaths") as string]
|
||||
}
|
||||
|
||||
// Multi-root mode
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
import * as path from "path"
|
||||
import { MigrationReporter, type UsageStats } from "./MigrationReporter"
|
||||
import { parseWorkspaceInlinePath } from "./utils/parseWorkspaceInlinePath"
|
||||
import { WorkspacePathAdapter } from "./WorkspacePathAdapter"
|
||||
import { WorkspaceRoot } from "./WorkspaceRoot"
|
||||
|
||||
/**
|
||||
@@ -251,11 +253,77 @@ export class WorkspaceResolver {
|
||||
export const workspaceResolver = new WorkspaceResolver()
|
||||
|
||||
/**
|
||||
* Phase 0: Convenience function for easy migration from path.resolve()
|
||||
* This is what we'll use to replace existing path.resolve(cwd, ...) calls
|
||||
* Result type for multi-root workspace path resolution
|
||||
*/
|
||||
export function resolveWorkspacePath(cwd: string, relativePath: string, context?: string): string {
|
||||
return workspaceResolver.resolveWorkspacePath(cwd, relativePath, context) as string
|
||||
export interface WorkspacePathResult {
|
||||
absolutePath: string
|
||||
displayPath: string
|
||||
resolvedPath: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for workspace path resolution
|
||||
*/
|
||||
export interface WorkspaceConfig {
|
||||
cwd: string
|
||||
isMultiRootEnabled?: boolean
|
||||
workspaceManager?: any
|
||||
}
|
||||
|
||||
/**
|
||||
* Enhanced workspace path resolution that handles both single and multi-root workspaces
|
||||
*
|
||||
* @param cwdOrConfig - Either a string (for backward compatibility) or a config object
|
||||
* @param relativePath - The relative path to resolve
|
||||
* @param context - Component/handler name for tracking usage
|
||||
* @returns Either a string (for backward compatibility) or a WorkspacePathResult object
|
||||
*/
|
||||
export function resolveWorkspacePath(
|
||||
cwdOrConfig: string | WorkspaceConfig,
|
||||
relativePath: string,
|
||||
context?: string,
|
||||
): string | WorkspacePathResult {
|
||||
// Backward compatibility: if first param is a string, return string
|
||||
if (typeof cwdOrConfig === "string") {
|
||||
return workspaceResolver.resolveWorkspacePath(cwdOrConfig, relativePath, context) as string
|
||||
}
|
||||
|
||||
// New behavior: handle multi-root workspaces
|
||||
const config = cwdOrConfig
|
||||
|
||||
// If multi-root is enabled and we have a workspace manager
|
||||
if (config.isMultiRootEnabled && config.workspaceManager) {
|
||||
// Parse workspace hint from the path (e.g., @frontend:src/index.ts)
|
||||
const { workspaceHint, relPath: parsedPath } = parseWorkspaceInlinePath(relativePath)
|
||||
|
||||
// Create adapter for multi-workspace path resolution
|
||||
const adapter = new WorkspacePathAdapter({
|
||||
cwd: config.cwd,
|
||||
isMultiRootEnabled: true,
|
||||
workspaceManager: config.workspaceManager,
|
||||
})
|
||||
|
||||
// Resolve to the correct workspace root
|
||||
const absolutePath = adapter.resolvePath(parsedPath, workspaceHint)
|
||||
|
||||
// Build display path with workspace hint if present
|
||||
const displayPath = workspaceHint ? `@${workspaceHint}:${parsedPath}` : parsedPath
|
||||
|
||||
return {
|
||||
absolutePath,
|
||||
displayPath,
|
||||
resolvedPath: parsedPath,
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to single-workspace behavior
|
||||
const absolutePath = workspaceResolver.resolveWorkspacePath(config.cwd, relativePath, context) as string
|
||||
|
||||
return {
|
||||
absolutePath,
|
||||
displayPath: relativePath,
|
||||
resolvedPath: relativePath,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ import { expect } from "chai"
|
||||
import * as path from "path"
|
||||
import sinon from "sinon"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import * as featureFlags from "@/services/feature-flags"
|
||||
import * as telemetry from "@/services/telemetry"
|
||||
import * as pathUtils from "@/utils/path"
|
||||
import { setupWorkspaceManager } from "../setup"
|
||||
@@ -97,6 +98,11 @@ describe("setupWorkspaceManager", () => {
|
||||
const stateManager = makeStateManager({ multiRootEnabled: true })
|
||||
const detectRoots = sandbox.stub().resolves(defaultRoots)
|
||||
|
||||
// Stub featureFlagsService to return true for multi-root
|
||||
sandbox.stub(featureFlags, "featureFlagsService").value({
|
||||
getMultiRootEnabled: () => true,
|
||||
})
|
||||
|
||||
const manager = await setupWorkspaceManager({
|
||||
stateManager: stateManager as any,
|
||||
historyItem: undefined,
|
||||
@@ -162,6 +168,11 @@ describe("setupWorkspaceManager", () => {
|
||||
const stateManager = makeStateManager({ multiRootEnabled: true })
|
||||
const detectRoots = sandbox.stub().rejects(new Error("boom"))
|
||||
|
||||
// Stub featureFlagsService to return true for multi-root
|
||||
sandbox.stub(featureFlags, "featureFlagsService").value({
|
||||
getMultiRootEnabled: () => true,
|
||||
})
|
||||
|
||||
const manager = await setupWorkspaceManager({
|
||||
stateManager: stateManager as any,
|
||||
historyItem: undefined,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { featureFlagsService } from "@/services/feature-flags"
|
||||
import { telemetryService } from "@/services/telemetry"
|
||||
import type { HistoryItem } from "@/shared/HistoryItem"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
@@ -24,13 +25,12 @@ export async function setupWorkspaceManager({
|
||||
detectRoots: DetectRoots
|
||||
}): Promise<WorkspaceRootManager> {
|
||||
const cwd = await getCwd(getDesktopDir())
|
||||
const multiRootEnabled = stateManager.getGlobalStateKey("multiRootEnabled")
|
||||
const startTime = performance.now()
|
||||
|
||||
const isMultiRootEnabled = featureFlagsService.getMultiRootEnabled()
|
||||
try {
|
||||
let manager: WorkspaceRootManager
|
||||
// Multi-root mode condition which is always false for now as isMultiRootEnabled is hardcoded to false
|
||||
if (multiRootEnabled) {
|
||||
if (isMultiRootEnabled) {
|
||||
// Multi-root: detect workspace folders
|
||||
const roots = await detectRoots()
|
||||
manager = new WorkspaceRootManager(roots, 0)
|
||||
|
||||
@@ -79,6 +79,7 @@ export class FeatureFlagsService {
|
||||
* Convenience: multi-root workspace remote gate
|
||||
*/
|
||||
public getMultiRootEnabled(): boolean {
|
||||
// return true // For testing
|
||||
return this.getBooleanFlagEnabled(FeatureFlag.MULTI_ROOT_WORKSPACE, false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user