nano-brain 2026.3.4 → 2026.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/chunker.ts +8 -0
- package/test/chunker.test.ts +2 -6
- package/test/codebase-chunker.test.ts +2 -3
package/package.json
CHANGED
package/src/chunker.ts
CHANGED
|
@@ -144,6 +144,10 @@ export function chunkMarkdown(
|
|
|
144
144
|
const overlap = options?.overlap ?? 540;
|
|
145
145
|
const windowSize = 800;
|
|
146
146
|
|
|
147
|
+
if (content.trim().length === 0) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
|
|
147
151
|
if (content.length <= maxChunkSize) {
|
|
148
152
|
return [{
|
|
149
153
|
hash,
|
|
@@ -331,6 +335,10 @@ export function chunkSourceCode(
|
|
|
331
335
|
const overlap = options?.overlap ?? 540
|
|
332
336
|
const windowSize = 800
|
|
333
337
|
|
|
338
|
+
if (content.trim().length === 0) {
|
|
339
|
+
return []
|
|
340
|
+
}
|
|
341
|
+
|
|
334
342
|
const relativePath = path.relative(workspaceRoot, filePath)
|
|
335
343
|
const language = inferLanguage(filePath)
|
|
336
344
|
|
package/test/chunker.test.ts
CHANGED
|
@@ -258,10 +258,7 @@ describe('chunkMarkdown - basic', () => {
|
|
|
258
258
|
const hash = 'test-hash';
|
|
259
259
|
const chunks = chunkMarkdown(content, hash);
|
|
260
260
|
|
|
261
|
-
expect(chunks.length).toBe(
|
|
262
|
-
expect(chunks[0].text).toBe('');
|
|
263
|
-
expect(chunks[0].startLine).toBe(1);
|
|
264
|
-
expect(chunks[0].endLine).toBe(1);
|
|
261
|
+
expect(chunks.length).toBe(0);
|
|
265
262
|
});
|
|
266
263
|
|
|
267
264
|
it('handles single line', () => {
|
|
@@ -432,8 +429,7 @@ describe('chunkMarkdown - edge cases', () => {
|
|
|
432
429
|
const hash = 'test-hash';
|
|
433
430
|
const chunks = chunkMarkdown(content, hash);
|
|
434
431
|
|
|
435
|
-
expect(chunks.length).toBe(
|
|
436
|
-
expect(chunks[0].text).toBe(content);
|
|
432
|
+
expect(chunks.length).toBe(0);
|
|
437
433
|
});
|
|
438
434
|
|
|
439
435
|
it('handles content with no break points', () => {
|
|
@@ -393,8 +393,7 @@ describe('chunkSourceCode', () => {
|
|
|
393
393
|
const hash = 'test-hash';
|
|
394
394
|
const chunks = chunkSourceCode(content, hash, '/workspace/file.ts', '/workspace');
|
|
395
395
|
|
|
396
|
-
expect(chunks.length).toBe(
|
|
397
|
-
expect(chunks[0].text).toContain('File:');
|
|
396
|
+
expect(chunks.length).toBe(0);
|
|
398
397
|
});
|
|
399
398
|
|
|
400
399
|
it('should handle single line content', () => {
|
|
@@ -411,7 +410,7 @@ describe('chunkSourceCode', () => {
|
|
|
411
410
|
const hash = 'test-hash';
|
|
412
411
|
const chunks = chunkSourceCode(content, hash, '/workspace/file.ts', '/workspace');
|
|
413
412
|
|
|
414
|
-
expect(chunks.length).toBe(
|
|
413
|
+
expect(chunks.length).toBe(0);
|
|
415
414
|
});
|
|
416
415
|
|
|
417
416
|
it('should handle file at workspace root', () => {
|