detached 00f04d7

Ignore cyclic skill links on Windows

commit
00f04d7af3ec0c9194ffb7d34bc8280fdbc3760a
author
patriceckhart · · 2026-09-28 04:37 UTC
parent
f9a6e9f
signature
unsigned
2 files · +23 -1
M packages/agent/skills/skills.go +9 -1
@@ -33,6 +33,7 @@ import (
3333 "io/fs"
3434 "os"
3535 "path/filepath"
36+ "runtime"
3637 "sort"
3738 "strings"
3839 "syscall"
@@ -248,7 +249,7 @@ func scanSource(source Source) ([]*Skill, []error) {
248249 if statErr != nil {
249250 // Dangling and cyclic links are not skills. Anything
250251 // else (permissions, I/O) is worth reporting.
251- if !errors.Is(statErr, fs.ErrNotExist) && !errors.Is(statErr, syscall.ELOOP) {
252+ if !errors.Is(statErr, fs.ErrNotExist) && !symlinkLoopError(statErr) {
252253 errs = append(errs, fmt.Errorf("%s: %w", path, statErr))
253254 }
254255 continue
@@ -287,6 +288,13 @@ func scanSource(source Source) ([]*Skill, []error) {
287288 return out, errs
288289 }
289290
291+func symlinkLoopError(err error) bool {
292+ // Windows reports cyclic links as ERROR_CANT_RESOLVE_FILENAME (1921),
293+ // rather than ELOOP. syscall does not export a name for this error.
294+ return errors.Is(err, syscall.ELOOP) ||
295+ (runtime.GOOS == "windows" && errors.Is(err, syscall.Errno(1921)))
296+}
297+
290298 // deriveName builds a skill name for a SKILL.md file that carries no
291299 // frontmatter `name`, from its directory path relative to the source root.
292300 func deriveName(root, path string) (string, error) {
@@ -33,6 +33,7 @@ import (
33 "io/fs"33 "io/fs"
34 "os"34 "os"
35 "path/filepath"35 "path/filepath"
36+ "runtime"
36 "sort"37 "sort"
37 "strings"38 "strings"
38 "syscall"39 "syscall"
@@ -248,7 +249,7 @@ func scanSource(source Source) ([]*Skill, []error) {
248 if statErr != nil {249 if statErr != nil {
249 // Dangling and cyclic links are not skills. Anything250 // Dangling and cyclic links are not skills. Anything
250 // else (permissions, I/O) is worth reporting.251 // else (permissions, I/O) is worth reporting.
251- if !errors.Is(statErr, fs.ErrNotExist) && !errors.Is(statErr, syscall.ELOOP) {252+ if !errors.Is(statErr, fs.ErrNotExist) && !symlinkLoopError(statErr) {
252 errs = append(errs, fmt.Errorf("%s: %w", path, statErr))253 errs = append(errs, fmt.Errorf("%s: %w", path, statErr))
253 }254 }
254 continue255 continue
@@ -287,6 +288,13 @@ func scanSource(source Source) ([]*Skill, []error) {
287 return out, errs288 return out, errs
288 }289 }
289 290
291+func symlinkLoopError(err error) bool {
292+ // Windows reports cyclic links as ERROR_CANT_RESOLVE_FILENAME (1921),
293+ // rather than ELOOP. syscall does not export a name for this error.
294+ return errors.Is(err, syscall.ELOOP) ||
295+ (runtime.GOOS == "windows" && errors.Is(err, syscall.Errno(1921)))
296+}
297+
290 // deriveName builds a skill name for a SKILL.md file that carries no298 // deriveName builds a skill name for a SKILL.md file that carries no
291 // frontmatter `name`, from its directory path relative to the source root.299 // frontmatter `name`, from its directory path relative to the source root.
292 func deriveName(root, path string) (string, error) {300 func deriveName(root, path string) (string, error) {
M packages/agent/skills/skills_test.go +14 -0
@@ -1,10 +1,12 @@
11 package skills
22
33 import (
4+ "fmt"
45 "os"
56 "path/filepath"
67 "runtime"
78 "strings"
9+ "syscall"
810 "testing"
911 )
1012
@@ -246,6 +248,18 @@ func TestDiscoverSourcesIgnoresCyclicSymlink(t *testing.T) {
246248 }
247249 }
248250
251+func TestSymlinkLoopError(t *testing.T) {
252+ if !symlinkLoopError(fmt.Errorf("stat: %w", syscall.ELOOP)) {
253+ t.Error("ELOOP should be ignored")
254+ }
255+ if runtime.GOOS == "windows" && !symlinkLoopError(fmt.Errorf("stat: %w", syscall.Errno(1921))) {
256+ t.Error("Windows cyclic-link error should be ignored")
257+ }
258+ if symlinkLoopError(fmt.Errorf("stat: %w", os.ErrPermission)) {
259+ t.Error("permission errors must still be reported")
260+ }
261+}
262+
249263 func mustEvalSymlinks(t *testing.T, path string) string {
250264 t.Helper()
251265 resolved, err := filepath.EvalSymlinks(path)
@@ -1,10 +1,12 @@
1 package skills1 package skills
2 2
3 import (3 import (
4+ "fmt"
4 "os"5 "os"
5 "path/filepath"6 "path/filepath"
6 "runtime"7 "runtime"
7 "strings"8 "strings"
9+ "syscall"
8 "testing"10 "testing"
9 )11 )
10 12
@@ -246,6 +248,18 @@ func TestDiscoverSourcesIgnoresCyclicSymlink(t *testing.T) {
246 }248 }
247 }249 }
248 250
251+func TestSymlinkLoopError(t *testing.T) {
252+ if !symlinkLoopError(fmt.Errorf("stat: %w", syscall.ELOOP)) {
253+ t.Error("ELOOP should be ignored")
254+ }
255+ if runtime.GOOS == "windows" && !symlinkLoopError(fmt.Errorf("stat: %w", syscall.Errno(1921))) {
256+ t.Error("Windows cyclic-link error should be ignored")
257+ }
258+ if symlinkLoopError(fmt.Errorf("stat: %w", os.ErrPermission)) {
259+ t.Error("permission errors must still be reported")
260+ }
261+}
262+
249 func mustEvalSymlinks(t *testing.T, path string) string {263 func mustEvalSymlinks(t *testing.T, path string) string {
250 t.Helper()264 t.Helper()
251 resolved, err := filepath.EvalSymlinks(path)265 resolved, err := filepath.EvalSymlinks(path)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close