MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / lineChunk

Function lineChunk

src/context/ast-chunk.ts:101–112  ·  view source on GitHub ↗
(rel: string, content: string, chunkLines = 40, overlap = 8)

Source from the content-addressed store, hash-verified

99
100/** Line-based fallback — identical semantics to the original chunkFile. */
101export function lineChunk(rel: string, content: string, chunkLines = 40, overlap = 8): Chunk[] {
102 const lines = content.split('\n');
103 const out: Chunk[] = [];
104 for (let i = 0; i < lines.length; i += (chunkLines - overlap)) {
105 const start = i;
106 const end = Math.min(i + chunkLines, lines.length);
107 if (end - start < 4) continue;
108 out.push(mkChunk(rel, lines, start, end));
109 if (end >= lines.length) break;
110 }
111 return out;
112}
113
114/**
115 * Chunk a file on AST boundaries. Falls back to line chunking on any failure.

Callers 1

astChunkFileFunction · 0.85

Calls 2

mkChunkFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected