You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constformattedError=`File does not exist at path: ${absolutePath}\n\n<error_details>\nThe specified file could not be found. Please verify the file path and try again.\n</error_details>`
1325
+
awaitthis.say("error",formattedError)
1326
+
pushToolResult(formattedError)
1327
+
break
1328
+
}
1329
+
1330
+
1331
+
1332
+
letparsedOperations: Array<{
1333
+
search: string
1334
+
replace: string
1335
+
start_line?: number
1336
+
end_line?: number
1337
+
use_regex?: boolean
1338
+
ignore_case?: boolean
1339
+
regex_flags?: string
1340
+
}>
1341
+
1342
+
try{
1343
+
parsedOperations=JSON.parse(operations)
1344
+
if(!Array.isArray(parsedOperations)){
1345
+
thrownewError("Operations must be an array")
1346
+
}
1347
+
}catch(error){
1348
+
this.consecutiveMistakeCount++
1349
+
awaitthis.say(
1350
+
"error",
1351
+
`Failed to parse operations JSON: ${error.message}`
`The user made the following updates to your content:\n\n${userEdits}\n\n`+
1437
+
`The updated content, which includes both your original modifications and the user's edits, has been successfully saved to ${relPath.toPosix()}. Here is the full, updated content of the file, including line numbers:\n\n`+
Copy file name to clipboardExpand all lines: src/core/prompts/sections/rules.ts
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ RULES
15
15
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '${cwd.toPosix()}', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '${cwd.toPosix()}'). For example, if you needed to run \`npm install\` in a project outside of '${cwd.toPosix()}', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
16
16
- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
17
17
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
18
+
- You should use search_and_replace when suggesting edits that involve either small individual changes or pattern-based modifications that need to be applied consistently across a file.
18
19
${diffStrategy ? "- 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." : "- 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."}
19
20
- 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.
20
21
- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
Description: Request to perform search and replace operations on a file. Each operation can specify a search pattern (string or regex) and replacement text, with optional line range restrictions and regex flags. Shows a diff preview before applying changes.
4
+
Parameters:
5
+
- path: (required) The path of the file to modify (relative to the current working directory ${cwd})
6
+
- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
7
+
* search: (required) The text or pattern to search for
8
+
* replace: (required) The text to replace matches with
9
+
* start_line: (optional) Starting line number for restricted replacement
10
+
* end_line: (optional) Ending line number for restricted replacement
11
+
* use_regex: (optional) Whether to treat search as a regex pattern
12
+
* ignore_case: (optional) Whether to ignore case when matching
13
+
* regex_flags: (optional) Additional regex flags when use_regex is true
14
+
15
+
Usage:
16
+
<search_and_replace>
17
+
<path>File path here</path>
18
+
<operations>[
19
+
{
20
+
"search": "text to find",
21
+
"replace": "replacement text",
22
+
"start_line": 1,
23
+
"end_line": 10
24
+
}
25
+
]</operations>
26
+
</search_and_replace>
27
+
28
+
Example: Replace "foo" with "bar" in lines 1-10 of example.ts
29
+
<search_and_replace>
30
+
<path>example.ts</path>
31
+
<operations>[
32
+
{
33
+
"search": "foo",
34
+
"replace": "bar",
35
+
"start_line": 1,
36
+
"end_line": 10
37
+
}
38
+
]</operations>
39
+
</search_and_replace>
40
+
41
+
Example: Replace all occurrences of "old" with "new" using regex
0 commit comments