@@ -14,6 +14,7 @@ import (
1414 "github.com/charmbracelet/crush/internal/csync"
1515 "github.com/charmbracelet/crush/internal/diff"
1616 "github.com/charmbracelet/crush/internal/filepathext"
17+ "github.com/charmbracelet/crush/internal/filetracker"
1718 "github.com/charmbracelet/crush/internal/fsext"
1819 "github.com/charmbracelet/crush/internal/history"
1920
@@ -159,8 +160,8 @@ func createNewFile(edit editContext, filePath, content string, call fantasy.Tool
159160 slog.Error("Error creating file history version", "error", err)
160161 }
161162
162− recordFileWrite(filePath)
163− recordFileRead(filePath)
163+ filetracker.RecordWrite(filePath)
164+ filetracker.RecordRead(filePath)
164165
165166 return fantasy.WithResponseMetadata(
166167 fantasy.NewTextResponse("File created: "+filePath),
@@ -186,12 +187,12 @@ func deleteContent(edit editContext, filePath, oldString string, replaceAll bool
186187 return fantasy.NewTextErrorResponse(fmt.Sprintf("path is a directory, not a file: %s", filePath)), nil
187188 }
188189
189− if getLastReadTime(filePath).IsZero() {
190+ if filetracker.LastReadTime(filePath).IsZero() {
190191 return fantasy.NewTextErrorResponse("you must read the file before editing it. Use the View tool first"), nil
191192 }
192193
193194 modTime := fileInfo.ModTime()
194− lastRead := getLastReadTime(filePath)
195+ lastRead := filetracker.LastReadTime(filePath)
195196 if modTime.After(lastRead) {
196197 return fantasy.NewTextErrorResponse(
197198 fmt.Sprintf("file %s has been modified since it was last read (mod time: %s, last read: %s)",
@@ -292,8 +293,8 @@ func deleteContent(edit editContext, filePath, oldString string, replaceAll bool
292293 slog.Error("Error creating file history version", "error", err)
293294 }
294295
295− recordFileWrite(filePath)
296− recordFileRead(filePath)
296+ filetracker.RecordWrite(filePath)
297+ filetracker.RecordRead(filePath)
297298
298299 return fantasy.WithResponseMetadata(
299300 fantasy.NewTextResponse("Content deleted from file: "+filePath),
@@ -319,12 +320,12 @@ func replaceContent(edit editContext, filePath, oldString, newString string, rep
319320 return fantasy.NewTextErrorResponse(fmt.Sprintf("path is a directory, not a file: %s", filePath)), nil
320321 }
321322
322− if getLastReadTime(filePath).IsZero() {
323+ if filetracker.LastReadTime(filePath).IsZero() {
323324 return fantasy.NewTextErrorResponse("you must read the file before editing it. Use the View tool first"), nil
324325 }
325326
326327 modTime := fileInfo.ModTime()
327− lastRead := getLastReadTime(filePath)
328+ lastRead := filetracker.LastReadTime(filePath)
328329 if modTime.After(lastRead) {
329330 return fantasy.NewTextErrorResponse(
330331 fmt.Sprintf("file %s has been modified since it was last read (mod time: %s, last read: %s)",
@@ -427,8 +428,8 @@ func replaceContent(edit editContext, filePath, oldString, newString string, rep
427428 slog.Error("Error creating file history version", "error", err)
428429 }
429430
430− recordFileWrite(filePath)
431− recordFileRead(filePath)
431+ filetracker.RecordWrite(filePath)
432+ filetracker.RecordRead(filePath)
432433
433434 return fantasy.WithResponseMetadata(
434435 fantasy.NewTextResponse("Content replaced in file: "+filePath),