From 588d29c79d381b3f695017aa5528d588ff3557da Mon Sep 17 00:00:00 2001 From: Willie Date: Fri, 9 Oct 2026 00:37:28 +0800 Subject: [PATCH] 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. --- internal/config/path_overlap.go | 12 +++++++++--- internal/config/path_overlap_test.go | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/config/path_overlap.go b/internal/config/path_overlap.go index a423d9617..c9f3715a3 100644 --- a/internal/config/path_overlap.go +++ b/internal/config/path_overlap.go @@ -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, diff --git a/internal/config/path_overlap_test.go b/internal/config/path_overlap_test.go index e124baf9c..c06082214 100644 --- a/internal/config/path_overlap_test.go +++ b/internal/config/path_overlap_test.go @@ -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"}},