mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Agent discovery was treating non-agent files (CLAUDE.md, AGENTS.md, etc.) as agent resources when they appeared in tracked repos. Two fixes: - Expand ConventionalExcludes with 7 well-known convention filenames (CLAUDE.md, AGENTS.md, GEMINI.md, COPILOT.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SUPPORT.md) - For tracked repos with an agents/ subdirectory, only discover files inside agents/ — skip repo root files and other subdirs (docs/, etc.) Also includes UI polish: - Display flat names (__ separator) as path separators in toasts/labels - Consolidate batch install errors into single toast - Show .agentignore state in sync diff/preview responses - Track badge + friendly repo name in resource list/folder tree
70 lines
2.8 KiB
Go
70 lines
2.8 KiB
Go
package resource
|
|
|
|
// ResourceKind encapsulates per-kind behavior for skills and agents.
|
|
// Each kind defines how resources are discovered, named, linked, and validated.
|
|
type ResourceKind interface {
|
|
// Kind returns the resource kind identifier ("skill" or "agent").
|
|
Kind() string
|
|
|
|
// Discover scans sourceDir and returns all resources found.
|
|
Discover(sourceDir string) ([]DiscoveredResource, error)
|
|
|
|
// ResolveName extracts the canonical name from a resource at the given path.
|
|
// For skills: reads SKILL.md frontmatter name field.
|
|
// For agents: uses filename, with optional frontmatter name override.
|
|
ResolveName(path string) string
|
|
|
|
// FlatName computes the flattened name used in target directories.
|
|
// For skills: path/to/skill → path__to__skill (nested separator).
|
|
// For agents: dir/file.md → file.md (directory prefix stripped).
|
|
FlatName(relPath string) string
|
|
|
|
// CreateLink creates a symlink from dst pointing to src.
|
|
// For skills: directory symlink. For agents: file symlink.
|
|
// Both use os.Symlink; the distinction is semantic (unit shape).
|
|
CreateLink(src, dst string) error
|
|
|
|
// SupportsAudit reports whether this kind supports security audit scanning.
|
|
SupportsAudit() bool
|
|
|
|
// SupportsTrack reports whether this kind supports tracked repo updates.
|
|
SupportsTrack() bool
|
|
|
|
// SupportsCollect reports whether this kind supports collecting from targets.
|
|
SupportsCollect() bool
|
|
}
|
|
|
|
// DiscoveredResource represents a resource found during source directory scan.
|
|
// Used for both skills and agents.
|
|
type DiscoveredResource struct {
|
|
Name string // Canonical name (from frontmatter or filename)
|
|
Kind string // "skill" or "agent"
|
|
RelPath string // Relative path from source root
|
|
AbsPath string // Full absolute path
|
|
IsNested bool // Whether this resource is inside a subdirectory
|
|
FlatName string // Flattened name for target directories
|
|
IsInRepo bool // Whether this resource is inside a tracked repo
|
|
RepoRelPath string // Relative path of the tracked repo root (when IsInRepo)
|
|
Disabled bool // Whether this resource is ignored by ignore file
|
|
SourcePath string // Full path preserving caller's logical path (may differ from AbsPath if symlinked)
|
|
Targets []string // Per-resource target restrictions from frontmatter (nil = all targets)
|
|
}
|
|
|
|
// ConventionalExcludes are filenames excluded from agent discovery.
|
|
// These are well-known convention files that appear in repos but are not agents.
|
|
var ConventionalExcludes = map[string]bool{
|
|
"README.md": true,
|
|
"CHANGELOG.md": true,
|
|
"LICENSE.md": true,
|
|
"HISTORY.md": true,
|
|
"SECURITY.md": true,
|
|
"SKILL.md": true,
|
|
"CLAUDE.md": true,
|
|
"AGENTS.md": true,
|
|
"GEMINI.md": true,
|
|
"COPILOT.md": true,
|
|
"CONTRIBUTING.md": true,
|
|
"CODE_OF_CONDUCT.md": true,
|
|
"SUPPORT.md": true,
|
|
}
|