Skip to content

fix: properly resolve symlinked directories in scanner#8

Merged
Railly merged 1 commit intoRailly:mainfrom
trevorh:fix/scanner-bugs
Apr 2, 2026
Merged

fix: properly resolve symlinked directories in scanner#8
Railly merged 1 commit intoRailly:mainfrom
trevorh:fix/scanner-bugs

Conversation

@trevorh
Copy link
Copy Markdown
Contributor

@trevorh trevorh commented Mar 30, 2026

Summary

  • Fixes symlink handling in scanDirectoryWithSkillMd and scanFlatMd — instead of treating all symlinks as directories, now resolves the symlink target with statSync to verify it actually points to a directory
  • Adds missing readdirSync import to tool-configs.ts
  • Extracts repeated join(baseDir, entry.name) into fullPath variable for clarity

Context

The current code does entry.isDirectory() || entry.isSymbolicLink() which incorrectly treats symlinks to files as directories. This fix uses statSync(fullPath, { throwIfNoEntry: false })?.isDirectory() to properly check the symlink target.

Test plan

  • Create a symlink pointing to a file inside a skill directory — verify it's skipped (not treated as a subdirectory)
  • Create a symlink pointing to a directory containing skills — verify skills are discovered
  • Verify normal (non-symlinked) skill directories still scan correctly

🤖 Generated with Claude Code

…nner

- tool-configs.ts: readdirSync was used but never imported, causing a
  ReferenceError when cliExists scanned the nvm directory
- scanner.ts: scanFlatMd and scanDirectoryWithSkillMd assumed all symlinks
  were directories, crashing with ENOTDIR on symlinked files (e.g.
  ~/.claude/commands/diff-review.md)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Railly Railly merged commit 2c821e3 into Railly:main Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants