fix(sync): ignore target naming for symlink targets sharing a folder

Codex review on #499: two targets on one folder that both resolve to
symlink mode were reported as a conflict when their target_naming
differed. Symlink mode links the whole folder to the source and never
uses per-skill names, so the naming cannot make them undo each other.
Compare naming only when the shared mode is not symlink.
This commit is contained in:
Willie
2026-10-09 00:37:28 +08:00
parent 06a0d36536
commit 588d29c79d
2 changed files with 19 additions and 3 deletions
+9 -3
View File
@@ -158,9 +158,15 @@ func SkillsFolderConflicts(targets map[string]TargetConfig, defaultMode string)
}
func sameSkillsSettings(a, b ResourceTargetConfig, defaultMode string) bool {
return effectiveMode(a.Mode, defaultMode) == effectiveMode(b.Mode, defaultMode) &&
EffectiveTargetNaming(a.TargetNaming) == EffectiveTargetNaming(b.TargetNaming) &&
sameSet(a.Include, b.Include) && sameSet(a.Exclude, b.Exclude)
mode := effectiveMode(a.Mode, defaultMode)
if mode != effectiveMode(b.Mode, defaultMode) {
return false
}
// symlink mode links the whole folder to the source, so skill names never apply.
if mode != "symlink" && EffectiveTargetNaming(a.TargetNaming) != EffectiveTargetNaming(b.TargetNaming) {
return false
}
return sameSet(a.Include, b.Include) && sameSet(a.Exclude, b.Exclude)
}
// effectiveMode mirrors the sync package's mode resolution: the target's own,
+10
View File
@@ -118,6 +118,16 @@ func TestSkillsFolderConflicts_DifferentMode(t *testing.T) {
}
}
func TestSkillsFolderConflicts_SymlinkIgnoresTargetNaming(t *testing.T) {
got := SkillsFolderConflicts(map[string]TargetConfig{
"aflat": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "symlink", TargetNaming: "flat"}},
"bstd": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", TargetNaming: "standard"}},
}, "symlink")
if len(got) != 0 {
t.Errorf("expected no conflict, got %+v", got)
}
}
func TestSkillsFolderConflicts_UnsetEqualsDefault(t *testing.T) {
got := SkillsFolderConflicts(map[string]TargetConfig{
"unset": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}},