@@ -3,6 +3,7 @@ import { Cline } from "../Cline"
33import { ClineSayTool } from "../../shared/ExtensionMessage"
44import { ToolUse } from "../assistant-message"
55import { formatResponse } from "../prompts/responses"
6+ import { t } from "../../i18n"
67import { AskApproval , HandleError , PushToolResult , RemoveClosingTag } from "./types"
78import { isPathOutsideWorkspace } from "../../utils/pathUtils"
89import { getReadablePath } from "../../utils/path"
@@ -97,21 +98,36 @@ export async function readFileTool(
9798 break
9899 }
99100
101+ const { maxReadFileLine = 500 } = ( await cline . providerRef . deref ( ) ?. getState ( ) ) ?? { }
102+
103+ // Create line snippet description for approval message
104+ let lineSnippet = ""
105+ if ( startLine !== undefined && endLine !== undefined ) {
106+ lineSnippet = t ( "tools:readFile.linesRange" , { start : startLine + 1 , end : endLine + 1 } )
107+ } else if ( startLine !== undefined ) {
108+ lineSnippet = t ( "tools:readFile.linesFromToEnd" , { start : startLine + 1 } )
109+ } else if ( endLine !== undefined ) {
110+ lineSnippet = t ( "tools:readFile.linesFromStartTo" , { end : endLine + 1 } )
111+ } else if ( maxReadFileLine === 0 ) {
112+ lineSnippet = t ( "tools:readFile.definitionsOnly" )
113+ } else if ( maxReadFileLine > 0 ) {
114+ lineSnippet = t ( "tools:readFile.maxLines" , { max : maxReadFileLine } )
115+ }
116+
100117 cline . consecutiveMistakeCount = 0
101118 const absolutePath = path . resolve ( cline . cwd , relPath )
119+
102120 const completeMessage = JSON . stringify ( {
103121 ...sharedMessageProps ,
104122 content : absolutePath ,
123+ reason : lineSnippet ,
105124 } satisfies ClineSayTool )
106125
107126 const didApprove = await askApproval ( "tool" , completeMessage )
108127 if ( ! didApprove ) {
109128 break
110129 }
111130
112- // Get the maxReadFileLine setting
113- const { maxReadFileLine = 500 } = ( await cline . providerRef . deref ( ) ?. getState ( ) ) ?? { }
114-
115131 // Count total lines in the file
116132 let totalLines = 0
117133 try {
0 commit comments