Files
skillshare/internal/config/path_overlap_test.go
T
Willie 449fe40d6f fix(targets): move goose and openhands to .agents/skills
Both tools now document ~/.agents/skills and <project>/.agents/skills as
their skills locations and keep the old directories only for backward
compatibility. Writing to the old path next to `universal` makes them read
every skill from two places.

Global configs pin absolute paths, so they are unaffected and keep their
overlap warning. Project configs store target names only, so an existing
project follows the new default on its next sync while the links it created
in .goose/skills or .openhands/skills would stay behind and show up as
duplicates. Project sync now removes those leftovers from also_scans
directories that no configured target writes to.

That directory belongs to another tool, so the cleanup runs the prune with
ManagedOnly: only symlinks into the source and manifest-tracked folders are
removed. The flat-name heuristic would otherwise delete hand-made folders
such as `_drafts`. Targets with an explicit path are skipped, and --dry-run
only previews.

Refs #135
2026-09-21 02:55:18 +08:00

63 lines
2.2 KiB
Go

package config
import (
"slices"
"testing"
)
func TestDetectPathOverlap_CrossRuntimeDiscovery(t *testing.T) {
// codex's runtime reads ~/.agents/skills, which universal writes to.
involved := DetectPathOverlap(map[string]TargetConfig{
"codex": {Skills: &ResourceTargetConfig{Path: "~/.codex/skills"}},
"universal": {Skills: &ResourceTargetConfig{Path: "~/.agents/skills"}},
}, false)
for _, want := range []string{"codex", "universal"} {
if !slices.Contains(involved, want) {
t.Errorf("DetectPathOverlap = %v, missing %s", involved, want)
}
}
}
func TestDetectPathOverlap_CodexSharesUniversalPath(t *testing.T) {
// Default codex path is universal's ~/.agents/skills — a shared-primary overlap.
involved := DetectPathOverlap(map[string]TargetConfig{
"codex": {Skills: &ResourceTargetConfig{Path: "~/.agents/skills"}},
"universal": {Skills: &ResourceTargetConfig{Path: "~/.agents/skills"}},
}, false)
for _, want := range []string{"codex", "universal"} {
if !slices.Contains(involved, want) {
t.Errorf("DetectPathOverlap = %v, missing %s", involved, want)
}
}
}
func TestDetectPathOverlap_LegacyGoosePathStillWarns(t *testing.T) {
// A config written before the default moved keeps goose on its own path;
// goose still reads universal's ~/.agents/skills, so the warning must stay.
involved := DetectPathOverlap(map[string]TargetConfig{
"goose": {Skills: &ResourceTargetConfig{Path: "~/.config/goose/skills"}},
"universal": {Skills: &ResourceTargetConfig{Path: "~/.agents/skills"}},
}, false)
for _, want := range []string{"goose", "universal"} {
if !slices.Contains(involved, want) {
t.Errorf("DetectPathOverlap = %v, missing %s", involved, want)
}
}
}
func TestDetectPathOverlap_IgnoresScannerOwnPath(t *testing.T) {
// claude's runtime scans its own ~/.claude/skills; that is not an overlap
// with the unrelated target writing elsewhere.
involved := DetectPathOverlap(map[string]TargetConfig{
"claude": {Skills: &ResourceTargetConfig{Path: "~/.claude/skills"}},
"junie": {Skills: &ResourceTargetConfig{Path: "~/.junie/skills"}},
}, false)
if len(involved) != 0 {
t.Errorf("expected no overlap, got %v", involved)
}
}