Skip to content

fix(skills): discover skill directories that are symlinks - #1048

Open
shokosanma wants to merge 1 commit into
siteboon:mainfrom
shokosanma:fix/discover-symlinked-skills
Open

fix(skills): discover skill directories that are symlinks#1048
shokosanma wants to merge 1 commit into
siteboon:mainfrom
shokosanma:fix/discover-symlinked-skills

Conversation

@shokosanma

@shokosanma shokosanma commented Jul 21, 2026

Copy link
Copy Markdown

Summary

  • Treat directory symlinks as traversable when discovering provider skill SKILL.md files.
  • Fixes cases like ~/.cursor/skills where Dirent.isDirectory() is false for symlinks even when the target is a directory.

Test plan

  • Place a skill behind a symlink under a provider skills root (e.g. ~/.cursor/skills/my-skill → real dir with SKILL.md)
  • Confirm the skill appears in CloudCLI skill discovery / settings
  • Confirm normal (non-symlink) skill directories still discover correctly
  • Confirm broken/non-directory symlinks do not crash discovery

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • Skill discovery now supports provider skill directories accessed through symbolic links.
    • Recursive and direct searches can locate SKILL.md files within symlinked directories.

Dirent.isDirectory() is false for symlinks even when the target is a
directory, so ~/.cursor/skills style links were skipped during discovery.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Provider skill discovery

Layer / File(s) Summary
Support symbolic-linked skill directories
server/shared/utils.ts
Recursive traversal and direct lookup now process symbolic links in addition to real directories.

Possibly related issues

  • Issue 992: Updates the same skill discovery function to support symbolic-linked skills.
  • Issue 972: Tracks the symbolic-linked skill-directory discovery bug addressed here.

Possibly related PRs

Suggested reviewers: blackmammoth

Poem

A rabbit hopped through links unseen,
Where skill files hid in folders green.
“Now symlinks count!” the bunny cried,
And SKILL.md was found inside.
Wiggle ears—discovery’s wide!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: skill discovery now includes symlinked directories.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/shared/utils.ts`:
- Around line 913-916: Update the recursive traversal around collectRecursive to
resolve each directory to its canonical real path and maintain a
visited-directory set; skip descent when that canonical path has already been
visited, while preserving normal symlink-to-directory traversal and
deduplication. Add a regression test covering a self-referential or
parent-directory symlink to verify traversal terminates without duplicate
results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a5d51d74-d61e-431c-bfcd-7681a3cc8997

📥 Commits

Reviewing files that changed from the base of the PR and between 27eaf01 and 6e13221.

📒 Files selected for processing (1)
  • server/shared/utils.ts

Comment thread server/shared/utils.ts
Comment on lines +913 to 916
// Symlinks to skill directories are common in ~/.cursor/skills; Dirent.isDirectory()
// is false for links even when the target is a directory.
if (entry.isDirectory() || entry.isSymbolicLink()) {
await collectRecursive(path.join(dirPath, entry.name));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard recursive traversal against symlink cycles.

Following every symlink without tracking visited directories allows links such as skills/loop -> .. to recurse indefinitely, producing duplicate results and potentially exhausting I/O or failing with excessively long paths. Track each directory by its canonical/real path before descending.

Proposed fix
+import { realpath } from 'node:fs/promises';

 export async function findProviderSkillMarkdownFiles(...) {
   const skillFiles: string[] = [];
+  const visitedDirectories = new Set<string>();

   const collectRecursive = async (dirPath: string): Promise<void> => {
+    let canonicalPath: string;
+    try {
+      canonicalPath = await realpath(dirPath);
+    } catch {
+      return;
+    }
+    if (visitedDirectories.has(canonicalPath)) {
+      return;
+    }
+    visitedDirectories.add(canonicalPath);

     let entries;

Please also add a regression test for a self-referential or parent-directory symlink.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Symlinks to skill directories are common in ~/.cursor/skills; Dirent.isDirectory()
// is false for links even when the target is a directory.
if (entry.isDirectory() || entry.isSymbolicLink()) {
await collectRecursive(path.join(dirPath, entry.name));
import { realpath } from 'node:fs/promises';
export async function findProviderSkillMarkdownFiles(...) {
const skillFiles: string[] = [];
const visitedDirectories = new Set<string>();
const collectRecursive = async (dirPath: string): Promise<void> => {
let canonicalPath: string;
try {
canonicalPath = await realpath(dirPath);
} catch {
return;
}
if (visitedDirectories.has(canonicalPath)) {
return;
}
visitedDirectories.add(canonicalPath);
// Symlinks to skill directories are common in ~/.cursor/skills; Dirent.isDirectory()
// is false for links even when the target is a directory.
if (entry.isDirectory() || entry.isSymbolicLink()) {
await collectRecursive(path.join(dirPath, entry.name));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/shared/utils.ts` around lines 913 - 916, Update the recursive
traversal around collectRecursive to resolve each directory to its canonical
real path and maintain a visited-directory set; skip descent when that canonical
path has already been visited, while preserving normal symlink-to-directory
traversal and deduplication. Add a regression test covering a self-referential
or parent-directory symlink to verify traversal terminates without duplicate
results.

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.

1 participant