mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
Merge branch 'main' into runkids/460-plugin-config-write
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
@@ -516,6 +517,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 +593,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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
@@ -122,6 +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())...)
|
||||
|
||||
// Also discover agents in the tracked repo
|
||||
agents := discoverAgents(destPath, len(skills) > 0)
|
||||
@@ -200,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)
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package install
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"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
|
||||
}
|
||||
|
||||
// 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("%q (pinned at %s", l.Path, shortHash(l.Commit))
|
||||
if l.URL != "" {
|
||||
s += fmt.Sprintf(" from %q", 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. 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 {
|
||||
// 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, "?")
|
||||
return raw
|
||||
}
|
||||
|
||||
// repoGitlinks lists the submodules recorded in HEAD of repoPath. extraEnv
|
||||
// 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()
|
||||
|
||||
cmd := gitCommand(ctx, "ls-tree", "-r", "-z", "HEAD")
|
||||
cmd.Dir = repoPath
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("list submodules: %w", err)
|
||||
}
|
||||
var links []gitlink
|
||||
for _, entry := range strings.Split(string(out), "\x00") {
|
||||
meta, p, ok := strings.Cut(entry, "\t")
|
||||
fields := strings.Fields(meta)
|
||||
if ok && len(fields) == 3 && fields[0] == "160000" {
|
||||
links = append(links, gitlink{Path: p, Commit: fields[2]})
|
||||
}
|
||||
}
|
||||
if len(links) == 0 {
|
||||
return nil, 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, nil
|
||||
}
|
||||
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, p := range paths {
|
||||
for i := range links {
|
||||
if links[i].Path == p {
|
||||
links[i].URL = urls[name]
|
||||
}
|
||||
}
|
||||
}
|
||||
return links, nil
|
||||
}
|
||||
|
||||
// submoduleError refuses a subdir that is a submodule or lies inside one,
|
||||
// which would otherwise install an empty directory or report a missing path.
|
||||
// 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, "/")
|
||||
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], "/")
|
||||
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
|
||||
}
|
||||
|
||||
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. 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 links {
|
||||
warnings = append(warnings, fmt.Sprintf("skipped git submodule %s: skillshare does not fetch submodules", l))
|
||||
}
|
||||
return warnings
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
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://" + filepath.ToSlash(up) // git records forward slashes on Windows too
|
||||
|
||||
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", "vendor//up"} {
|
||||
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 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")
|
||||
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 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") {
|
||||
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",
|
||||
"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",
|
||||
"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) {
|
||||
t.Errorf("String() for %q = %q, want %q without credentials", raw, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, `--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 `..`.
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ export interface DiscoverResult {
|
||||
needsSelection: boolean;
|
||||
skills: DiscoveredSkill[];
|
||||
agents: DiscoveredAgent[];
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
export interface BatchInstallResultItem {
|
||||
|
||||
@@ -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)
|
||||
@@ -140,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');
|
||||
@@ -153,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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -283,7 +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 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[]) => {
|
||||
@@ -345,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);
|
||||
|
||||
@@ -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`, `--track` and `update` 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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
### `"<path>" is in git submodule "<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
|
||||
|
||||
Reference in New Issue
Block a user