@@ -56,9 +56,7 @@ export class JsonYamlChunker {
5656 const chunks = this . chunkStructuredData ( data , [ ] , 0 )
5757
5858 const totalTokens = chunks . reduce ( ( sum , c ) => sum + c . tokenCount , 0 )
59- logger . info (
60- `JSON chunking complete: ${ chunks . length } chunks, ${ totalTokens } total tokens`
61- )
59+ logger . info ( `JSON chunking complete: ${ chunks . length } chunks, ${ totalTokens } total tokens` )
6260
6361 return chunks
6462 } catch ( error ) {
@@ -84,11 +82,13 @@ export class JsonYamlChunker {
8482 return [ ]
8583 }
8684
87- return [ {
88- text : content ,
89- tokenCount : estimateTokens ( content ) ,
90- metadata : { startIndex : 0 , endIndex : content . length } ,
91- } ]
85+ return [
86+ {
87+ text : content ,
88+ tokenCount : estimateTokens ( content ) ,
89+ metadata : { startIndex : 0 , endIndex : content . length } ,
90+ } ,
91+ ]
9292 }
9393
9494 /**
@@ -108,7 +108,9 @@ export class JsonYamlChunker {
108108
109109 if ( itemTokens > this . chunkSize ) {
110110 if ( currentBatch . length > 0 ) {
111- chunks . push ( this . buildBatchChunk ( contextHeader , currentBatch , i - currentBatch . length , i - 1 ) )
111+ chunks . push (
112+ this . buildBatchChunk ( contextHeader , currentBatch , i - currentBatch . length , i - 1 )
113+ )
112114 currentBatch = [ ]
113115 currentTokens = 0
114116 }
@@ -123,7 +125,9 @@ export class JsonYamlChunker {
123125 } )
124126 }
125127 } else if ( currentTokens + itemTokens > this . chunkSize && currentBatch . length > 0 ) {
126- chunks . push ( this . buildBatchChunk ( contextHeader , currentBatch , i - currentBatch . length , i - 1 ) )
128+ chunks . push (
129+ this . buildBatchChunk ( contextHeader , currentBatch , i - currentBatch . length , i - 1 )
130+ )
127131 currentBatch = [ item ]
128132 currentTokens = itemTokens
129133 } else {
@@ -133,7 +137,14 @@ export class JsonYamlChunker {
133137 }
134138
135139 if ( currentBatch . length > 0 ) {
136- chunks . push ( this . buildBatchChunk ( contextHeader , currentBatch , arr . length - currentBatch . length , arr . length - 1 ) )
140+ chunks . push (
141+ this . buildBatchChunk (
142+ contextHeader ,
143+ currentBatch ,
144+ arr . length - currentBatch . length ,
145+ arr . length - 1
146+ )
147+ )
137148 }
138149
139150 return chunks
@@ -152,11 +163,13 @@ export class JsonYamlChunker {
152163 if ( fullTokens <= this . chunkSize ) {
153164 const contextHeader = path . length > 0 ? `// ${ path . join ( '.' ) } \n` : ''
154165 const text = contextHeader + fullContent
155- return [ {
156- text,
157- tokenCount : estimateTokens ( text ) ,
158- metadata : { startIndex : 0 , endIndex : text . length } ,
159- } ]
166+ return [
167+ {
168+ text,
169+ tokenCount : estimateTokens ( text ) ,
170+ metadata : { startIndex : 0 , endIndex : text . length } ,
171+ } ,
172+ ]
160173 }
161174
162175 const contextHeader = path . length > 0 ? `// ${ path . join ( '.' ) } \n` : ''
@@ -188,7 +201,10 @@ export class JsonYamlChunker {
188201 metadata : { startIndex : 0 , endIndex : valueStr . length } ,
189202 } )
190203 }
191- } else if ( currentTokens + valueTokens > this . chunkSize && Object . keys ( currentObj ) . length > 0 ) {
204+ } else if (
205+ currentTokens + valueTokens > this . chunkSize &&
206+ Object . keys ( currentObj ) . length > 0
207+ ) {
192208 const objContent = contextHeader + JSON . stringify ( currentObj , null , 2 )
193209 chunks . push ( {
194210 text : objContent ,
@@ -218,7 +234,12 @@ export class JsonYamlChunker {
218234 /**
219235 * Build a chunk from a batch of array items
220236 */
221- private buildBatchChunk ( contextHeader : string , batch : JsonValue [ ] , startIdx : number , endIdx : number ) : Chunk {
237+ private buildBatchChunk (
238+ contextHeader : string ,
239+ batch : JsonValue [ ] ,
240+ startIdx : number ,
241+ endIdx : number
242+ ) : Chunk {
222243 const batchContent = contextHeader + JSON . stringify ( batch , null , 2 )
223244 return {
224245 text : batchContent ,
0 commit comments