Repository navigation
Description
Summary
The workspace scans in detect_framework and read_workspace_context skip files under node_modules and .git but never prune those directories, so os.walk still traverses them. detect_framework also walks the whole tree twice, and the substring test ".git" in root wrongly skips directories such as .github.
Where
mcp-server/tools/detect_framework.py:67-68(_scan_manifeststhen_scan_code)mcp-server/tools/detect_framework.py:114-116(_scan_manifests)mcp-server/tools/detect_framework.py:143-145(_scan_code)mcp-server/tools/manifest_common.py:61-63(read_workspace_context)
Details
for root, _dirs, files in os.walk(workspace_path):
if "node_modules" in root or ".git" in root:
continuecontinueskips the files at that level, but_dirsis never edited, so every directory undernode_modulesand.gitis still visited.detect_frameworkcalls two functions that each do a fullos.walkof the same tree.read_workspace_context(used by the scaffolder and manifest generator) has the same pattern and walks the whole tree whenever no manifest declares anauthor.".git" in rootis a substring check on the full path. It also matches.github,.gitlab, and any workspace path that itself contains.git(for example a folder namedfoo.github.io), in which case every file is skipped.- Nothing bounds the walk, so pointing the tool at a very large directory makes the call slow.
Impact
Resources with NUI builds commonly contain node_modules with tens of thousands of directories, so framework detection and workspace-aware scaffolding pay for a full traversal (twice for detection) on the single-threaded stdio server. The substring bug silently drops signals and can make detection report "standalone" for every resource in a path containing .git.
Steps to reproduce
- Create a workspace with an
fxmanifest.luaand a largeweb/node_modulestree. - Time
detect_framework(<dir>)and instrumentos.walk: directories undernode_modulesare visited twice. - Put a resource under a folder named
x.github.ioand rundetect_frameworkon it: no signals are found.
Suggested fix
- At the top of each walk, prune in place by exact name:
dirs[:] = [d for d in dirs if d not in {"node_modules", ".git", "dist", "build", ".venv"}], and drop the substring check onroot. - Merge
_scan_manifestsand_scan_codeinto one walk that handles bothfxmanifest.luaand code extensions. - Optionally cap the number of files or directories scanned and note it in the output when the cap is hit.
Acceptance criteria
- No walk descends into
node_modules,.gitor the other excluded directory names. -
detect_frameworktraverses the tree once. - Directories such as
.githuband paths containing.gitas a substring are scanned normally.
Getting started
- Relevant files:
mcp-server/tools/detect_framework.py,mcp-server/tools/manifest_common.py - How to run checks: there is no test suite yet; run the MCP server with
cd mcp-server && pip install -r requirements.txt && python server.py, and CI checks live in.github/workflows/validate.yml - Related docs: Python
os.walkdocumentation (in-place pruning ofdirnames)
Filed by repo-audit/full-audit at 701824d. Severity: medium. Effort: S. audit-key: performance|mcp-server/tools/detect_framework.py|os.walk pruning
Activity
TMHSDigital commentedon Nov 21, 2026
Fixed in 66f04fe.
Added walk_workspace(), which prunes node_modules, .git, dist, build, virtualenvs and pycache by exact name before descending; detect_framework now scores manifests and code in a single walk, and read_workspace_context uses the same walk.
Verified: New tests assert exactly one os.walk traversal, that pruned directories are never visited, and that .github and paths containing ".git" (for example my.github.io) are scanned.