MCPcopy Create free account
hub / github.com/openai/plugins / visitSnapshot

Function visitSnapshot

plugins/plugin-eval/src/core/benchmark-workspace.js:183–215  ·  view source on GitHub ↗
(rootPath, currentPath, entries)

Source from the content-addressed store, hash-verified

181}
182
183async function visitSnapshot(rootPath, currentPath, entries) {
184 const directoryEntries = await fs.readdir(currentPath, { withFileTypes: true });
185
186 for (const entry of directoryEntries) {
187 const entryPath = path.join(currentPath, entry.name);
188 const relativeEntryPath = relativePath(rootPath, entryPath);
189
190 if (entry.isDirectory()) {
191 if (SNAPSHOT_IGNORED_DIRS.has(entry.name)) {
192 continue;
193 }
194 await visitSnapshot(rootPath, entryPath, entries);
195 continue;
196 }
197
198 if (!entry.isFile()) {
199 continue;
200 }
201
202 const stats = await fs.stat(entryPath);
203 const isText = isProbablyTextFile(entryPath);
204 const text = isText ? await readText(entryPath) : null;
205
206 entries.set(relativeEntryPath, {
207 path: relativeEntryPath,
208 absolutePath: entryPath,
209 size: stats.size,
210 hash: await hashFile(entryPath),
211 isText,
212 lineCount: text === null ? null : text.replace(/\r\n/g, "\n").split("\n").length,
213 });
214 }
215}
216
217export async function snapshotWorkspace(rootPath) {
218 const entries = new Map();

Callers 1

snapshotWorkspaceFunction · 0.85

Calls 7

relativePathFunction · 0.90
isProbablyTextFileFunction · 0.90
readTextFunction · 0.90
hashFileFunction · 0.85
statMethod · 0.80
setMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected