chore(clean up): remove unused imports, unnecessary object impls, concurrency/coroutine issues, trailing commas, etc.
This commit is contained in:
+8
-3
@@ -24,6 +24,7 @@ import kotlinx.serialization.json.buildJsonArray
|
||||
import kotlinx.serialization.json.buildJsonObject
|
||||
import kotlinx.serialization.json.put
|
||||
import kotlinx.serialization.json.putJsonObject
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
@@ -40,7 +41,7 @@ class FileWriteTool(
|
||||
) : Tool, FileAffectingTool, ToolExecutor {
|
||||
|
||||
private companion object {
|
||||
val log = LoggerFactory.getLogger(FileWriteTool::class.java)
|
||||
val log: Logger = LoggerFactory.getLogger(FileWriteTool::class.java)
|
||||
}
|
||||
|
||||
private val normalizedAllowedPaths: Set<Path> = allowedPaths.map { it.normalize().toAbsolutePath() }.toSet()
|
||||
@@ -172,7 +173,9 @@ class FileWriteTool(
|
||||
): ToolResult = when (operation) {
|
||||
"write" -> {
|
||||
val content = request.parameters["content"] as String
|
||||
Files.writeString(path, content)
|
||||
withContext(Dispatchers.IO) {
|
||||
Files.writeString(path, content)
|
||||
}
|
||||
storeArtifact(pathString, content, request.parameters["mode"] as? String ?: "0644")
|
||||
ToolResult.Success(
|
||||
invocationId = request.invocationId,
|
||||
@@ -182,7 +185,9 @@ class FileWriteTool(
|
||||
|
||||
"delete" -> {
|
||||
if (Files.exists(path)) {
|
||||
Files.deleteIfExists(path)
|
||||
withContext(Dispatchers.IO) {
|
||||
Files.deleteIfExists(path)
|
||||
}
|
||||
ToolResult.Success(
|
||||
invocationId = request.invocationId,
|
||||
output = "File deleted successfully: $pathString",
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ class FileWriteToolTest {
|
||||
|
||||
assertTrue(result is ToolResult.Success)
|
||||
val success = result as ToolResult.Success
|
||||
assertEquals("File written successfully to ${filePath}", success.output)
|
||||
assertEquals("File written successfully to $filePath", success.output)
|
||||
assertEquals(invocationId, success.invocationId)
|
||||
assertEquals(content, Files.readString(filePath))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user