Skip to content

Commit 4e3ea69

Browse files
committed
update rule & prompt for insert-code-block
1 parent 179ea79 commit 4e3ea69

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/core/prompts/sections/rules.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function getRulesSection(
88
supportsComputerUse: boolean,
99
diffStrategy?: DiffStrategy,
1010
context?: vscode.ExtensionContext,
11+
experiments?: Record<string, boolean> | undefined,
1112
): string {
1213
const settingsDir = context ? path.join(context.globalStorageUri.fsPath, "settings") : "<settings directory>"
1314
const customModesPath = path.join(settingsDir, "cline_custom_modes.json")
@@ -26,6 +27,8 @@ ${
2627
? "- You should use apply_diff instead of write_to_file when making changes to existing files since it is much faster and easier to apply a diff than to write the entire file again. Only use write_to_file to edit files when apply_diff has failed repeatedly to apply the diff."
2728
: "- When you want to modify a file, use the write_to_file tool directly with the desired content. You do not need to display the content before using the tool."
2829
}
30+
${experiments?.["insert_code_block"] === true ? "- Use the insert_code_block tool to add code snippets or content block to files, such as adding a new function to a JavaScript file or inserting a new route in a Python file. This tool will insert it at the specified line location." : ""}
31+
${experiments?.["search_and_replace"] === true ? "- Use the search_and_replace tool to find and replace text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text." : ""}
2932
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
3033
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
3134
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"

src/core/prompts/system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ${getCapabilitiesSection(cwd, supportsComputerUse, mcpHub, effectiveDiffStrategy
8080
8181
${modesSection}
8282
83-
${getRulesSection(cwd, supportsComputerUse, effectiveDiffStrategy, context)}
83+
${getRulesSection(cwd, supportsComputerUse, effectiveDiffStrategy, context, experiments)}
8484
8585
${getSystemInfoSection(cwd, mode, customModeConfigs)}
8686

src/core/prompts/tools/insert-code-block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Parameters:
77
- path: (required) The path of the file to insert code into (relative to the current working directory ${args.cwd.toPosix()})
88
- operations: (required) A JSON array of insertion operations. Each operation is an object with:
99
* start_line: (required) The line number where the code block should be inserted. The content currently at that line will end up below the inserted code block.
10-
* content: (required) The code block to insert at the specified position
10+
* content: (required) The code block to insert at the specified position. IMPORTANT NOTE: If the content is a single line, it can be a string. If it's a multi-line content, it should be a string with newline characters (\n) for line breaks.
1111
Usage:
1212
<insert_code_block>
1313
<path>File path here</path>

0 commit comments

Comments
 (0)