@@ -13,7 +13,7 @@ import (
1313var stderrWriter io.Writer = os .Stderr
1414
1515// CreateSkillLink installs skillName from sourceSkillDir into agentSkillsDir.
16- // useCopy= true copies files recursively; useCopy=false creates a symlink.
16+ // When useCopy is true the directory is copied recursively; otherwise a symlink is created .
1717// The operation is idempotent: a correct existing symlink or copy is left unchanged.
1818func CreateSkillLink (sourceSkillDir , agentSkillsDir , skillName string , useCopy bool ) error {
1919 if err := os .MkdirAll (agentSkillsDir , 0o755 ); err != nil {
@@ -24,7 +24,8 @@ func CreateSkillLink(sourceSkillDir, agentSkillsDir, skillName string, useCopy b
2424
2525 info , err := os .Lstat (linkPath )
2626 if err == nil {
27- if info .Mode ()& os .ModeSymlink != 0 {
27+ switch {
28+ case info .Mode ()& os .ModeSymlink != 0 :
2829 // For useCopy=false: skip if already pointing to the right place.
2930 // For useCopy=true: remove the symlink so we can replace it with a copy.
3031 if ! useCopy && isSymlinkCorrect (linkPath , sourceSkillDir ) {
@@ -33,15 +34,15 @@ func CreateSkillLink(sourceSkillDir, agentSkillsDir, skillName string, useCopy b
3334 if rmErr := os .Remove (linkPath ); rmErr != nil {
3435 return fmt .Errorf ("remove existing symlink %s: %w" , linkPath , rmErr )
3536 }
36- } else if info .IsDir () {
37+ case info .IsDir ():
3738 if ! useCopy {
3839 fmt .Fprintf (stderrWriter ,
3940 "warning: %s is a copied directory; remove it manually to switch to symlink mode\n " ,
4041 linkPath )
4142 return nil
4243 }
43- // useCopy =true: fall through to re-copy with replace semantics.
44- } else {
44+ // UseCopy =true: fall through to re-copy with replace semantics.
45+ default :
4546 return fmt .Errorf ("%s exists as a regular file; remove it before installing skill %q" , linkPath , skillName )
4647 }
4748 } else if ! os .IsNotExist (err ) {
@@ -55,11 +56,11 @@ func CreateSkillLink(sourceSkillDir, agentSkillsDir, skillName string, useCopy b
5556}
5657
5758// isSymlinkCorrect returns true if linkPath is a non-broken symlink resolving to sourceSkillDir.
58- // os.SameFile is used instead of string comparison to handle case-insensitive filesystems (e.g. macOS APFS).
59+ // Uses os.SameFile instead of string comparison to handle case-insensitive filesystems (e.g. macOS APFS).
5960func isSymlinkCorrect (linkPath , sourceSkillDir string ) bool {
6061 linkInfo , err := os .Stat (linkPath )
6162 if err != nil {
62- return false // broken symlink
63+ return false // Broken symlink.
6364 }
6465 srcInfo , err := os .Stat (sourceSkillDir )
6566 if err != nil {
@@ -123,7 +124,7 @@ func copyDir(src, dst string) error {
123124 return mergeErr
124125 }
125126 } else {
126- tmpRemoved = true // rename succeeded; temp dir is now dst
127+ tmpRemoved = true // Rename succeeded; temp dir is now dst.
127128 }
128129 return nil
129130}
0 commit comments