Skip to content

Commit 85f37b2

Browse files
committed
feat(read_file): enhance file reading capabilities with multi-file support and improved parameter handling
fix(read_file): change return to continue on approval rejection in readFileTool Enhance readFileTool with improved error handling and validation - Introduced a FileEntry interface for better type management. - Added validation for start_line and end_line to ensure proper ranges. - Implemented RooIgnore validation before processing files. - Enhanced error handling with dedicated functions for file and global errors. - Streamlined file reading logic to handle binary files, definitions-only mode, and line thresholds more effectively. - Improved user feedback for empty files and read limits. chore: update Jest snapshot for system prompt tool usage Refactor read-file tool to support XML input format and multiple line ranges - Updated the `getReadFileDescription` function to reflect new XML structure for file reading requests. - Modified `readFileTool` to parse XML input, allowing multiple line ranges for each file. - Removed old parsing logic that handled line ranges as separate parameters. - Implemented validation for line ranges and ensured proper error handling for file access. - Adjusted approval messaging to accommodate new line range format. - Enhanced error handling to provide consistent feedback for file read errors. update from KJ7LNW comment feat: add maxConcurrentFileReads setting to enhance read_file tool performance feat: enhance readFileTool with XML parsing and file processing state tracking feat: enhance readFileTool to include user feedback handling and processing state tracking chore: clean up read_file tool documentation by removing extra newlines feat: update read_file tool tests to handle user feedback and approval states feat: add tests for feedback message formatting and XML special character handling in read_file tool Implement code changes to enhance functionality and improve performance feat: increase max concurrent file reads and adjust slider range in settings feat: increase default max concurrent file reads from 5 to 15 across settings and context management
1 parent 8447670 commit 85f37b2

40 files changed

+1810
-848
lines changed

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { checkpointSave } from "../checkpoints"
3232
import { formatResponse } from "../prompts/responses"
3333
import { validateToolUse } from "../tools/validateToolUse"
3434
import { Task } from "../task/Task"
35+
import { parseXml } from "../../utils/xml"
3536

3637
/**
3738
* Processes and presents assistant message content to the user interface.
@@ -153,8 +154,35 @@ export async function presentAssistantMessage(cline: Task) {
153154
switch (block.name) {
154155
case "execute_command":
155156
return `[${block.name} for '${block.params.command}']`
156-
case "read_file":
157-
return `[${block.name} for '${block.params.path}']`
157+
case "read_file": {
158+
// Handle both single path and multiple files via args
159+
if (block.params.args) {
160+
try {
161+
const parsed = parseXml(block.params.args) as any
162+
const files = Array.isArray(parsed.file) ? parsed.file : [parsed.file].filter(Boolean)
163+
const paths = files.map((f: any) => f?.path).filter(Boolean) as string[]
164+
165+
if (paths.length === 0) {
166+
return `[${block.name} with no valid paths]`
167+
} else if (paths.length === 1) {
168+
return `[${block.name} for '${paths[0]}']`
169+
} else if (paths.length <= 3) {
170+
const pathList = paths.map((p) => `'${p}'`).join(", ")
171+
return `[${block.name} for ${pathList}]`
172+
} else {
173+
return `[${block.name} for ${paths.length} files]`
174+
}
175+
} catch (error) {
176+
console.error("Failed to parse read_file args XML for description:", error)
177+
return `[${block.name} with unparseable args]`
178+
}
179+
} else if (block.params.path) {
180+
// Fallback for legacy single-path usage
181+
return `[${block.name} for '${block.params.path}']`
182+
} else {
183+
return `[${block.name} with missing path/args]`
184+
}
185+
}
158186
case "fetch_instructions":
159187
return `[${block.name} for '${block.params.task}']`
160188
case "write_to_file":

0 commit comments

Comments
 (0)