mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
fix(update): surface missing tracked repos in update --all across CLI, API, and UI
When tracked repo metadata is committed but the gitignored clone dirs are absent on a fresh machine, `update --all` silently reported zero work: the batch path skipped missing repos with no message, and the web UI's update-all paths only listed repos present on disk. Missing tracked repos are now detected and surfaced everywhere: - CLI: a warning block (human output) plus an aggregated `missing_tracked_repos` summary (names + one-shot rehydrate hint) in JSON; the per-item error is concise. Fixed for both global and project modes, and batch and single-target paths. - Server: GET /api/update/missing-tracked-repos and the update-all/stream summaries report them; POST /api/update/rehydrate re-clones them from metadata (mirrors bare `skillshare install`). - UI: the Update page shows a warning banner listing missing repos with a Rehydrate button; strings added to all 11 locales. Closes #212
This commit is contained in:
@@ -5,8 +5,34 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// missingTrackedRepoShortReason is the concise per-item reason used in summarized
|
||||
// output (JSON items, UI). The full rehydration hint is surfaced once via
|
||||
// missingTrackedRepoHint instead of being repeated on every item.
|
||||
const missingTrackedRepoShortReason = "clone directory absent"
|
||||
|
||||
// missingTrackedRepoHint is the one-shot recovery instruction for missing
|
||||
// tracked repos, shown alongside the summarized list.
|
||||
func missingTrackedRepoHint() string {
|
||||
return "Run 'skillshare install' to rehydrate tracked repositories"
|
||||
}
|
||||
|
||||
func missingTrackedRepoMessage(name string) string {
|
||||
return fmt.Sprintf("tracked repository clone is missing: %s (metadata exists but directory is absent). Run 'skillshare install' to rehydrate tracked repositories.", name)
|
||||
return fmt.Sprintf("tracked repository clone is missing: %s (metadata exists but directory is absent). %s.", name, missingTrackedRepoHint())
|
||||
}
|
||||
|
||||
// missingTrackedRepoResult returns a skipped updateResult for a tracked repo
|
||||
// whose clone directory is absent on disk, and true. If the directory exists it
|
||||
// returns the zero value and false. Shared by the global and project single-target
|
||||
// update paths so both report missing repos consistently (issue #212).
|
||||
func missingTrackedRepoResult(t updateTarget) (updateResult, bool) {
|
||||
if _, err := os.Stat(t.path); os.IsNotExist(err) {
|
||||
return updateResult{
|
||||
skipped: 1,
|
||||
items: []updateJSONItem{{Name: t.name, Type: "repo", Status: "skipped", Error: missingTrackedRepoShortReason}},
|
||||
missingTrackedRepos: []string{t.name},
|
||||
}, true
|
||||
}
|
||||
return updateResult{}, false
|
||||
}
|
||||
|
||||
func updateTrackedRepoErrorMessage(target updateTarget, err error) string {
|
||||
|
||||
+25
-14
@@ -31,13 +31,22 @@ type updateOptions struct {
|
||||
|
||||
// updateJSONOutput is the JSON representation for update --json output.
|
||||
type updateJSONOutput struct {
|
||||
Updated int `json:"updated"`
|
||||
Skipped int `json:"skipped"`
|
||||
SecurityFailed int `json:"security_failed"`
|
||||
Pruned int `json:"pruned"`
|
||||
DryRun bool `json:"dry_run"`
|
||||
Duration string `json:"duration"`
|
||||
Items []updateJSONItem `json:"items"`
|
||||
Updated int `json:"updated"`
|
||||
Skipped int `json:"skipped"`
|
||||
SecurityFailed int `json:"security_failed"`
|
||||
Pruned int `json:"pruned"`
|
||||
DryRun bool `json:"dry_run"`
|
||||
Duration string `json:"duration"`
|
||||
Items []updateJSONItem `json:"items"`
|
||||
MissingTrackedRepos *missingTrackedReposSummary `json:"missing_tracked_repos,omitempty"`
|
||||
}
|
||||
|
||||
// missingTrackedReposSummary aggregates tracked repos declared in metadata whose
|
||||
// clone directories are absent on disk, so the per-item error stays concise while
|
||||
// the recovery hint is surfaced once. See issue #212.
|
||||
type missingTrackedReposSummary struct {
|
||||
Names []string `json:"names"`
|
||||
Hint string `json:"hint"`
|
||||
}
|
||||
|
||||
type updateJSONItem struct {
|
||||
@@ -380,13 +389,8 @@ func cmdUpdate(args []string) error {
|
||||
var r updateResult
|
||||
var updateErr error
|
||||
if t.isRepo {
|
||||
if opts.all {
|
||||
if _, statErr := os.Stat(t.path); os.IsNotExist(statErr) {
|
||||
r.skipped = 1
|
||||
r.items = append(r.items, updateJSONItem{Name: t.name, Type: "repo", Status: "skipped", Error: missingTrackedRepoMessage(t.name)})
|
||||
} else {
|
||||
r, updateErr = updateTrackedRepo(uc, t.name)
|
||||
}
|
||||
if mr, missing := missingTrackedRepoResult(t); opts.all && missing {
|
||||
r = mr
|
||||
} else {
|
||||
r, updateErr = updateTrackedRepo(uc, t.name)
|
||||
}
|
||||
@@ -404,6 +408,7 @@ func cmdUpdate(args []string) error {
|
||||
if opts.jsonOutput {
|
||||
return jsonWriteResult(&r, updateErr)
|
||||
}
|
||||
displayMissingTrackedReposWarning(r.missingTrackedRepos)
|
||||
return updateErr
|
||||
}
|
||||
|
||||
@@ -444,6 +449,12 @@ func updateOutputJSON(result *updateResult, dryRun bool, start time.Time, update
|
||||
output.SecurityFailed = result.securityFailed
|
||||
output.Pruned = result.pruned
|
||||
output.Items = result.items
|
||||
if len(result.missingTrackedRepos) > 0 {
|
||||
output.MissingTrackedRepos = &missingTrackedReposSummary{
|
||||
Names: result.missingTrackedRepos,
|
||||
Hint: missingTrackedRepoHint(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return writeJSONResult(&output, updateErr)
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@ import (
|
||||
|
||||
// updateResult tracks the result of an update operation
|
||||
type updateResult struct {
|
||||
updated int
|
||||
skipped int
|
||||
securityFailed int
|
||||
pruned int
|
||||
items []updateJSONItem
|
||||
updated int
|
||||
skipped int
|
||||
securityFailed int
|
||||
pruned int
|
||||
items []updateJSONItem
|
||||
missingTrackedRepos []string // names of tracked repos declared in metadata but absent on disk
|
||||
}
|
||||
|
||||
// batchBlockedEntry records a skill that was blocked by security audit during batch update.
|
||||
@@ -232,3 +233,17 @@ func displayStaleWarning(stale []string) {
|
||||
}
|
||||
ui.Info("Run with --prune to remove stale skills")
|
||||
}
|
||||
|
||||
// displayMissingTrackedReposWarning warns about tracked repos declared in
|
||||
// metadata whose clone directories are absent on disk (issue #212).
|
||||
func displayMissingTrackedReposWarning(missing []string) {
|
||||
if len(missing) == 0 {
|
||||
return
|
||||
}
|
||||
fmt.Println()
|
||||
ui.Warning("%d tracked repo(s) declared in metadata but missing on disk:", len(missing))
|
||||
for _, name := range missing {
|
||||
ui.ListItem("warning", name, missingTrackedRepoShortReason)
|
||||
}
|
||||
ui.Info("%s", missingTrackedRepoHint())
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -61,6 +62,7 @@ func executeBatchUpdate(uc *updateContext, targets []updateTarget) (updateResult
|
||||
var blockedEntries []batchBlockedEntry
|
||||
var staleNames []string
|
||||
var prunedNames []string
|
||||
var missingRepoNames []string
|
||||
|
||||
// Group skills by RepoURL to optimize updates
|
||||
repoGroups := make(map[string][]updateTarget)
|
||||
@@ -105,6 +107,15 @@ func executeBatchUpdate(uc *updateContext, targets []updateTarget) (updateResult
|
||||
}
|
||||
for _, t := range trackedRepos {
|
||||
progressBar.UpdateTitle(fmt.Sprintf("Updating %s", t.name))
|
||||
// Tracked repo declared in metadata but clone dir is absent (issue #212):
|
||||
// surface it instead of silently skipping (mirrors the single-target path).
|
||||
if _, statErr := os.Stat(t.path); os.IsNotExist(statErr) {
|
||||
result.skipped++
|
||||
missingRepoNames = append(missingRepoNames, t.name)
|
||||
result.items = append(result.items, updateJSONItem{Name: t.name, Type: "repo", Status: "skipped", Error: missingTrackedRepoShortReason})
|
||||
progressBar.Increment()
|
||||
continue
|
||||
}
|
||||
updated, auditResult, err := updateTrackedRepoQuick(uc, t.path)
|
||||
if err != nil {
|
||||
if isSecurityError(err) {
|
||||
@@ -125,6 +136,7 @@ func executeBatchUpdate(uc *updateContext, targets []updateTarget) (updateResult
|
||||
}
|
||||
progressBar.Increment()
|
||||
}
|
||||
result.missingTrackedRepos = missingRepoNames
|
||||
|
||||
// Phase 2: grouped skills (one clone per repo)
|
||||
if len(repoGroups) > 0 {
|
||||
@@ -276,6 +288,7 @@ func executeBatchUpdate(uc *updateContext, targets []updateTarget) (updateResult
|
||||
displayUpdateBlockedSection(blockedEntries)
|
||||
displayPrunedSection(prunedNames)
|
||||
displayStaleWarning(staleNames)
|
||||
displayMissingTrackedReposWarning(missingRepoNames)
|
||||
displayUpdateAuditResults(auditEntries, uc.opts.auditVerbose)
|
||||
ui.UpdateSummary(ui.UpdateStats{
|
||||
Updated: result.updated,
|
||||
|
||||
@@ -230,6 +230,20 @@ func updateAllProjectSkills(uc *updateContext) (*updateResult, error) {
|
||||
return nil, fmt.Errorf("failed to scan skills: %w", err)
|
||||
}
|
||||
|
||||
// Tracked repos declared in metadata but absent on disk (issue #212):
|
||||
// surface them instead of silently ignoring (mirrors global --all).
|
||||
existing := make(map[string]bool, len(targets))
|
||||
for _, t := range targets {
|
||||
existing[t.name] = true
|
||||
}
|
||||
missingRepos, _ := install.GetMissingTrackedRepos(uc.sourcePath)
|
||||
for _, repo := range missingRepos {
|
||||
if !existing[repo.Name] {
|
||||
existing[repo.Name] = true
|
||||
targets = append(targets, updateTarget{name: repo.Name, path: filepath.Join(uc.sourcePath, filepath.FromSlash(repo.Name)), isRepo: true})
|
||||
}
|
||||
}
|
||||
|
||||
var repoCount, skillCount int
|
||||
for _, t := range targets {
|
||||
if t.isRepo {
|
||||
@@ -252,7 +266,12 @@ func updateAllProjectSkills(uc *updateContext) (*updateResult, error) {
|
||||
var r updateResult
|
||||
var updateErr error
|
||||
if t.isRepo {
|
||||
r, updateErr = updateTrackedRepo(uc, t.name)
|
||||
if mr, missing := missingTrackedRepoResult(t); missing {
|
||||
r = mr
|
||||
displayMissingTrackedReposWarning(r.missingTrackedRepos)
|
||||
} else {
|
||||
r, updateErr = updateTrackedRepo(uc, t.name)
|
||||
}
|
||||
} else {
|
||||
r, updateErr = updateRegularSkill(uc, t.name)
|
||||
}
|
||||
|
||||
@@ -308,3 +308,9 @@ func GetTrackedRepos(sourceDir string) ([]string, error) {
|
||||
func GetMissingTrackedRepos(sourceDir string) ([]TrackedRepoMeta, error) {
|
||||
return getMissingTrackedReposImpl(sourceDir)
|
||||
}
|
||||
|
||||
// RehydrateMissingTrackedRepos re-clones tracked repos declared in metadata whose
|
||||
// clone directories are absent on disk. Repos already present are left untouched.
|
||||
func RehydrateMissingTrackedRepos(sourceDir string, parseOpts ParseOptions, opts InstallOptions) ([]RehydrateResult, error) {
|
||||
return rehydrateMissingTrackedReposImpl(sourceDir, parseOpts, opts)
|
||||
}
|
||||
|
||||
@@ -78,6 +78,80 @@ func getMissingTrackedReposImpl(sourceDir string) ([]TrackedRepoMeta, error) {
|
||||
return missing, nil
|
||||
}
|
||||
|
||||
// RehydrateResult reports the outcome of rehydrating one missing tracked repo.
|
||||
type RehydrateResult struct {
|
||||
Name string `json:"name"`
|
||||
Action string `json:"action"` // "rehydrated" | "error"
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// rehydrateMissingTrackedReposImpl re-clones tracked repos declared in metadata
|
||||
// whose clone directories are absent on disk. It mirrors the tracked-repo phase
|
||||
// of InstallFromConfig (bare `skillshare install`); repos already on disk are
|
||||
// left untouched. See issue #212.
|
||||
func rehydrateMissingTrackedReposImpl(sourceDir string, parseOpts ParseOptions, opts InstallOptions) ([]RehydrateResult, error) {
|
||||
store, err := LoadMetadata(sourceDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
existingRepos, err := GetTrackedRepos(sourceDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
existing := make(map[string]bool, len(existingRepos))
|
||||
for _, repo := range existingRepos {
|
||||
existing[filepath.ToSlash(repo)] = true
|
||||
}
|
||||
|
||||
opts.Quiet = true
|
||||
opts.Update = false
|
||||
var results []RehydrateResult
|
||||
for _, key := range store.List() {
|
||||
entry := store.Get(key)
|
||||
if entry == nil || !entry.Tracked {
|
||||
continue
|
||||
}
|
||||
relPath := filepath.ToSlash(KeyToRelPath(key, entry))
|
||||
if !strings.HasPrefix(filepath.Base(relPath), "_") {
|
||||
continue
|
||||
}
|
||||
if existing[relPath] {
|
||||
continue
|
||||
}
|
||||
|
||||
groupDir, bareName := splitTrackedRelPath(relPath)
|
||||
source, perr := ParseSourceWithOptions(entry.Source, parseOpts)
|
||||
if perr != nil {
|
||||
results = append(results, RehydrateResult{Name: relPath, Action: "error", Error: "invalid source: " + perr.Error()})
|
||||
continue
|
||||
}
|
||||
source.Name = bareName
|
||||
source.Branch = entry.Branch
|
||||
|
||||
trackOpts := opts
|
||||
trackOpts.Name = bareName
|
||||
if groupDir != "" {
|
||||
trackOpts.Into = groupDir
|
||||
}
|
||||
if _, ierr := InstallTrackedRepo(source, sourceDir, trackOpts); ierr != nil {
|
||||
results = append(results, RehydrateResult{Name: relPath, Action: "error", Error: ierr.Error()})
|
||||
continue
|
||||
}
|
||||
results = append(results, RehydrateResult{Name: relPath, Action: "rehydrated"})
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// splitTrackedRelPath splits a tracked repo's relative path into its parent
|
||||
// group directory and base name (the base retains its leading "_").
|
||||
func splitTrackedRelPath(relPath string) (group, name string) {
|
||||
relPath = strings.Trim(relPath, "/")
|
||||
if idx := strings.LastIndex(relPath, "/"); idx >= 0 {
|
||||
return relPath[:idx], relPath[idx+1:]
|
||||
}
|
||||
return "", relPath
|
||||
}
|
||||
|
||||
// FindRepoInstalls scans sourceDir for skills whose meta repo_url matches
|
||||
// cloneURL. Returns relative paths (e.g. "feature-radar/feature-radar-archive").
|
||||
// Tracked repos (_-prefixed) are skipped.
|
||||
|
||||
@@ -45,6 +45,35 @@ func makeRemote(t *testing.T, extraBranch string) (remoteURL string) {
|
||||
return "file://" + remote
|
||||
}
|
||||
|
||||
// TestRehydrateMissingTrackedRepos_ReclonesAbsent verifies that a tracked repo
|
||||
// declared in metadata but absent on disk is re-cloned (issue #212).
|
||||
func TestRehydrateMissingTrackedRepos_ReclonesAbsent(t *testing.T) {
|
||||
remoteURL := makeRemote(t, "")
|
||||
sourceDir := t.TempDir()
|
||||
|
||||
// Declare the tracked repo in metadata WITHOUT cloning it (fresh machine).
|
||||
store := LoadMetadataOrNew(sourceDir)
|
||||
store.Set("_team-skills", &MetadataEntry{Source: remoteURL, Tracked: true})
|
||||
if err := store.Save(sourceDir); err != nil {
|
||||
t.Fatalf("save metadata: %v", err)
|
||||
}
|
||||
|
||||
results, err := RehydrateMissingTrackedRepos(sourceDir, ParseOptions{}, InstallOptions{SkipAudit: true})
|
||||
if err != nil {
|
||||
t.Fatalf("RehydrateMissingTrackedRepos() error = %v", err)
|
||||
}
|
||||
if len(results) != 1 || results[0].Action != "rehydrated" {
|
||||
t.Fatalf("unexpected results: %+v", results)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(sourceDir, "_team-skills", ".git")); err != nil {
|
||||
t.Fatalf("expected cloned repo at _team-skills: %v", err)
|
||||
}
|
||||
// After rehydration nothing should remain missing.
|
||||
if missing, _ := GetMissingTrackedRepos(sourceDir); len(missing) != 0 {
|
||||
t.Fatalf("expected no missing repos after rehydrate, got %+v", missing)
|
||||
}
|
||||
}
|
||||
|
||||
// TestInstallTrackedRepo_NameFromSource verifies that when opts.Name is empty,
|
||||
// the directory name is taken from source.Name rather than being derived from
|
||||
// the remote URL via TrackName().
|
||||
|
||||
@@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"skillshare/internal/audit"
|
||||
"skillshare/internal/config"
|
||||
"skillshare/internal/git"
|
||||
"skillshare/internal/install"
|
||||
"skillshare/internal/utils"
|
||||
@@ -23,6 +25,28 @@ type updateRequest struct {
|
||||
SkipAudit bool `json:"skipAudit"`
|
||||
}
|
||||
|
||||
// missingTrackedRepoInfo describes a tracked repo declared in metadata whose
|
||||
// clone directory is absent on disk. Carried in update responses so the UI can
|
||||
// warn and offer rehydration (issue #212).
|
||||
type missingTrackedRepoInfo struct {
|
||||
Name string `json:"name"`
|
||||
Source string `json:"source"`
|
||||
Branch string `json:"branch,omitempty"`
|
||||
}
|
||||
|
||||
// missingTrackedRepos returns tracked repos declared in metadata but absent on disk.
|
||||
func (s *Server) missingTrackedRepos() []missingTrackedRepoInfo {
|
||||
repos, err := install.GetMissingTrackedRepos(s.cfg.EffectiveSkillsSource())
|
||||
if err != nil || len(repos) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]missingTrackedRepoInfo, 0, len(repos))
|
||||
for _, r := range repos {
|
||||
out = append(out, missingTrackedRepoInfo{Name: r.Name, Source: r.Source, Branch: r.Branch})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
type updateResultItem struct {
|
||||
Name string `json:"name"`
|
||||
Action string `json:"action"` // "updated", "up-to-date", "skipped", "error", "blocked"
|
||||
@@ -94,7 +118,7 @@ func (s *Server) handleUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
"results_blocked": blocked,
|
||||
"scope": "ui",
|
||||
}, msg)
|
||||
writeJSON(w, map[string]any{"results": results})
|
||||
writeJSON(w, map[string]any{"results": results, "missingTrackedRepos": s.missingTrackedRepos()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -451,6 +475,77 @@ func (s *Server) updateAll(force, skipAudit bool) []updateResultItem {
|
||||
return results
|
||||
}
|
||||
|
||||
// handleMissingTrackedRepos returns tracked repos declared in metadata whose
|
||||
// clone directories are absent on disk (issue #212), so the UI can warn on load.
|
||||
func (s *Server) handleMissingTrackedRepos(w http.ResponseWriter, r *http.Request) {
|
||||
s.mu.RLock()
|
||||
repos := s.missingTrackedRepos()
|
||||
s.mu.RUnlock()
|
||||
if repos == nil {
|
||||
repos = []missingTrackedRepoInfo{}
|
||||
}
|
||||
writeJSON(w, map[string]any{"repos": repos})
|
||||
}
|
||||
|
||||
// handleRehydrateTrackedRepos re-clones tracked repos declared in metadata whose
|
||||
// clone directories are absent on disk (issue #212). Mirrors bare CLI install.
|
||||
func (s *Server) handleRehydrateTrackedRepos(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
sourceDir := s.cfg.EffectiveSkillsSource()
|
||||
opts := install.InstallOptions{
|
||||
AuditThreshold: s.updateAuditThreshold(),
|
||||
SourceDir: sourceDir,
|
||||
}
|
||||
if s.IsProjectMode() {
|
||||
opts.AuditProjectRoot = s.projectRoot
|
||||
}
|
||||
|
||||
results, err := install.RehydrateMissingTrackedRepos(sourceDir, s.parseOpts(), opts)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// Reload metadata + reconcile config so newly cloned repos register.
|
||||
if st, lerr := install.LoadMetadataWithMigration(sourceDir, ""); lerr == nil && st != nil {
|
||||
s.skillsStore = st
|
||||
}
|
||||
if s.IsProjectMode() {
|
||||
if rErr := config.ReconcileProjectSkills(s.projectRoot, s.projectCfg, s.skillsStore, sourceDir); rErr != nil {
|
||||
log.Printf("warning: failed to reconcile project skills config: %v", rErr)
|
||||
}
|
||||
} else {
|
||||
if rErr := config.ReconcileGlobalSkills(s.cfg, s.skillsStore); rErr != nil {
|
||||
log.Printf("warning: failed to reconcile global skills config: %v", rErr)
|
||||
}
|
||||
}
|
||||
|
||||
rehydrated, failed := 0, 0
|
||||
for _, res := range results {
|
||||
if res.Action == "rehydrated" {
|
||||
rehydrated++
|
||||
} else {
|
||||
failed++
|
||||
}
|
||||
}
|
||||
status, msg := "ok", ""
|
||||
if failed > 0 {
|
||||
status = "partial"
|
||||
msg = fmt.Sprintf("%d repo(s) failed to rehydrate", failed)
|
||||
}
|
||||
s.writeOpsLog("install", status, start, map[string]any{
|
||||
"name": "--rehydrate",
|
||||
"tracked": true,
|
||||
"scope": "ui",
|
||||
"rehydrated": rehydrated,
|
||||
"failed": failed,
|
||||
}, msg)
|
||||
writeJSON(w, map[string]any{"results": results})
|
||||
}
|
||||
|
||||
// getServerUpdatableSkills returns relative paths of skills that have metadata with a remote source.
|
||||
// It walks the source directory recursively to find nested skills (e.g. utils/ascii-box-check).
|
||||
func getServerUpdatableSkills(sourceDir string, store *install.MetadataStore) ([]string, error) {
|
||||
|
||||
@@ -101,11 +101,12 @@ func (s *Server) handleUpdateStream(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var results []updateResultItem
|
||||
summary := struct {
|
||||
Updated int `json:"updated"`
|
||||
UpToDate int `json:"upToDate"`
|
||||
Blocked int `json:"blocked"`
|
||||
Errors int `json:"errors"`
|
||||
Skipped int `json:"skipped"`
|
||||
Updated int `json:"updated"`
|
||||
UpToDate int `json:"upToDate"`
|
||||
Blocked int `json:"blocked"`
|
||||
Errors int `json:"errors"`
|
||||
Skipped int `json:"skipped"`
|
||||
MissingTrackedRepos []missingTrackedRepoInfo `json:"missingTrackedRepos,omitempty"`
|
||||
}{}
|
||||
|
||||
for _, item := range items {
|
||||
@@ -145,6 +146,14 @@ func (s *Server) handleUpdateStream(w http.ResponseWriter, r *http.Request) {
|
||||
safeSend("result", result)
|
||||
}
|
||||
|
||||
// Surface tracked repos declared in metadata but absent on disk (issue #212).
|
||||
// Only relevant for the update-all flow, not targeted updates.
|
||||
if namesParam == "" {
|
||||
s.mu.RLock()
|
||||
summary.MissingTrackedRepos = s.missingTrackedRepos()
|
||||
s.mu.RUnlock()
|
||||
}
|
||||
|
||||
// Write ops log
|
||||
s.mu.Lock()
|
||||
status := "ok"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -40,6 +42,47 @@ func initGitRepo(t *testing.T, dir string) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestMissingTrackedRepos_ReportedFromMetadata verifies the server detects tracked
|
||||
// repos declared in metadata whose clone dirs are absent (issue #212).
|
||||
func TestMissingTrackedRepos_ReportedFromMetadata(t *testing.T) {
|
||||
s, src := newTestServer(t)
|
||||
|
||||
store := install.LoadMetadataOrNew(src)
|
||||
store.Set("_team-skills", &install.MetadataEntry{
|
||||
Source: "https://github.com/example/team-skills",
|
||||
Branch: "main",
|
||||
Tracked: true,
|
||||
})
|
||||
if err := store.Save(src); err != nil {
|
||||
t.Fatalf("save metadata: %v", err)
|
||||
}
|
||||
|
||||
missing := s.missingTrackedRepos()
|
||||
if len(missing) != 1 {
|
||||
t.Fatalf("expected 1 missing repo, got %d (%+v)", len(missing), missing)
|
||||
}
|
||||
if missing[0].Name != "_team-skills" || missing[0].Branch != "main" {
|
||||
t.Fatalf("unexpected missing repo: %+v", missing[0])
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleRehydrate_NoMissing_OK verifies the rehydrate endpoint succeeds with
|
||||
// an empty result set when nothing is missing.
|
||||
func TestHandleRehydrate_NoMissing_OK(t *testing.T) {
|
||||
s, _ := newTestServer(t)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/update/rehydrate", nil)
|
||||
rr := httptest.NewRecorder()
|
||||
s.handleRehydrateTrackedRepos(rr, req)
|
||||
|
||||
if rr.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d: %s", rr.Code, rr.Body.String())
|
||||
}
|
||||
if !strings.Contains(rr.Body.String(), "results") {
|
||||
t.Fatalf("expected results field, got %s", rr.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateSingle_NestedTrackedRepo_Resolves(t *testing.T) {
|
||||
s, src := newTestServer(t)
|
||||
|
||||
|
||||
@@ -424,6 +424,8 @@ func (s *Server) registerRoutes() {
|
||||
// Update & Check
|
||||
s.mux.HandleFunc("POST /api/update", s.handleUpdate)
|
||||
s.mux.HandleFunc("GET /api/update/stream", s.handleUpdateStream)
|
||||
s.mux.HandleFunc("GET /api/update/missing-tracked-repos", s.handleMissingTrackedRepos)
|
||||
s.mux.HandleFunc("POST /api/update/rehydrate", s.handleRehydrateTrackedRepos)
|
||||
s.mux.HandleFunc("GET /api/check/stream", s.handleCheckStream)
|
||||
s.mux.HandleFunc("GET /api/check", s.handleCheck)
|
||||
|
||||
|
||||
@@ -125,6 +125,10 @@ func TestTrackedMetadataMissingClone_UpdateAllJSONSkipsMissingRepo(t *testing.T)
|
||||
Status string `json:"status"`
|
||||
Error string `json:"error"`
|
||||
} `json:"items"`
|
||||
MissingTrackedRepos *struct {
|
||||
Names []string `json:"names"`
|
||||
Hint string `json:"hint"`
|
||||
} `json:"missing_tracked_repos"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(result.Stdout), &output); err != nil {
|
||||
t.Fatalf("failed to parse JSON output: %v\nstdout: %s", err, result.Stdout)
|
||||
@@ -140,9 +144,18 @@ func TestTrackedMetadataMissingClone_UpdateAllJSONSkipsMissingRepo(t *testing.T)
|
||||
if item.Name != missingTrackedRepoName || item.Type != "repo" || item.Status != "skipped" {
|
||||
t.Fatalf("expected skipped repo item for %q, got %+v", missingTrackedRepoName, item)
|
||||
}
|
||||
message := strings.ToLower(item.Error)
|
||||
if !strings.Contains(message, "missing") || !strings.Contains(item.Error, "skillshare install") {
|
||||
t.Fatalf("expected missing-repo error message with skillshare install suggestion, got %q", item.Error)
|
||||
// Per-item error is concise; the actionable hint is aggregated in the summary.
|
||||
if !strings.Contains(strings.ToLower(item.Error), "absent") {
|
||||
t.Fatalf("expected concise per-item error, got %q", item.Error)
|
||||
}
|
||||
if output.MissingTrackedRepos == nil {
|
||||
t.Fatalf("expected missing_tracked_repos summary in output: %s", result.Stdout)
|
||||
}
|
||||
if len(output.MissingTrackedRepos.Names) != 1 || output.MissingTrackedRepos.Names[0] != missingTrackedRepoName {
|
||||
t.Fatalf("expected summary names [%q], got %v", missingTrackedRepoName, output.MissingTrackedRepos.Names)
|
||||
}
|
||||
if !strings.Contains(output.MissingTrackedRepos.Hint, "skillshare install") {
|
||||
t.Fatalf("expected summary hint with skillshare install suggestion, got %q", output.MissingTrackedRepos.Hint)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,29 @@ func TestUpdateProject_MultiNames_DryRun(t *testing.T) {
|
||||
result.AssertAnyOutputContains(t, "dry-run")
|
||||
}
|
||||
|
||||
// TestUpdateProject_All_MissingTrackedRepos_Warns verifies project-mode
|
||||
// `update --all -p` surfaces tracked repos declared in project metadata whose
|
||||
// clone dirs are absent, instead of silently ignoring them (issue #212).
|
||||
func TestUpdateProject_All_MissingTrackedRepos_Warns(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
projectRoot := sb.SetupProjectDir("claude")
|
||||
|
||||
// Placeholder skill (no meta) ensures the project skills dir exists.
|
||||
sb.CreateProjectSkill(projectRoot, "placeholder", map[string]string{"SKILL.md": "# P"})
|
||||
|
||||
skillsDir := filepath.Join(projectRoot, ".skillshare", "skills")
|
||||
writeMissingTrackedRepoMeta(t, skillsDir, "_repo-a")
|
||||
writeMissingTrackedRepoMeta(t, skillsDir, "_repo-b")
|
||||
|
||||
result := sb.RunCLIInDir(projectRoot, "update", "--all", "-p")
|
||||
result.AssertSuccess(t)
|
||||
result.AssertAnyOutputContains(t, "missing on disk")
|
||||
result.AssertAnyOutputContains(t, "_repo-a")
|
||||
result.AssertAnyOutputContains(t, "_repo-b")
|
||||
result.AssertAnyOutputContains(t, "skillshare install")
|
||||
}
|
||||
|
||||
func TestUpdateProject_Group_DryRun(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -85,6 +85,72 @@ func TestUpdate_MultipleNames_PartialNotFound(t *testing.T) {
|
||||
result.AssertAnyOutputContains(t, "ghost")
|
||||
}
|
||||
|
||||
// writeMissingTrackedRepoMeta declares a tracked repo in .metadata.json without
|
||||
// creating its clone directory, simulating a fresh machine where metadata is
|
||||
// committed but the gitignored clone dirs are absent (issue #212).
|
||||
func writeMissingTrackedRepoMeta(t *testing.T, sourceDir, name string) {
|
||||
t.Helper()
|
||||
store, err := install.LoadMetadata(sourceDir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to load metadata: %v", err)
|
||||
}
|
||||
store.Set(name, &install.MetadataEntry{
|
||||
Source: "https://github.com/example/" + strings.TrimPrefix(name, "_"),
|
||||
RepoURL: "https://github.com/example/" + strings.TrimPrefix(name, "_") + ".git",
|
||||
Tracked: true,
|
||||
})
|
||||
if err := store.Save(sourceDir); err != nil {
|
||||
t.Fatalf("failed to save metadata: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestUpdate_All_MissingTrackedRepos_BatchWarns verifies that `update --all`
|
||||
// surfaces a warning (not a silent skip) when multiple tracked repos are
|
||||
// declared in metadata but their clone directories are missing. Regression
|
||||
// test for issue #212.
|
||||
func TestUpdate_All_MissingTrackedRepos_BatchWarns(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
setupGlobalConfig(sb)
|
||||
|
||||
// Placeholder skill (no metadata) just ensures the source dir exists; it is
|
||||
// not an update target since it has no metadata entry.
|
||||
sb.CreateSkill("placeholder", map[string]string{"SKILL.md": "# Placeholder"})
|
||||
|
||||
// Two missing tracked repos → two targets → batch path (not single-target).
|
||||
writeMissingTrackedRepoMeta(t, sb.SourcePath, "_repo-a")
|
||||
writeMissingTrackedRepoMeta(t, sb.SourcePath, "_repo-b")
|
||||
|
||||
result := sb.RunCLI("update", "--all")
|
||||
result.AssertSuccess(t)
|
||||
result.AssertAnyOutputContains(t, "missing on disk")
|
||||
result.AssertAnyOutputContains(t, "_repo-a")
|
||||
result.AssertAnyOutputContains(t, "_repo-b")
|
||||
result.AssertAnyOutputContains(t, "skillshare install")
|
||||
}
|
||||
|
||||
// TestUpdate_All_MissingTrackedRepos_JSON verifies the JSON output reports each
|
||||
// missing tracked repo as a skipped item carrying the rehydration hint.
|
||||
func TestUpdate_All_MissingTrackedRepos_JSON(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
setupGlobalConfig(sb)
|
||||
|
||||
sb.CreateSkill("placeholder", map[string]string{"SKILL.md": "# Placeholder"})
|
||||
writeMissingTrackedRepoMeta(t, sb.SourcePath, "_repo-a")
|
||||
writeMissingTrackedRepoMeta(t, sb.SourcePath, "_repo-b")
|
||||
|
||||
result := sb.RunCLI("update", "--all", "--json")
|
||||
result.AssertSuccess(t)
|
||||
// Aggregated summary carries the names + one-shot rehydration hint.
|
||||
result.AssertOutputContains(t, "missing_tracked_repos")
|
||||
result.AssertOutputContains(t, "_repo-a")
|
||||
result.AssertOutputContains(t, "_repo-b")
|
||||
result.AssertOutputContains(t, "rehydrate tracked repositories")
|
||||
// Per-item error is concise (not the repeated long sentence).
|
||||
result.AssertOutputContains(t, "clone directory absent")
|
||||
}
|
||||
|
||||
func TestUpdate_Group_DryRun(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -405,6 +405,16 @@ export const api = {
|
||||
}, onError, 'Update stream failed');
|
||||
},
|
||||
|
||||
// Tracked repos declared in metadata but absent on disk (issue #212)
|
||||
missingTrackedRepos: () =>
|
||||
apiFetch<{ repos: MissingTrackedRepo[] }>('/update/missing-tracked-repos'),
|
||||
|
||||
// Rehydrate tracked repos declared in metadata but absent on disk (issue #212)
|
||||
rehydrateTrackedRepos: () =>
|
||||
apiFetch<{ results: RehydrateResultItem[] }>('/update/rehydrate', {
|
||||
method: 'POST',
|
||||
}),
|
||||
|
||||
// Repo uninstall
|
||||
deleteRepo: (name: string) =>
|
||||
apiFetch<{ success: boolean; name: string }>(`/repos/${encodeURIComponent(name)}`, { method: 'DELETE' }),
|
||||
@@ -913,12 +923,25 @@ export interface UpdateResultItem {
|
||||
auditRiskLabel?: string;
|
||||
}
|
||||
|
||||
export interface MissingTrackedRepo {
|
||||
name: string;
|
||||
source: string;
|
||||
branch?: string;
|
||||
}
|
||||
|
||||
export interface UpdateStreamSummary {
|
||||
updated: number;
|
||||
upToDate: number;
|
||||
blocked: number;
|
||||
errors: number;
|
||||
skipped: number;
|
||||
missingTrackedRepos?: MissingTrackedRepo[];
|
||||
}
|
||||
|
||||
export interface RehydrateResultItem {
|
||||
name: string;
|
||||
action: string; // "rehydrated" | "error"
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface AvailableTarget {
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "Gelöscht",
|
||||
"update.updating.purging": "Wird gelöscht...",
|
||||
"update.updating.subtitle": "Ausgewählte Skills werden aktualisiert...",
|
||||
"update.missingRepos.title": "{count} getrackte(s) Repo(s) fehlen auf der Festplatte",
|
||||
"update.missingRepos.description": "Diese getrackten Repositorys sind in den Metadaten deklariert, aber ihre Klon-Verzeichnisse fehlen. Rehydrieren, um sie aus ihren Quellen neu zu klonen.",
|
||||
"update.missingRepos.rehydrate": "Rehydrieren",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} getrackte(s) Repo(s) rehydriert",
|
||||
"update.missingRepos.rehydratePartial": "{count} Repo(s) konnten nicht rehydriert werden",
|
||||
"updateDialog.copyCommand": "Befehl kopieren",
|
||||
"updateDialog.newVersion": "Neue Version verfügbar",
|
||||
"updateDialog.restartDev": "DEV-Modus-Neustart simuliert.",
|
||||
|
||||
@@ -1122,6 +1122,11 @@
|
||||
"update.updating.purged": "Purged",
|
||||
"update.updating.purging": "Purging...",
|
||||
"update.updating.subtitle": "Updating selected skills...",
|
||||
"update.missingRepos.title": "{count} tracked repo(s) missing on disk",
|
||||
"update.missingRepos.description": "These tracked repositories are declared in metadata but their clone directories are absent. Rehydrate to re-clone them from their sources.",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "Rehydrated {count} tracked repo(s)",
|
||||
"update.missingRepos.rehydratePartial": "{count} repo(s) failed to rehydrate",
|
||||
"theme.clean": "Clean",
|
||||
"theme.dark": "Dark",
|
||||
"theme.light": "Light",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "Purgado",
|
||||
"update.updating.purging": "Purgando...",
|
||||
"update.updating.subtitle": "Actualizando las skills seleccionadas...",
|
||||
"update.missingRepos.title": "Faltan {count} repo(s) rastreado(s) en el disco",
|
||||
"update.missingRepos.description": "Estos repositorios rastreados están declarados en los metadatos, pero faltan sus directorios de clonación. Rehidrata para volver a clonarlos desde sus orígenes.",
|
||||
"update.missingRepos.rehydrate": "Rehidratar",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} repo(s) rastreado(s) rehidratado(s)",
|
||||
"update.missingRepos.rehydratePartial": "No se pudieron rehidratar {count} repo(s)",
|
||||
"updateDialog.copyCommand": "Copiar comando",
|
||||
"updateDialog.newVersion": "Nueva versión disponible",
|
||||
"updateDialog.restartDev": "Reinicio en modo DEV simulado.",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "پاکسازی شد",
|
||||
"update.updating.purging": "در حال پاکسازی...",
|
||||
"update.updating.subtitle": "در حال بهروزرسانی اسکیلهای انتخابشده...",
|
||||
"update.missingRepos.title": "{count} مخزن ردیابیشده روی دیسک وجود ندارد",
|
||||
"update.missingRepos.description": "این مخازن ردیابیشده در فراداده اعلام شدهاند اما دایرکتوری کلون آنها وجود ندارد. برای کلون مجدد از منبع، Rehydrate کنید.",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} مخزن ردیابیشده مجدداً کلون شد",
|
||||
"update.missingRepos.rehydratePartial": "کلون مجدد {count} مخزن ناموفق بود",
|
||||
"updateDialog.copyCommand": "کپی دستور",
|
||||
"updateDialog.newVersion": "نسخه جدید موجود است",
|
||||
"updateDialog.restartDev": "راهاندازی مجدد در حالت DEV شبیهسازی شد.",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "Purgé",
|
||||
"update.updating.purging": "Purge en cours...",
|
||||
"update.updating.subtitle": "Mise à jour des skills sélectionnés...",
|
||||
"update.missingRepos.title": "{count} dépôt(s) suivi(s) manquant(s) sur le disque",
|
||||
"update.missingRepos.description": "Ces dépôts suivis sont déclarés dans les métadonnées, mais leurs répertoires de clonage sont absents. Réhydratez pour les recloner depuis leurs sources.",
|
||||
"update.missingRepos.rehydrate": "Réhydrater",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} dépôt(s) suivi(s) réhydraté(s)",
|
||||
"update.missingRepos.rehydratePartial": "Échec de la réhydratation de {count} dépôt(s)",
|
||||
"updateDialog.copyCommand": "Copier la commande",
|
||||
"updateDialog.newVersion": "Nouvelle version disponible",
|
||||
"updateDialog.restartDev": "Redémarrage simulé en mode DEV.",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "Dihapus bersih",
|
||||
"update.updating.purging": "Menghapus bersih...",
|
||||
"update.updating.subtitle": "Memperbarui skill yang dipilih...",
|
||||
"update.missingRepos.title": "{count} repo terlacak hilang di disk",
|
||||
"update.missingRepos.description": "Repositori terlacak ini dideklarasikan di metadata, tetapi direktori klonnya tidak ada. Rehydrate untuk mengkloningnya kembali dari sumbernya.",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} repo terlacak berhasil di-rehydrate",
|
||||
"update.missingRepos.rehydratePartial": "{count} repo gagal di-rehydrate",
|
||||
"updateDialog.copyCommand": "Salin perintah",
|
||||
"updateDialog.newVersion": "Versi baru tersedia",
|
||||
"updateDialog.restartDev": "Mulai ulang mode DEV disimulasikan.",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "削除済み",
|
||||
"update.updating.purging": "削除中...",
|
||||
"update.updating.subtitle": "選択したスキルを更新中...",
|
||||
"update.missingRepos.title": "{count} 件の tracked リポジトリがディスク上に見つかりません",
|
||||
"update.missingRepos.description": "これらの tracked リポジトリはメタデータに宣言されていますが、clone ディレクトリが存在しません。Rehydrate でソースから再度 clone します。",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} 件の tracked リポジトリを rehydrate しました",
|
||||
"update.missingRepos.rehydratePartial": "{count} 件のリポジトリの rehydrate に失敗しました",
|
||||
"updateDialog.copyCommand": "コマンドをコピー",
|
||||
"updateDialog.newVersion": "新しいバージョンが利用可能です",
|
||||
"updateDialog.restartDev": "DEV モードの再起動をシミュレートしました。",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "제거됨",
|
||||
"update.updating.purging": "제거 중...",
|
||||
"update.updating.subtitle": "선택한 skills 업데이트 중...",
|
||||
"update.missingRepos.title": "{count}개의 tracked 저장소가 디스크에 없습니다",
|
||||
"update.missingRepos.description": "이 tracked 저장소들은 메타데이터에 선언되어 있지만 clone 디렉터리가 없습니다. Rehydrate하면 소스에서 다시 clone합니다.",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "{count}개의 tracked 저장소를 rehydrate했습니다",
|
||||
"update.missingRepos.rehydratePartial": "{count}개의 저장소 rehydrate에 실패했습니다",
|
||||
"updateDialog.copyCommand": "명령 복사",
|
||||
"updateDialog.newVersion": "새 버전 사용 가능",
|
||||
"updateDialog.restartDev": "DEV 모드 재시작을 시뮬레이션했습니다.",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "Limpo",
|
||||
"update.updating.purging": "Limpando...",
|
||||
"update.updating.subtitle": "Atualizando skills selecionadas...",
|
||||
"update.missingRepos.title": "{count} repositório(s) rastreado(s) ausente(s) no disco",
|
||||
"update.missingRepos.description": "Esses repositórios rastreados estão declarados nos metadados, mas seus diretórios de clonagem estão ausentes. Reidrate para cloná-los novamente a partir das origens.",
|
||||
"update.missingRepos.rehydrate": "Reidratar",
|
||||
"update.missingRepos.rehydrateSuccess": "{count} repositório(s) rastreado(s) reidratado(s)",
|
||||
"update.missingRepos.rehydratePartial": "Falha ao reidratar {count} repositório(s)",
|
||||
"updateDialog.copyCommand": "Copiar comando",
|
||||
"updateDialog.newVersion": "Nova versão disponível",
|
||||
"updateDialog.restartDev": "Reinicialização em modo DEV simulada.",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "已清除",
|
||||
"update.updating.purging": "清除中...",
|
||||
"update.updating.subtitle": "正在更新所选 skill...",
|
||||
"update.missingRepos.title": "{count} 个 tracked repo 在磁盘上缺失",
|
||||
"update.missingRepos.description": "这些 tracked 仓库已在 metadata 中声明,但 clone 目录不存在。Rehydrate 会从来源重新 clone。",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "已 rehydrate {count} 个 tracked repo",
|
||||
"update.missingRepos.rehydratePartial": "{count} 个 repo rehydrate 失败",
|
||||
"updateDialog.copyCommand": "复制命令",
|
||||
"updateDialog.newVersion": "有新版本可用",
|
||||
"updateDialog.restartDev": "已模拟 DEV 模式重启。",
|
||||
|
||||
@@ -1296,6 +1296,11 @@
|
||||
"update.updating.purged": "已清除",
|
||||
"update.updating.purging": "清除中…",
|
||||
"update.updating.subtitle": "更新已選取的 skills 中…",
|
||||
"update.missingRepos.title": "{count} 個 tracked repo 在磁碟上遺失",
|
||||
"update.missingRepos.description": "這些 tracked 儲存庫已在 metadata 中宣告,但 clone 目錄不存在。Rehydrate 會從來源重新 clone。",
|
||||
"update.missingRepos.rehydrate": "Rehydrate",
|
||||
"update.missingRepos.rehydrateSuccess": "已 rehydrate {count} 個 tracked repo",
|
||||
"update.missingRepos.rehydratePartial": "{count} 個 repo rehydrate 失敗",
|
||||
"updateDialog.copyCommand": "複製指令",
|
||||
"updateDialog.newVersion": "有新版本可用",
|
||||
"updateDialog.restartDev": "已模擬 DEV 模式重新啟動。",
|
||||
|
||||
@@ -34,6 +34,7 @@ export const queryKeys = {
|
||||
|
||||
config: ['config'] as const,
|
||||
check: ['check'] as const,
|
||||
missingTrackedRepos: ['missing-tracked-repos'] as const,
|
||||
syncMatrix: (target?: string) => ['sync-matrix', target ?? '__all'] as const,
|
||||
|
||||
templates: ['templates'] as const,
|
||||
@@ -60,6 +61,7 @@ export const staleTimes = {
|
||||
audit: 5 * 60 * 1000, // 5min — full audit scan, expensive
|
||||
auditSkill: 5 * 60 * 1000, // 5min — per-skill audit, rarely changes
|
||||
check: 60 * 1000, // 1min
|
||||
missingTrackedRepos: 60 * 1000, // 1min
|
||||
syncMatrix: 30 * 1000, // 30s — changes after filter edits
|
||||
extras: 30 * 1000, // 30s — fast-changing like diff
|
||||
doctor: 60 * 1000, // 1min — health checks
|
||||
|
||||
@@ -22,6 +22,8 @@ vi.mock('../api/client', async (importOriginal) => {
|
||||
listSkills: vi.fn(),
|
||||
checkStream: vi.fn(),
|
||||
updateAllStream: vi.fn(),
|
||||
missingTrackedRepos: vi.fn(),
|
||||
rehydrateTrackedRepos: vi.fn(),
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -46,6 +48,7 @@ describe('UpdatePage', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
localStorage.clear();
|
||||
vi.mocked(api.missingTrackedRepos).mockResolvedValue({ repos: [] });
|
||||
});
|
||||
|
||||
const nestedSkill = {
|
||||
@@ -189,4 +192,25 @@ describe('UpdatePage', () => {
|
||||
expect(within(row as HTMLElement).getByText('Up to date')).toBeInTheDocument();
|
||||
expect(within(row as HTMLElement).queryByText('Unchecked')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('warns about missing tracked repos and rehydrates on click (issue #212)', async () => {
|
||||
vi.mocked(api.listSkills).mockResolvedValue({ resources: [nestedSkill] });
|
||||
vi.mocked(api.missingTrackedRepos).mockResolvedValue({
|
||||
repos: [{ name: '_team-skills', source: 'https://github.com/example/team-skills', branch: 'main' }],
|
||||
});
|
||||
vi.mocked(api.rehydrateTrackedRepos).mockResolvedValue({
|
||||
results: [{ name: '_team-skills', action: 'rehydrated' }],
|
||||
});
|
||||
|
||||
const user = userEvent.setup();
|
||||
renderUpdatePage();
|
||||
|
||||
// Banner lists the missing repo.
|
||||
expect(await screen.findByText('_team-skills')).toBeInTheDocument();
|
||||
|
||||
const rehydrateBtn = screen.getByRole('button', { name: /rehydrate/i });
|
||||
await user.click(rehydrateBtn);
|
||||
|
||||
await waitFor(() => expect(api.rehydrateTrackedRepos).toHaveBeenCalled());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
ArrowUpCircle, RefreshCw, Search, Check, Zap, Trash2,
|
||||
Circle, CheckCircle, XCircle, MinusCircle, ShieldAlert, Loader2,
|
||||
LayoutGrid, Users, Globe, Puzzle, Bot,
|
||||
LayoutGrid, Users, Globe, Puzzle, Bot, AlertTriangle, DownloadCloud,
|
||||
} from 'lucide-react';
|
||||
import { Virtuoso } from 'react-virtuoso';
|
||||
import Card from '../components/Card';
|
||||
@@ -97,6 +97,15 @@ export default function UpdatePage() {
|
||||
queryFn: () => api.listSkills(),
|
||||
staleTime: staleTimes.skills,
|
||||
});
|
||||
|
||||
// Tracked repos declared in metadata but missing on disk (issue #212)
|
||||
const { data: missingReposData } = useQuery({
|
||||
queryKey: queryKeys.missingTrackedRepos,
|
||||
queryFn: () => api.missingTrackedRepos(),
|
||||
staleTime: staleTimes.missingTrackedRepos,
|
||||
});
|
||||
const missingTrackedRepos = missingReposData?.repos ?? [];
|
||||
const [rehydrating, setRehydrating] = useState(false);
|
||||
const allSkills = skillsData?.resources ?? [];
|
||||
|
||||
// Tab state (skills vs agents)
|
||||
@@ -525,6 +534,25 @@ export default function UpdatePage() {
|
||||
itemRefs.current = {};
|
||||
}, []);
|
||||
|
||||
const handleRehydrate = useCallback(async () => {
|
||||
setRehydrating(true);
|
||||
try {
|
||||
const { results } = await api.rehydrateTrackedRepos();
|
||||
const failed = results.filter((r) => r.action !== 'rehydrated');
|
||||
if (failed.length > 0) {
|
||||
toast(t('update.missingRepos.rehydratePartial', { count: failed.length }), 'error');
|
||||
} else {
|
||||
toast(t('update.missingRepos.rehydrateSuccess', { count: results.length }), 'success');
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.missingTrackedRepos });
|
||||
invalidateSkillData();
|
||||
} catch (err) {
|
||||
toast((err as Error).message, 'error');
|
||||
} finally {
|
||||
setRehydrating(false);
|
||||
}
|
||||
}, [t, toast, queryClient, invalidateSkillData]);
|
||||
|
||||
/* ── Derived counts ──────────────────────────────── */
|
||||
|
||||
const { successCount, skippedCount, blockedCount, errorCount, completedCount } = useMemo(() => {
|
||||
@@ -621,13 +649,43 @@ export default function UpdatePage() {
|
||||
}
|
||||
/>
|
||||
|
||||
{allUpdatableItems.length === 0 ? (
|
||||
{missingTrackedRepos.length > 0 && (
|
||||
<div
|
||||
className="flex items-start gap-2 p-3 bg-warning/10 text-sm"
|
||||
style={{ borderRadius: radius.md }}
|
||||
>
|
||||
<AlertTriangle size={16} className="text-warning shrink-0 mt-0.5" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="font-medium text-pencil">
|
||||
{t('update.missingRepos.title', { count: missingTrackedRepos.length })}
|
||||
</p>
|
||||
<p className="text-pencil-light mt-0.5">{t('update.missingRepos.description')}</p>
|
||||
<ul className="mt-2 space-y-1">
|
||||
{missingTrackedRepos.map((repo) => (
|
||||
<li key={repo.name} className="flex items-center gap-2 min-w-0">
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-warning shrink-0" />
|
||||
<span className="font-mono text-pencil shrink-0">{repo.name}</span>
|
||||
{repo.source && (
|
||||
<span className="text-pencil-light truncate text-xs">{repo.source}</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
<Button variant="primary" size="sm" onClick={handleRehydrate} loading={rehydrating}>
|
||||
<DownloadCloud size={16} />
|
||||
{t('update.missingRepos.rehydrate')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{allUpdatableItems.length === 0 && missingTrackedRepos.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={Check}
|
||||
title={t('update.empty.title')}
|
||||
description={t('update.empty.description')}
|
||||
/>
|
||||
) : (
|
||||
) : allUpdatableItems.length === 0 ? null : (
|
||||
<>
|
||||
{/* Resource type tabs (Skills / Agents) */}
|
||||
<nav
|
||||
|
||||
Reference in New Issue
Block a user