Skip hidden directories in recursive skill loading#1875
Conversation
There was a problem hiding this comment.
Review Summary
✅ This PR effectively optimizes directory traversal by skipping hidden directories like .git, .node_modules, and .cache early using fs.SkipDir. The logic correctly handles the root directory edge case.
Note
One minor behavioral change: the refactored code no longer filters out hidden or symlinked skill files (e.g., .SKILL.md or symlinked SKILL.md), only hidden directories. The original code checked isHiddenOrSymlink(d) for both directories and files, but the new code only applies this check to directories (line 222). This may be intentional since hidden skill files are rare, but it's worth noting the behavior change.
|
I'm not sure about symlinks though, seems like something someone would do |
Return fs.SkipDir for hidden directories and symlinks instead of descending into them. This avoids walking large trees like .git, .node_modules, or .cache that can never contain skills. Assisted-By: cagent
Signed-off-by: David Gageot <david.gageot@docker.com>
| var skills []Skill | ||
| for _, entry := range entries { | ||
| if !entry.IsDir() || isHiddenOrSymlink(entry) { | ||
| if !entry.IsDir() || (isHidden(entry) || isSymlink(entry)) { |
There was a problem hiding this comment.
why not following symlinks? The real change with symlink are security issues to ensure that they don't allow to go outside of the project folder....
There was a problem hiding this comment.
I didn't want to work on loadSkillsFlat in that PR. Happy to work on it in another PR
Return fs.SkipDir for hidden directories and symlinks instead of descending into them. This avoids walking large trees like .git, .node_modules, or .cache that can never contain skills.
Assisted-By: cagent