Files
skillshare/internal/sync/ignore_report.go
T
Rusty Shackleford 5729eee088 feat(project): manage global registrations from the CLI (#603)
Add global project list, show, add, edit, sync and remove so setup scripts
can register repositories without editing YAML or opening the dashboard.
Keep dry runs read-only and report completed work when a target fails.

Reuse the shared project service and sync runners. Include command docs,
translations, completions and regression coverage. Quote overlap hints for
their shell and log partial project syncs consistently with ordinary sync.
2026-10-26 01:38:04 +08:00

56 lines
1.8 KiB
Go

package sync
import (
"os"
"path/filepath"
"skillshare/internal/resource"
"skillshare/internal/skillignore"
"skillshare/internal/utils"
)
// IgnoreReport is the .skillignore/.agentignore envelope that the dashboard
// and CLI sync responses share. Lists are never nil so JSON emits [].
type IgnoreReport struct {
IgnoredCount int `json:"ignored_count"`
IgnoredSkills []string `json:"ignored_skills"`
IgnoreRoot string `json:"ignore_root"`
IgnoreRepos []string `json:"ignore_repos"`
AgentIgnoreRoot string `json:"agent_ignore_root"`
AgentIgnoredCount int `json:"agent_ignored_count"`
AgentIgnoredSkills []string `json:"agent_ignored_skills"`
}
// NewIgnoreReport summarizes skill ignore stats and the agent source's
// .agentignore state. Pass pre-discovered agents (including disabled ones) to
// avoid a second traversal; nil triggers discovery.
func NewIgnoreReport(stats *skillignore.IgnoreStats, agentsSource string, agents []resource.DiscoveredResource) IgnoreReport {
r := IgnoreReport{IgnoredSkills: []string{}, IgnoreRepos: []string{}, AgentIgnoredSkills: []string{}}
if stats != nil {
if len(stats.IgnoredSkills) > 0 {
r.IgnoredSkills = stats.IgnoredSkills
}
r.IgnoreRoot = stats.RootFile
if stats.RepoFiles != nil {
r.IgnoreRepos = stats.RepoFiles
}
}
r.IgnoredCount = len(r.IgnoredSkills)
if agentsSource != "" {
ignoreFile := filepath.Join(utils.ResolveSymlink(agentsSource), ".agentignore")
if _, err := os.Stat(ignoreFile); err == nil {
r.AgentIgnoreRoot = ignoreFile
}
if agents == nil {
agents, _ = resource.AgentKind{}.Discover(agentsSource)
}
for _, a := range agents {
if a.Disabled {
r.AgentIgnoredSkills = append(r.AgentIgnoredSkills, a.RelPath)
}
}
}
r.AgentIgnoredCount = len(r.AgentIgnoredSkills)
return r
}