fix(mcp): treat skillshare/config.yaml as a project config too

configProjectRoot matched only <root>/.skillshare/config.yaml, so a
project that keeps its config in the visible skillshare/ folder was
treated as a global config and its MCP saves skipped the project
boundary entirely, config.yaml included. Match every project config
folder name through projectdir.IsName.
This commit is contained in:
Willie
2026-10-07 13:04:58 +08:00
parent cc2d07d7db
commit 2ec925b880
2 changed files with 13 additions and 9 deletions
+7 -6
View File
@@ -41,17 +41,18 @@ func TestExternalMutationLeavesConfigUntouched(t *testing.T) {
// mutation must not rewrite one outside the project.
func TestProjectExternalMutationStaysInsideProject(t *testing.T) {
for _, tc := range []struct {
name, source string
refused bool
name, dir, source string
refused bool
}{
{"outside the project", "../../outside.yaml", true},
{"next to config.yaml", "./mcp.yaml", false},
{"at the project root", "../mcp.yaml", false},
{"outside the project", ".skillshare", "../../outside.yaml", true},
{"outside the project, visible config folder", "skillshare", "../../outside.yaml", true},
{"next to config.yaml", ".skillshare", "./mcp.yaml", false},
{"at the project root", ".skillshare", "../mcp.yaml", false},
} {
t.Run(tc.name, func(t *testing.T) {
global := testService(t)
root := filepath.Join(global.Home, "project")
configPath := filepath.Join(root, ".skillshare", "config.yaml")
configPath := filepath.Join(root, tc.dir, "config.yaml")
if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil {
t.Fatal(err)
}
+6 -3
View File
@@ -11,6 +11,7 @@ import (
"strings"
"github.com/gofrs/flock"
"skillshare/internal/projectdir"
)
// Service is scoped to one Skillshare config; StateDir is shared across scopes
@@ -33,10 +34,12 @@ type Service struct {
account string
}
// configProjectRoot returns the project whose own config ConfigPath is, so saves stay
// inside it. A global config scoped to a project in mcp.projects returns "".
// configProjectRoot returns the project whose own config ConfigPath is (in .skillshare/
// or skillshare/), so saves stay inside it. A global config scoped to a project in
// mcp.projects returns "".
func (s *Service) configProjectRoot() string {
if s.ProjectRoot != "" && filepath.Clean(s.ConfigPath) == filepath.Join(s.ProjectRoot, ".skillshare", "config.yaml") {
dir := filepath.Dir(filepath.Clean(s.ConfigPath))
if s.ProjectRoot != "" && projectdir.IsName(filepath.Base(dir)) && filepath.Dir(dir) == filepath.Clean(s.ProjectRoot) {
return s.ProjectRoot
}
return ""