MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / walk

Function walk

apps/kimi-code/src/feedback/codebase/scanner.ts:130–165  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

128 let totalSize = 0;
129
130 async function walk(dir: string): Promise<void> {
131 if (stopped) return;
132 throwIfAborted(signal);
133 const entries = await readdir(dir, { withFileTypes: true });
134 for (const entry of entries) {
135 if (stopped) return;
136 throwIfAborted(signal);
137 if (files.length >= limits.maxFiles) {
138 exceedsLimit = { reason: 'file-count', limit: limits.maxFiles };
139 stopped = true;
140 return;
141 }
142 if (entry.isSymbolicLink()) continue;
143 const absolutePath = join(dir, entry.name);
144 if (entry.isDirectory()) {
145 if (isIgnoredDirName(entry.name)) continue;
146 await walk(absolutePath);
147 if (stopped) return;
148 continue;
149 }
150 if (!entry.isFile()) continue;
151 const relativePath = toPosixPath(relative(root, absolutePath));
152 if (isSensitivePath(relativePath)) continue;
153 const file = await statFile(root, relativePath);
154 if (file) {
155 if (file.size > limits.maxFileSize) continue;
156 if (totalSize + file.size > limits.maxArchiveSize) {
157 exceedsLimit = { reason: 'total-size', limit: limits.maxArchiveSize };
158 stopped = true;
159 return;
160 }
161 files.push(file);
162 totalSize += file.size;
163 }
164 }
165 }
166
167 await walk(root);
168 return { files, exceedsLimit };

Callers 1

scanWithoutFilterFunction · 0.70

Calls 7

isIgnoredDirNameFunction · 0.90
isSensitivePathFunction · 0.90
statFileFunction · 0.85
throwIfAbortedFunction · 0.70
toPosixPathFunction · 0.70
readdirFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected