mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Backend: - PATCH /api/targets/:name accepts agent_include/agent_exclude fields - POST /api/sync-matrix/preview returns agent entries with kind=agent - GET /api/overview returns agentsSource and extrasSource paths - Fix ResolveProjectTargets to resolve Agents sub-key (path + filters) - Add agent filter CLI flags: --add-agent-include, --add-agent-exclude, --remove-agent-include, --remove-agent-exclude, --agent-mode - Unify target list JSON/TUI to show agent info and filters Frontend: - FilterStudioPage: kind-driven single-context view (?kind=skill|agent) - KindBadge: use design system tokens (ss-badge + wobble in playful) - TargetsPage: link to Filter Studio with ?kind= param - ResourceDetailPage: capitalize type labels (Local, GitHub) - ResourcesPage: sync activeTab from URL searchParams on navigation - DashboardPage: show agents/extras source dirs, link skills card with ?tab=skills for reliable tab switching - API client: extend updateTarget and previewSyncMatrix for agent filters Tests: - Agent include/exclude round-trip persistence - Invalid agent pattern returns 400 - Preview with agent entries and kind field - No agent entries for targets without agent path - CLI target agent filter integration tests
124 lines
2.8 KiB
Go
124 lines
2.8 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"skillshare/internal/git"
|
|
"skillshare/internal/install"
|
|
"skillshare/internal/resource"
|
|
"skillshare/internal/sync"
|
|
"skillshare/internal/utils"
|
|
versioncheck "skillshare/internal/version"
|
|
)
|
|
|
|
type trackedRepoItem struct {
|
|
Name string `json:"name"`
|
|
SkillCount int `json:"skillCount"`
|
|
Dirty bool `json:"dirty"`
|
|
}
|
|
|
|
func (s *Server) handleOverview(w http.ResponseWriter, r *http.Request) {
|
|
// Snapshot config under RLock, then release before I/O.
|
|
s.mu.RLock()
|
|
source := s.cfg.Source
|
|
agentsSource := s.agentsSource()
|
|
extrasSource := s.cfg.ExtrasSource
|
|
if s.IsProjectMode() {
|
|
extrasSource = filepath.Join(s.projectRoot, ".skillshare", "extras")
|
|
}
|
|
cfgMode := s.cfg.Mode
|
|
targetCount := len(s.cfg.Targets)
|
|
projectRoot := s.projectRoot
|
|
s.mu.RUnlock()
|
|
|
|
isProjectMode := projectRoot != ""
|
|
|
|
// Count skills
|
|
skills, err := sync.DiscoverSourceSkills(source)
|
|
if err != nil {
|
|
writeError(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
|
|
// Count top-level source entries (for display)
|
|
topLevelCount := 0
|
|
entries, _ := os.ReadDir(source)
|
|
for _, e := range entries {
|
|
if e.IsDir() && !utils.IsHidden(e.Name()) {
|
|
topLevelCount++
|
|
}
|
|
}
|
|
|
|
mode := cfgMode
|
|
if mode == "" {
|
|
mode = "merge"
|
|
}
|
|
|
|
// Tracked repos
|
|
trackedRepos := buildTrackedRepos(source, skills)
|
|
|
|
// Count agents
|
|
agentCount := 0
|
|
if agentsSource != "" {
|
|
if agents, discoverErr := (resource.AgentKind{}).Discover(agentsSource); discoverErr == nil {
|
|
agentCount = len(agents)
|
|
}
|
|
}
|
|
|
|
resp := map[string]any{
|
|
"source": source,
|
|
"skillCount": len(skills),
|
|
"agentCount": agentCount,
|
|
"topLevelCount": topLevelCount,
|
|
"targetCount": targetCount,
|
|
"mode": mode,
|
|
"version": versioncheck.Version,
|
|
"trackedRepos": trackedRepos,
|
|
"isProjectMode": isProjectMode,
|
|
}
|
|
if agentsSource != "" {
|
|
resp["agentsSource"] = agentsSource
|
|
}
|
|
if extrasSource != "" {
|
|
resp["extrasSource"] = extrasSource
|
|
}
|
|
if isProjectMode {
|
|
resp["projectRoot"] = projectRoot
|
|
}
|
|
|
|
writeJSON(w, resp)
|
|
}
|
|
|
|
func buildTrackedRepos(sourceDir string, skills []sync.DiscoveredSkill) []trackedRepoItem {
|
|
repoNames, err := install.GetTrackedRepos(sourceDir)
|
|
if err != nil || len(repoNames) == 0 {
|
|
return []trackedRepoItem{}
|
|
}
|
|
|
|
items := make([]trackedRepoItem, 0, len(repoNames))
|
|
for _, repoName := range repoNames {
|
|
repoPath := filepath.Join(sourceDir, repoName)
|
|
|
|
// Count skills belonging to this repo
|
|
skillCount := 0
|
|
for _, sk := range skills {
|
|
if sk.IsInRepo && strings.HasPrefix(sk.RelPath, repoName+"/") {
|
|
skillCount++
|
|
}
|
|
}
|
|
|
|
// Check git dirty status
|
|
dirty, _ := git.IsDirty(repoPath)
|
|
|
|
items = append(items, trackedRepoItem{
|
|
Name: repoName,
|
|
SkillCount: skillCount,
|
|
Dirty: dirty,
|
|
})
|
|
}
|
|
return items
|
|
}
|