Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion internal/skills/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,16 @@ func (s *Skill) Resources() []string {
continue
}
for _, e := range entries {
if e.IsDir() {
isDir := e.IsDir()
if !isDir && e.Type()&os.ModeSymlink != 0 {
info, err := os.Stat(filepath.Join(dir, e.Name()))
if err != nil {
// Skip unresolvable symlinks (e.g. broken or inaccessible target)
continue
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
isDir = info.IsDir()
}
if isDir {
continue
}
out = append(out, sub+"/"+e.Name())
Expand Down
37 changes: 37 additions & 0 deletions internal/skills/skills_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,43 @@ func TestSkillResources(t *testing.T) {
}
}

func TestSkillResources_Symlinks(t *testing.T) {
dir := t.TempDir()
skillDir := filepath.Join(dir, "my-skill")
if err := os.MkdirAll(filepath.Join(skillDir, "scripts"), 0o755); err != nil {
t.Fatal(err)
}

extDir := t.TempDir()
extScript := filepath.Join(extDir, "external.sh")
if err := os.WriteFile(extScript, []byte("echo hi"), 0o755); err != nil {
t.Fatal(err)
}
extSubdir := filepath.Join(extDir, "subfolder")
if err := os.MkdirAll(extSubdir, 0o755); err != nil {
t.Fatal(err)
}

// Symlink a file into scripts
if err := os.Symlink(extScript, filepath.Join(skillDir, "scripts", "linked.sh")); err != nil {
t.Skipf("symlinks unsupported: %v", err)
}
// Symlink a directory into scripts (should be skipped, not treated as a file)
if err := os.Symlink(extSubdir, filepath.Join(skillDir, "scripts", "linked-dir")); err != nil {
t.Skipf("symlinks unsupported: %v", err)
}
// Broken/dangling symlink into scripts (should be skipped)
if err := os.Symlink(filepath.Join(extDir, "nonexistent.sh"), filepath.Join(skillDir, "scripts", "dangling.sh")); err != nil {
t.Skipf("symlinks unsupported: %v", err)
}

s := &Skill{Name: "my-skill", Path: filepath.Join(skillDir, "SKILL.md")}
res := s.Resources()
if len(res) != 1 || res[0] != "scripts/linked.sh" {
t.Fatalf("expected [scripts/linked.sh], got %v", res)
}
}

// TestValidate_SpecWarnings verifies the lenient spec checks: deviations in
// name format, length limits, directory mismatch and body length are
// reported as warnings (the skill still loads), never as errors.
Expand Down
Loading