Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmd/sin-code/internal/mcpclient/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// tool-name prefixes ("websearch__search", "browser__navigate", ...), which
// the permission matrix gates via the "mcp" policy class.
func DefaultServers() []ServerConfig {
skillsDir := os.Getenv("SIN_SKILLS_DIR")
skillsDir := skillsDirOrDefault()
py := func(repo string) ServerConfig {
name := shortName(repo)
cfg := ServerConfig{Name: name, Transport: "stdio"}
Expand Down Expand Up @@ -85,3 +85,14 @@ func shortName(repo string) string {
}
return repo
}

// skillsDirOrDefault returns the configured SIN_SKILLS_DIR or the default
// local share location used by skillmgr. This keeps the registry in sync
// with where skillmgr actually installs skills.
func skillsDirOrDefault() string {
if d := os.Getenv("SIN_SKILLS_DIR"); d != "" {
return d
}
home, _ := os.UserHomeDir()
return filepath.Join(home, ".local", "share", "sin-code", "skills")
}
27 changes: 27 additions & 0 deletions cmd/sin-code/internal/mcpclient/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestDefaultServersWebsearchUsesLocalBinaryWhenPresent(t *testing.T) {
}

func TestDefaultServersWebsearchFallsBackToPathBinary(t *testing.T) {
// Use a HOME that has no sin-code skills checkout so the default skills
// dir check fails and the registry falls back to the binary on PATH.
t.Setenv("HOME", t.TempDir())
t.Setenv("SIN_SKILLS_DIR", "")
for _, s := range DefaultServers() {
if s.Name != "websearch" {
Expand All @@ -47,3 +50,27 @@ func TestDefaultServersWebsearchFallsBackToPathBinary(t *testing.T) {
}
t.Fatal("websearch server not found in DefaultServers")
}

func TestDefaultServersWebsearchUsesDefaultSkillsDir(t *testing.T) {
home := t.TempDir()
bin := filepath.Join(home, ".local", "share", "sin-code", "skills", "web_search_bundle", "sin-websearch")
if err := os.MkdirAll(filepath.Dir(bin), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(bin, []byte("#!/bin/sh\necho fake"), 0o755); err != nil {
t.Fatal(err)
}

t.Setenv("SIN_SKILLS_DIR", "")
t.Setenv("HOME", home)
for _, s := range DefaultServers() {
if s.Name != "websearch" {
continue
}
if s.Command != bin {
t.Fatalf("websearch command should use default skills dir binary %q, got %q", bin, s.Command)
}
return
}
t.Fatal("websearch server not found in DefaultServers")
}
Loading