test: add integration tests for clone/parse/pipeline, fix chunker edge case
- tests/integration-test.ts: clones p-limit repo, parses, generates diagrams (11/11 pass) - tests/pipeline-test.ts: mock LLM provider pipeline test (29/29 pass) - Fix chunkCode to handle single lines exceeding maxChars limit - Add tsx devDependency for test execution
This commit is contained in:
@@ -12,10 +12,21 @@ export function chunkCode(content: string, maxTokens: number): string[] {
|
||||
let currentLen = 0;
|
||||
|
||||
for (const line of lines) {
|
||||
if (currentLen + line.length > maxChars && current.length > 0) {
|
||||
chunks.push(current.join("\n"));
|
||||
current = [];
|
||||
currentLen = 0;
|
||||
if (currentLen + line.length > maxChars) {
|
||||
if (current.length > 0) {
|
||||
chunks.push(current.join("\n"));
|
||||
current = [];
|
||||
currentLen = 0;
|
||||
}
|
||||
if (line.length > maxChars) {
|
||||
let remaining = line;
|
||||
while (remaining.length > 0) {
|
||||
const chunk = remaining.substring(0, maxChars);
|
||||
chunks.push(chunk);
|
||||
remaining = remaining.substring(maxChars);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
current.push(line);
|
||||
currentLen += line.length + 1;
|
||||
|
||||
Reference in New Issue
Block a user