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
Perform precise string replacement operations in the generated document.
33
+
Usage:
34
+
- Before making any edits, you must use the `Read` tool at least once in the conversation. If you attempt to edit without reading the file, the tool will report an error.
35
+
- When editing the text output from the `Read` tool, make sure to retain its exact indentation (tabs/spaces), that is, the form that appears after the line number prefix. The line number prefix format is: space + line number + tab. Everything after that tab is the actual file content and must match it. Do not include any components of the line number prefix in the old string or new string.
36
+
- Always prioritize editing existing files in the code repository. Do not overwrite the content unless explicitly required.
37
+
- Use emojis only when the user explicitly requests it. Do not add emojis to the file unless required.
38
+
- If the `oldString` is not unique in the file, the edit will fail. Either provide a longer string with more context to make it unique, or use `replaceAll` to change all instances of the "old string".
39
+
- Use `replaceAll` to replace and rename strings throughout the file. This parameter is very useful when renaming variables, etc.
40
+
""")]
41
+
publicstringEdit(
42
+
[Description("The text to replace")]
43
+
stringoldString,
44
+
[Description("The text to replace it with (must be different from old_string)")]
45
+
stringnewString,
46
+
[Description("Replace all occurences of old_string (default false)")]
47
+
boolreplaceAll=false)
48
+
{
49
+
if(string.IsNullOrEmpty(Content))
50
+
{
51
+
return"<system-reminder>Document content is empty, please write content first.</system-reminder>";
52
+
}
53
+
54
+
if(string.IsNullOrEmpty(oldString))
55
+
{
56
+
return"<system-reminder>Old string cannot be empty.</system-reminder>";
57
+
}
58
+
59
+
if(oldString==newString)
60
+
{
61
+
return"<system-reminder>New string must be different from old string.</system-reminder>";
62
+
}
63
+
64
+
if(!Content.Contains(oldString))
65
+
{
66
+
return"<system-reminder>Old string not found in document.</system-reminder>";
return"<system-reminder>Old string is not unique in the document. Use replaceAll=true to replace all occurrences or provide a longer string with more context.</system-reminder>";
0 commit comments