From 8b350ed6d0fa9bf9dfff2c384c6915dd87bbdf57 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 20:51:39 +0800 Subject: [PATCH 1/8] fix(server): report tracked repo source for nested skills Tracked repo metadata is keyed by the repo directory (e.g. "_skills"), but skills inside the repo are discovered with their full path ("_skills/skills/engineering/tdd"). The lookup found no entry for them, so /api/resources returned an empty source and the dashboard's update cards showed "tracked" without owner/repo. Repos whose SKILL.md sits at the root matched the key directly and looked fine, which is why the issue appeared to correlate with partial clones. Nested repo skills now fall back to the repo's tracked entry. They also ignore a bare-basename match, which GetByPath keeps for legacy short keys but which can belong to an unrelated top-level skill of the same name. GetByPath itself is unchanged because update, uninstall and check depend on its current behavior. Fixes #467 --- internal/server/handler_skills.go | 4 +- internal/server/handler_skills_test.go | 53 ++++++++++++++++++++++++++ internal/server/server.go | 22 +++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/internal/server/handler_skills.go b/internal/server/handler_skills.go index 05105dffc..f83fa0648 100644 --- a/internal/server/handler_skills.go +++ b/internal/server/handler_skills.go @@ -113,7 +113,7 @@ func (s *Server) handleListSkills(w http.ResponseWriter, r *http.Request) { } enrichSkillLink(&item, source, walk, linkTargets) - if entry := s.skillEntry(d.RelPath); entry != nil { + if entry := s.discoveredSkillEntry(d.RelPath, d.IsInRepo); entry != nil { if !entry.InstalledAt.IsZero() { item.InstalledAt = entry.InstalledAt.Format(time.RFC3339) } @@ -229,7 +229,7 @@ func (s *Server) handleGetSkill(w http.ResponseWriter, r *http.Request) { } enrichSkillLink(&item, source, walk, make(map[string]string)) - if entry := s.skillEntry(d.RelPath); entry != nil { + if entry := s.discoveredSkillEntry(d.RelPath, d.IsInRepo); entry != nil { if !entry.InstalledAt.IsZero() { item.InstalledAt = entry.InstalledAt.Format(time.RFC3339) } diff --git a/internal/server/handler_skills_test.go b/internal/server/handler_skills_test.go index 1623dc594..ede8b8ad4 100644 --- a/internal/server/handler_skills_test.go +++ b/internal/server/handler_skills_test.go @@ -55,6 +55,59 @@ func TestHandleListSkills_WithSkills(t *testing.T) { } } +// listedSources saves store, lists resources through the full handler (which +// reloads metadata from disk), and returns each resource's source by relPath. +func listedSources(t *testing.T, s *Server, src string, store *install.MetadataStore) map[string]string { + t.Helper() + if err := store.Save(src); err != nil { + t.Fatalf("save metadata: %v", err) + } + rr := httptest.NewRecorder() + s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodGet, "/api/resources", nil)) + var resp struct { + Resources []struct { + RelPath string `json:"relPath"` + Source string `json:"source"` + } `json:"resources"` + } + if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { + t.Fatalf("decode resources: %v: %s", err, rr.Body.String()) + } + sources := make(map[string]string) + for _, r := range resp.Resources { + sources[r.RelPath] = r.Source + } + return sources +} + +func TestHandleListSkills_NestedTrackedSkillUsesRepoSource(t *testing.T) { + s, src := newTestServer(t) + addTrackedRepo(t, src, "_team-skills") + addSkill(t, src, "_team-skills/skills/vue") + const remote = "https://github.com/team/skills.git" + store := install.NewMetadataStore() + store.Set("_team-skills", &install.MetadataEntry{Source: remote, Tracked: true}) + + if got := listedSources(t, s, src, store)["_team-skills/skills/vue"]; got != remote { + t.Fatalf("expected nested tracked skill to report source %q, got %q", remote, got) + } +} + +func TestHandleListSkills_NestedTrackedSkillIgnoresSameNamedTopLevelSkill(t *testing.T) { + s, src := newTestServer(t) + addTrackedRepo(t, src, "_team-skills") + addSkill(t, src, "_team-skills/skills/vue") + addSkill(t, src, "vue") + const remote = "https://github.com/team/skills.git" + store := install.NewMetadataStore() + store.Set("_team-skills", &install.MetadataEntry{Source: remote, Tracked: true}) + store.Set("vue", &install.MetadataEntry{Source: "github.com/other/vue"}) + + if got := listedSources(t, s, src, store)["_team-skills/skills/vue"]; got != remote { + t.Fatalf("expected nested tracked skill to report source %q, got %q", remote, got) + } +} + func TestHandleListSkills_ManualOnly(t *testing.T) { s, src := newTestServer(t) addSkill(t, src, "auto") diff --git a/internal/server/server.go b/internal/server/server.go index e9a856402..0721955e8 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -160,6 +160,28 @@ func (s *Server) skillEntry(relPath string) *install.MetadataEntry { return copyMetadataEntry(s.skillsStore.GetByPath(relPath)) } +// discoveredSkillEntry returns a copy of the metadata entry for a discovered +// skill. A skill nested inside a tracked repo has no entry of its own, so it +// falls back to the repo's entry, which carries the repo source. +func (s *Server) discoveredSkillEntry(relPath string, inRepo bool) *install.MetadataEntry { + if !inRepo { + return s.skillEntry(relPath) + } + s.mu.RLock() + defer s.mu.RUnlock() + // GetByPath also matches a bare basename key, which for a nested repo skill + // can be an unrelated top-level skill of the same name. Only an exact or + // group-matched entry belongs to the skill itself. + if e := s.skillsStore.GetByPath(relPath); e != nil && (e.Group != "" || s.skillsStore.Has(relPath)) { + return copyMetadataEntry(e) + } + repo, _, _ := strings.Cut(relPath, "/") + if e := s.skillsStore.Get(repo); e != nil && e.Tracked { + return copyMetadataEntry(e) + } + return nil +} + // agentEntry returns a copy of the agents metadata entry for key, or nil. // It takes s.mu.RLock, so the caller must not hold s.mu. func (s *Server) agentEntry(key string) *install.MetadataEntry { From 4dd62d4ce51167910c9601b6353046e0802945e9 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:23:26 +0800 Subject: [PATCH 2/8] fix: treat tracked repos installed with --into as repos `install --track --into org` clones to org/_repo, but skill discovery only marked a skill as in-repo when the first path segment started with "_". Everything downstream also assumed the repo name was that first segment. Skills of such a repo were therefore treated as loose skills: no source in the dashboard, not grouped under the repo, a skill count of 0 in `status`, and an install hint that pointed at the wrong name. Discovery now records each skill's tracked repo root (RepoRelPath). A first-segment "_" folder still counts as before; a deeper one counts only when the walk saw it as a git clone, so a plain org/_drafts folder stays a folder. The repo's .skillignore is looked up by the same root. Consumers move from "first segment" to that root: - the API exposes it as repoPath, and the dashboard groups, updates and uninstalls repos by it; - `list` and `status` use it for repo names and counts; - batch uninstall accepts a nested repo name, so the dashboard can still remove an --into repo now that its skills are in-repo; - repo names sent to the dashboard by check and update-all use slash paths, so they match repoPath on Windows too; - the install hint suggests `skillshare update org/_repo`. Fixes #470 --- cmd/skillshare/install_handlers.go | 3 +- cmd/skillshare/list.go | 5 +-- cmd/skillshare/status.go | 15 +++---- internal/server/handler_skills.go | 9 +++- internal/server/handler_skills_test.go | 27 +++++++++++ internal/server/handler_uninstall.go | 3 +- .../server/handler_uninstall_links_test.go | 15 +++++++ internal/server/handler_update.go | 2 +- internal/server/handler_update_stream.go | 2 +- internal/server/server.go | 10 ++--- internal/server/source_links.go | 5 ++- internal/sync/discover_test.go | 45 +++++++++++++++++++ internal/sync/discover_walk.go | 42 ++++++++++------- internal/sync/sync.go | 12 ++--- .../install_track_root_skill_test.go | 43 ++++++++++++++++++ ui/src/api/types/resources.ts | 2 + .../components/skill-editor/SkillEditor.tsx | 4 +- ui/src/lib/resourceGrouping.test.ts | 7 +++ ui/src/lib/resourceGrouping.ts | 2 +- ui/src/lib/resourceNames.ts | 4 +- ui/src/pages/ResourceDetailPage.tsx | 4 +- ui/src/pages/UpdatePage.tsx | 8 ++-- .../docs/understand/tracked-repositories.md | 2 + .../understand/tracked-repositories.md | 2 + .../understand/tracked-repositories.md | 2 + .../understand/tracked-repositories.md | 2 + .../understand/tracked-repositories.md | 2 + 27 files changed, 220 insertions(+), 59 deletions(-) diff --git a/cmd/skillshare/install_handlers.go b/cmd/skillshare/install_handlers.go index 1489d8460..43dcd4bc5 100644 --- a/cmd/skillshare/install_handlers.go +++ b/cmd/skillshare/install_handlers.go @@ -113,7 +113,8 @@ func handleTrackedRepoInstall(source *install.Source, cfg *config.Config, opts i if result.SkillCount > 0 { next = append(next, "skillshare sync", "link them into your targets") } - next = append(next, "skillshare update "+result.RepoName, "update this repo later") + // --into places the repo in a folder; update takes the path from the source root. + next = append(next, "skillshare update "+filepath.ToSlash(filepath.Join(opts.Into, result.RepoName)), "update this repo later") } ui.Next(next...) } diff --git a/cmd/skillshare/list.go b/cmd/skillshare/list.go index d0d89eb3b..1e00aa075 100644 --- a/cmd/skillshare/list.go +++ b/cmd/skillshare/list.go @@ -298,10 +298,7 @@ func buildSkillEntries(discovered []sync.DiscoveredSkill) []skillEntry { Disabled: d.Disabled, } if d.IsInRepo { - parts := strings.SplitN(d.RelPath, "/", 2) - if len(parts) > 0 { - skills[i].RepoName = parts[0] - } + skills[i].RepoName = d.RepoRelPath } // Enrich from centralized metadata store diff --git a/cmd/skillshare/status.go b/cmd/skillshare/status.go index c019f862f..4f9e13237 100644 --- a/cmd/skillshare/status.go +++ b/cmd/skillshare/status.go @@ -260,18 +260,13 @@ func buildTrackedRepoJSON(sourcePath string, trackedRepos []string, discovered [ missingRepos, _ := install.GetMissingTrackedRepos(sourcePath, walks...) - // Count skills per repo (single pass). A tracked repo may surface skills - // at the repo root (RelPath equals the repo name, no slash) or nested - // (RelPath has the form "/..."), so both shapes must be counted. + // Count skills per repo (single pass). RepoRelPath covers skills at the + // repo root and nested ones, and repos placed with --into (org/_repo). + // trackedRepos holds OS-native paths, RepoRelPath slash paths. repoSkillCount := make(map[string]int, len(trackedRepos)) for _, d := range discovered { - if !d.IsInRepo { - continue - } - if idx := strings.Index(d.RelPath, "/"); idx > 0 { - repoSkillCount[d.RelPath[:idx]]++ - } else { - repoSkillCount[d.RelPath]++ + if d.IsInRepo { + repoSkillCount[filepath.FromSlash(d.RepoRelPath)]++ } } diff --git a/internal/server/handler_skills.go b/internal/server/handler_skills.go index f83fa0648..bf87cb206 100644 --- a/internal/server/handler_skills.go +++ b/internal/server/handler_skills.go @@ -28,6 +28,7 @@ type skillItem struct { LinkName string `json:"linkName,omitempty"` LinkTarget string `json:"linkTarget,omitempty"` IsInRepo bool `json:"isInRepo"` + RepoPath string `json:"repoPath,omitempty"` Targets []string `json:"targets,omitempty"` InstalledAt string `json:"installedAt,omitempty"` Source string `json:"source,omitempty"` @@ -107,13 +108,14 @@ func (s *Server) handleListSkills(w http.ResponseWriter, r *http.Request) { RelPath: d.RelPath, SourcePath: d.SourcePath, IsInRepo: d.IsInRepo, + RepoPath: d.RepoRelPath, Targets: d.Targets, Disabled: d.Disabled, ManualOnly: manualOnly(d.SourcePath), } enrichSkillLink(&item, source, walk, linkTargets) - if entry := s.discoveredSkillEntry(d.RelPath, d.IsInRepo); entry != nil { + if entry := s.discoveredSkillEntry(d.RelPath, d.RepoRelPath); entry != nil { if !entry.InstalledAt.IsZero() { item.InstalledAt = entry.InstalledAt.Format(time.RFC3339) } @@ -140,6 +142,7 @@ func (s *Server) handleListSkills(w http.ResponseWriter, r *http.Request) { RelPath: d.RelPath, SourcePath: d.SourcePath, IsInRepo: d.IsInRepo, + RepoPath: d.RepoRelPath, Disabled: d.Disabled, Targets: d.Targets, } @@ -223,13 +226,14 @@ func (s *Server) handleGetSkill(w http.ResponseWriter, r *http.Request) { RelPath: d.RelPath, SourcePath: d.SourcePath, IsInRepo: d.IsInRepo, + RepoPath: d.RepoRelPath, Targets: d.Targets, Disabled: d.Disabled, ManualOnly: manualOnly(d.SourcePath), } enrichSkillLink(&item, source, walk, make(map[string]string)) - if entry := s.discoveredSkillEntry(d.RelPath, d.IsInRepo); entry != nil { + if entry := s.discoveredSkillEntry(d.RelPath, d.RepoRelPath); entry != nil { if !entry.InstalledAt.IsZero() { item.InstalledAt = entry.InstalledAt.Format(time.RFC3339) } @@ -299,6 +303,7 @@ func (s *Server) handleGetSkill(w http.ResponseWriter, r *http.Request) { RelPath: d.RelPath, SourcePath: d.SourcePath, IsInRepo: d.IsInRepo, + RepoPath: d.RepoRelPath, Disabled: d.Disabled, Targets: d.Targets, } diff --git a/internal/server/handler_skills_test.go b/internal/server/handler_skills_test.go index ede8b8ad4..df393ce45 100644 --- a/internal/server/handler_skills_test.go +++ b/internal/server/handler_skills_test.go @@ -93,6 +93,33 @@ func TestHandleListSkills_NestedTrackedSkillUsesRepoSource(t *testing.T) { } } +func TestHandleListSkills_TrackedRepoInstalledIntoReportsRepo(t *testing.T) { + s, src := newTestServer(t) + addTrackedRepo(t, src, "org/_team-skills") + addSkill(t, src, "org/_team-skills/skills/vue") + const remote = "https://github.com/team/skills.git" + store := install.NewMetadataStore() + store.Set("org/_team-skills", &install.MetadataEntry{Source: remote, Tracked: true}) + if err := store.Save(src); err != nil { + t.Fatalf("save metadata: %v", err) + } + + rr := httptest.NewRecorder() + s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodGet, "/api/resources", nil)) + var resp struct { + Resources []struct { + Source string `json:"source"` + RepoPath string `json:"repoPath"` + } `json:"resources"` + } + if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { + t.Fatalf("decode resources: %v: %s", err, rr.Body.String()) + } + if len(resp.Resources) != 1 || resp.Resources[0].Source != remote || resp.Resources[0].RepoPath != "org/_team-skills" { + t.Fatalf("expected skill in repo org/_team-skills with source %q, got %+v", remote, resp.Resources) + } +} + func TestHandleListSkills_NestedTrackedSkillIgnoresSameNamedTopLevelSkill(t *testing.T) { s, src := newTestServer(t) addTrackedRepo(t, src, "_team-skills") diff --git a/internal/server/handler_uninstall.go b/internal/server/handler_uninstall.go index fb32974ff..c2055f528 100644 --- a/internal/server/handler_uninstall.go +++ b/internal/server/handler_uninstall.go @@ -186,7 +186,8 @@ func (s *Server) resolveBatchUninstallItem(discovered []sync.DiscoveredSkill, so repoPath := filepath.Join(source, name) _, repoFollowed := walk.Follow.Resolve(repoPath) - managedRepo := strings.HasPrefix(name, "_") && filepath.Base(name) == name && !repoFollowed && install.IsGitRepo(repoPath) + // A repo installed with --into is named by its path, e.g. org/_team. + managedRepo := strings.HasPrefix(filepath.Base(name), "_") && !repoFollowed && install.IsGitRepo(repoPath) var skill *sync.DiscoveredSkill if !managedRepo { var err error diff --git a/internal/server/handler_uninstall_links_test.go b/internal/server/handler_uninstall_links_test.go index 457589833..d3afe421b 100644 --- a/internal/server/handler_uninstall_links_test.go +++ b/internal/server/handler_uninstall_links_test.go @@ -225,6 +225,21 @@ func TestHandleUninstallSkill_AmbiguousLinkedBasename(t *testing.T) { } } +func TestHandleBatchUninstall_RepoInstalledInto(t *testing.T) { + s, src := newTestServer(t) + addTrackedRepo(t, src, "org/_team") + addSkill(t, filepath.Join(src, "org", "_team"), "foo") + body, err := json.Marshal(batchUninstallRequest{Names: []string{"org/_team"}, Force: true}) + if err != nil { + t.Fatal(err) + } + rr := httptest.NewRecorder() + s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodPost, "/api/uninstall/batch", bytes.NewReader(body))) + if _, err := os.Stat(filepath.Join(src, "org", "_team")); !os.IsNotExist(err) { + t.Fatalf("expected org/_team to be uninstalled, stat err %v: %s", err, rr.Body.String()) + } +} + func TestHandleBatchUninstall_RepoBeforeLinkedBasename(t *testing.T) { s, src := newTestServer(t) addTrackedRepo(t, src, "_team") diff --git a/internal/server/handler_update.go b/internal/server/handler_update.go index bbf15e2cf..48fcfa7cc 100644 --- a/internal/server/handler_update.go +++ b/internal/server/handler_update.go @@ -450,7 +450,7 @@ func (s *Server) updateAll(force, skipAudit bool) []updateResultItem { if err == nil { for _, repo := range repos { repoPath := filepath.Join(s.cfg.EffectiveSkillsSource(), repo) - results = append(results, s.updateTrackedRepo(repo, repoPath, s.cfg.EffectiveSkillsSource(), force, skipAudit, walk.Follow)) + results = append(results, s.updateTrackedRepo(filepath.ToSlash(repo), repoPath, s.cfg.EffectiveSkillsSource(), force, skipAudit, walk.Follow)) } } diff --git a/internal/server/handler_update_stream.go b/internal/server/handler_update_stream.go index 8232e0866..21024138a 100644 --- a/internal/server/handler_update_stream.go +++ b/internal/server/handler_update_stream.go @@ -85,7 +85,7 @@ func (s *Server) handleUpdateStream(w http.ResponseWriter, r *http.Request) { if err == nil { for _, repo := range repos { items = append(items, updateItem{ - name: repo, + name: filepath.ToSlash(repo), isRepo: true, path: filepath.Join(source, repo), }) diff --git a/internal/server/server.go b/internal/server/server.go index 0721955e8..5230d45b9 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -162,9 +162,10 @@ func (s *Server) skillEntry(relPath string) *install.MetadataEntry { // discoveredSkillEntry returns a copy of the metadata entry for a discovered // skill. A skill nested inside a tracked repo has no entry of its own, so it -// falls back to the repo's entry, which carries the repo source. -func (s *Server) discoveredSkillEntry(relPath string, inRepo bool) *install.MetadataEntry { - if !inRepo { +// falls back to the repo's entry, which carries the repo source. repoRelPath is +// the skill's tracked repo root from discovery, empty outside a repo. +func (s *Server) discoveredSkillEntry(relPath, repoRelPath string) *install.MetadataEntry { + if repoRelPath == "" { return s.skillEntry(relPath) } s.mu.RLock() @@ -175,8 +176,7 @@ func (s *Server) discoveredSkillEntry(relPath string, inRepo bool) *install.Meta if e := s.skillsStore.GetByPath(relPath); e != nil && (e.Group != "" || s.skillsStore.Has(relPath)) { return copyMetadataEntry(e) } - repo, _, _ := strings.Cut(relPath, "/") - if e := s.skillsStore.Get(repo); e != nil && e.Tracked { + if e := s.skillsStore.Get(repoRelPath); e != nil && e.Tracked { return copyMetadataEntry(e) } return nil diff --git a/internal/server/source_links.go b/internal/server/source_links.go index 6862235f6..bed22ead6 100644 --- a/internal/server/source_links.go +++ b/internal/server/source_links.go @@ -19,8 +19,9 @@ func dashboardRepos(source string, walk sourcewalk.Options) ([]string, []linkedR managed := make([]string, 0, len(repos)) linked := []linkedRepoInfo{} seen := map[string]bool{} - for _, name := range repos { - path := filepath.Join(source, name) + for _, rel := range repos { + // The dashboard matches repos by slash path (org/_team); GetTrackedRepos is OS-native. + path, name := filepath.Join(source, rel), filepath.ToSlash(rel) if target, ok := walk.Follow.Resolve(path); ok { linked = append(linked, linkedRepoInfo{Name: name, Target: target}) seen[name] = true diff --git a/internal/sync/discover_test.go b/internal/sync/discover_test.go index d09059a95..68681025b 100644 --- a/internal/sync/discover_test.go +++ b/internal/sync/discover_test.go @@ -137,6 +137,51 @@ func TestDiscoverSourceSkills_TrackedRepo(t *testing.T) { } } +func TestDiscoverSourceSkills_TrackedRepoInstalledInto(t *testing.T) { + src := t.TempDir() + // install --track --into org places the clone at org/_repo + os.MkdirAll(filepath.Join(src, "org", "_repo", ".git"), 0755) + writeSkillMD(t, filepath.Join(src, "org", "_repo", "skills", "vue"), "---\nname: vue\n---\n# Vue") + + skills, err := DiscoverSourceSkills(src) + if err != nil { + t.Fatal(err) + } + if len(skills) != 1 || !skills[0].IsInRepo || skills[0].RepoRelPath != "org/_repo" { + t.Fatalf("expected one skill in repo org/_repo, got %+v", skills) + } +} + +func TestDiscoverSourceSkills_NestedUnderscoreDirWithoutGitIsNotRepo(t *testing.T) { + src := t.TempDir() + writeSkillMD(t, filepath.Join(src, "org", "_drafts", "vue"), "---\nname: vue\n---\n# Vue") + + skills, err := DiscoverSourceSkills(src) + if err != nil { + t.Fatal(err) + } + if len(skills) != 1 || skills[0].IsInRepo { + t.Fatalf("expected one skill outside any repo, got %+v", skills) + } +} + +func TestDiscoverSourceSkills_TrackedRepoInstalledIntoRespectsSkillIgnore(t *testing.T) { + src := t.TempDir() + repoDir := filepath.Join(src, "org", "_repo") + os.MkdirAll(filepath.Join(repoDir, ".git"), 0755) + os.WriteFile(filepath.Join(repoDir, ".skillignore"), []byte("drafts\n"), 0644) + writeSkillMD(t, filepath.Join(repoDir, "drafts", "wip"), "---\nname: wip\n---\n# WIP") + writeSkillMD(t, filepath.Join(repoDir, "vue"), "---\nname: vue\n---\n# Vue") + + skills, err := DiscoverSourceSkills(src) + if err != nil { + t.Fatal(err) + } + if len(skills) != 1 || skills[0].RelPath != "org/_repo/vue" { + t.Fatalf("expected only org/_repo/vue, got %+v", skills) + } +} + func TestDiscoverSourceSkills_ParsesTargets(t *testing.T) { src := t.TempDir() content := "---\nname: targeted\ntargets:\n - claude\n - cursor\n---\n# Targeted" diff --git a/internal/sync/discover_walk.go b/internal/sync/discover_walk.go index c9fab9b88..ed93896de 100644 --- a/internal/sync/discover_walk.go +++ b/internal/sync/discover_walk.go @@ -139,6 +139,22 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di var skills []DiscoveredSkill var trackedRepos []string ignoreMatchers := make(map[string]*skillignore.Matcher) // tracked repo abs path → .skillignore matcher + repoRoots := make(map[string]bool) // slash rel paths of git repos seen so far, e.g. org/_team from --into + + // repoOf returns the tracked repo root containing parts, or "". A _-prefixed + // first segment always counts; a deeper one only when the walk saw it as a + // git repo, so a plain org/_drafts folder is not mistaken for a repo. + repoOf := func(parts []string) string { + if utils.IsTrackedRepoDir(parts[0]) { + return parts[0] + } + for i := 1; i < len(parts); i++ { + if root := strings.Join(parts[:i+1], "/"); utils.IsTrackedRepoDir(parts[i]) && repoRoots[root] { + return root + } + } + return "" + } walkRoot := utils.ResolveSymlink(sourcePath) rootMatcher := skillignore.ReadMatcher(walkRoot) @@ -189,9 +205,10 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di // Collect tracked repos: _-prefixed directories that are git repos if info.IsDir() && info.Name() != "." && utils.IsTrackedRepoDir(info.Name()) { if install.IsGitRepo(path) { - if opts.collectTracked { - relPath, relErr := filepath.Rel(walkRoot, path) - if relErr == nil && relPath != "." { + relPath, relErr := filepath.Rel(walkRoot, path) + if relErr == nil && relPath != "." { + repoRoots[filepath.ToSlash(relPath)] = true + if opts.collectTracked { trackedRepos = append(trackedRepos, relPath) } } @@ -219,12 +236,9 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di relPath, relErr := filepath.Rel(walkRoot, path) if relErr == nil && relPath != "." { relPath = strings.ReplaceAll(relPath, "\\", "/") - parts := strings.Split(relPath, "/") - if len(parts) > 1 && utils.IsTrackedRepoDir(parts[0]) { - repoAbsPath := filepath.Join(walkRoot, parts[0]) - if m, ok := ignoreMatchers[repoAbsPath]; ok { - repoRelPath := strings.Join(parts[1:], "/") - if m.CanSkipDir(repoRelPath) { + if repo := repoOf(strings.Split(relPath, "/")); repo != "" && repo != relPath { + if m, ok := ignoreMatchers[filepath.Join(walkRoot, filepath.FromSlash(repo))]; ok { + if m.CanSkipDir(strings.TrimPrefix(relPath, repo+"/")) { return filepath.SkipDir } } @@ -246,17 +260,14 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di relPath = strings.ReplaceAll(relPath, "\\", "/") - isInRepo := false - parts := strings.Split(relPath, "/") - if len(parts) > 0 && utils.IsTrackedRepoDir(parts[0]) { - isInRepo = true - } + repoRelPath := repoOf(strings.Split(relPath, "/")) + isInRepo := repoRelPath != "" // Root-level .skillignore fallback (for files in non-skipped dirs), // then the repo-level .skillignore inside tracked repos. With // includeIgnored the skill is kept, flagged Disabled, and measured // like any other so analyze can price it for symlink-mode targets. - disabled := rootMatcher.Match(relPath, false) || (isInRepo && isSkillIgnored(parts, walkRoot, ignoreMatchers)) + disabled := rootMatcher.Match(relPath, false) || (isInRepo && isSkillIgnored(relPath, repoRelPath, walkRoot, ignoreMatchers)) if disabled { if opts.collectIgnored { stats.IgnoredSkills = append(stats.IgnoredSkills, relPath) @@ -308,6 +319,7 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di RelPath: relPath, FlatName: utils.PathToFlatName(relPath), IsInRepo: isInRepo, + RepoRelPath: repoRelPath, Targets: targets, DescChars: ctx.DescChars, BodyChars: ctx.BodyChars, diff --git a/internal/sync/sync.go b/internal/sync/sync.go index 15d049453..f703361bd 100644 --- a/internal/sync/sync.go +++ b/internal/sync/sync.go @@ -23,6 +23,7 @@ type DiscoveredSkill struct { RelPath string // Relative path from source: _team/frontend/ui FlatName string // Flat name for target: _team__frontend__ui IsInRepo bool // Whether this skill is inside a tracked repo (_-prefixed directory) + RepoRelPath string // Tracked repo root relative to source (_team, or org/_team via --into); set when IsInRepo Targets []string // From SKILL.md frontmatter; nil = all targets DescChars int // Rune count of name + description (populated when collectContext) BodyChars int // Rune count of body after frontmatter (populated when collectContext) @@ -36,17 +37,16 @@ type DiscoveredSkill struct { // isSkillIgnored checks whether a skill inside a tracked repo should be // skipped based on the repo's .skillignore matcher. -// parts is strings.Split(relPath, "/"), where relPath is relative to source root. -func isSkillIgnored(parts []string, walkRoot string, ignoreMatchers map[string]*skillignore.Matcher) bool { - if len(parts) < 2 { +// relPath and repoRelPath are slash paths relative to the source root. +func isSkillIgnored(relPath, repoRelPath, walkRoot string, ignoreMatchers map[string]*skillignore.Matcher) bool { + if relPath == repoRelPath { return false } - repoAbsPath := filepath.Join(walkRoot, parts[0]) - m, ok := ignoreMatchers[repoAbsPath] + m, ok := ignoreMatchers[filepath.Join(walkRoot, filepath.FromSlash(repoRelPath))] if !ok { return false } - return m.Match(strings.Join(parts[1:], "/"), false) + return m.Match(strings.TrimPrefix(relPath, repoRelPath+"/"), false) } // walkOptions returns the optional traversal policy passed to a Discover diff --git a/tests/integration/install_track_root_skill_test.go b/tests/integration/install_track_root_skill_test.go index e23b0bac3..eb0c67c35 100644 --- a/tests/integration/install_track_root_skill_test.go +++ b/tests/integration/install_track_root_skill_test.go @@ -212,6 +212,49 @@ func TestInstall_Track_RootSkillMd_ShowsInStatus(t *testing.T) { } } +func TestInstall_Track_Into_SuggestsUpdateByRepoPath(t *testing.T) { + sb := testutil.NewSandbox(t) + defer sb.Cleanup() + setupGlobalConfig(sb) + + repoURL := setupBareRepoWithNestedAndRootSkill(t, sb, "into-hint") + + result := sb.RunCLI("install", repoURL, "--track", "--name", "team-skills", "--into", "org") + result.AssertSuccess(t) + result.AssertOutputContains(t, "skillshare update org/_team-skills") +} + +func TestInstall_Track_Into_StatusCountsRepoSkills(t *testing.T) { + sb := testutil.NewSandbox(t) + defer sb.Cleanup() + setupGlobalConfig(sb) + + repoURL := setupBareRepoWithNestedAndRootSkill(t, sb, "into-status") + sb.RunCLI("install", repoURL, "--track", "--name", "team-skills", "--into", "org").AssertSuccess(t) + + statusResult := sb.RunCLI("status", "--json") + statusResult.AssertSuccess(t) + var output struct { + TrackedRepos []struct { + Name string `json:"name"` + SkillCount int `json:"skill_count"` + } `json:"tracked_repos"` + } + if err := json.Unmarshal([]byte(statusResult.Stdout), &output); err != nil { + t.Fatalf("failed to parse status --json: %v\nstdout: %s", err, statusResult.Stdout) + } + want := filepath.Join("org", "_team-skills") + for _, r := range output.TrackedRepos { + if r.Name == want { + if r.SkillCount == 0 { + t.Fatalf("expected %s to count its skills, got %+v", want, r) + } + return + } + } + t.Fatalf("tracked_repos should contain %q, got %+v", want, output.TrackedRepos) +} + // TestInstall_Track_RootSkillMd_ReportsOneSkill verifies that the install // output correctly reports 1 skill (not 0) for a tracked repo whose only // SKILL.md is at the repo root. Phase B / AC1. diff --git a/ui/src/api/types/resources.ts b/ui/src/api/types/resources.ts index a0a684d7d..71d5886f4 100644 --- a/ui/src/api/types/resources.ts +++ b/ui/src/api/types/resources.ts @@ -36,6 +36,8 @@ export interface Skill { linkName?: string; linkTarget?: string; isInRepo: boolean; + /** Tracked repo root relative to the source (`_team`, or `org/_team` when installed with --into). */ + repoPath?: string; targets?: string[]; installedAt?: string; source?: string; diff --git a/ui/src/components/skill-editor/SkillEditor.tsx b/ui/src/components/skill-editor/SkillEditor.tsx index 90332e976..b3b4d2471 100644 --- a/ui/src/components/skill-editor/SkillEditor.tsx +++ b/ui/src/components/skill-editor/SkillEditor.tsx @@ -5,7 +5,7 @@ import { api, ApiError, type Skill } from '../../api/client'; import { composeSkillMarkdown, parseSkillMarkdown, type Frontmatter } from '../../lib/frontmatter'; import { highlightLines } from '../../lib/highlight'; import { parseRemoteURL } from '../../lib/parseRemoteURL'; -import { formatTrackedRepoName } from '../../lib/resourceNames'; +import { folderOf, formatTrackedRepoName } from '../../lib/resourceNames'; import { useI18n, useT, plural } from '../../i18n'; import Button from '../Button'; import ConfirmDialog from '../ConfirmDialog'; @@ -199,7 +199,7 @@ export default function SkillEditor({ resource, docName, initialContent, onBack, const bodyLines = useMemo(() => highlightLines(body, 'md'), [body]); const gutter = `calc(30px + ${String(bodyLines.length).length}ch)`; const repo = resource.isInRepo - ? parseRemoteURL(resource.repoUrl)?.ownerRepo ?? formatTrackedRepoName(resource.relPath.split('/')[0]) + ? parseRemoteURL(resource.repoUrl)?.ownerRepo ?? formatTrackedRepoName(folderOf(resource)) : ''; return ( diff --git a/ui/src/lib/resourceGrouping.test.ts b/ui/src/lib/resourceGrouping.test.ts index 4ae4d8c78..6d958360a 100644 --- a/ui/src/lib/resourceGrouping.test.ts +++ b/ui/src/lib/resourceGrouping.test.ts @@ -30,6 +30,13 @@ describe('groupBySource', () => { expect(groups.map((g) => [g.key, g.items.length])).toEqual([['_repo-a', 2], ['_repo-b', 1], ['local', 1]]); }); + + it('groups a repo installed with --into under its full repo path', () => { + const repo = { isInRepo: true, type: 'tracked', repoPath: 'org/_repo' }; + const groups = groupBySource([skill('org/_repo/skills/x', repo), skill('org/_repo/skills/y', repo)]); + + expect(groups.map((g) => [g.key, g.items.length])).toEqual([['org/_repo', 2]]); + }); }); describe('groupByFolder', () => { diff --git a/ui/src/lib/resourceGrouping.ts b/ui/src/lib/resourceGrouping.ts index 1074d3284..541e54f88 100644 --- a/ui/src/lib/resourceGrouping.ts +++ b/ui/src/lib/resourceGrouping.ts @@ -74,7 +74,7 @@ export function sortSkills(skills: Skill[], sortType: SortType): Skill[] { } export function repoOf(s: Skill): string | undefined { - return s.isInRepo ? s.relPath.split('/')[0] : undefined; + return s.isInRepo ? folderOf(s) : undefined; } export function sourceLinkOf(s: Skill): SourceLink | undefined { diff --git a/ui/src/lib/resourceNames.ts b/ui/src/lib/resourceNames.ts index 964081a7d..1c65d6e35 100644 --- a/ui/src/lib/resourceNames.ts +++ b/ui/src/lib/resourceNames.ts @@ -11,8 +11,8 @@ export function formatTrackedRepoName(name: string): string { } /** Folder a skill or agent lives in: its tracked repo, else its full parent path; '' at the source root. */ -export function folderOf(resource: { relPath: string; isInRepo: boolean }): string { - if (resource.isInRepo) return resource.relPath.split('/')[0]; +export function folderOf(resource: { relPath: string; isInRepo: boolean; repoPath?: string }): string { + if (resource.isInRepo) return resource.repoPath ?? resource.relPath.split('/')[0]; const i = resource.relPath.lastIndexOf('/'); return i > 0 ? resource.relPath.slice(0, i) : ''; } diff --git a/ui/src/pages/ResourceDetailPage.tsx b/ui/src/pages/ResourceDetailPage.tsx index cae585bae..dae0a09ae 100644 --- a/ui/src/pages/ResourceDetailPage.tsx +++ b/ui/src/pages/ResourceDetailPage.tsx @@ -13,7 +13,7 @@ import { SEV, parseFindings, thresholdOf } from '../lib/auditMessage'; import { parseSkillMarkdown } from '../lib/frontmatter'; import { isMarkdown } from '../lib/highlight'; import { parseRemoteURL } from '../lib/parseRemoteURL'; -import { resourceHref } from '../lib/resourceNames'; +import { folderOf, resourceHref } from '../lib/resourceNames'; import { sourceLinkOf } from '../lib/resourceGrouping'; import { targetFilterPatch } from '../lib/targetFilter'; import { useSyncMatrix } from '../hooks/useSyncMatrix'; @@ -142,7 +142,7 @@ export default function ResourceDetailPage() { const runUpdate = async (skipAudit: boolean) => { setUpdating(true); try { - const target = resource.isInRepo ? resource.relPath.split('/')[0] : isAgent ? resource.flatName : resource.relPath; + const target = resource.isInRepo ? folderOf(resource) : isAgent ? resource.flatName : resource.relPath; const res = await api.update({ name: target, kind: resource.kind, skipAudit }); const item = res.results[0]; if (item?.action === 'updated') { diff --git a/ui/src/pages/UpdatePage.tsx b/ui/src/pages/UpdatePage.tsx index 90accae40..de7aeb0db 100644 --- a/ui/src/pages/UpdatePage.tsx +++ b/ui/src/pages/UpdatePage.tsx @@ -7,7 +7,7 @@ import type { CheckResult, LinkedRepo, Skill, UpdateResultItem } from '../api/cl import { queryKeys, staleTimes } from '../lib/queryKeys'; import { clearAuditCache } from '../lib/auditCache'; import { parseRemoteURL } from '../lib/parseRemoteURL'; -import { formatTrackedRepoName } from '../lib/resourceNames'; +import { folderOf, formatTrackedRepoName } from '../lib/resourceNames'; import { formatRelativeTime, useI18n, useT } from '../i18n'; import Button from '../components/Button'; import { Checkbox } from '../components/Checkbox'; @@ -90,7 +90,7 @@ export function updateUnits(resources: Skill[], kind: Kind, linkedRepos: LinkedR units.push({ name: s.relPath, label: s.name, isRepo: false, items: [s], source: s.source }); continue; } - const dir = s.relPath.split('/')[0]; + const dir = folderOf(s); let unit = repos.get(dir); if (!unit) { unit = { name: dir, label: formatTrackedRepoName(dir), isRepo: true, items: [], source: s.repoUrl ?? s.source }; @@ -185,7 +185,7 @@ export default function UpdatePage({ kind }: { kind: Kind }) { ? { status: 'error', message: repo.message, checkedAt } : { status: 'up-to-date', message: repo.message, checkedAt }; for (const item of updatable) { - if (!item.isInRepo || item.relPath.split('/')[0] !== repo.name) continue; + if (!item.isInRepo || folderOf(item) !== repo.name) continue; next.set(item.name, repoStatus); pending.delete(item.name); } @@ -258,7 +258,7 @@ export default function UpdatePage({ kind }: { kind: Kind }) { if (!isSuccessfulUpdateAction(result.action)) continue; for (const item of updatable) { const hit = result.isRepo - ? item.isInRepo && item.relPath.split('/')[0] === result.name + ? item.isInRepo && folderOf(item) === result.name : !item.isInRepo && matchesCheckSkill(item, result.name); if (hit) next.set(item.name, { ...status, message: result.message }); } diff --git a/website/docs/understand/tracked-repositories.md b/website/docs/understand/tracked-repositories.md index 35afa5a39..73670baf2 100644 --- a/website/docs/understand/tracked-repositories.md +++ b/website/docs/understand/tracked-repositories.md @@ -67,6 +67,8 @@ Tracked repos are prefixed with `_` to distinguish them from regular skills: └── _team-skills/ # Tracked repo (underscore prefix) ``` +A tracked repo installed with `--into` sits inside a folder, such as `devops/_team-skills/`. It is still treated as one repo: its skills are grouped under it, `status` counts them, and you update or uninstall it as `devops/_team-skills`. Below the top level, an `_` folder counts as a tracked repo only when it is a git clone, so a plain folder like `devops/_drafts/` stays a regular folder. + --- ## Nested Skills & Auto-Flattening {#nested-skills--auto-flattening} diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md index 764f0737d..e0e3f4ff2 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md @@ -67,6 +67,8 @@ skillshare sync └── _team-skills/ # Tracked repo (underscore prefix) ``` +`--into` でインストールした追跡リポジトリは、`devops/_team-skills/` のようにフォルダの中に置かれます。それでも 1 つのリポジトリとして扱われます。中の Skill はその下にまとめられ、`status` でも数えられ、更新やアンインストールには `devops/_team-skills` という名前を使います。最上位より下では、git clone された `_` フォルダだけが追跡リポジトリとみなされるため、`devops/_drafts/` のような普通のフォルダは通常のフォルダのままです。 + --- ## ネストされた Skill と自動フラット化 {#nested-skills--auto-flattening} diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md b/website/i18n/ko/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md index 372e89e58..ccf309d1d 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md @@ -67,6 +67,8 @@ Tracked repo는 일반 skill과 구분하기 위해 `_` 접두사가 붙습니 └── _team-skills/ # Tracked repo (underscore prefix) ``` +`--into`로 설치한 tracked repo는 `devops/_team-skills/`처럼 폴더 안에 놓입니다. 그래도 하나의 repo로 취급됩니다. 안에 있는 skill은 그 아래로 묶이고, `status`에서도 집계되며, 업데이트나 제거할 때는 `devops/_team-skills`라는 이름을 사용합니다. 최상위 아래에서는 git clone된 `_` 폴더만 tracked repo로 간주되므로, `devops/_drafts/` 같은 일반 폴더는 그대로 일반 폴더입니다. + --- ## 중첩 Skill과 자동 평탄화 {#nested-skills--auto-flattening} diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md index 03e3eb3fe..b05563ec2 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md @@ -67,6 +67,8 @@ Tracked repos 会以 `_` 为前缀,以便与普通 Skill 区分: └── _team-skills/ # Tracked Repo(下划线前缀) ``` +用 `--into` 安装的 tracked repo 会放在文件夹里,例如 `devops/_team-skills/`。它仍然被视为一个 repo:其中的 Skill 会归在它下面,`status` 会统计这些 Skill,更新或卸载时使用 `devops/_team-skills` 这个名称。在第一层以下,只有 git clone 得到的 `_` 文件夹才算 tracked repo,因此像 `devops/_drafts/` 这样的普通文件夹仍是普通文件夹。 + --- ## 嵌套 Skill 与自动扁平化 {#nested-skills--auto-flattening} diff --git a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md index d8d551796..76359eba8 100644 --- a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md +++ b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/understand/tracked-repositories.md @@ -67,6 +67,8 @@ Tracked repos 會以 `_` 為前綴,以便與一般 skills 區分: └── _team-skills/ # Tracked repo (underscore prefix) ``` +用 `--into` 安裝的 tracked repo 會放在資料夾裡,例如 `devops/_team-skills/`。它仍然視為一個 repo:裡面的 skills 會歸在它底下,`status` 會計入這些 skills,更新或解除安裝時使用 `devops/_team-skills` 這個名稱。在第一層以下,只有 git clone 出來的 `_` 資料夾才算 tracked repo,所以像 `devops/_drafts/` 這樣的一般資料夾仍是普通資料夾。 + --- ## 巢狀 Skills 與自動扁平化 {#nested-skills--auto-flattening} From d861696be65453965e3e777f2e9ca396ba9fc578 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:24:31 +0800 Subject: [PATCH 3/8] test(server): keep nested repo uninstall inside the source Batch uninstall now accepts nested repo names such as org/_team. If org is a link that the follow policy does not follow, the name resolves to a repo outside the source. uninstall's sourcefs move-out check already refuses it; this test pins that boundary so a later change to name resolution cannot remove a repo outside the source. --- .../server/handler_uninstall_links_test.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/internal/server/handler_uninstall_links_test.go b/internal/server/handler_uninstall_links_test.go index d3afe421b..1f1184ecd 100644 --- a/internal/server/handler_uninstall_links_test.go +++ b/internal/server/handler_uninstall_links_test.go @@ -240,6 +240,33 @@ func TestHandleBatchUninstall_RepoInstalledInto(t *testing.T) { } } +func TestHandleBatchUninstall_NestedRepoBehindUnfollowedLinkIsKept(t *testing.T) { + s, src := newTestServer(t) + outside := t.TempDir() + addTrackedRepo(t, outside, "_evil") + if err := os.Symlink(outside, filepath.Join(src, "org")); err != nil { + t.Fatal(err) + } + body, err := json.Marshal(batchUninstallRequest{Names: []string{"org/_evil"}, Force: true}) + if err != nil { + t.Fatal(err) + } + rr := httptest.NewRecorder() + s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodPost, "/api/uninstall/batch", bytes.NewReader(body))) + var resp struct { + Summary batchUninstallSummary `json:"summary"` + } + if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { + t.Fatal(err) + } + if resp.Summary.Failed != 1 { + t.Fatalf("expected the request to be refused: %s", rr.Body.String()) + } + if _, err := os.Stat(filepath.Join(outside, "_evil", ".git")); err != nil { + t.Fatalf("repo outside the source was removed through an unfollowed link: %v: %s", err, rr.Body.String()) + } +} + func TestHandleBatchUninstall_RepoBeforeLinkedBasename(t *testing.T) { s, src := newTestServer(t) addTrackedRepo(t, src, "_team") From c9b649143d89eff795625c25e420225d2b749798 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:35:05 +0800 Subject: [PATCH 4/8] refactor: return slash repo paths and simplify --into repo lookup GetTrackedRepos returned OS-native paths, so every caller that compared them with slash paths (RepoRelPath, dashboard repoPath, metadata keys) had to convert first. Two callers in install_queries already did, and this branch added four more. It now returns slash paths on every OS, matching GetMissingTrackedRepos; filepath.Join and filepath.Base accept them on Windows, and `update org/_repo` now also matches by full path there. The per-call-site conversions are gone. Smaller cleanups in the same code: - repoOf takes the slash relPath and looks up prefixes by substring, so the walk no longer splits and joins per directory; - repo .skillignore matchers are keyed by the same slash rel path, so isSkillIgnored no longer needs walkRoot; - batch uninstall uses utils.IsTrackedRepoDir instead of a literal "_"; - the dashboard uses repoOf where it spelled out isInRepo && folderOf; - the new tests reuse postBatchUninstall and share one --into sandbox. --- cmd/skillshare/status.go | 3 +- internal/install/install.go | 5 ++- internal/install/install_queries.go | 6 +-- internal/install/updatable_test.go | 2 +- internal/server/handler_uninstall.go | 3 +- .../server/handler_uninstall_links_test.go | 28 +++----------- internal/server/handler_update.go | 2 +- internal/server/handler_update_stream.go | 2 +- internal/server/source_links.go | 5 +-- internal/sync/discover_walk.go | 37 ++++++++++--------- internal/sync/sync.go | 7 ++-- .../install_track_root_skill_test.go | 17 +++------ ui/src/pages/ResourceDetailPage.tsx | 6 +-- ui/src/pages/UpdatePage.tsx | 5 ++- 14 files changed, 55 insertions(+), 73 deletions(-) diff --git a/cmd/skillshare/status.go b/cmd/skillshare/status.go index 4f9e13237..626c8d5e5 100644 --- a/cmd/skillshare/status.go +++ b/cmd/skillshare/status.go @@ -262,11 +262,10 @@ func buildTrackedRepoJSON(sourcePath string, trackedRepos []string, discovered [ // Count skills per repo (single pass). RepoRelPath covers skills at the // repo root and nested ones, and repos placed with --into (org/_repo). - // trackedRepos holds OS-native paths, RepoRelPath slash paths. repoSkillCount := make(map[string]int, len(trackedRepos)) for _, d := range discovered { if d.IsInRepo { - repoSkillCount[filepath.FromSlash(d.RepoRelPath)]++ + repoSkillCount[d.RepoRelPath]++ } } diff --git a/internal/install/install.go b/internal/install/install.go index 023d7bf1a..6a2c1b28c 100644 --- a/internal/install/install.go +++ b/internal/install/install.go @@ -340,8 +340,9 @@ func GetUpdatableSkills(sourceDir string) ([]string, error) { return getUpdatableSkillsImpl(sourceDir) } -// GetTrackedRepos returns tracked repositories in the source directory. An -// optional walk policy follows first-level source links; omitted, none are. +// GetTrackedRepos returns tracked repositories in the source directory as +// slash paths relative to it (org/_team), on every OS. An optional walk policy +// follows first-level source links; omitted, none are. func GetTrackedRepos(sourceDir string, walk ...sourcewalk.Options) ([]string, error) { var opts sourcewalk.Options if len(walk) > 0 { diff --git a/internal/install/install_queries.go b/internal/install/install_queries.go index 72f2b5850..021fc4ed6 100644 --- a/internal/install/install_queries.go +++ b/internal/install/install_queries.go @@ -52,7 +52,7 @@ func getMissingTrackedReposImpl(sourceDir string, walks ...sourcewalk.Options) ( } existing := make(map[string]bool, len(existingRepos)) for _, repo := range existingRepos { - existing[filepath.ToSlash(repo)] = true + existing[repo] = true } var missing []TrackedRepoMeta @@ -101,7 +101,7 @@ func rehydrateMissingTrackedReposImpl(sourceDir string, parseOpts ParseOptions, } existing := make(map[string]bool, len(existingRepos)) for _, repo := range existingRepos { - existing[filepath.ToSlash(repo)] = true + existing[repo] = true } opts.Quiet = true @@ -237,7 +237,7 @@ func getTrackedReposImpl(sourceDir string, walk sourcewalk.Options) ([]string, e if IsGitRepo(path) { relPath, relErr := filepath.Rel(walkRoot, path) if relErr == nil { - repos = append(repos, relPath) + repos = append(repos, filepath.ToSlash(relPath)) } return filepath.SkipDir // Don't recurse into tracked repos } diff --git a/internal/install/updatable_test.go b/internal/install/updatable_test.go index 6fa62a1e2..cbdd36f6a 100644 --- a/internal/install/updatable_test.go +++ b/internal/install/updatable_test.go @@ -175,7 +175,7 @@ func TestGetTrackedRepos_FindsNested(t *testing.T) { if len(repos) != 1 { t.Fatalf("expected 1 nested tracked repo, got %d", len(repos)) } - if repos[0] != filepath.Join("frontend", "_ui-skills") { + if repos[0] != "frontend/_ui-skills" { t.Errorf("expected 'frontend/_ui-skills', got %q", repos[0]) } } diff --git a/internal/server/handler_uninstall.go b/internal/server/handler_uninstall.go index c2055f528..b1de88668 100644 --- a/internal/server/handler_uninstall.go +++ b/internal/server/handler_uninstall.go @@ -13,6 +13,7 @@ import ( "skillshare/internal/sourcewalk" "skillshare/internal/sync" "skillshare/internal/uninstall" + "skillshare/internal/utils" ) type batchUninstallRequest struct { @@ -187,7 +188,7 @@ func (s *Server) resolveBatchUninstallItem(discovered []sync.DiscoveredSkill, so repoPath := filepath.Join(source, name) _, repoFollowed := walk.Follow.Resolve(repoPath) // A repo installed with --into is named by its path, e.g. org/_team. - managedRepo := strings.HasPrefix(filepath.Base(name), "_") && !repoFollowed && install.IsGitRepo(repoPath) + managedRepo := utils.IsTrackedRepoDir(filepath.Base(name)) && !repoFollowed && install.IsGitRepo(repoPath) var skill *sync.DiscoveredSkill if !managedRepo { var err error diff --git a/internal/server/handler_uninstall_links_test.go b/internal/server/handler_uninstall_links_test.go index 1f1184ecd..92a6cff72 100644 --- a/internal/server/handler_uninstall_links_test.go +++ b/internal/server/handler_uninstall_links_test.go @@ -229,14 +229,9 @@ func TestHandleBatchUninstall_RepoInstalledInto(t *testing.T) { s, src := newTestServer(t) addTrackedRepo(t, src, "org/_team") addSkill(t, filepath.Join(src, "org", "_team"), "foo") - body, err := json.Marshal(batchUninstallRequest{Names: []string{"org/_team"}, Force: true}) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodPost, "/api/uninstall/batch", bytes.NewReader(body))) + _, res := postBatchUninstall(t, s, true, "org/_team") if _, err := os.Stat(filepath.Join(src, "org", "_team")); !os.IsNotExist(err) { - t.Fatalf("expected org/_team to be uninstalled, stat err %v: %s", err, rr.Body.String()) + t.Fatalf("expected org/_team to be uninstalled, stat err %v: %+v", err, res) } } @@ -247,23 +242,12 @@ func TestHandleBatchUninstall_NestedRepoBehindUnfollowedLinkIsKept(t *testing.T) if err := os.Symlink(outside, filepath.Join(src, "org")); err != nil { t.Fatal(err) } - body, err := json.Marshal(batchUninstallRequest{Names: []string{"org/_evil"}, Force: true}) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodPost, "/api/uninstall/batch", bytes.NewReader(body))) - var resp struct { - Summary batchUninstallSummary `json:"summary"` - } - if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { - t.Fatal(err) - } - if resp.Summary.Failed != 1 { - t.Fatalf("expected the request to be refused: %s", rr.Body.String()) + _, res := postBatchUninstall(t, s, true, "org/_evil") + if len(res) != 1 || res[0].Success { + t.Fatalf("expected the request to be refused: %+v", res) } if _, err := os.Stat(filepath.Join(outside, "_evil", ".git")); err != nil { - t.Fatalf("repo outside the source was removed through an unfollowed link: %v: %s", err, rr.Body.String()) + t.Fatalf("repo outside the source was removed through an unfollowed link: %v", err) } } diff --git a/internal/server/handler_update.go b/internal/server/handler_update.go index 48fcfa7cc..bbf15e2cf 100644 --- a/internal/server/handler_update.go +++ b/internal/server/handler_update.go @@ -450,7 +450,7 @@ func (s *Server) updateAll(force, skipAudit bool) []updateResultItem { if err == nil { for _, repo := range repos { repoPath := filepath.Join(s.cfg.EffectiveSkillsSource(), repo) - results = append(results, s.updateTrackedRepo(filepath.ToSlash(repo), repoPath, s.cfg.EffectiveSkillsSource(), force, skipAudit, walk.Follow)) + results = append(results, s.updateTrackedRepo(repo, repoPath, s.cfg.EffectiveSkillsSource(), force, skipAudit, walk.Follow)) } } diff --git a/internal/server/handler_update_stream.go b/internal/server/handler_update_stream.go index 21024138a..8232e0866 100644 --- a/internal/server/handler_update_stream.go +++ b/internal/server/handler_update_stream.go @@ -85,7 +85,7 @@ func (s *Server) handleUpdateStream(w http.ResponseWriter, r *http.Request) { if err == nil { for _, repo := range repos { items = append(items, updateItem{ - name: filepath.ToSlash(repo), + name: repo, isRepo: true, path: filepath.Join(source, repo), }) diff --git a/internal/server/source_links.go b/internal/server/source_links.go index bed22ead6..6862235f6 100644 --- a/internal/server/source_links.go +++ b/internal/server/source_links.go @@ -19,9 +19,8 @@ func dashboardRepos(source string, walk sourcewalk.Options) ([]string, []linkedR managed := make([]string, 0, len(repos)) linked := []linkedRepoInfo{} seen := map[string]bool{} - for _, rel := range repos { - // The dashboard matches repos by slash path (org/_team); GetTrackedRepos is OS-native. - path, name := filepath.Join(source, rel), filepath.ToSlash(rel) + for _, name := range repos { + path := filepath.Join(source, name) if target, ok := walk.Follow.Resolve(path); ok { linked = append(linked, linkedRepoInfo{Name: name, Target: target}) seen[name] = true diff --git a/internal/sync/discover_walk.go b/internal/sync/discover_walk.go index ed93896de..d6db7cb98 100644 --- a/internal/sync/discover_walk.go +++ b/internal/sync/discover_walk.go @@ -138,19 +138,20 @@ func matchesHostSkillPath(relPath, targetName, targetPath string) bool { func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]DiscoveredSkill, []string, *skillignore.IgnoreStats, error) { var skills []DiscoveredSkill var trackedRepos []string - ignoreMatchers := make(map[string]*skillignore.Matcher) // tracked repo abs path → .skillignore matcher - repoRoots := make(map[string]bool) // slash rel paths of git repos seen so far, e.g. org/_team from --into + ignoreMatchers := make(map[string]*skillignore.Matcher) // tracked repo slash rel path → .skillignore matcher + repoRoots := make(map[string]bool) // slash rel paths of _-prefixed git repos seen so far, e.g. org/_team from --into - // repoOf returns the tracked repo root containing parts, or "". A _-prefixed - // first segment always counts; a deeper one only when the walk saw it as a - // git repo, so a plain org/_drafts folder is not mistaken for a repo. - repoOf := func(parts []string) string { - if utils.IsTrackedRepoDir(parts[0]) { - return parts[0] + // repoOf returns the tracked repo root containing slash relPath, or "". A + // _-prefixed first segment always counts; a deeper one only when the walk + // saw it as a git repo, so a plain org/_drafts folder is not mistaken for a repo. + repoOf := func(relPath string) string { + first, _, _ := strings.Cut(relPath, "/") + if utils.IsTrackedRepoDir(first) { + return first } - for i := 1; i < len(parts); i++ { - if root := strings.Join(parts[:i+1], "/"); utils.IsTrackedRepoDir(parts[i]) && repoRoots[root] { - return root + for i := len(first) + 1; i <= len(relPath); i++ { + if (i == len(relPath) || relPath[i] == '/') && repoRoots[relPath[:i]] { + return relPath[:i] } } return "" @@ -206,15 +207,17 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di if info.IsDir() && info.Name() != "." && utils.IsTrackedRepoDir(info.Name()) { if install.IsGitRepo(path) { relPath, relErr := filepath.Rel(walkRoot, path) + repoRel := "" if relErr == nil && relPath != "." { - repoRoots[filepath.ToSlash(relPath)] = true + repoRel = filepath.ToSlash(relPath) + repoRoots[repoRel] = true if opts.collectTracked { trackedRepos = append(trackedRepos, relPath) } } m := skillignore.ReadMatcher(path) if m.HasRules() { - ignoreMatchers[path] = m + ignoreMatchers[repoRel] = m // Record repo-level .skillignore in stats if opts.collectIgnored { repoIgnorePath := filepath.Join(path, ".skillignore") @@ -236,8 +239,8 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di relPath, relErr := filepath.Rel(walkRoot, path) if relErr == nil && relPath != "." { relPath = strings.ReplaceAll(relPath, "\\", "/") - if repo := repoOf(strings.Split(relPath, "/")); repo != "" && repo != relPath { - if m, ok := ignoreMatchers[filepath.Join(walkRoot, filepath.FromSlash(repo))]; ok { + if repo := repoOf(relPath); repo != "" && repo != relPath { + if m, ok := ignoreMatchers[repo]; ok { if m.CanSkipDir(strings.TrimPrefix(relPath, repo+"/")) { return filepath.SkipDir } @@ -260,14 +263,14 @@ func discoverSourceSkillsInternal(sourcePath string, opts discoverOptions) ([]Di relPath = strings.ReplaceAll(relPath, "\\", "/") - repoRelPath := repoOf(strings.Split(relPath, "/")) + repoRelPath := repoOf(relPath) isInRepo := repoRelPath != "" // Root-level .skillignore fallback (for files in non-skipped dirs), // then the repo-level .skillignore inside tracked repos. With // includeIgnored the skill is kept, flagged Disabled, and measured // like any other so analyze can price it for symlink-mode targets. - disabled := rootMatcher.Match(relPath, false) || (isInRepo && isSkillIgnored(relPath, repoRelPath, walkRoot, ignoreMatchers)) + disabled := rootMatcher.Match(relPath, false) || (isInRepo && isSkillIgnored(relPath, repoRelPath, ignoreMatchers)) if disabled { if opts.collectIgnored { stats.IgnoredSkills = append(stats.IgnoredSkills, relPath) diff --git a/internal/sync/sync.go b/internal/sync/sync.go index f703361bd..4d5dfc1ff 100644 --- a/internal/sync/sync.go +++ b/internal/sync/sync.go @@ -37,12 +37,13 @@ type DiscoveredSkill struct { // isSkillIgnored checks whether a skill inside a tracked repo should be // skipped based on the repo's .skillignore matcher. -// relPath and repoRelPath are slash paths relative to the source root. -func isSkillIgnored(relPath, repoRelPath, walkRoot string, ignoreMatchers map[string]*skillignore.Matcher) bool { +// relPath and repoRelPath are slash paths relative to the source root, and +// ignoreMatchers is keyed by repo root in the same form. +func isSkillIgnored(relPath, repoRelPath string, ignoreMatchers map[string]*skillignore.Matcher) bool { if relPath == repoRelPath { return false } - m, ok := ignoreMatchers[filepath.Join(walkRoot, filepath.FromSlash(repoRelPath))] + m, ok := ignoreMatchers[repoRelPath] if !ok { return false } diff --git a/tests/integration/install_track_root_skill_test.go b/tests/integration/install_track_root_skill_test.go index eb0c67c35..1b0a44735 100644 --- a/tests/integration/install_track_root_skill_test.go +++ b/tests/integration/install_track_root_skill_test.go @@ -212,25 +212,18 @@ func TestInstall_Track_RootSkillMd_ShowsInStatus(t *testing.T) { } } -func TestInstall_Track_Into_SuggestsUpdateByRepoPath(t *testing.T) { +// TestInstall_Track_Into_NamesRepoByPath verifies that a tracked repo +// installed with --into is named by its path in the install hint and status. +func TestInstall_Track_Into_NamesRepoByPath(t *testing.T) { sb := testutil.NewSandbox(t) defer sb.Cleanup() setupGlobalConfig(sb) - repoURL := setupBareRepoWithNestedAndRootSkill(t, sb, "into-hint") + repoURL := setupBareRepoWithNestedAndRootSkill(t, sb, "into") result := sb.RunCLI("install", repoURL, "--track", "--name", "team-skills", "--into", "org") result.AssertSuccess(t) result.AssertOutputContains(t, "skillshare update org/_team-skills") -} - -func TestInstall_Track_Into_StatusCountsRepoSkills(t *testing.T) { - sb := testutil.NewSandbox(t) - defer sb.Cleanup() - setupGlobalConfig(sb) - - repoURL := setupBareRepoWithNestedAndRootSkill(t, sb, "into-status") - sb.RunCLI("install", repoURL, "--track", "--name", "team-skills", "--into", "org").AssertSuccess(t) statusResult := sb.RunCLI("status", "--json") statusResult.AssertSuccess(t) @@ -243,7 +236,7 @@ func TestInstall_Track_Into_StatusCountsRepoSkills(t *testing.T) { if err := json.Unmarshal([]byte(statusResult.Stdout), &output); err != nil { t.Fatalf("failed to parse status --json: %v\nstdout: %s", err, statusResult.Stdout) } - want := filepath.Join("org", "_team-skills") + const want = "org/_team-skills" for _, r := range output.TrackedRepos { if r.Name == want { if r.SkillCount == 0 { diff --git a/ui/src/pages/ResourceDetailPage.tsx b/ui/src/pages/ResourceDetailPage.tsx index dae0a09ae..625cdb371 100644 --- a/ui/src/pages/ResourceDetailPage.tsx +++ b/ui/src/pages/ResourceDetailPage.tsx @@ -13,8 +13,8 @@ import { SEV, parseFindings, thresholdOf } from '../lib/auditMessage'; import { parseSkillMarkdown } from '../lib/frontmatter'; import { isMarkdown } from '../lib/highlight'; import { parseRemoteURL } from '../lib/parseRemoteURL'; -import { folderOf, resourceHref } from '../lib/resourceNames'; -import { sourceLinkOf } from '../lib/resourceGrouping'; +import { resourceHref } from '../lib/resourceNames'; +import { repoOf, sourceLinkOf } from '../lib/resourceGrouping'; import { targetFilterPatch } from '../lib/targetFilter'; import { useSyncMatrix } from '../hooks/useSyncMatrix'; import { projectUrl } from '../components/projects/projectView'; @@ -142,7 +142,7 @@ export default function ResourceDetailPage() { const runUpdate = async (skipAudit: boolean) => { setUpdating(true); try { - const target = resource.isInRepo ? folderOf(resource) : isAgent ? resource.flatName : resource.relPath; + const target = repoOf(resource) ?? (isAgent ? resource.flatName : resource.relPath); const res = await api.update({ name: target, kind: resource.kind, skipAudit }); const item = res.results[0]; if (item?.action === 'updated') { diff --git a/ui/src/pages/UpdatePage.tsx b/ui/src/pages/UpdatePage.tsx index de7aeb0db..dbae2a369 100644 --- a/ui/src/pages/UpdatePage.tsx +++ b/ui/src/pages/UpdatePage.tsx @@ -8,6 +8,7 @@ import { queryKeys, staleTimes } from '../lib/queryKeys'; import { clearAuditCache } from '../lib/auditCache'; import { parseRemoteURL } from '../lib/parseRemoteURL'; import { folderOf, formatTrackedRepoName } from '../lib/resourceNames'; +import { repoOf } from '../lib/resourceGrouping'; import { formatRelativeTime, useI18n, useT } from '../i18n'; import Button from '../components/Button'; import { Checkbox } from '../components/Checkbox'; @@ -185,7 +186,7 @@ export default function UpdatePage({ kind }: { kind: Kind }) { ? { status: 'error', message: repo.message, checkedAt } : { status: 'up-to-date', message: repo.message, checkedAt }; for (const item of updatable) { - if (!item.isInRepo || folderOf(item) !== repo.name) continue; + if (repoOf(item) !== repo.name) continue; next.set(item.name, repoStatus); pending.delete(item.name); } @@ -258,7 +259,7 @@ export default function UpdatePage({ kind }: { kind: Kind }) { if (!isSuccessfulUpdateAction(result.action)) continue; for (const item of updatable) { const hit = result.isRepo - ? item.isInRepo && folderOf(item) === result.name + ? repoOf(item) === result.name : !item.isInRepo && matchesCheckSkill(item, result.name); if (hit) next.set(item.name, { ...status, message: result.message }); } From d15d9d794cfab188214d347ea0aee0af45beef27 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:35:05 +0800 Subject: [PATCH 5/8] fix: use the --into repo path in skill counts, list groups and the tree Codex review of #472 found three views still deriving a skill's repo from the first path segment: - Skill counts in `list`, human-readable `status` and the dashboard overview matched `/` prefixes, so an `org/_team` repo whose only skill is its root SKILL.md counted zero, and `status` disagreed with `status --json`. They now compare RepoRelPath with the repo name. - The list TUI took the group as the second path segment, so a skill at org/_team/skills/vue got group `_team` instead of `skills` and the `g:` filter missed it. The group is now the first segment below RepoName. Test fixtures that used a RepoName unrelated to RelPath now use the repo path, as real entries do. - The dashboard tree treated only top-level `_` folders as repo roots, and merged `org / _team / skills` into one row, so an --into repo had no update or uninstall actions in Tree view. buildTree now marks repo roots from each skill's repo path, and a merged chain stops at one. --- cmd/skillshare/list.go | 6 ++---- cmd/skillshare/list_tui_filter.go | 10 ++++++---- cmd/skillshare/list_tui_filter_test.go | 13 ++++++++++--- cmd/skillshare/list_tui_test.go | 4 ++-- cmd/skillshare/status_render.go | 2 +- internal/server/handler_overview.go | 3 +-- ui/src/components/resources/tree.test.ts | 8 ++++++++ ui/src/components/resources/tree.ts | 13 +++++++++---- 8 files changed, 39 insertions(+), 20 deletions(-) diff --git a/cmd/skillshare/list.go b/cmd/skillshare/list.go index 1e00aa075..c1d45a719 100644 --- a/cmd/skillshare/list.go +++ b/cmd/skillshare/list.go @@ -295,11 +295,9 @@ func buildSkillEntries(discovered []sync.DiscoveredSkill) []skillEntry { Kind: "skill", IsNested: d.IsInRepo || utils.HasNestedSeparator(d.FlatName), RelPath: d.RelPath, + RepoName: d.RepoRelPath, Disabled: d.Disabled, } - if d.IsInRepo { - skills[i].RepoName = d.RepoRelPath - } // Enrich from centralized metadata store if entry := store.GetByPath(d.RelPath); entry != nil { @@ -571,7 +569,7 @@ func displayTrackedRepos(trackedRepos []string, discovered []sync.DiscoveredSkil func countRepoSkills(repoName string, discovered []sync.DiscoveredSkill) int { count := 0 for _, d := range discovered { - if d.IsInRepo && strings.HasPrefix(d.RelPath, repoName+"/") { + if d.RepoRelPath == repoName { count++ } } diff --git a/cmd/skillshare/list_tui_filter.go b/cmd/skillshare/list_tui_filter.go index e5ee3ec2d..dae90caac 100644 --- a/cmd/skillshare/list_tui_filter.go +++ b/cmd/skillshare/list_tui_filter.go @@ -187,11 +187,13 @@ func skillGroup(e skillEntry) string { } if e.RepoName != "" { - // Tracked: first segment is repo dir, second is group - if len(parts) >= 3 { - return parts[1] + // Tracked: the group is the first segment below the repo root, which + // --into can place deeper than the first segment (org/_team). + group, _, nested := strings.Cut(strings.TrimPrefix(e.RelPath, e.RepoName+"/"), "/") + if !nested { + return "" } - return "" + return group } // Non-tracked: first segment is group diff --git a/cmd/skillshare/list_tui_filter_test.go b/cmd/skillshare/list_tui_filter_test.go index ca32f71b9..d32715675 100644 --- a/cmd/skillshare/list_tui_filter_test.go +++ b/cmd/skillshare/list_tui_filter_test.go @@ -133,14 +133,21 @@ func TestParseFilterQuery_EmptyValueIgnored(t *testing.T) { } func TestSkillGroup_TrackedNested(t *testing.T) { - e := skillEntry{RelPath: "_team-repo/security/audit", RepoName: "team/repo"} + e := skillEntry{RelPath: "_team-repo/security/audit", RepoName: "_team-repo"} + if got := skillGroup(e); got != "security" { + t.Fatalf("skillGroup() = %q, want %q", got, "security") + } +} + +func TestSkillGroup_TrackedInstalledInto(t *testing.T) { + e := skillEntry{RelPath: "org/_team-repo/security/audit", RepoName: "org/_team-repo"} if got := skillGroup(e); got != "security" { t.Fatalf("skillGroup() = %q, want %q", got, "security") } } func TestSkillGroup_TrackedRoot(t *testing.T) { - e := skillEntry{RelPath: "_team-repo/my-skill", RepoName: "team/repo"} + e := skillEntry{RelPath: "_team-repo/my-skill", RepoName: "_team-repo"} if got := skillGroup(e); got != "" { t.Fatalf("skillGroup() = %q, want empty for tracked root-level", got) } @@ -254,7 +261,7 @@ func TestMatchSkillItem_ANDLogic(t *testing.T) { item := skillItem{entry: skillEntry{ Name: "audit", RelPath: "_team-repo/security/audit", - RepoName: "team/repo", + RepoName: "_team-repo", }} // All conditions match diff --git a/cmd/skillshare/list_tui_test.go b/cmd/skillshare/list_tui_test.go index 3d2dc1e66..24546e25f 100644 --- a/cmd/skillshare/list_tui_test.go +++ b/cmd/skillshare/list_tui_test.go @@ -104,8 +104,8 @@ func TestApplyFilter_WithTags(t *testing.T) { items := []skillItem{ {entry: skillEntry{Name: "local-skill", RelPath: "local-skill"}}, {entry: skillEntry{Name: "react-tips", RelPath: "frontend/react-tips"}}, - {entry: skillEntry{Name: "audit", RelPath: "_team-repo/security/audit", RepoName: "team/repo"}}, - {entry: skillEntry{Name: "lint", RelPath: "_team-repo/lint", RepoName: "team/repo"}}, + {entry: skillEntry{Name: "audit", RelPath: "_team-repo/security/audit", RepoName: "_team-repo"}}, + {entry: skillEntry{Name: "lint", RelPath: "_team-repo/lint", RepoName: "_team-repo"}}, {entry: skillEntry{Name: "remote-a", RelPath: "remote-a", Source: "github.com/foo/bar"}}, } diff --git a/cmd/skillshare/status_render.go b/cmd/skillshare/status_render.go index 69d4b47e1..a9568f7df 100644 --- a/cmd/skillshare/status_render.go +++ b/cmd/skillshare/status_render.go @@ -227,7 +227,7 @@ func printTrackedReposStatus(sourcePath string, discovered []sync.DiscoveredSkil for _, repoName := range trackedRepos { skillCount := 0 for _, d := range discovered { - if d.IsInRepo && strings.HasPrefix(d.RelPath, repoName+"/") { + if d.RepoRelPath == repoName { skillCount++ } } diff --git a/internal/server/handler_overview.go b/internal/server/handler_overview.go index 41ede0507..8af9d6290 100644 --- a/internal/server/handler_overview.go +++ b/internal/server/handler_overview.go @@ -3,7 +3,6 @@ package server import ( "net/http" "path/filepath" - "strings" "skillshare/internal/git" "skillshare/internal/install" @@ -108,7 +107,7 @@ func buildTrackedRepos(sourceDir string, skills []sync.DiscoveredSkill, walk sou // Count skills belonging to this repo skillCount := 0 for _, sk := range skills { - if sk.IsInRepo && strings.HasPrefix(sk.RelPath, repoName+"/") { + if sk.RepoRelPath == repoName { skillCount++ } } diff --git a/ui/src/components/resources/tree.test.ts b/ui/src/components/resources/tree.test.ts index a29d4aa77..a1b424862 100644 --- a/ui/src/components/resources/tree.test.ts +++ b/ui/src/components/resources/tree.test.ts @@ -20,6 +20,14 @@ const labels = (rows: ReturnType) => rows.map((r) => `${' '.repeat(r.depth)}${r.type === 'folder' ? r.names.join(' / ') : r.skill.name}`); describe('flattenTree', () => { + it('marks a repo installed with --into as a repo root, not its parent folder', () => { + const repo = { isInRepo: true, repoPath: 'org/_repo' }; + const rows = flattenTree(buildTree([skill('org/_repo/skills/x', repo)]), new Set(), false); + + expect(rows.filter((r) => r.type === 'folder').map((r) => [r.names.join(' / '), r.type === 'folder' && r.repo])) + .toEqual([['org', false], ['_repo', true], ['skills', false]]); + }); + it('merges chains of single-folder folders into one row, but never a tracked repo root', () => { expect(labels(flattenTree(buildTree(SKILLS), new Set(), false))).toEqual([ '_repo', diff --git a/ui/src/components/resources/tree.ts b/ui/src/components/resources/tree.ts index 77259369a..812daed06 100644 --- a/ui/src/components/resources/tree.ts +++ b/ui/src/components/resources/tree.ts @@ -1,5 +1,5 @@ import type { Skill, SourceLink } from '../../api/client'; -import { sourceLinkOf } from '../../lib/resourceGrouping'; +import { repoOf, sourceLinkOf } from '../../lib/resourceGrouping'; /* Pure helpers behind the Skills page tree view: folder tree, visible rows, selection. */ @@ -16,6 +16,7 @@ export interface FolderNode { skills: Skill[]; count: number; // skills in this folder and every subfolder link?: SourceLink; + repo?: boolean; // tracked repo root: _team, or org/_team when installed with --into } /** @@ -48,15 +49,16 @@ export function summarize(skills: Skill[]): TargetSummary { return { display: shown.length > 3 ? `${shown.length} targets` : shown.join(', '), targets: shown, isUniform }; } -/** A tracked repo is a top-level folder whose name starts with "_". */ +/** A tracked repo root, as marked by buildTree from its skills' repo paths. */ export function isRepoRoot(node: FolderNode): boolean { - return !node.path.includes('/') && node.name.startsWith('_'); + return !!node.repo; } export function buildTree(skills: Skill[], links: SourceLink[] = []): FolderNode { const root: FolderNode = { name: '', path: '', children: new Map(), skills: [], count: 0 }; for (const skill of skills) { const link = sourceLinkOf(skill); + const repo = repoOf(skill); const slash = skill.relPath.lastIndexOf('/'); let node = root; const parent = slash > 0 ? skill.relPath.slice(0, slash) : link?.name; @@ -68,6 +70,7 @@ export function buildTree(skills: Skill[], links: SourceLink[] = []): FolderNode } node = node.children.get(seg)!; if (node.path === link?.name) node.link = link; + if (node.path === repo) node.repo = true; } } node.skills.push(skill); @@ -97,7 +100,9 @@ export function flattenTree(root: FolderNode, collapsed: ReadonlySet, ex const names = [child.name]; // Repo and link roots keep their own row so their tags and actions stay visible. while (!repo && !child.link && deepest.skills.length === 0 && deepest.children.size === 1) { - deepest = deepest.children.values().next().value!; + const next = deepest.children.values().next().value!; + if (isRepoRoot(next)) break; // an --into repo (org/_team) keeps its own row too + deepest = next; names.push(deepest.name); } const isCollapsed = !expandAll && collapsed.has(deepest.path); From f9ed43611d9ed9b362b1d1b47044584478b731cb Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:41:43 +0800 Subject: [PATCH 6/8] fix: keep git folders inside a tracked repo out of repo uninstall Batch uninstall treated any name whose last segment starts with "_" and is a git checkout as a tracked repo. A submodule such as _team/vendor/_lib inside a tracked repo matched, so the dashboard could move it out of the repo's checkout, leaving the repo dirty for update. The fallback for "_"-prefixed names had the same hole before --into support. --into folders cannot start with "_" (validate.IntoPath), so a repo name may have "_" only in its last segment; both checks now use that rule. Also, the list TUI gave the root skill of an --into repo (RelPath equal to RepoName, e.g. org/_team) the group "org"; it now has no group, like a top-level repo's root skill. --- cmd/skillshare/list_tui_filter.go | 5 +++-- cmd/skillshare/list_tui_filter_test.go | 7 +++++++ internal/server/handler_uninstall.go | 11 ++++++++--- internal/server/handler_uninstall_links_test.go | 13 +++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cmd/skillshare/list_tui_filter.go b/cmd/skillshare/list_tui_filter.go index dae90caac..5197cfbb8 100644 --- a/cmd/skillshare/list_tui_filter.go +++ b/cmd/skillshare/list_tui_filter.go @@ -189,8 +189,9 @@ func skillGroup(e skillEntry) string { if e.RepoName != "" { // Tracked: the group is the first segment below the repo root, which // --into can place deeper than the first segment (org/_team). - group, _, nested := strings.Cut(strings.TrimPrefix(e.RelPath, e.RepoName+"/"), "/") - if !nested { + rest, below := strings.CutPrefix(e.RelPath, e.RepoName+"/") + group, _, nested := strings.Cut(rest, "/") + if !below || !nested { return "" } return group diff --git a/cmd/skillshare/list_tui_filter_test.go b/cmd/skillshare/list_tui_filter_test.go index d32715675..9de0a42bb 100644 --- a/cmd/skillshare/list_tui_filter_test.go +++ b/cmd/skillshare/list_tui_filter_test.go @@ -146,6 +146,13 @@ func TestSkillGroup_TrackedInstalledInto(t *testing.T) { } } +func TestSkillGroup_TrackedInstalledIntoRootSkill(t *testing.T) { + e := skillEntry{RelPath: "org/_team-repo", RepoName: "org/_team-repo"} + if got := skillGroup(e); got != "" { + t.Fatalf("skillGroup() = %q, want empty for the repo's root skill", got) + } +} + func TestSkillGroup_TrackedRoot(t *testing.T) { e := skillEntry{RelPath: "_team-repo/my-skill", RepoName: "_team-repo"} if got := skillGroup(e); got != "" { diff --git a/internal/server/handler_uninstall.go b/internal/server/handler_uninstall.go index b1de88668..6c9eb6e91 100644 --- a/internal/server/handler_uninstall.go +++ b/internal/server/handler_uninstall.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "path" "path/filepath" "strings" "time" @@ -187,8 +188,12 @@ func (s *Server) resolveBatchUninstallItem(discovered []sync.DiscoveredSkill, so repoPath := filepath.Join(source, name) _, repoFollowed := walk.Follow.Resolve(repoPath) - // A repo installed with --into is named by its path, e.g. org/_team. - managedRepo := utils.IsTrackedRepoDir(filepath.Base(name)) && !repoFollowed && install.IsGitRepo(repoPath) + // A repo installed with --into is named by its path, e.g. org/_team. --into + // folders cannot start with "_" (validate.IntoPath), so a deeper _ git dir + // such as _team/vendor/_lib is part of a tracked repo, not a repo of its own. + parent, base := path.Split(name) + repoName := utils.IsTrackedRepoDir(base) && !strings.Contains("/"+parent, "/_") + managedRepo := repoName && !repoFollowed && install.IsGitRepo(repoPath) var skill *sync.DiscoveredSkill if !managedRepo { var err error @@ -201,7 +206,7 @@ func (s *Server) resolveBatchUninstallItem(discovered []sync.DiscoveredSkill, so _, followed = walk.Follow.Resolve(skill.SourcePath) } // An explicit managed repo takes precedence over a skill's basename. - if managedRepo || (strings.HasPrefix(name, "_") && !followed) { + if managedRepo || (repoName && !followed) { if !install.IsGitRepo(repoPath) { return uninstall.Item{}, errors.New("not a tracked repository: " + name) } diff --git a/internal/server/handler_uninstall_links_test.go b/internal/server/handler_uninstall_links_test.go index 92a6cff72..58d8bb83a 100644 --- a/internal/server/handler_uninstall_links_test.go +++ b/internal/server/handler_uninstall_links_test.go @@ -235,6 +235,19 @@ func TestHandleBatchUninstall_RepoInstalledInto(t *testing.T) { } } +func TestHandleBatchUninstall_GitDirInsideTrackedRepoIsKept(t *testing.T) { + s, src := newTestServer(t) + addTrackedRepo(t, src, "_team") + addTrackedRepo(t, src, "_team/vendor/_lib") // e.g. a submodule checkout + _, res := postBatchUninstall(t, s, true, "_team/vendor/_lib") + if len(res) != 1 || res[0].Success { + t.Fatalf("expected the request to be refused: %+v", res) + } + if _, err := os.Stat(filepath.Join(src, "_team", "vendor", "_lib", ".git")); err != nil { + t.Fatalf("folder inside a tracked repo was removed: %v", err) + } +} + func TestHandleBatchUninstall_NestedRepoBehindUnfollowedLinkIsKept(t *testing.T) { s, src := newTestServer(t) outside := t.TempDir() From 371561ef9f67ce48f209b06985326c1d947cd473 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:42:32 +0800 Subject: [PATCH 7/8] fix(ui): give a repo-root skill its tracked repo row in the tree A tracked repo whose skill is its root SKILL.md has relPath equal to its repo path (org/_team, or _team). buildTree placed the skill under the parent folder only, so the repo node was never created: Tree view showed no repo row, update action or repo context menu for it. The skill now sits in its repo's own folder, which gives top-level repos with a root SKILL.md that row as well. --- ui/src/components/resources/tree.test.ts | 6 ++++++ ui/src/components/resources/tree.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/src/components/resources/tree.test.ts b/ui/src/components/resources/tree.test.ts index a1b424862..62ca078a8 100644 --- a/ui/src/components/resources/tree.test.ts +++ b/ui/src/components/resources/tree.test.ts @@ -20,6 +20,12 @@ const labels = (rows: ReturnType) => rows.map((r) => `${' '.repeat(r.depth)}${r.type === 'folder' ? r.names.join(' / ') : r.skill.name}`); describe('flattenTree', () => { + it('gives a repo whose skill is its root SKILL.md its own repo row', () => { + const rows = flattenTree(buildTree([skill('org/_repo', { isInRepo: true, repoPath: 'org/_repo' })]), new Set(), false); + + expect(rows.map((r) => (r.type === 'folder' ? [r.names.join(' / '), r.repo] : [r.skill.name]))).toEqual([['org', false], ['_repo', true], ['_repo']]); + }); + it('marks a repo installed with --into as a repo root, not its parent folder', () => { const repo = { isInRepo: true, repoPath: 'org/_repo' }; const rows = flattenTree(buildTree([skill('org/_repo/skills/x', repo)]), new Set(), false); diff --git a/ui/src/components/resources/tree.ts b/ui/src/components/resources/tree.ts index 812daed06..4e93c85d7 100644 --- a/ui/src/components/resources/tree.ts +++ b/ui/src/components/resources/tree.ts @@ -61,7 +61,8 @@ export function buildTree(skills: Skill[], links: SourceLink[] = []): FolderNode const repo = repoOf(skill); const slash = skill.relPath.lastIndexOf('/'); let node = root; - const parent = slash > 0 ? skill.relPath.slice(0, slash) : link?.name; + // A repo's root SKILL.md sits in the repo's own folder, so the repo gets its row. + const parent = skill.relPath === repo ? repo : slash > 0 ? skill.relPath.slice(0, slash) : link?.name; if (parent) { for (const seg of parent.split('/')) { if (!node.children.has(seg)) { From 504713b065b45156d0164e05db75a78a09b8fd87 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 7 Oct 2026 21:51:41 +0800 Subject: [PATCH 8/8] fix(uninstall): refuse removing part of a tracked repo's checkout The CLI removed any skill or folder inside a tracked repo on its own: `skillshare uninstall _team/foo` moved the skill out of the repo's checkout, and `_team/vendor/_lib` (a submodule) was even treated as a tracked repo because the CLI marks every git checkout as one. Either way the repo was left dirty for the next update. The dashboard already refused single skills inside a repo, but the rule lived only in its handler. The rule now lives in internal/uninstall, which both the CLI and the dashboard go through: an item below a "_"-prefixed git checkout fails with ErrInsideRepo in Preflight and Run, even with --force. A followed source link is the user's own checkout, so skills below it can still be removed one at a time. The uninstall reference documents the rule and how to name a repo installed with --into, with ja/ko/zh-Hans/zh-Hant translations. --- internal/uninstall/uninstall.go | 39 +++++++++++++++++-- internal/uninstall/uninstall_test.go | 21 ++++++++++ tests/integration/uninstall_test.go | 20 ++++++++++ website/docs/reference/commands/uninstall.md | 3 ++ .../current/reference/commands/uninstall.md | 3 ++ .../current/reference/commands/uninstall.md | 3 ++ .../current/reference/commands/uninstall.md | 3 ++ .../current/reference/commands/uninstall.md | 3 ++ 8 files changed, 91 insertions(+), 4 deletions(-) diff --git a/internal/uninstall/uninstall.go b/internal/uninstall/uninstall.go index c4236fc9a..71f5e5fd4 100644 --- a/internal/uninstall/uninstall.go +++ b/internal/uninstall/uninstall.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "path/filepath" + "strings" gosync "sync" "skillshare/internal/git" @@ -14,6 +15,7 @@ import ( "skillshare/internal/sourcefs" "skillshare/internal/sourcewalk" "skillshare/internal/trash" + "skillshare/internal/utils" ) // Item is one resolved skill, group directory or tracked repo. @@ -38,6 +40,9 @@ type Options struct { // ErrDirty refuses a tracked repo with uncommitted changes. var ErrDirty = errors.New("uncommitted changes") +// ErrInsideRepo refuses a skill or folder inside a tracked repo's checkout. +var ErrInsideRepo = errors.New("inside a tracked repo; uninstall the repo instead") + // StatusError refuses a tracked repo whose git status could not be read. type StatusError struct{ Err error } @@ -66,15 +71,16 @@ type Outcome struct { // Preflight reports why each item cannot be uninstalled, without changing // anything and regardless of Force, so a caller can warn or confirm first. -// The error is a move-out refusal, ErrDirty or a *StatusError. Move-out comes -// first: a linked folder is never told to retry with force. +// The error is a move-out refusal (including ErrInsideRepo), ErrDirty or a +// *StatusError. Move-out comes first: a linked folder is never told to retry +// with force. func Preflight(items []Item, o Options) []error { errs := make([]error, len(items)) const maxDirtyWorkers = 8 sem := make(chan struct{}, maxDirtyWorkers) var wg gosync.WaitGroup for i, item := range items { - if errs[i] = sourcefs.CheckSkillMoveOut(o.SourceDir, item.Path, o.Follow); errs[i] != nil || !item.Repo { + if errs[i] = checkMoveOut(item, o); errs[i] != nil || !item.Repo { continue } wg.Add(1) @@ -129,10 +135,35 @@ func Run(items []Item, o Options) Outcome { return out } -func moveOut(item Item, o Options) error { +// checkMoveOut refuses an item that may not leave the source: one behind a +// link the policy does not allow, or one inside a tracked repo's checkout. +// Force skips neither. +func checkMoveOut(item Item, o Options) error { if err := sourcefs.CheckSkillMoveOut(o.SourceDir, item.Path, o.Follow); err != nil { return err } + rel, err := filepath.Rel(o.SourceDir, item.Path) + if err != nil { + return nil + } + // A tracked repo is a _-prefixed git checkout; removing part of it would + // leave it dirty for update. A followed source link is the user's own + // checkout, whose skills may go one at a time. + dir := o.SourceDir + parents := strings.Split(filepath.ToSlash(rel), "/") + for _, seg := range parents[:len(parents)-1] { + dir = filepath.Join(dir, seg) + if _, followed := o.Follow.Resolve(dir); utils.IsTrackedRepoDir(seg) && !followed && install.IsGitRepo(dir) { + return ErrInsideRepo + } + } + return nil +} + +func moveOut(item Item, o Options) error { + if err := checkMoveOut(item, o); err != nil { + return err + } if item.Repo && !o.Force { if err := checkDirty(item.Path); err != nil { return err diff --git a/internal/uninstall/uninstall_test.go b/internal/uninstall/uninstall_test.go index 6ce8d7193..d9ee58b82 100644 --- a/internal/uninstall/uninstall_test.go +++ b/internal/uninstall/uninstall_test.go @@ -196,6 +196,27 @@ func TestRun_RefusesLinkedSkillRoot(t *testing.T) { } } +func TestRun_RefusesItemsInsideTrackedRepoEvenWhenForced(t *testing.T) { + f := newFixture(t) + f.repo(t, "_team") + skill := f.skill(t, "_team/foo") + sub := f.skill(t, "_team/vendor/_lib") + runGit(t, sub.Path, "init", "-q") // e.g. a submodule checkout + sub.Repo = true + f.opts.Force = true + items := []Item{skill, sub} + + preflight, run := Preflight(items, f.opts), Run(items, f.opts).Results + for i := range items { + if !errors.Is(preflight[i], ErrInsideRepo) || !errors.Is(run[i].Err, ErrInsideRepo) { + t.Fatalf("%s: expected ErrInsideRepo, got preflight %v, run %v", items[i].Name, preflight[i], run[i].Err) + } + if !exists(items[i].Path) { + t.Errorf("%s must stay in the repo", items[i].Name) + } + } +} + func TestPreflight_ReportsDirtyRepoEvenWhenForced(t *testing.T) { f := newFixture(t) dirty := f.repo(t, "_dirty") diff --git a/tests/integration/uninstall_test.go b/tests/integration/uninstall_test.go index 98f3b3ae8..d081e8045 100644 --- a/tests/integration/uninstall_test.go +++ b/tests/integration/uninstall_test.go @@ -681,6 +681,26 @@ targets: {} result.AssertAnyOutputContains(t, "remaining") } +func TestUninstall_SkillInsideTrackedRepoIsRefused(t *testing.T) { + sb := testutil.NewSandbox(t) + defer sb.Cleanup() + + repoPath := filepath.Join(sb.SourcePath, "_team") + skillPath := filepath.Join(repoPath, "foo") + os.MkdirAll(skillPath, 0755) + os.WriteFile(filepath.Join(skillPath, "SKILL.md"), []byte("# Foo"), 0644) + initGitRepo(t, repoPath) + sb.WriteConfig(`source: ` + sb.SourcePath + ` +targets: {} +`) + + result := sb.RunCLI("uninstall", "_team/foo", "--force") + result.AssertAnyOutputContains(t, "uninstall the repo instead") + if !sb.FileExists(skillPath) { + t.Error("a skill inside a tracked repo must stay in the repo's checkout") + } +} + // makeUnreadableTrackedRepo creates a tracked repo whose `git status` fails // because its .git directory is empty. func makeUnreadableTrackedRepo(t *testing.T, sb *testutil.Sandbox, name string) string { diff --git a/website/docs/reference/commands/uninstall.md b/website/docs/reference/commands/uninstall.md index 780246203..7fd043e47 100644 --- a/website/docs/reference/commands/uninstall.md +++ b/website/docs/reference/commands/uninstall.md @@ -174,11 +174,14 @@ For tracked repositories (folders starting with `_`): - Fails with `failed to check git status` when skillshare cannot read the repo's git status; other items in the batch are still removed, and `--force` skips the check - Automatically removes the entry from `.gitignore` - The `_` prefix is optional when uninstalling +- A repo installed with `--into` is named by its path, such as `devops/_team-skills` +- A skill or folder inside a tracked repo cannot be removed on its own, even with `--force`; the command fails with `inside a tracked repo; uninstall the repo instead`. Skills below a followed source link can still be removed one at a time ```bash skillshare uninstall _team-skills # With prefix skillshare uninstall team-skills # Without prefix (auto-detected) skillshare uninstall _team-skills --force # Force remove with uncommitted changes +skillshare uninstall devops/_team-skills # Repo installed with --into devops ``` ## Examples diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md index b19b20eb8..51214c182 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md @@ -174,11 +174,14 @@ tracked repositories(`_` で始まるフォルダ)の場合: - skillshare がリポジトリの git status を読み取れない場合は `failed to check git status` で失敗します。バッチ内の他の項目は引き続き削除され、`--force` を使うとこのチェックをスキップします - `.gitignore` からエントリを自動的に削除します - uninstall 時に `_` prefix は省略可能です +- `--into` でインストールしたリポジトリは `devops/_team-skills` のようにパスで指定します +- 追跡リポジトリ内の Skill やフォルダは、`--force` を付けても単独では削除できず、`inside a tracked repo; uninstall the repo instead` で失敗します。followed source link 配下の Skill は 1 つずつ削除できます ```bash skillshare uninstall _team-skills # prefix 付き skillshare uninstall team-skills # prefix なし(自動検出) skillshare uninstall _team-skills --force # 未コミットの変更があっても強制削除 +skillshare uninstall devops/_team-skills # --into devops でインストールしたリポジトリ ``` ## 例 diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md b/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md index 1b32ff43d..69dcf1e05 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md @@ -174,11 +174,14 @@ tracked repository(`_`로 시작하는 폴더)의 경우: - skillshare가 repo의 git status를 읽을 수 없으면 `failed to check git status`로 실패합니다. 배치의 다른 항목은 계속 제거되며, `--force`를 사용하면 이 확인을 건너뜁니다 - `.gitignore`에서 항목을 자동으로 제거합니다 - uninstall 시 `_` 접두사는 선택 사항입니다 +- `--into`로 설치한 repo는 `devops/_team-skills`처럼 경로로 지정합니다 +- tracked repo 안의 skill이나 폴더는 `--force`를 붙여도 따로 제거할 수 없으며, `inside a tracked repo; uninstall the repo instead`로 실패합니다. followed source link 아래의 skill은 하나씩 제거할 수 있습니다 ```bash skillshare uninstall _team-skills # With prefix skillshare uninstall team-skills # Without prefix (auto-detected) skillshare uninstall _team-skills --force # Force remove with uncommitted changes +skillshare uninstall devops/_team-skills # Repo installed with --into devops ``` ## 예시 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md index f679be161..be55bf789 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md @@ -179,11 +179,14 @@ skillshare uninstall frontend/hooks -G frontend --force # hooks removed once - 当 skillshare 无法读取该仓库的 git status 时,以 `failed to check git status` 失败;批次中的其他项目仍会被移除,`--force` 会跳过此检查 - 自动从 `.gitignore` 中移除该条目 - Uninstall 时 `_` 前缀是可选的 +- 用 `--into` 安装的 repo 以路径命名,例如 `devops/_team-skills` +- tracked repo 中的 Skill 或文件夹不能单独移除,加上 `--force` 也一样;命令会以 `inside a tracked repo; uninstall the repo instead` 失败。位于 followed source link 下的 Skill 仍可逐个移除 ```bash skillshare uninstall _team-skills # With prefix skillshare uninstall team-skills # Without prefix (auto-detected) skillshare uninstall _team-skills --force # Force remove with uncommitted changes +skillshare uninstall devops/_team-skills # Repo installed with --into devops ``` ## 示例 diff --git a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md index 660144372..ba6ecd5d0 100644 --- a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md +++ b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/uninstall.md @@ -174,11 +174,14 @@ skillshare uninstall frontend/hooks -G frontend --force # hooks 只會被移除 - 當 skillshare 無法讀取該儲存庫的 git status 時,會以 `failed to check git status` 失敗;批次中的其他項目仍會被移除,`--force` 會略過此檢查 - 自動從 `.gitignore` 移除該項目 - 解除安裝時 `_` 前綴為選填 +- 用 `--into` 安裝的 repo 以路徑命名,例如 `devops/_team-skills` +- tracked repo 裡的 skill 或資料夾不能單獨移除,加上 `--force` 也一樣;指令會以 `inside a tracked repo; uninstall the repo instead` 失敗。位於 followed source link 底下的 skill 仍可逐一移除 ```bash skillshare uninstall _team-skills # 含前綴 skillshare uninstall team-skills # 不含前綴(自動偵測) skillshare uninstall _team-skills --force # 強制移除,即使有未提交的變更 +skillshare uninstall devops/_team-skills # 用 --into devops 安裝的 repo ``` ## 範例