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
Copy file name to clipboardExpand all lines: src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
+56-84Lines changed: 56 additions & 84 deletions
Original file line number
Diff line number
Diff line change
@@ -659,53 +659,39 @@ Example: Insert a new function and its import statement
659
659
</insert_content>
660
660
661
661
## search_and_replace
662
-
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.
663
-
Parameters:
664
-
- path: (required) The path of the file to modify (relative to the current workspace directory /test/path)
665
-
- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
666
-
* search: (required) The text or pattern to search for
667
-
* replace: (required) The text to replace matches with. If multiple lines need to be replaced, use "
668
-
" for newlines
669
-
* start_line: (optional) Starting line number for restricted replacement
670
-
* end_line: (optional) Ending line number for restricted replacement
671
-
* use_regex: (optional) Whether to treat search as a regex pattern
672
-
* ignore_case: (optional) Whether to ignore case when matching
673
-
* regex_flags: (optional) Additional regex flags when use_regex is true
674
-
Usage:
675
-
<search_and_replace>
676
-
<path>File path here</path>
677
-
<operations>[
678
-
{
679
-
"search": "text to find",
680
-
"replace": "replacement text",
681
-
"start_line": 1,
682
-
"end_line": 10
683
-
}
684
-
]</operations>
685
-
</search_and_replace>
686
-
Example: Replace "foo" with "bar" in lines 1-10 of example.ts
662
+
Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. Shows a diff preview before applying changes.
663
+
664
+
Required Parameters:
665
+
- path: The path of the file to modify (relative to the current workspace directory /test/path)
666
+
- search: The text or pattern to search for
667
+
- replace: The text to replace matches with
668
+
669
+
Optional Parameters:
670
+
- start_line: Starting line number for restricted replacement (1-based)
671
+
- end_line: Ending line number for restricted replacement (1-based)
672
+
- use_regex: Set to "true" to treat search as a regex pattern (default: false)
673
+
- ignore_case: Set to "true" to ignore case when matching (default: false)
674
+
675
+
Notes:
676
+
- When use_regex is true, the search parameter is treated as a regular expression pattern
677
+
- When ignore_case is true, the search is case-insensitive regardless of regex mode
678
+
679
+
Examples:
680
+
681
+
1. Simple text replacement:
687
682
<search_and_replace>
688
683
<path>example.ts</path>
689
-
<operations>[
690
-
{
691
-
"search": "foo",
692
-
"replace": "bar",
693
-
"start_line": 1,
694
-
"end_line": 10
695
-
}
696
-
]</operations>
684
+
<search>oldText</search>
685
+
<replace>newText</replace>
697
686
</search_and_replace>
698
-
Example: Replace all occurrences of "old" with "new" using regex
687
+
688
+
2. Case-insensitive regex pattern:
699
689
<search_and_replace>
700
690
<path>example.ts</path>
701
-
<operations>[
702
-
{
703
-
"search": "old\\w+",
704
-
"replace": "new$&",
705
-
"use_regex": true,
706
-
"ignore_case": true
707
-
}
708
-
]</operations>
691
+
<search>oldw+</search>
692
+
<replace>new$&</replace>
693
+
<use_regex>true</use_regex>
694
+
<ignore_case>true</ignore_case>
709
695
</search_and_replace>
710
696
711
697
## execute_command
@@ -1133,53 +1119,39 @@ Example: Requesting to append to a log file
1133
1119
</append_to_file>
1134
1120
1135
1121
## search_and_replace
1136
-
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.
1137
-
Parameters:
1138
-
- path: (required) The path of the file to modify (relative to the current workspace directory /test/path)
1139
-
- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
1140
-
* search: (required) The text or pattern to search for
1141
-
* replace: (required) The text to replace matches with. If multiple lines need to be replaced, use "
1142
-
" for newlines
1143
-
* start_line: (optional) Starting line number for restricted replacement
1144
-
* end_line: (optional) Ending line number for restricted replacement
1145
-
* use_regex: (optional) Whether to treat search as a regex pattern
1146
-
* ignore_case: (optional) Whether to ignore case when matching
1147
-
* regex_flags: (optional) Additional regex flags when use_regex is true
1148
-
Usage:
1149
-
<search_and_replace>
1150
-
<path>File path here</path>
1151
-
<operations>[
1152
-
{
1153
-
"search": "text to find",
1154
-
"replace": "replacement text",
1155
-
"start_line": 1,
1156
-
"end_line": 10
1157
-
}
1158
-
]</operations>
1159
-
</search_and_replace>
1160
-
Example: Replace "foo" with "bar" in lines 1-10 of example.ts
1122
+
Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. Shows a diff preview before applying changes.
1123
+
1124
+
Required Parameters:
1125
+
- path: The path of the file to modify (relative to the current workspace directory /test/path)
1126
+
- search: The text or pattern to search for
1127
+
- replace: The text to replace matches with
1128
+
1129
+
Optional Parameters:
1130
+
- start_line: Starting line number for restricted replacement (1-based)
1131
+
- end_line: Ending line number for restricted replacement (1-based)
1132
+
- use_regex: Set to "true" to treat search as a regex pattern (default: false)
1133
+
- ignore_case: Set to "true" to ignore case when matching (default: false)
1134
+
1135
+
Notes:
1136
+
- When use_regex is true, the search parameter is treated as a regular expression pattern
1137
+
- When ignore_case is true, the search is case-insensitive regardless of regex mode
1138
+
1139
+
Examples:
1140
+
1141
+
1. Simple text replacement:
1161
1142
<search_and_replace>
1162
1143
<path>example.ts</path>
1163
-
<operations>[
1164
-
{
1165
-
"search": "foo",
1166
-
"replace": "bar",
1167
-
"start_line": 1,
1168
-
"end_line": 10
1169
-
}
1170
-
]</operations>
1144
+
<search>oldText</search>
1145
+
<replace>newText</replace>
1171
1146
</search_and_replace>
1172
-
Example: Replace all occurrences of "old" with "new" using regex
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.
6
-
Parameters:
7
-
- path: (required) The path of the file to modify (relative to the current workspace directory ${args.cwd.toPosix()})
8
-
- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
9
-
* search: (required) The text or pattern to search for
10
-
* replace: (required) The text to replace matches with. If multiple lines need to be replaced, use "\n" for newlines
11
-
* start_line: (optional) Starting line number for restricted replacement
12
-
* end_line: (optional) Ending line number for restricted replacement
13
-
* use_regex: (optional) Whether to treat search as a regex pattern
14
-
* ignore_case: (optional) Whether to ignore case when matching
15
-
* regex_flags: (optional) Additional regex flags when use_regex is true
16
-
Usage:
17
-
<search_and_replace>
18
-
<path>File path here</path>
19
-
<operations>[
20
-
{
21
-
"search": "text to find",
22
-
"replace": "replacement text",
23
-
"start_line": 1,
24
-
"end_line": 10
25
-
}
26
-
]</operations>
27
-
</search_and_replace>
28
-
Example: Replace "foo" with "bar" in lines 1-10 of example.ts
5
+
Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. Shows a diff preview before applying changes.
6
+
7
+
Required Parameters:
8
+
- path: The path of the file to modify (relative to the current workspace directory ${args.cwd.toPosix()})
9
+
- search: The text or pattern to search for
10
+
- replace: The text to replace matches with
11
+
12
+
Optional Parameters:
13
+
- start_line: Starting line number for restricted replacement (1-based)
14
+
- end_line: Ending line number for restricted replacement (1-based)
15
+
- use_regex: Set to "true" to treat search as a regex pattern (default: false)
16
+
- ignore_case: Set to "true" to ignore case when matching (default: false)
17
+
18
+
Notes:
19
+
- When use_regex is true, the search parameter is treated as a regular expression pattern
20
+
- When ignore_case is true, the search is case-insensitive regardless of regex mode
21
+
22
+
Examples:
23
+
24
+
1. Simple text replacement:
29
25
<search_and_replace>
30
26
<path>example.ts</path>
31
-
<operations>[
32
-
{
33
-
"search": "foo",
34
-
"replace": "bar",
35
-
"start_line": 1,
36
-
"end_line": 10
37
-
}
38
-
]</operations>
27
+
<search>oldText</search>
28
+
<replace>newText</replace>
39
29
</search_and_replace>
40
-
Example: Replace all occurrences of "old" with "new" using regex
0 commit comments