createBackup 创建文件备份
(ctx context.Context, filePath, content string, tc *tools.ToolContext)
| 313 | |
| 314 | // createBackup 创建文件备份 |
| 315 | func (t *EditTool) createBackup(ctx context.Context, filePath, content string, tc *tools.ToolContext) string { |
| 316 | timestamp := time.Now().Format("20060102_150405") |
| 317 | backupPath := filePath + ".backup_" + timestamp |
| 318 | |
| 319 | err := tc.Sandbox.FS().Write(ctx, backupPath, content) |
| 320 | if err != nil { |
| 321 | return "" |
| 322 | } |
| 323 | |
| 324 | return backupPath |
| 325 | } |
| 326 | |
| 327 | func (t *EditTool) Prompt() string { |
| 328 | return `对文件进行精确的字符串替换编辑。 |