Compare commits

...
Author SHA1 Message Date
pashpashpash 4443f3e933 formatted read file tool 2025-04-09 11:21:57 -07:00
pashpashpash cc4035141a formatted index 2025-04-09 11:21:26 -07:00
2 changed files with 29 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": minor
---
formatted read files tool
+24 -2
View File
@@ -1957,12 +1957,34 @@ export class Task {
// Track file read operation
await this.fileContextTracker.trackFileContext(relPath, "read_tool")
pushToolResult(content)
// Format the result as XML
let xmlResult: string
if (content === "") {
// Empty file case
xmlResult = `<file><path>${relPath}</path><content/><notice>File is empty</notice></file>`
} else {
// Normal file with content
xmlResult = `<file><path>${relPath}</path><content>\n${content}\n</content></file>`
}
pushToolResult(xmlResult)
break
}
} catch (error) {
await handleError("reading file", error)
const errorMessage = error instanceof Error ? error.message : JSON.stringify(serializeError(error))
// Show error in UI (similar to what handleError would do)
await this.say(
"error",
`Error reading file:\n${errorMessage ?? JSON.stringify(serializeError(error), null, 2)}`,
)
// Ensure relPath is defined for the XML, even in error cases
const safeRelPath = relPath || "unknown_path"
// Format error as XML without content tag
const errorXml = `<file><path>${safeRelPath}</path><error>${errorMessage}</error></file>`
pushToolResult(errorXml)
break
}