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
Copy file name to clipboardExpand all lines: src/main/java/uno/anahata/ai/tools/spi/LocalFiles.java
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -77,9 +77,9 @@ public static byte[] readBinaryFile(@AIToolParam("The absolute path of the file
77
77
* @return A FileInfo object containing content and metadata.
78
78
* @throws IOException if the file is not found or is a directory.
79
79
*/
80
-
@AIToolMethod(value = "Reads a single file and returns a FileInfo object containing its path, content, size, and last modified timestamp.", requiresApproval = false, behavior = ContextBehavior.STATEFUL_REPLACE)
80
+
@AIToolMethod(value = "Reads a single text file and returns a FileInfo object containing its path, content, size, and last modified timestamp.", requiresApproval = false, behavior = ContextBehavior.STATEFUL_REPLACE)
81
81
publicstaticFileInforeadFile(
82
-
@AIToolParam("The absolute path of the file to read.") Stringpath
82
+
@AIToolParam("The absolute path of the text file to read.") Stringpath
83
83
) throwsIOException {
84
84
PathfilePath = Paths.get(path);
85
85
if (!Files.exists(filePath)) {
@@ -95,7 +95,7 @@ public static FileInfo readFile(
95
95
.filter(s -> s.getResourceId().equals(path))
96
96
.findFirst();
97
97
if (status.isPresent() && status.get().getStatus() == ResourceStatus.VALID) {
98
-
thrownewRuntimeException("Redundant Read: The file at " + path + " is already VALID in your context. Do not reload it.");
98
+
thrownewRuntimeException("Redundant Read: The text file at " + path + " is already VALID in your context (Part ID: " + status.get().getPartId() + "). Do not reload it.");
99
99
}
100
100
101
101
Stringcontent = Files.readString(filePath);
@@ -106,17 +106,17 @@ public static FileInfo readFile(
106
106
}
107
107
108
108
/**
109
-
* Writes content to an existing file, using optimistic locking.
109
+
* Writes content to an existing text file, using optimistic locking.
110
110
*
111
111
* @param path The absolute path to the file.
112
112
* @param content The new content to write.
113
113
* @param lastModified The expected last modified timestamp for safety.
114
114
* @return An updated FileInfo object.
115
115
* @throws IOException if a modification conflict occurs or the file is missing.
116
116
*/
117
-
@AIToolMethod(value = "Writes content to an existing file, but only if the file exists and has not been modified since the provided timestamp. This is a safeguard against overwriting concurrent changes. Returns the updated FileInfo object. Don not use this to create new files unse LocalFiles.createFile instead", behavior = ContextBehavior.STATEFUL_REPLACE)
117
+
@AIToolMethod(value = "Writes content to an existing text file, but only if the file exists and has not been modified since the provided timestamp. This is a safeguard against overwriting concurrent changes. Returns the updated FileInfo object. Don not use this to create new files unse LocalFiles.createFile instead", behavior = ContextBehavior.STATEFUL_REPLACE)
118
118
publicstaticFileInfowriteFile(
119
-
@AIToolParam("The absolute path of the file to write to.") Stringpath,
119
+
@AIToolParam("The absolute path of the text file to write to.") Stringpath,
120
120
@AIToolParam("The new content to write to the file.") Stringcontent,
121
121
@AIToolParam("The expected 'last modified' timestamp of the file on disk. The write will fail if the actual timestamp is different.") longlastModified
122
122
) throwsIOException {
@@ -125,12 +125,12 @@ public static FileInfo writeFile(
thrownewIOException("File modification conflict. The file at " + path
128
+
thrownewIOException("File modification conflict. The text file at " + path
129
129
+ " was modified on disk after it was read. Expected timestamp: " + lastModified
130
130
+ ", but found: " + currentLastModified);
131
131
}
132
132
} elseif (lastModified > 0) {
133
-
thrownewIOException("File modification conflict. The file at " + path
133
+
thrownewIOException("File modification conflict. The text file at " + path
134
134
+ " was expected to exist with timestamp " + lastModified + " but it has been deleted.");
135
135
}
136
136
@@ -140,21 +140,21 @@ public static FileInfo writeFile(
140
140
}
141
141
142
142
/**
143
-
* Creates a new file with the given content.
143
+
* Creates a new text file with the given content.
144
144
*
145
145
* @param path The absolute path to the file.
146
146
* @param content The initial content.
147
147
* @return A FileInfo object for the new file.
148
148
* @throws IOException if the path already exists.
149
149
*/
150
-
@AIToolMethod(value = "Creates a new file with the given content, creating parent directories if necessary. Throws an IOException if a file or directory already exists at the specified path.", behavior = ContextBehavior.STATEFUL_REPLACE)
150
+
@AIToolMethod(value = "Creates a new text file with the given content, creating parent directories if necessary. Throws an IOException if a file or directory already exists at the specified path.", behavior = ContextBehavior.STATEFUL_REPLACE)
151
151
publicstaticFileInfocreateFile(
152
-
@AIToolParam("The absolute path of the file to create.") Stringpath,
152
+
@AIToolParam("The absolute path of the text file to create.") Stringpath,
153
153
@AIToolParam("The initial content to write to the file. Can be empty.") Stringcontent
0 commit comments