-
Notifications
You must be signed in to change notification settings - Fork 52.8k
fix(skills): follow symlinks during skill discovery (#35184) #35213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tranquil-Flow
wants to merge
1
commit into
NousResearch:main
Choose a base branch
from
Tranquil-Flow:fix/35184-review-rev1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+62
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Regression test: skill discovery follows symlinked category directories (#35184).""" | ||
|
|
||
| import os | ||
| import tempfile | ||
| from pathlib import Path | ||
| from unittest.mock import patch | ||
|
|
||
| from tools.skill_manager_tool import _find_skill | ||
|
|
||
|
|
||
| def test_find_skill_follows_symlinks(): | ||
| """#35184: _find_skill should discover skills under symlinked | ||
| category directories, not just direct subdirectories. | ||
|
|
||
| pathlib.Path.rglob() does not follow symlinks into directories, | ||
| so skills in symlinked categories were invisible. The fix uses | ||
| iter_skill_index_files() which calls os.walk(followlinks=True). | ||
| """ | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| # Create a real skills dir | ||
| skills_dir = Path(tmp) / "skills" | ||
| skills_dir.mkdir() | ||
|
|
||
| # Create a skill in a real subdirectory | ||
| real_cat = skills_dir / "real-cat" | ||
| real_cat.mkdir() | ||
| skill_dir = real_cat / "my-symlinked-skill" | ||
| skill_dir.mkdir() | ||
| (skill_dir / "SKILL.md").write_text("# My Skill") | ||
|
|
||
| # Create a skill in an external location | ||
| alt_location = Path(tmp) / "alt-skills" | ||
| alt_location.mkdir() | ||
| symlinked_cat = alt_location / "symlinked-cat" | ||
| symlinked_cat.mkdir() | ||
| symlinked_skill = symlinked_cat / "my-symlinked-skill-2" | ||
| symlinked_skill.mkdir() | ||
| (symlinked_skill / "SKILL.md").write_text("# Symlinked Skill") | ||
|
|
||
| # Symlink the external category into skills dir | ||
| symlink = skills_dir / "linked-cat" | ||
| os.symlink(symlinked_cat, symlink, target_is_directory=True) | ||
|
|
||
| with patch("agent.skill_utils.get_all_skills_dirs", return_value=[skills_dir]): | ||
| # Direct (non-symlinked) skill — always worked | ||
| result1 = _find_skill("my-symlinked-skill") | ||
| assert result1 is not None, "Direct skill should be found" | ||
| assert result1["path"] == skill_dir | ||
|
|
||
| # Symlinked skill — was broken with rglob, fixed with iter_skill_index_files | ||
| result2 = _find_skill("my-symlinked-skill-2") | ||
| assert result2 is not None, ( | ||
| "Skill under symlinked category should be found " | ||
| "(regression: rglob does not follow symlinks)" | ||
| ) | ||
| assert result2["path"].resolve() == symlinked_skill.resolve(), ( | ||
| f"Expected {symlinked_skill.resolve()}, got {result2['path'].resolve()}" | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle
OSErrorandNotImplementedErrorhere and skip when symlinks are unavailable. The established helper intests/tools/test_skills_tool.py:47-55keeps these tests portable to restricted Windows environments.