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:
Vectry
2026-02-09 16:21:21 +00:00
parent 79dad6124f
commit d0c4b1ae28
5 changed files with 988 additions and 4 deletions

View File

@@ -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;