mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-01 23:43:16 +01:00
Batch dependency Markdown reads through the bounded Git snapshot reader and queue newly discovered dependencies once. Preserve package contents, limits, authorization, audits, and reference order. Validation: 63 affected cases; full typecheck/build; exact-head full CI, E2E, Superagent and Apex 5/5. Local Git comparison: 502 individual reads reduced to three batches with identical entries. Co-Authored-By: Paperclip <noreply@paperclip.ing>
23 lines
1.4 KiB
TypeScript
23 lines
1.4 KiB
TypeScript
import { expect, it, vi } from 'vitest';
|
|
import { skillRepositoryDependencies } from '../services/skill-repository-dependencies.js';
|
|
import { MAX_REPOSITORY_FILES } from '../services/skill-repository-package.js';
|
|
import type { GitSkillTreeEntry } from '../services/skill-source-git-snapshot.js';
|
|
|
|
it('keeps path visits bounded for a reference chain at the repository file limit', async () => {
|
|
let pathVisits = 0;
|
|
const paths = ['skills/main/SKILL.md', ...Array.from({ length: MAX_REPOSITORY_FILES - 1 }, (_, i) => `shared/${i}.md`)];
|
|
const entries: GitSkillTreeEntry[] = paths.map((name, i) => ({
|
|
get path() { pathVisits++; return name; },
|
|
sha: i.toString(16).padStart(40, '0'), mode: '100644', type: 'blob', size: 100,
|
|
}));
|
|
const content = new Map(paths.map((name, i) => [name, Buffer.from(i === 0 ? '[Next](../../shared/0.md)'
|
|
: `[Next](${i === paths.length - 1 ? '0' : String(i)}.md)`)]));
|
|
const read = vi.fn(async (entry: GitSkillTreeEntry) => content.get(entry.path)!);
|
|
const prefetch = vi.fn(async () => {});
|
|
const selected = await skillRepositoryDependencies(entries, [entries[0]!], new Set(['skills/main']), read, prefetch);
|
|
expect(selected).toEqual(entries);
|
|
expect(read).toHaveBeenCalledTimes(MAX_REPOSITORY_FILES);
|
|
expect(prefetch).toHaveBeenCalledTimes(MAX_REPOSITORY_FILES);
|
|
expect(pathVisits).toBeLessThan(MAX_REPOSITORY_FILES * 100);
|
|
});
|