@@ -14,7 +14,7 @@ import { readLines } from "../../integrations/misc/read-lines"
1414import { extractTextFromFile , addLineNumbers , getSupportedBinaryFormats } from "../../integrations/misc/extract-text"
1515import { parseSourceCodeDefinitionsForFile } from "../../services/tree-sitter"
1616import { parseXml } from "../../utils/xml"
17- import { blockFileReadWhenTooLarge } from "./kilocode"
17+ import { blockFileReadWhenTooLarge , getNativeReadFileToolDescription , parseNativeFiles } from "./kilocode"
1818import {
1919 DEFAULT_MAX_IMAGE_FILE_SIZE_MB ,
2020 DEFAULT_MAX_TOTAL_IMAGE_SIZE_MB ,
@@ -26,7 +26,11 @@ import {
2626
2727export function getReadFileToolDescription ( blockName : string , blockParams : any ) : string {
2828 // Handle both single path and multiple files via args
29- if ( blockParams . args ) {
29+ // kilocode_change start
30+ if ( blockParams . files && Array . isArray ( blockParams . files ) ) {
31+ return getNativeReadFileToolDescription ( blockName , parseNativeFiles ( blockParams . files ) )
32+ // kilocode_change end
33+ } else if ( blockParams . args ) {
3034 try {
3135 const parsed = parseXml ( blockParams . args ) as any
3236 const files = Array . isArray ( parsed . file ) ? parsed . file : [ parsed . file ] . filter ( Boolean )
@@ -131,28 +135,7 @@ export async function readFileTool(
131135 // kilocode_change start
132136 // Handle native JSON format first (from OpenAI-style tool calls)
133137 if ( nativeFiles && Array . isArray ( nativeFiles ) ) {
134- for ( const file of nativeFiles ) {
135- if ( ! file . path ) continue
136-
137- const fileEntry : FileEntry = {
138- path : file . path ,
139- lineRanges : [ ] ,
140- }
141-
142- // Handle line_ranges array from native format
143- if ( file . line_ranges && Array . isArray ( file . line_ranges ) ) {
144- for ( const range of file . line_ranges ) {
145- const match = String ( range ) . match ( / ( \d + ) - ( \d + ) / )
146- if ( match ) {
147- const [ , start , end ] = match . map ( Number )
148- if ( ! isNaN ( start ) && ! isNaN ( end ) ) {
149- fileEntry . lineRanges ?. push ( { start, end } )
150- }
151- }
152- }
153- }
154- fileEntries . push ( fileEntry )
155- }
138+ fileEntries . push ( ...parseNativeFiles ( nativeFiles ) )
156139 // kilocode_change end
157140 } else if ( argsXmlTag ) {
158141 // Parse file entries from XML (new multi-file format)
0 commit comments