From b7265d649606158a67ae75fc3a3d12add32a5f0a Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 01:58:59 +0800 Subject: [PATCH 01/11] fix(install): refuse git submodule paths instead of installing empty dirs skillshare never fetches submodules, so a gitlink is an empty directory after any clone. Installing that path reported success with nothing in it, a path inside it failed with a misleading "does not exist", and whole-repo discovery dropped its skills without a word. Refuse a subdir that is or lies inside a submodule, naming the submodule, its pinned commit and upstream URL, and warn for each submodule skipped by whole-repo discovery and --track. Refs #433 Release-As: 0.25.1 --- cmd/skillshare/install_handlers.go | 8 +- internal/install/install_apply.go | 6 + internal/install/install_discovery.go | 9 ++ internal/install/install_tracked.go | 1 + internal/install/submodule.go | 96 ++++++++++++++++ internal/install/submodule_test.go | 105 ++++++++++++++++++ skills/skillshare/references/install.md | 2 + website/docs/reference/commands/install.md | 4 + website/docs/troubleshooting/common-errors.md | 6 + 9 files changed, 232 insertions(+), 5 deletions(-) create mode 100644 internal/install/submodule.go create mode 100644 internal/install/submodule_test.go diff --git a/cmd/skillshare/install_handlers.go b/cmd/skillshare/install_handlers.go index 59bc7859a..1489d8460 100644 --- a/cmd/skillshare/install_handlers.go +++ b/cmd/skillshare/install_handlers.go @@ -165,11 +165,9 @@ func handleGitInstall(source *install.Source, cfg *config.Config, opts install.I ui.StepContinue("Into", opts.Into) } - // Show subdir-specific warnings (e.g. GitHub API fallback notices) - if source.HasSubdir() { - for _, w := range discovery.Warnings { - ui.Warning("%s", w) - } + // Show discovery warnings (API fallback notices, skipped submodules) + for _, w := range discovery.Warnings { + ui.Warning("%s", w) } // Cross-path duplicate detection: block if same repo is already installed diff --git a/internal/install/install_apply.go b/internal/install/install_apply.go index 899a77468..0d62e8f86 100644 --- a/internal/install/install_apply.go +++ b/internal/install/install_apply.go @@ -516,6 +516,9 @@ func installFromGitSubdir(source *Source, destPath string, result *InstallResult if gitSupportsSparseCheckout() { resolved = source.Subdir if err := sparseCloneSubdir(source.CloneURL, resolved, tempRepoPath, source.ref(), source.authEnv(), opts.OnProgress); err == nil { + if err := submoduleError(tempRepoPath, resolved, source.authEnv()); err != nil { + return nil, err + } subdirPath = filepath.Join(tempRepoPath, resolved) if info, statErr := os.Stat(subdirPath); statErr != nil || !info.IsDir() { subdirPath = "" @@ -589,6 +592,9 @@ func installFromGitSubdir(source *Source, destPath string, result *InstallResult if err := cloneRepoForSource(source, tempRepoPath, source.Branch, true, opts.OnProgress); err != nil { return nil, fmt.Errorf("failed to clone repository: %w", err) } + if err := submoduleError(tempRepoPath, source.Subdir, source.authEnv()); err != nil { + return nil, err + } var err error resolved, err = resolveSubdir(tempRepoPath, source.Subdir) diff --git a/internal/install/install_discovery.go b/internal/install/install_discovery.go index 0fd367c5e..1c07efbe8 100644 --- a/internal/install/install_discovery.go +++ b/internal/install/install_discovery.go @@ -62,6 +62,7 @@ func discoverFromGitWithProgressImpl(source *Source, onProgress ProgressCallback Agents: agents, Source: source, CommitHash: commitHash, + Warnings: submoduleWarnings(repoPath, source.authEnv()), }, nil } @@ -347,6 +348,10 @@ func discoverFromGitSubdirWithProgressImpl(source *Source, onProgress ProgressCa // Works for GitHub and non-GitHub hosts. if gitSupportsSparseCheckout() { if err := sparseCloneSubdir(source.CloneURL, source.Subdir, repoPath, source.ref(), source.authEnv(), onProgress); err == nil { + if err := submoduleError(repoPath, source.Subdir, source.authEnv()); err != nil { + cleanupTempRepo(tempDir) + return nil, err + } subdirPath = filepath.Join(repoPath, source.Subdir) if info, statErr := os.Stat(subdirPath); statErr == nil && info.IsDir() { source.recordCommit(repoPath) @@ -472,6 +477,10 @@ func discoverFromGitSubdirWithProgressImpl(source *Source, onProgress ProgressCa cleanupTempRepo(tempDir) return nil, fmt.Errorf("failed to clone repository: %w", err) } + if err := submoduleError(repoPath, source.Subdir, source.authEnv()); err != nil { + cleanupTempRepo(tempDir) + return nil, err + } resolved, err := resolveSubdir(repoPath, source.Subdir) if err != nil { diff --git a/internal/install/install_tracked.go b/internal/install/install_tracked.go index 55df98707..ac8a733d7 100644 --- a/internal/install/install_tracked.go +++ b/internal/install/install_tracked.go @@ -122,6 +122,7 @@ func installTrackedRepoImpl(source *Source, sourceDir string, opts InstallOption for _, skill := range skills { result.Skills = append(result.Skills, skill.Name) } + result.Warnings = append(result.Warnings, submoduleWarnings(destPath, source.authEnv())...) // Also discover agents in the tracked repo agents := discoverAgents(destPath, len(skills) > 0) diff --git a/internal/install/submodule.go b/internal/install/submodule.go new file mode 100644 index 000000000..acb8956dd --- /dev/null +++ b/internal/install/submodule.go @@ -0,0 +1,96 @@ +package install + +import ( + "context" + "fmt" + "path/filepath" + "strings" +) + +// gitlink is a submodule entry in a repo's tree. skillshare does not fetch +// submodules, so its directory is empty after any clone. +type gitlink struct { + Path string + Commit string + URL string // from .gitmodules; "" when not recorded +} + +func (l gitlink) String() string { + s := fmt.Sprintf("'%s' (pinned at %s", l.Path, shortHash(l.Commit)) + if l.URL != "" { + s += " from " + l.URL + } + return s + ")" +} + +// repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv +// authenticates the lazy .gitmodules fetch in a partial clone. Any git failure +// returns nil: callers only use the result to explain an empty directory. +func repoGitlinks(repoPath string, extraEnv []string) []gitlink { + ctx, cancel := context.WithTimeout(context.Background(), gitCommandTimeout) + defer cancel() + + cmd := gitCommand(ctx, "ls-tree", "-r", "-z", "HEAD") + cmd.Dir = repoPath + out, err := cmd.Output() + if err != nil { + return nil + } + var links []gitlink + for _, entry := range strings.Split(string(out), "\x00") { + meta, path, ok := strings.Cut(entry, "\t") + fields := strings.Fields(meta) + if ok && len(fields) == 3 && fields[0] == "160000" { + links = append(links, gitlink{Path: path, Commit: fields[2]}) + } + } + if len(links) == 0 { + return nil + } + + cmd = gitCommand(ctx, "config", "-z", "--blob", "HEAD:.gitmodules", "--get-regexp", `^submodule\..*\.(path|url)$`) + cmd.Dir = repoPath + cmd.Env = append(cmd.Env, extraEnv...) + out, err = cmd.Output() + if err != nil { + return links + } + paths, urls := map[string]string{}, map[string]string{} + for _, entry := range strings.Split(string(out), "\x00") { + key, val, _ := strings.Cut(entry, "\n") + if name, ok := strings.CutSuffix(key, ".path"); ok { + paths[name] = val + } else if name, ok := strings.CutSuffix(key, ".url"); ok { + urls[name] = val + } + } + for name, path := range paths { + for i := range links { + if links[i].Path == path { + links[i].URL = urls[name] + } + } + } + return links +} + +// submoduleError refuses a subdir that is a submodule or lies inside one, +// which would otherwise install an empty directory or report a missing path. +func submoduleError(repoPath, subdir string, extraEnv []string) error { + subdir = strings.Trim(filepath.ToSlash(subdir), "/") + for _, l := range repoGitlinks(repoPath, extraEnv) { + if subdir == l.Path || strings.HasPrefix(subdir, l.Path+"/") { + return fmt.Errorf("'%s' is in git submodule %s, and skillshare does not fetch submodules; install from that repository instead, or copy the files into this one", subdir, l) + } + } + return nil +} + +// submoduleWarnings names each submodule whose contents a whole-repo install skips. +func submoduleWarnings(repoPath string, extraEnv []string) []string { + var warnings []string + for _, l := range repoGitlinks(repoPath, extraEnv) { + warnings = append(warnings, fmt.Sprintf("skipped git submodule %s: skillshare does not fetch submodules", l)) + } + return warnings +} diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go new file mode 100644 index 000000000..37aed5fd9 --- /dev/null +++ b/internal/install/submodule_test.go @@ -0,0 +1,105 @@ +package install + +import ( + "os" + "os/exec" + "path/filepath" + "strings" + "testing" +) + +// newHubWithSubmodule builds a bare hub repo with its own skill at own/ and an +// upstream repo mounted as a submodule at vendor/up (holding skills/a). +func newHubWithSubmodule(t *testing.T) (hubURL, upURL string) { + t.Helper() + if _, err := exec.LookPath("git"); err != nil { + t.Skip("git not available") + } + tmp := t.TempDir() + commit := func(dir string, files map[string]string) { + mustRunGit(t, "", "init", "-q", dir) + mustRunGit(t, dir, "config", "user.email", "test@test.com") + mustRunGit(t, dir, "config", "user.name", "Test") + for name, body := range files { + path := filepath.Join(dir, name) + if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, []byte(body), 0644); err != nil { + t.Fatal(err) + } + } + mustRunGit(t, dir, "add", ".") + mustRunGit(t, dir, "commit", "-q", "-m", "init") + } + + up := filepath.Join(tmp, "up") + commit(up, map[string]string{"skills/a/SKILL.md": "# a"}) + upURL = "file://" + up + + work := filepath.Join(tmp, "work") + commit(work, map[string]string{"own/SKILL.md": "# own"}) + mustRunGit(t, work, "-c", "protocol.file.allow=always", "submodule", "add", "-q", upURL, "vendor/up") + mustRunGit(t, work, "commit", "-q", "-m", "add submodule") + + hub := filepath.Join(tmp, "hub.git") + mustRunGit(t, "", "clone", "-q", "--bare", work, hub) + return "file://" + hub, upURL +} + +func hubSource(hubURL, subdir string) *Source { + return &Source{ + Type: SourceTypeGitHTTPS, + Raw: hubURL + "/" + subdir, + CloneURL: hubURL, + Subdir: subdir, + Name: filepath.Base(subdir), + } +} + +func TestDiscoverFromGitSubdir_RefusesSubmodulePaths(t *testing.T) { + hubURL, upURL := newHubWithSubmodule(t) + + for _, subdir := range []string{"vendor/up", "vendor/up/skills/a"} { + t.Run(subdir, func(t *testing.T) { + result, err := DiscoverFromGitSubdir(hubSource(hubURL, subdir)) + if err == nil { + CleanupDiscovery(result) + t.Fatalf("expected an error, got %d skill(s)", len(result.Skills)) + } + if !strings.Contains(err.Error(), "git submodule 'vendor/up'") || !strings.Contains(err.Error(), upURL) { + t.Fatalf("error should name the submodule and its upstream, got: %v", err) + } + }) + } +} + +func TestInstall_RefusesSubmoduleSubdir(t *testing.T) { + hubURL, _ := newHubWithSubmodule(t) + dest := filepath.Join(t.TempDir(), "up") + + _, err := Install(hubSource(hubURL, "vendor/up"), dest, InstallOptions{SkipAudit: true}) + if err == nil || !strings.Contains(err.Error(), "git submodule") { + t.Fatalf("expected a submodule error, got: %v", err) + } + if _, statErr := os.Stat(dest); !os.IsNotExist(statErr) { + t.Fatalf("nothing should be installed at %s", dest) + } +} + +func TestDiscoverFromGit_WarnsSkippedSubmodule(t *testing.T) { + hubURL, upURL := newHubWithSubmodule(t) + + result, err := DiscoverFromGit(&Source{Type: SourceTypeGitHTTPS, Raw: hubURL, CloneURL: hubURL, Name: "hub"}) + if err != nil { + t.Fatal(err) + } + defer CleanupDiscovery(result) + + if len(result.Skills) != 1 || result.Skills[0].Name != "own" { + t.Fatalf("expected only the hub's own skill, got %+v", result.Skills) + } + if len(result.Warnings) != 1 || !strings.Contains(result.Warnings[0], "skipped git submodule 'vendor/up'") || !strings.Contains(result.Warnings[0], upURL) { + t.Fatalf("expected one submodule warning, got %q", result.Warnings) + } +} diff --git a/skills/skillshare/references/install.md b/skills/skillshare/references/install.md index 1e09c0066..696ddb6c3 100644 --- a/skills/skillshare/references/install.md +++ b/skills/skillshare/references/install.md @@ -83,6 +83,8 @@ skillshare install user/repo --skip-audit # Skip security scan **Fuzzy subdirectory resolution:** When a monorepo has nested skill directories, you can specify just the skill name — e.g., `user/repo/vue-best-practices` finds `skills/vue-best-practices/` automatically. Fails with an error if multiple matches exist. +**Git submodules:** skillshare does not fetch submodules. A path that is, or lies inside, a submodule fails with an error naming its upstream URL; install from that upstream instead. Whole-repo browsing and `--track` warn about each submodule they skip. + **Tracked repos:** Prefixed with `_`, nested with `__` (e.g., `_team__frontend__ui`). Tracked custom names must not contain path separators (`/`, `\`) or `..`. diff --git a/website/docs/reference/commands/install.md b/website/docs/reference/commands/install.md index 2fd325fe4..86bb367d9 100644 --- a/website/docs/reference/commands/install.md +++ b/website/docs/reference/commands/install.md @@ -198,6 +198,10 @@ A local path is copied into the source directory. In global mode, a relative pat When specifying a subdirectory path like `owner/repo/skill-name`, if the exact path doesn't exist in the repo, skillshare scans all `SKILL.md` files and matches by directory basename. If multiple skills share the same name, an ambiguity error is shown with full paths so you can specify the exact one. ::: +:::note Git submodules are not fetched +skillshare does not fetch git submodules. Installing a path that is a submodule, or lies inside one, fails with an error that names the submodule, its pinned commit, and its upstream URL; install from that upstream repository instead, or copy the files into the hub. When you browse a whole repository, `install` and `--track` warn about each submodule they skip. +::: + ## Install from Config (No Arguments) {#install-from-config-no-arguments} When run without a source argument, `skillshare install` reads the recorded remote skill metadata (global mode) or the project `skills:` manifest (project mode) and installs all remote skills that don't already exist locally: diff --git a/website/docs/troubleshooting/common-errors.md b/website/docs/troubleshooting/common-errors.md index c93d42e7e..688fab184 100644 --- a/website/docs/troubleshooting/common-errors.md +++ b/website/docs/troubleshooting/common-errors.md @@ -453,6 +453,12 @@ See [Environment Variables — Git SSL / TLS](/docs/reference/appendix/environme **Solution:** Check the source path is correct and points to a skill directory. +### `'' is in git submodule '' ..., and skillshare does not fetch submodules` + +**Cause:** The path you asked for is a git submodule in the repository, or sits inside one. skillshare does not fetch submodules, so the directory would be empty. + +**Solution:** Install from the upstream repository named in the error. If you maintain the hub, copy the skill files into it instead of mounting them as a submodule. + --- ## Update Errors From e4b72cb554f497b07ce2baeac32ed669e474c441 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:03:26 +0800 Subject: [PATCH 02/11] fix(install): hide credentials in submodule URLs shown to the user .gitmodules may hold an authenticated URL; drop userinfo, query and fragment before it reaches warnings, errors or API responses. --- internal/install/submodule.go | 15 ++++++++++++++- internal/install/submodule_test.go | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index acb8956dd..5b8156923 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -3,6 +3,7 @@ package install import ( "context" "fmt" + "net/url" "path/filepath" "strings" ) @@ -18,11 +19,23 @@ type gitlink struct { func (l gitlink) String() string { s := fmt.Sprintf("'%s' (pinned at %s", l.Path, shortHash(l.Commit)) if l.URL != "" { - s += " from " + l.URL + s += " from " + displayURL(l.URL) } return s + ")" } +// displayURL drops userinfo, query and fragment from a .gitmodules URL, which +// may carry a token, before it reaches terminal output or an API error. +// url.Redacted is not enough: a token is often the username alone. +func displayURL(raw string) string { + u, err := url.Parse(raw) + if err != nil || u.Host == "" { + return raw // scp-style or relative URL: no userinfo to strip + } + u.User, u.RawQuery, u.Fragment = nil, "", "" + return u.String() +} + // repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv // authenticates the lazy .gitmodules fetch in a partial clone. Any git failure // returns nil: callers only use the result to explain an empty directory. diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 37aed5fd9..34c89219f 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -87,6 +87,18 @@ func TestInstall_RefusesSubmoduleSubdir(t *testing.T) { } } +func TestGitlinkString_HidesURLCredentials(t *testing.T) { + for _, raw := range []string{ + "https://user:s3cret@example.com/org/up.git", + "https://s3cret@example.com/org/up.git?token=s3cret", + } { + got := gitlink{Path: "vendor/up", Commit: "abc", URL: raw}.String() + if strings.Contains(got, "s3cret") || !strings.Contains(got, "https://example.com/org/up.git") { + t.Errorf("String() = %q, want the URL without credentials", got) + } + } +} + func TestDiscoverFromGit_WarnsSkippedSubmodule(t *testing.T) { hubURL, upURL := newHubWithSubmodule(t) From 1971e9dfc4665d6eed0a2f73b649000d31ad4fed Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:04:59 +0800 Subject: [PATCH 03/11] test(install): compare submodule URL with forward slashes on Windows git writes the .gitmodules file URL with forward slashes, so a backslash temp path never matched. --- internal/install/submodule_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 34c89219f..e4948eb28 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -35,7 +35,7 @@ func newHubWithSubmodule(t *testing.T) (hubURL, upURL string) { up := filepath.Join(tmp, "up") commit(up, map[string]string{"skills/a/SKILL.md": "# a"}) - upURL = "file://" + up + upURL = "file://" + filepath.ToSlash(up) // git records forward slashes on Windows too work := filepath.Join(tmp, "work") commit(work, map[string]string{"own/SKILL.md": "# own"}) From cdac248e96f17fb4deb33259e3783205cf5f589d Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:10:03 +0800 Subject: [PATCH 04/11] fix(install): strip secrets from any submodule URL and show warnings in the dashboard Redact query, fragment and userinfo from relative, scp-style and malformed .gitmodules URLs too, clean the subdir before matching gitlinks so vendor//up is caught, and return discovery warnings from /api/discover so the install dialog shows skipped submodules. --- internal/install/submodule.go | 39 ++++++++++++++++-------- internal/install/submodule_test.go | 15 +++++---- internal/server/handler_install.go | 1 + ui/src/api/types/install.ts | 1 + ui/src/components/InstallDialog.test.tsx | 16 ++++++++++ ui/src/components/InstallDialog.tsx | 1 + 6 files changed, 54 insertions(+), 19 deletions(-) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index 5b8156923..a29a1d8eb 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -3,7 +3,7 @@ package install import ( "context" "fmt" - "net/url" + "path" "path/filepath" "strings" ) @@ -25,15 +25,28 @@ func (l gitlink) String() string { } // displayURL drops userinfo, query and fragment from a .gitmodules URL, which -// may carry a token, before it reaches terminal output or an API error. -// url.Redacted is not enough: a token is often the username alone. +// may carry a token, before it reaches terminal output or an API error. It +// works on the text rather than net/url so relative, scp-style and malformed +// URLs are stripped too; a token is often the username alone. func displayURL(raw string) string { - u, err := url.Parse(raw) - if err != nil || u.Host == "" { - return raw // scp-style or relative URL: no userinfo to strip + raw, _, _ = strings.Cut(raw, "#") + raw, _, _ = strings.Cut(raw, "?") + scheme, rest, ok := strings.Cut(raw, "://") + if !ok { + // scp-style user@host:path; a relative path has a "/" before any "@". + if at := strings.Index(raw, "@"); at >= 0 && !strings.Contains(raw[:at], "/") { + return raw[at+1:] + } + return raw } - u.User, u.RawQuery, u.Fragment = nil, "", "" - return u.String() + authority, tail, hasPath := strings.Cut(rest, "/") + if i := strings.LastIndex(authority, "@"); i >= 0 { + authority = authority[i+1:] + } + if hasPath { + authority += "/" + tail + } + return scheme + "://" + authority } // repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv @@ -51,10 +64,10 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { } var links []gitlink for _, entry := range strings.Split(string(out), "\x00") { - meta, path, ok := strings.Cut(entry, "\t") + meta, p, ok := strings.Cut(entry, "\t") fields := strings.Fields(meta) if ok && len(fields) == 3 && fields[0] == "160000" { - links = append(links, gitlink{Path: path, Commit: fields[2]}) + links = append(links, gitlink{Path: p, Commit: fields[2]}) } } if len(links) == 0 { @@ -77,9 +90,9 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { urls[name] = val } } - for name, path := range paths { + for name, p := range paths { for i := range links { - if links[i].Path == path { + if links[i].Path == p { links[i].URL = urls[name] } } @@ -90,7 +103,7 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { // submoduleError refuses a subdir that is a submodule or lies inside one, // which would otherwise install an empty directory or report a missing path. func submoduleError(repoPath, subdir string, extraEnv []string) error { - subdir = strings.Trim(filepath.ToSlash(subdir), "/") + subdir = strings.TrimPrefix(path.Clean("/"+filepath.ToSlash(subdir)), "/") for _, l := range repoGitlinks(repoPath, extraEnv) { if subdir == l.Path || strings.HasPrefix(subdir, l.Path+"/") { return fmt.Errorf("'%s' is in git submodule %s, and skillshare does not fetch submodules; install from that repository instead, or copy the files into this one", subdir, l) diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index e4948eb28..75017bb55 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -60,7 +60,7 @@ func hubSource(hubURL, subdir string) *Source { func TestDiscoverFromGitSubdir_RefusesSubmodulePaths(t *testing.T) { hubURL, upURL := newHubWithSubmodule(t) - for _, subdir := range []string{"vendor/up", "vendor/up/skills/a"} { + for _, subdir := range []string{"vendor/up", "vendor/up/skills/a", "vendor//up"} { t.Run(subdir, func(t *testing.T) { result, err := DiscoverFromGitSubdir(hubSource(hubURL, subdir)) if err == nil { @@ -88,13 +88,16 @@ func TestInstall_RefusesSubmoduleSubdir(t *testing.T) { } func TestGitlinkString_HidesURLCredentials(t *testing.T) { - for _, raw := range []string{ - "https://user:s3cret@example.com/org/up.git", - "https://s3cret@example.com/org/up.git?token=s3cret", + for raw, want := range map[string]string{ + "https://user:s3cret@example.com/org/up.git": "https://example.com/org/up.git", + "https://s3cret@example.com/org/up.git?token=s3cret": "https://example.com/org/up.git", + "https://user:s3 cret@example.com/org/up.git#s3cret": "https://example.com/org/up.git", + "../up.git?token=s3cret": "../up.git", + "s3cret@example.com:org/up.git": "example.com:org/up.git", } { got := gitlink{Path: "vendor/up", Commit: "abc", URL: raw}.String() - if strings.Contains(got, "s3cret") || !strings.Contains(got, "https://example.com/org/up.git") { - t.Errorf("String() = %q, want the URL without credentials", got) + if strings.Contains(got, "s3cret") || !strings.Contains(got, want) { + t.Errorf("String() for %q = %q, want %q without credentials", raw, got, want) } } } diff --git a/internal/server/handler_install.go b/internal/server/handler_install.go index f1fc6ed45..bf6ace935 100644 --- a/internal/server/handler_install.go +++ b/internal/server/handler_install.go @@ -102,6 +102,7 @@ func (s *Server) handleDiscover(w http.ResponseWriter, r *http.Request) { "needsSelection": len(discovery.Skills) > 1 || len(discovery.Agents) > 0, "skills": skills, "agents": agents, + "warnings": discovery.Warnings, }) } diff --git a/ui/src/api/types/install.ts b/ui/src/api/types/install.ts index 4487f309c..bb24ea1dd 100644 --- a/ui/src/api/types/install.ts +++ b/ui/src/api/types/install.ts @@ -59,6 +59,7 @@ export interface DiscoverResult { needsSelection: boolean; skills: DiscoveredSkill[]; agents: DiscoveredAgent[]; + warnings?: string[]; } export interface BatchInstallResultItem { diff --git a/ui/src/components/InstallDialog.test.tsx b/ui/src/components/InstallDialog.test.tsx index a1e34abb7..e1ff40709 100644 --- a/ui/src/components/InstallDialog.test.tsx +++ b/ui/src/components/InstallDialog.test.tsx @@ -63,6 +63,22 @@ describe('InstallDialog', () => { )); }); + it('shows discovery warnings such as skipped submodules', async () => { + vi.mocked(api.discover).mockResolvedValue({ + needsSelection: true, + skills: [{ name: 'pdf', path: 'pdf' }, { name: 'docx', path: 'docx' }], + agents: [], + warnings: ["skipped git submodule 'vendor/up' (pinned at abc from https://example.com/up.git): skillshare does not fetch submodules"], + }); + const user = userEvent.setup(); + renderDialog('url'); + + await user.type(screen.getByLabelText(/git url/i), 'owner/hub'); + await user.click(screen.getByRole('button', { name: /find skills/i })); + + expect(await screen.findByText(/skipped git submodule 'vendor\/up'/)).toBeInTheDocument(); + }); + it('force installs only the skill the audit blocked', async () => { vi.mocked(api.discover).mockResolvedValue({ needsSelection: true, skills: [{ name: 'deploy', path: 'deploy' }], agents: [] }); vi.mocked(api.installBatch) diff --git a/ui/src/components/InstallDialog.tsx b/ui/src/components/InstallDialog.tsx index fdfb5648e..560dd4b5b 100644 --- a/ui/src/components/InstallDialog.tsx +++ b/ui/src/components/InstallDialog.tsx @@ -284,6 +284,7 @@ export default function InstallDialog({ kind, initialTab, initialSource, onClose withBusy('force', () => ('skills' in b.retry ? runBatch({ ...b.retry, force: true }) : runSingle({ ...b.retry, force: true }))); const applyDiscovery = (from: string, d: DiscoverResult) => { + for (const w of d.warnings ?? []) toast(w, 'warning'); const skills = d.skills.map((s) => ({ ...s, kind: 'skill' as const })); const agents = (d.agents ?? []).map((a) => ({ name: a.name, path: a.path, kind: 'agent' as const })); const show = (items: DiscoveredSkill[]) => { From f1900251d376d5aee6da0ab87a59249c36034817 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:15:21 +0800 Subject: [PATCH 05/11] fix(install): match submodule paths case-insensitively and warn on search installs On Windows and macOS a case variant such as Vendor/Up opens the empty submodule checkout, so compare gitlink paths with EqualFold. Search results that install straight from discovery now show its warnings too. --- internal/install/submodule.go | 5 ++++- internal/install/submodule_test.go | 2 +- ui/src/components/InstallDialog.test.tsx | 8 +++++++- ui/src/components/InstallDialog.tsx | 8 +++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index a29a1d8eb..87ca39fe0 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -102,10 +102,13 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { // submoduleError refuses a subdir that is a submodule or lies inside one, // which would otherwise install an empty directory or report a missing path. +// Case is ignored: on Windows and macOS "Vendor/Up" opens the empty +// "vendor/up" checkout, and on Linux such a near-twin path does not exist. func submoduleError(repoPath, subdir string, extraEnv []string) error { subdir = strings.TrimPrefix(path.Clean("/"+filepath.ToSlash(subdir)), "/") for _, l := range repoGitlinks(repoPath, extraEnv) { - if subdir == l.Path || strings.HasPrefix(subdir, l.Path+"/") { + n := len(l.Path) + if len(subdir) >= n && strings.EqualFold(subdir[:n], l.Path) && (len(subdir) == n || subdir[n] == '/') { return fmt.Errorf("'%s' is in git submodule %s, and skillshare does not fetch submodules; install from that repository instead, or copy the files into this one", subdir, l) } } diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 75017bb55..01c9d571f 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -60,7 +60,7 @@ func hubSource(hubURL, subdir string) *Source { func TestDiscoverFromGitSubdir_RefusesSubmodulePaths(t *testing.T) { hubURL, upURL := newHubWithSubmodule(t) - for _, subdir := range []string{"vendor/up", "vendor/up/skills/a", "vendor//up"} { + for _, subdir := range []string{"vendor/up", "vendor/up/skills/a", "vendor//up", "Vendor/Up"} { t.Run(subdir, func(t *testing.T) { result, err := DiscoverFromGitSubdir(hubSource(hubURL, subdir)) if err == nil { diff --git a/ui/src/components/InstallDialog.test.tsx b/ui/src/components/InstallDialog.test.tsx index e1ff40709..ca8b196db 100644 --- a/ui/src/components/InstallDialog.test.tsx +++ b/ui/src/components/InstallDialog.test.tsx @@ -156,7 +156,12 @@ describe('InstallDialog', () => { vi.mocked(api.searchHub).mockResolvedValue({ results: [{ name: 'pdf', description: 'Read PDFs', source: 'anthropics/skills', skill: 'pdf', stars: 0, owner: 'anthropics', repo: 'skills' }], }); - vi.mocked(api.discover).mockResolvedValue({ needsSelection: true, skills: [{ name: 'pdf', path: 'pdf' }, { name: 'docx', path: 'docx' }], agents: [] }); + vi.mocked(api.discover).mockResolvedValue({ + needsSelection: true, + skills: [{ name: 'pdf', path: 'pdf' }, { name: 'docx', path: 'docx' }], + agents: [], + warnings: ["skipped git submodule 'vendor/up'"], + }); vi.mocked(api.installBatch).mockResolvedValue({ results: [{ name: 'pdf', action: 'installed' }], summary: 'Installed 1' }); const user = userEvent.setup(); renderDialog('search'); @@ -169,5 +174,6 @@ describe('InstallDialog', () => { expect.objectContaining({ source: 'anthropics/skills', skills: [expect.objectContaining({ name: 'pdf' })] }), )); expect(api.searchHub).toHaveBeenCalledWith('pdf', 'https://acme.dev/hub.json'); + expect(screen.getByText(/skipped git submodule 'vendor\/up'/)).toBeInTheDocument(); }); }); diff --git a/ui/src/components/InstallDialog.tsx b/ui/src/components/InstallDialog.tsx index 560dd4b5b..2c20a5e4b 100644 --- a/ui/src/components/InstallDialog.tsx +++ b/ui/src/components/InstallDialog.tsx @@ -283,8 +283,12 @@ export default function InstallDialog({ kind, initialTab, initialSource, onClose const forceInstall = (b: Blocked) => withBusy('force', () => ('skills' in b.retry ? runBatch({ ...b.retry, force: true }) : runSingle({ ...b.retry, force: true }))); - const applyDiscovery = (from: string, d: DiscoverResult) => { + const toastWarnings = (d: DiscoverResult) => { for (const w of d.warnings ?? []) toast(w, 'warning'); + }; + + const applyDiscovery = (from: string, d: DiscoverResult) => { + toastWarnings(d); const skills = d.skills.map((s) => ({ ...s, kind: 'skill' as const })); const agents = (d.agents ?? []).map((a) => ({ name: a.name, path: a.path, kind: 'agent' as const })); const show = (items: DiscoveredSkill[]) => { @@ -346,8 +350,10 @@ export default function InstallDialog({ kind, initialTab, initialSource, onClose const d = await api.discover(r.source); const matched = r.skill ? d.skills.filter((s) => s.name === r.skill) : []; if (matched.length > 0) { + toastWarnings(d); await runBatch({ source: r.source, skills: matched }); } else if (d.skills.length === 1 && !d.agents?.length) { + toastWarnings(d); await runBatch({ source: r.source, skills: d.skills }); } else { setTrack(false); From 39a6241b33cc7bcc0cffdd4044a51c8b2ec4cbba Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:22:10 +0800 Subject: [PATCH 06/11] fix(install): refuse tracked submodule paths and fold case only where the filesystem does A --track install with an explicit kind skips discovery, so check the subdir after the tracked clone and remove it on refusal. Match a case variant of a gitlink path only when it opens the same directory, so Linux keeps a real Vendor/Up next to a vendor/up gitlink. Strip everything before the last @ in a submodule URL so malformed and scheme-relative values fail closed. --- internal/install/install_tracked.go | 7 +++++ internal/install/submodule.go | 41 ++++++++++++++++------------- internal/install/submodule_test.go | 29 +++++++++++++++++++- 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/internal/install/install_tracked.go b/internal/install/install_tracked.go index ac8a733d7..c22771a0d 100644 --- a/internal/install/install_tracked.go +++ b/internal/install/install_tracked.go @@ -114,6 +114,13 @@ func installTrackedRepoImpl(source *Source, sourceDir string, opts InstallOption } } + if source.HasSubdir() { + if err := submoduleError(destPath, source.Subdir, source.authEnv()); err != nil { + _ = src.RemoveAll(destRel) + return nil, err + } + } + // Discover skills in the cloned repo. Include root SKILL.md so the count // matches what `skillshare sync` will see: every SKILL.md inside a tracked // repo (root and nested alike) becomes an independent skill on sync. diff --git a/internal/install/submodule.go b/internal/install/submodule.go index 87ca39fe0..b01306ea6 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -3,6 +3,7 @@ package install import ( "context" "fmt" + "os" "path" "path/filepath" "strings" @@ -25,28 +26,20 @@ func (l gitlink) String() string { } // displayURL drops userinfo, query and fragment from a .gitmodules URL, which -// may carry a token, before it reaches terminal output or an API error. It -// works on the text rather than net/url so relative, scp-style and malformed -// URLs are stripped too; a token is often the username alone. +// may carry a token, before it reaches terminal output or an API error. git +// accepts any text there, so this fails closed on the raw string: everything +// before the last "@" goes, keeping only a well-formed "scheme://" prefix. func displayURL(raw string) string { raw, _, _ = strings.Cut(raw, "#") raw, _, _ = strings.Cut(raw, "?") - scheme, rest, ok := strings.Cut(raw, "://") - if !ok { - // scp-style user@host:path; a relative path has a "/" before any "@". - if at := strings.Index(raw, "@"); at >= 0 && !strings.Contains(raw[:at], "/") { - return raw[at+1:] - } + at := strings.LastIndex(raw, "@") + if at < 0 { return raw } - authority, tail, hasPath := strings.Cut(rest, "/") - if i := strings.LastIndex(authority, "@"); i >= 0 { - authority = authority[i+1:] + if scheme, _, ok := strings.Cut(raw[:at], "://"); ok { + return scheme + "://" + raw[at+1:] } - if hasPath { - authority += "/" + tail - } - return scheme + "://" + authority + return raw[at+1:] } // repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv @@ -102,19 +95,29 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { // submoduleError refuses a subdir that is a submodule or lies inside one, // which would otherwise install an empty directory or report a missing path. -// Case is ignored: on Windows and macOS "Vendor/Up" opens the empty -// "vendor/up" checkout, and on Linux such a near-twin path does not exist. +// A case variant ("Vendor/Up" for "vendor/up") counts only when the +// filesystem opens the same directory for both, as Windows and macOS do. func submoduleError(repoPath, subdir string, extraEnv []string) error { subdir = strings.TrimPrefix(path.Clean("/"+filepath.ToSlash(subdir)), "/") for _, l := range repoGitlinks(repoPath, extraEnv) { n := len(l.Path) - if len(subdir) >= n && strings.EqualFold(subdir[:n], l.Path) && (len(subdir) == n || subdir[n] == '/') { + if len(subdir) < n || (len(subdir) > n && subdir[n] != '/') { + continue + } + prefix := subdir[:n] + if prefix == l.Path || (strings.EqualFold(prefix, l.Path) && sameDir(filepath.Join(repoPath, prefix), filepath.Join(repoPath, l.Path))) { return fmt.Errorf("'%s' is in git submodule %s, and skillshare does not fetch submodules; install from that repository instead, or copy the files into this one", subdir, l) } } return nil } +func sameDir(a, b string) bool { + ai, errA := os.Stat(a) + bi, errB := os.Stat(b) + return errA == nil && errB == nil && os.SameFile(ai, bi) +} + // submoduleWarnings names each submodule whose contents a whole-repo install skips. func submoduleWarnings(repoPath string, extraEnv []string) []string { var warnings []string diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 01c9d571f..84c847c22 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -60,7 +60,7 @@ func hubSource(hubURL, subdir string) *Source { func TestDiscoverFromGitSubdir_RefusesSubmodulePaths(t *testing.T) { hubURL, upURL := newHubWithSubmodule(t) - for _, subdir := range []string{"vendor/up", "vendor/up/skills/a", "vendor//up", "Vendor/Up"} { + for _, subdir := range []string{"vendor/up", "vendor/up/skills/a", "vendor//up"} { t.Run(subdir, func(t *testing.T) { result, err := DiscoverFromGitSubdir(hubSource(hubURL, subdir)) if err == nil { @@ -87,6 +87,31 @@ func TestInstall_RefusesSubmoduleSubdir(t *testing.T) { } } +func TestSubmoduleError_CaseVariantFollowsFilesystem(t *testing.T) { + hubURL, _ := newHubWithSubmodule(t) + repo := filepath.Join(t.TempDir(), "repo") + mustRunGit(t, "", "clone", "-q", hubURL, repo) // leaves vendor/up as an empty dir + + _, statErr := os.Stat(filepath.Join(repo, "Vendor", "Up")) + foldsCase := statErr == nil + if err := submoduleError(repo, "Vendor/Up", nil); (err != nil) != foldsCase { + t.Fatalf("case-insensitive filesystem = %v, but submoduleError(Vendor/Up) = %v", foldsCase, err) + } +} + +func TestInstallTrackedRepo_RefusesSubmoduleSubdir(t *testing.T) { + hubURL, _ := newHubWithSubmodule(t) + sourceDir := t.TempDir() + + _, err := InstallTrackedRepo(hubSource(hubURL, "vendor/up"), sourceDir, InstallOptions{Name: "up", Force: true}) + if err == nil || !strings.Contains(err.Error(), "git submodule") { + t.Fatalf("expected a submodule error, got: %v", err) + } + if _, statErr := os.Stat(filepath.Join(sourceDir, "_up")); !os.IsNotExist(statErr) { + t.Fatalf("the refused tracked clone should be removed, stat err = %v", statErr) + } +} + func TestGitlinkString_HidesURLCredentials(t *testing.T) { for raw, want := range map[string]string{ "https://user:s3cret@example.com/org/up.git": "https://example.com/org/up.git", @@ -94,6 +119,8 @@ func TestGitlinkString_HidesURLCredentials(t *testing.T) { "https://user:s3 cret@example.com/org/up.git#s3cret": "https://example.com/org/up.git", "../up.git?token=s3cret": "../up.git", "s3cret@example.com:org/up.git": "example.com:org/up.git", + "https:/user:s3cret@example.com/org/up.git": "example.com/org/up.git", + "//user:s3cret@example.com/org/up.git": "example.com/org/up.git", } { got := gitlink{Path: "vendor/up", Commit: "abc", URL: raw}.String() if strings.Contains(got, "s3cret") || !strings.Contains(got, want) { From 6607b82e2ba06c713a612134ca36b585f692efb5 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:29:48 +0800 Subject: [PATCH 07/11] fix(install): escape submodule diagnostics and match ancestors by filesystem identity Gitlink paths and .gitmodules URLs come from an untrusted repo, so quote them with %q to keep newlines and terminal escapes out of CLI output. Compare each ancestor of the subdir with the gitlink directory by os.SameFile instead of a byte-length prefix, so case and Unicode-normalization variants that open the same directory are caught. --- internal/install/submodule.go | 25 +++++++++++-------- internal/install/submodule_test.go | 11 ++++++-- ui/src/components/InstallDialog.test.tsx | 8 +++--- website/docs/troubleshooting/common-errors.md | 2 +- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index b01306ea6..9df0d6a5b 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -17,10 +17,12 @@ type gitlink struct { URL string // from .gitmodules; "" when not recorded } +// String quotes the path and URL with %q: both come from an untrusted repo +// and may hold newlines or terminal escape sequences. func (l gitlink) String() string { - s := fmt.Sprintf("'%s' (pinned at %s", l.Path, shortHash(l.Commit)) + s := fmt.Sprintf("%q (pinned at %s", l.Path, shortHash(l.Commit)) if l.URL != "" { - s += " from " + displayURL(l.URL) + s += fmt.Sprintf(" from %q", displayURL(l.URL)) } return s + ")" } @@ -95,18 +97,19 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { // submoduleError refuses a subdir that is a submodule or lies inside one, // which would otherwise install an empty directory or report a missing path. -// A case variant ("Vendor/Up" for "vendor/up") counts only when the -// filesystem opens the same directory for both, as Windows and macOS do. +// Each ancestor of subdir is matched by name, or by filesystem identity so a +// spelling the filesystem folds to the gitlink's directory (case on Windows +// and macOS, Unicode normalization on APFS) counts too. func submoduleError(repoPath, subdir string, extraEnv []string) error { subdir = strings.TrimPrefix(path.Clean("/"+filepath.ToSlash(subdir)), "/") + parts := strings.Split(subdir, "/") for _, l := range repoGitlinks(repoPath, extraEnv) { - n := len(l.Path) - if len(subdir) < n || (len(subdir) > n && subdir[n] != '/') { - continue - } - prefix := subdir[:n] - if prefix == l.Path || (strings.EqualFold(prefix, l.Path) && sameDir(filepath.Join(repoPath, prefix), filepath.Join(repoPath, l.Path))) { - return fmt.Errorf("'%s' is in git submodule %s, and skillshare does not fetch submodules; install from that repository instead, or copy the files into this one", subdir, l) + linkDir := filepath.Join(repoPath, filepath.FromSlash(l.Path)) + for i := range parts { + ancestor := strings.Join(parts[:i+1], "/") + if ancestor == l.Path || sameDir(filepath.Join(repoPath, filepath.FromSlash(ancestor)), linkDir) { + return fmt.Errorf("%q is in git submodule %s, and skillshare does not fetch submodules; install from that repository instead, or copy the files into this one", subdir, l) + } } } return nil diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 84c847c22..7a8147510 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -67,7 +67,7 @@ func TestDiscoverFromGitSubdir_RefusesSubmodulePaths(t *testing.T) { CleanupDiscovery(result) t.Fatalf("expected an error, got %d skill(s)", len(result.Skills)) } - if !strings.Contains(err.Error(), "git submodule 'vendor/up'") || !strings.Contains(err.Error(), upURL) { + if !strings.Contains(err.Error(), `git submodule "vendor/up"`) || !strings.Contains(err.Error(), upURL) { t.Fatalf("error should name the submodule and its upstream, got: %v", err) } }) @@ -112,6 +112,13 @@ func TestInstallTrackedRepo_RefusesSubmoduleSubdir(t *testing.T) { } } +func TestGitlinkString_EscapesControlCharacters(t *testing.T) { + got := gitlink{Path: "vendor/\x1b]52;c;Zm9v\x07up\n✓ fake", Commit: "abc", URL: "https://example.com/\x1b[31mup.git"}.String() + if strings.ContainsAny(got, "\x1b\x07\n") { + t.Fatalf("String() = %q, want control characters escaped", got) + } +} + func TestGitlinkString_HidesURLCredentials(t *testing.T) { for raw, want := range map[string]string{ "https://user:s3cret@example.com/org/up.git": "https://example.com/org/up.git", @@ -141,7 +148,7 @@ func TestDiscoverFromGit_WarnsSkippedSubmodule(t *testing.T) { if len(result.Skills) != 1 || result.Skills[0].Name != "own" { t.Fatalf("expected only the hub's own skill, got %+v", result.Skills) } - if len(result.Warnings) != 1 || !strings.Contains(result.Warnings[0], "skipped git submodule 'vendor/up'") || !strings.Contains(result.Warnings[0], upURL) { + if len(result.Warnings) != 1 || !strings.Contains(result.Warnings[0], `skipped git submodule "vendor/up"`) || !strings.Contains(result.Warnings[0], upURL) { t.Fatalf("expected one submodule warning, got %q", result.Warnings) } } diff --git a/ui/src/components/InstallDialog.test.tsx b/ui/src/components/InstallDialog.test.tsx index ca8b196db..e9d1c1a39 100644 --- a/ui/src/components/InstallDialog.test.tsx +++ b/ui/src/components/InstallDialog.test.tsx @@ -68,7 +68,7 @@ describe('InstallDialog', () => { needsSelection: true, skills: [{ name: 'pdf', path: 'pdf' }, { name: 'docx', path: 'docx' }], agents: [], - warnings: ["skipped git submodule 'vendor/up' (pinned at abc from https://example.com/up.git): skillshare does not fetch submodules"], + warnings: ['skipped git submodule "vendor/up" (pinned at abc from "https://example.com/up.git"): skillshare does not fetch submodules'], }); const user = userEvent.setup(); renderDialog('url'); @@ -76,7 +76,7 @@ describe('InstallDialog', () => { await user.type(screen.getByLabelText(/git url/i), 'owner/hub'); await user.click(screen.getByRole('button', { name: /find skills/i })); - expect(await screen.findByText(/skipped git submodule 'vendor\/up'/)).toBeInTheDocument(); + expect(await screen.findByText(/skipped git submodule "vendor\/up"/)).toBeInTheDocument(); }); it('force installs only the skill the audit blocked', async () => { @@ -160,7 +160,7 @@ describe('InstallDialog', () => { needsSelection: true, skills: [{ name: 'pdf', path: 'pdf' }, { name: 'docx', path: 'docx' }], agents: [], - warnings: ["skipped git submodule 'vendor/up'"], + warnings: ['skipped git submodule "vendor/up"'], }); vi.mocked(api.installBatch).mockResolvedValue({ results: [{ name: 'pdf', action: 'installed' }], summary: 'Installed 1' }); const user = userEvent.setup(); @@ -174,6 +174,6 @@ describe('InstallDialog', () => { expect.objectContaining({ source: 'anthropics/skills', skills: [expect.objectContaining({ name: 'pdf' })] }), )); expect(api.searchHub).toHaveBeenCalledWith('pdf', 'https://acme.dev/hub.json'); - expect(screen.getByText(/skipped git submodule 'vendor\/up'/)).toBeInTheDocument(); + expect(screen.getByText(/skipped git submodule "vendor\/up"/)).toBeInTheDocument(); }); }); diff --git a/website/docs/troubleshooting/common-errors.md b/website/docs/troubleshooting/common-errors.md index 688fab184..ee5778061 100644 --- a/website/docs/troubleshooting/common-errors.md +++ b/website/docs/troubleshooting/common-errors.md @@ -453,7 +453,7 @@ See [Environment Variables — Git SSL / TLS](/docs/reference/appendix/environme **Solution:** Check the source path is correct and points to a skill directory. -### `'' is in git submodule '' ..., and skillshare does not fetch submodules` +### `"" is in git submodule "" ..., and skillshare does not fetch submodules` **Cause:** The path you asked for is a git submodule in the repository, or sits inside one. skillshare does not fetch submodules, so the directory would be empty. From b1b5bcc3755e32acb1dab6a50370d8cc3406e017 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:36:44 +0800 Subject: [PATCH 08/11] fix(install): fail closed when submodules cannot be listed and warn on tracked updates A failed or timed-out git ls-tree used to look like a repo without submodules, letting an empty submodule path through; the refusal check now reports the failure while warnings stay best effort. Tracked updates also warn about submodules in the pulled tree. --- internal/install/install_tracked.go | 1 + internal/install/submodule.go | 27 +++++++++++++++++---------- internal/install/submodule_test.go | 27 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/internal/install/install_tracked.go b/internal/install/install_tracked.go index c22771a0d..51098d721 100644 --- a/internal/install/install_tracked.go +++ b/internal/install/install_tracked.go @@ -208,6 +208,7 @@ func updateTrackedRepo(repoPath string, result *TrackedRepoResult, opts InstallO for _, skill := range skills { result.Skills = append(result.Skills, skill.Name) } + result.Warnings = append(result.Warnings, submoduleWarnings(repoPath, nil)...) // Also discover agents in the tracked repo agents := discoverAgents(repoPath, len(skills) > 0) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index 9df0d6a5b..9c6414948 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -45,9 +45,9 @@ func displayURL(raw string) string { } // repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv -// authenticates the lazy .gitmodules fetch in a partial clone. Any git failure -// returns nil: callers only use the result to explain an empty directory. -func repoGitlinks(repoPath string, extraEnv []string) []gitlink { +// authenticates the lazy .gitmodules fetch in a partial clone. Only listing the +// tree can fail; a missing or unreadable .gitmodules just leaves URLs empty. +func repoGitlinks(repoPath string, extraEnv []string) ([]gitlink, error) { ctx, cancel := context.WithTimeout(context.Background(), gitCommandTimeout) defer cancel() @@ -55,7 +55,7 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { cmd.Dir = repoPath out, err := cmd.Output() if err != nil { - return nil + return nil, fmt.Errorf("list submodules: %w", err) } var links []gitlink for _, entry := range strings.Split(string(out), "\x00") { @@ -66,7 +66,7 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { } } if len(links) == 0 { - return nil + return nil, nil } cmd = gitCommand(ctx, "config", "-z", "--blob", "HEAD:.gitmodules", "--get-regexp", `^submodule\..*\.(path|url)$`) @@ -74,7 +74,7 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { cmd.Env = append(cmd.Env, extraEnv...) out, err = cmd.Output() if err != nil { - return links + return links, nil } paths, urls := map[string]string{}, map[string]string{} for _, entry := range strings.Split(string(out), "\x00") { @@ -92,7 +92,7 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { } } } - return links + return links, nil } // submoduleError refuses a subdir that is a submodule or lies inside one, @@ -103,7 +103,12 @@ func repoGitlinks(repoPath string, extraEnv []string) []gitlink { func submoduleError(repoPath, subdir string, extraEnv []string) error { subdir = strings.TrimPrefix(path.Clean("/"+filepath.ToSlash(subdir)), "/") parts := strings.Split(subdir, "/") - for _, l := range repoGitlinks(repoPath, extraEnv) { + links, err := repoGitlinks(repoPath, extraEnv) + if err != nil { + // Fail closed: an unchecked path may be an empty submodule directory. + return fmt.Errorf("check %q for git submodules: %w", subdir, err) + } + for _, l := range links { linkDir := filepath.Join(repoPath, filepath.FromSlash(l.Path)) for i := range parts { ancestor := strings.Join(parts[:i+1], "/") @@ -121,10 +126,12 @@ func sameDir(a, b string) bool { return errA == nil && errB == nil && os.SameFile(ai, bi) } -// submoduleWarnings names each submodule whose contents a whole-repo install skips. +// submoduleWarnings names each submodule whose contents a whole-repo install +// skips. It is best effort: a failed listing only loses the warnings. func submoduleWarnings(repoPath string, extraEnv []string) []string { + links, _ := repoGitlinks(repoPath, extraEnv) var warnings []string - for _, l := range repoGitlinks(repoPath, extraEnv) { + for _, l := range links { warnings = append(warnings, fmt.Sprintf("skipped git submodule %s: skillshare does not fetch submodules", l)) } return warnings diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 7a8147510..328031bd2 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -112,6 +112,33 @@ func TestInstallTrackedRepo_RefusesSubmoduleSubdir(t *testing.T) { } } +func TestSubmoduleError_FailsClosedWhenTreeUnreadable(t *testing.T) { + if _, err := exec.LookPath("git"); err != nil { + t.Skip("git not available") + } + t.Setenv("GIT_CEILING_DIRECTORIES", os.TempDir()) // keep git from finding an enclosing repo + if err := submoduleError(t.TempDir(), "vendor/up", nil); err == nil { + t.Fatal("expected an error when the tree cannot be listed") + } +} + +func TestInstallTrackedRepo_UpdateWarnsSkippedSubmodule(t *testing.T) { + hubURL, _ := newHubWithSubmodule(t) + sourceDir := t.TempDir() + source := &Source{Type: SourceTypeGitHTTPS, Raw: hubURL, CloneURL: hubURL, Name: "hub"} + if _, err := InstallTrackedRepo(source, sourceDir, InstallOptions{Name: "hub"}); err != nil { + t.Fatal(err) + } + + result, err := InstallTrackedRepo(source, sourceDir, InstallOptions{Name: "hub", Update: true, SkipAudit: true}) + if err != nil { + t.Fatal(err) + } + if result.Action != "updated" || !strings.Contains(strings.Join(result.Warnings, "\n"), `skipped git submodule "vendor/up"`) { + t.Fatalf("expected an update with a submodule warning, got action %q warnings %q", result.Action, result.Warnings) + } +} + func TestGitlinkString_EscapesControlCharacters(t *testing.T) { got := gitlink{Path: "vendor/\x1b]52;c;Zm9v\x07up\n✓ fake", Commit: "abc", URL: "https://example.com/\x1b[31mup.git"}.String() if strings.ContainsAny(got, "\x1b\x07\n") { From 79bb10658aaccfaa26be72fea49fbf7986ae98d6 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:40:48 +0800 Subject: [PATCH 09/11] fix(install): strip submodule URL userinfo before query and fragment A ? or # inside the userinfo used to cut away the @ before it was found, leaving the credential in place. --- internal/install/submodule.go | 17 +++++++++-------- internal/install/submodule_test.go | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index 9c6414948..355b2b7ed 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -32,16 +32,17 @@ func (l gitlink) String() string { // accepts any text there, so this fails closed on the raw string: everything // before the last "@" goes, keeping only a well-formed "scheme://" prefix. func displayURL(raw string) string { + // Userinfo first: a "?" or "#" inside it must not hide the "@". + if at := strings.LastIndex(raw, "@"); at >= 0 { + if scheme, _, ok := strings.Cut(raw[:at], "://"); ok { + raw = scheme + "://" + raw[at+1:] + } else { + raw = raw[at+1:] + } + } raw, _, _ = strings.Cut(raw, "#") raw, _, _ = strings.Cut(raw, "?") - at := strings.LastIndex(raw, "@") - if at < 0 { - return raw - } - if scheme, _, ok := strings.Cut(raw[:at], "://"); ok { - return scheme + "://" + raw[at+1:] - } - return raw[at+1:] + return raw } // repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 328031bd2..73c6a7e40 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -155,6 +155,8 @@ func TestGitlinkString_HidesURLCredentials(t *testing.T) { "s3cret@example.com:org/up.git": "example.com:org/up.git", "https:/user:s3cret@example.com/org/up.git": "example.com/org/up.git", "//user:s3cret@example.com/org/up.git": "example.com/org/up.git", + "https://user:s3cret?x@example.com/org/up.git": "https://example.com/org/up.git", + "https://user:s3cret#x@example.com/org/up.git": "https://example.com/org/up.git", } { got := gitlink{Path: "vendor/up", Commit: "abc", URL: raw}.String() if strings.Contains(got, "s3cret") || !strings.Contains(got, want) { From 0a484083e56d2f20a6851b7c600ed615fb4d2df5 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 02:46:26 +0800 Subject: [PATCH 10/11] fix(install): warn about submodules on direct whole-repo installs CLI search results install a repo-root skill through installFromGit without discovery, so the skipped-submodule warning has to come from that path too. --- internal/install/install_apply.go | 1 + internal/install/submodule_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/internal/install/install_apply.go b/internal/install/install_apply.go index 0d62e8f86..19986a39c 100644 --- a/internal/install/install_apply.go +++ b/internal/install/install_apply.go @@ -315,6 +315,7 @@ func installFromGit(source *Source, destPath string, result *InstallResult, opts // Check for SKILL.md checkSkillFile(destPath, result) + result.Warnings = append(result.Warnings, submoduleWarnings(destPath, source.authEnv())...) // Security audit if err := auditInstalledSkill(destPath, result, opts); err != nil { diff --git a/internal/install/submodule_test.go b/internal/install/submodule_test.go index 73c6a7e40..53d2cc27a 100644 --- a/internal/install/submodule_test.go +++ b/internal/install/submodule_test.go @@ -87,6 +87,19 @@ func TestInstall_RefusesSubmoduleSubdir(t *testing.T) { } } +func TestInstall_WholeRepoWarnsSkippedSubmodule(t *testing.T) { + hubURL, _ := newHubWithSubmodule(t) + dest := filepath.Join(t.TempDir(), "hub") + + result, err := Install(&Source{Type: SourceTypeGitHTTPS, Raw: hubURL, CloneURL: hubURL, Name: "hub"}, dest, InstallOptions{SkipAudit: true}) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(strings.Join(result.Warnings, "\n"), `skipped git submodule "vendor/up"`) { + t.Fatalf("expected a submodule warning, got %q", result.Warnings) + } +} + func TestSubmoduleError_CaseVariantFollowsFilesystem(t *testing.T) { hubURL, _ := newHubWithSubmodule(t) repo := filepath.Join(t.TempDir(), "repo") From f2f663689bfd6c2c85a8da658b2b4dc503b95e6e Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 09:35:59 +0800 Subject: [PATCH 11/11] fix(install): warn about submodules on tracked updates The CLI and dashboard update a tracked repo through update.TrackedRepo, which never looked for submodules. A pull that turned a skill directory into a submodule reported success and the skill vanished on the next sync. TrackedRepoResult now carries the skipped-submodule warnings and both callers show them. Refs #433 --- cmd/skillshare/update_handlers.go | 3 +++ internal/install/install_apply.go | 2 +- internal/install/install_discovery.go | 2 +- internal/install/install_tracked.go | 4 ++-- internal/install/submodule.go | 4 ++-- internal/server/handler_update.go | 3 +++ internal/update/tracked.go | 17 +++++++++++------ internal/update/tracked_test.go | 15 +++++++++++++++ skills/skillshare/references/install.md | 2 +- website/docs/reference/commands/install.md | 2 +- 10 files changed, 40 insertions(+), 14 deletions(-) diff --git a/cmd/skillshare/update_handlers.go b/cmd/skillshare/update_handlers.go index a95049b58..19008158f 100644 --- a/cmd/skillshare/update_handlers.go +++ b/cmd/skillshare/update_handlers.go @@ -159,6 +159,9 @@ func updateTrackedRepo(uc *updateContext, repoName string) (updateResult, error) if res.MetadataErr != nil { ui.Warning("Failed to refresh metadata for %s: %v", repoName, res.MetadataErr) } + for _, w := range res.Warnings { + ui.Warning("%s", w) + } if res.Status == update.StatusUpToDate { printUpdateRow(ui.MarkOK, repoName, "already up to date", time.Since(startUpdate)) return updateResult{skipped: 1}, nil diff --git a/internal/install/install_apply.go b/internal/install/install_apply.go index 19986a39c..cd684e331 100644 --- a/internal/install/install_apply.go +++ b/internal/install/install_apply.go @@ -315,7 +315,7 @@ func installFromGit(source *Source, destPath string, result *InstallResult, opts // Check for SKILL.md checkSkillFile(destPath, result) - result.Warnings = append(result.Warnings, submoduleWarnings(destPath, source.authEnv())...) + result.Warnings = append(result.Warnings, SubmoduleWarnings(destPath, source.authEnv())...) // Security audit if err := auditInstalledSkill(destPath, result, opts); err != nil { diff --git a/internal/install/install_discovery.go b/internal/install/install_discovery.go index 1c07efbe8..1f9b17adf 100644 --- a/internal/install/install_discovery.go +++ b/internal/install/install_discovery.go @@ -62,7 +62,7 @@ func discoverFromGitWithProgressImpl(source *Source, onProgress ProgressCallback Agents: agents, Source: source, CommitHash: commitHash, - Warnings: submoduleWarnings(repoPath, source.authEnv()), + Warnings: SubmoduleWarnings(repoPath, source.authEnv()), }, nil } diff --git a/internal/install/install_tracked.go b/internal/install/install_tracked.go index 51098d721..eb51590d4 100644 --- a/internal/install/install_tracked.go +++ b/internal/install/install_tracked.go @@ -129,7 +129,7 @@ func installTrackedRepoImpl(source *Source, sourceDir string, opts InstallOption for _, skill := range skills { result.Skills = append(result.Skills, skill.Name) } - result.Warnings = append(result.Warnings, submoduleWarnings(destPath, source.authEnv())...) + result.Warnings = append(result.Warnings, SubmoduleWarnings(destPath, source.authEnv())...) // Also discover agents in the tracked repo agents := discoverAgents(destPath, len(skills) > 0) @@ -208,7 +208,7 @@ func updateTrackedRepo(repoPath string, result *TrackedRepoResult, opts InstallO for _, skill := range skills { result.Skills = append(result.Skills, skill.Name) } - result.Warnings = append(result.Warnings, submoduleWarnings(repoPath, nil)...) + result.Warnings = append(result.Warnings, SubmoduleWarnings(repoPath, nil)...) // Also discover agents in the tracked repo agents := discoverAgents(repoPath, len(skills) > 0) diff --git a/internal/install/submodule.go b/internal/install/submodule.go index 355b2b7ed..0e720d1d2 100644 --- a/internal/install/submodule.go +++ b/internal/install/submodule.go @@ -127,9 +127,9 @@ func sameDir(a, b string) bool { return errA == nil && errB == nil && os.SameFile(ai, bi) } -// submoduleWarnings names each submodule whose contents a whole-repo install +// SubmoduleWarnings names each submodule whose contents a whole-repo install // skips. It is best effort: a failed listing only loses the warnings. -func submoduleWarnings(repoPath string, extraEnv []string) []string { +func SubmoduleWarnings(repoPath string, extraEnv []string) []string { links, _ := repoGitlinks(repoPath, extraEnv) var warnings []string for _, l := range links { diff --git a/internal/server/handler_update.go b/internal/server/handler_update.go index 5665864b3..bbf15e2cf 100644 --- a/internal/server/handler_update.go +++ b/internal/server/handler_update.go @@ -358,6 +358,9 @@ func (s *Server) updateTrackedRepo(name, repoPath, sourceDir string, force, skip default: item.Action = "updated" item.Message = fmt.Sprintf("%d commits, %d files changed", len(res.Info.Commits), res.Info.Stats.FilesChanged) + for _, w := range res.Warnings { + item.Message += "; " + w + } if res.Audit != nil { item.AuditRiskScore = res.Audit.RiskScore item.AuditRiskLabel = res.Audit.RiskLabel diff --git a/internal/update/tracked.go b/internal/update/tracked.go index e1c0105a2..71d559798 100644 --- a/internal/update/tracked.go +++ b/internal/update/tracked.go @@ -84,12 +84,13 @@ type TrackedRepoResult struct { Audit *audit.Result // nil when the audit was skipped or could not scan Threshold string // normalized block threshold of the audit - AcceptedSkipped int // findings ignored because they were accepted earlier - Overridden bool // blocking findings were let through by Force or Confirm - Recorded int // findings newly recorded as accepted - RecordErr error // recording accepted findings failed; the update stays applied - MetadataChanged bool // root-skill hashes were rewritten under SourceDir - MetadataErr error // refreshing metadata failed; the update stays applied + AcceptedSkipped int // findings ignored because they were accepted earlier + Overridden bool // blocking findings were let through by Force or Confirm + Recorded int // findings newly recorded as accepted + RecordErr error // recording accepted findings failed; the update stays applied + MetadataChanged bool // root-skill hashes were rewritten under SourceDir + MetadataErr error // refreshing metadata failed; the update stays applied + Warnings []string // git submodules the pulled checkout leaves empty } // TrackedRepo updates one tracked repo: it refuses or discards uncommitted @@ -136,6 +137,10 @@ func TrackedRepo(repoPath string, opts TrackedRepoOptions) (*TrackedRepoResult, } } + if !info.UpToDate { + res.Warnings = install.SubmoduleWarnings(repoPath, git.AuthEnvForRepo(repoPath)) + } + if opts.SourceDir != "" { res.MetadataChanged, res.MetadataErr = refreshMetadata(repoPath, opts) } diff --git a/internal/update/tracked_test.go b/internal/update/tracked_test.go index 77cad0ee9..e544d8e45 100644 --- a/internal/update/tracked_test.go +++ b/internal/update/tracked_test.go @@ -336,3 +336,18 @@ func TestTrackedRepo_RefreshesRootSkillMetadata(t *testing.T) { t.Errorf("root skill hashes were not refreshed: %+v", entry) } } + +func TestTrackedRepo_WarnsWhenPullAddsSubmodule(t *testing.T) { + f := newFixture(t, cleanSkill+"More help.\n") + testutil.RunGit(t, f.seed, "update-index", "--add", "--cacheinfo", "160000,"+f.before+",vendor/up") + testutil.RunGit(t, f.seed, "commit", "-m", "add submodule") + testutil.RunGit(t, f.seed, "push", "origin", "HEAD:main") + + res, err := TrackedRepo(f.repo, f.opts()) + if err != nil { + t.Fatal(err) + } + if got := strings.Join(res.Warnings, "\n"); !strings.Contains(got, `skipped git submodule "vendor/up"`) { + t.Fatalf("warnings = %q, want a skipped-submodule warning", got) + } +} diff --git a/skills/skillshare/references/install.md b/skills/skillshare/references/install.md index 696ddb6c3..61fd61784 100644 --- a/skills/skillshare/references/install.md +++ b/skills/skillshare/references/install.md @@ -83,7 +83,7 @@ skillshare install user/repo --skip-audit # Skip security scan **Fuzzy subdirectory resolution:** When a monorepo has nested skill directories, you can specify just the skill name — e.g., `user/repo/vue-best-practices` finds `skills/vue-best-practices/` automatically. Fails with an error if multiple matches exist. -**Git submodules:** skillshare does not fetch submodules. A path that is, or lies inside, a submodule fails with an error naming its upstream URL; install from that upstream instead. Whole-repo browsing and `--track` warn about each submodule they skip. +**Git submodules:** skillshare does not fetch submodules. A path that is, or lies inside, a submodule fails with an error naming its upstream URL; install from that upstream instead. Whole-repo browsing, `--track` and `update` warn about each submodule they skip. **Tracked repos:** Prefixed with `_`, nested with `__` (e.g., `_team__frontend__ui`). Tracked custom names must not contain path separators (`/`, `\`) or `..`. diff --git a/website/docs/reference/commands/install.md b/website/docs/reference/commands/install.md index 86bb367d9..d09963929 100644 --- a/website/docs/reference/commands/install.md +++ b/website/docs/reference/commands/install.md @@ -199,7 +199,7 @@ When specifying a subdirectory path like `owner/repo/skill-name`, if the exact p ::: :::note Git submodules are not fetched -skillshare does not fetch git submodules. Installing a path that is a submodule, or lies inside one, fails with an error that names the submodule, its pinned commit, and its upstream URL; install from that upstream repository instead, or copy the files into the hub. When you browse a whole repository, `install` and `--track` warn about each submodule they skip. +skillshare does not fetch git submodules. Installing a path that is a submodule, or lies inside one, fails with an error that names the submodule, its pinned commit, and its upstream URL; install from that upstream repository instead, or copy the files into the hub. When you browse a whole repository, `install`, `--track` and `update` warn about each submodule they skip. ::: ## Install from Config (No Arguments) {#install-from-config-no-arguments}