Private
Public Access
1
0

Add modify_file tool

Removed file_insert_lines, file_replace_lines
This commit is contained in:
2024-07-01 08:09:04 +00:00
parent c68084f8a5
commit 4ef841e945
5 changed files with 195 additions and 148 deletions

View File

@@ -65,3 +65,14 @@ func IsPathWithinCWD(path string) (bool, string) {
}
return true, ""
}
// AddLineNumbers takes a string of content and returns a new string with line
// numbers prefixed
func AddLineNumbers(content string) string {
lines := strings.Split(strings.TrimSuffix(content, "\n"), "\n")
result := strings.Builder{}
for i, line := range lines {
result.WriteString(fmt.Sprintf("%d\t%s\n", i+1, line))
}
return result.String()
}