fix: update remaining truncation notices with concrete line_range examples

This commit is contained in:
Roo Code 2025-12-21 16:40:06 +00:00
parent 5bf4eec3d8
commit 6e9486964e
2 changed files with 6 additions and 5 deletions

View file

@ -458,7 +458,7 @@ export class ReadFileTool extends BaseTool<"read_file"> {
task.rooIgnoreController,
)
if (defResult) {
const notice = `Showing only ${maxReadFileLine} of ${totalLines} total lines. Use line_range if you need to read more lines`
const notice = `Showing code definitions only (0 of ${totalLines} total lines). To read file content, use the read_file tool with line_range (e.g., <line_range>1-${Math.min(500, totalLines)}</line_range>)`
updateFileResult(relPath, {
xmlContent: `<file><path>${relPath}</path>\n<list_code_definition_names>${defResult}</list_code_definition_names>\n<notice>${notice}</notice>\n</file>`,
nativeContent: `File: ${relPath}\nCode Definitions:\n${defResult}\n\nNote: ${notice}`,
@ -493,7 +493,8 @@ export class ReadFileTool extends BaseTool<"read_file"> {
nativeInfo += `\nCode Definitions:\n${truncatedDefs}\n`
}
const notice = `Showing only ${maxReadFileLine} of ${totalLines} total lines. Use line_range if you need to read more lines`
const nextLine = maxReadFileLine + 1
const notice = `File truncated at line ${maxReadFileLine} of ${totalLines} total lines. To continue reading, use the read_file tool again with line_range starting at line ${nextLine} (e.g., <line_range>${nextLine}-${Math.min(nextLine + 499, totalLines)}</line_range>)`
xmlInfo += `<notice>${notice}</notice>\n`
nativeInfo += `\nNote: ${notice}`

View file

@ -423,7 +423,7 @@ describe("read_file tool with maxReadFileLine setting", () => {
expect(result).toContain(`<list_code_definition_names>`)
// Verify XML structure
expect(result).toContain("<notice>Showing only 0 of 5 total lines")
expect(result).toContain("<notice>Showing code definitions only (0 of 5 total lines)")
expect(result).toContain("</notice>")
expect(result).toContain("<list_code_definition_names>")
expect(result).toContain(sourceCodeDef.trim())
@ -450,7 +450,7 @@ describe("read_file tool with maxReadFileLine setting", () => {
expect(result).toContain(`<file><path>${testFilePath}</path>`)
expect(result).toContain(`<content lines="1-3">`)
expect(result).toContain(`<list_code_definition_names>`)
expect(result).toContain("<notice>Showing only 3 of 5 total lines")
expect(result).toContain("<notice>File truncated at line 3 of 5 total lines")
})
it("should truncate code definitions when file exceeds maxReadFileLine", async () => {
@ -481,7 +481,7 @@ describe("read_file tool with maxReadFileLine setting", () => {
expect(result).not.toContain("50--60 | function bar()")
expect(result).not.toContain("80--90 | function baz()")
expect(result).toContain("<notice>Showing only 30 of 100 total lines")
expect(result).toContain("<notice>File truncated at line 30 of 100 total lines")
})
it("should handle truncation when all definitions are beyond the line limit", async () => {