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

Function walkFiles

plugins/plugin-eval/src/lib/files.js:125–155  ·  view source on GitHub ↗
(rootPath, options = {})

Source from the content-addressed store, hash-verified

123}
124
125export async function walkFiles(rootPath, options = {}) {
126 const files = [];
127 const {
128 excludeDirs = [],
129 skipTopLevel = ["fixtures", "__fixtures__"],
130 } = options;
131 const excluded = new Set([...IGNORED_DIRS, ...excludeDirs]);
132
133 async function visit(currentPath, depth = 0) {
134 const entries = await fs.readdir(currentPath, { withFileTypes: true });
135 for (const entry of entries) {
136 const entryPath = path.join(currentPath, entry.name);
137 if (entry.isDirectory()) {
138 if (excluded.has(entry.name)) {
139 continue;
140 }
141 if (depth === 0 && skipTopLevel.includes(entry.name)) {
142 continue;
143 }
144 await visit(entryPath, depth + 1);
145 continue;
146 }
147 if (entry.isFile()) {
148 files.push(entryPath);
149 }
150 }
151 }
152
153 await visit(rootPath);
154 return files.sort();
155}
156
157export async function listImmediateDirectories(rootPath) {
158 const entries = await fs.readdir(rootPath, { withFileTypes: true });

Callers 3

gatherDeferredTextFilesFunction · 0.90
analyzeCodeMetricsFunction · 0.90
evaluateSkillFunction · 0.90

Calls 1

visitFunction · 0.70

Tested by

no test coverage detected