summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/tools/file.go
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-03-25 13:04:36 +0100
committerKujtim Hoxha <[email protected]>2025-03-26 01:12:30 +0100
commit904061c243f70696bfe781e97bf4e392e6954d07 (patch)
tree4428f96d09968ee0cde44e6ebbaee4757f80050e /internal/llm/tools/file.go
parent005b8ac16776512b2d4b1f22bd989da162ca1bad (diff)
downloadopencode-904061c243f70696bfe781e97bf4e392e6954d07.tar.gz
opencode-904061c243f70696bfe781e97bf4e392e6954d07.zip
additional tools
Diffstat (limited to 'internal/llm/tools/file.go')
-rw-r--r--internal/llm/tools/file.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/internal/llm/tools/file.go b/internal/llm/tools/file.go
new file mode 100644
index 000000000..7f34fdc1f
--- /dev/null
+++ b/internal/llm/tools/file.go
@@ -0,0 +1,53 @@
+package tools
+
+import (
+ "sync"
+ "time"
+)
+
+// File record to track when files were read/written
+type fileRecord struct {
+ path string
+ readTime time.Time
+ writeTime time.Time
+}
+
+var (
+ fileRecords = make(map[string]fileRecord)
+ fileRecordMutex sync.RWMutex
+)
+
+func recordFileRead(path string) {
+ fileRecordMutex.Lock()
+ defer fileRecordMutex.Unlock()
+
+ record, exists := fileRecords[path]
+ if !exists {
+ record = fileRecord{path: path}
+ }
+ record.readTime = time.Now()
+ fileRecords[path] = record
+}
+
+func getLastReadTime(path string) time.Time {
+ fileRecordMutex.RLock()
+ defer fileRecordMutex.RUnlock()
+
+ record, exists := fileRecords[path]
+ if !exists {
+ return time.Time{}
+ }
+ return record.readTime
+}
+
+func recordFileWrite(path string) {
+ fileRecordMutex.Lock()
+ defer fileRecordMutex.Unlock()
+
+ record, exists := fileRecords[path]
+ if !exists {
+ record = fileRecord{path: path}
+ }
+ record.writeTime = time.Now()
+ fileRecords[path] = record
+}