Documentation
¶
Overview ¶
Package fetch 提供从远程源发现和下载 Skill 的能力。
Index ¶
- Variables
- func TrustLevelForRepo(owner, repo string) string
- type GitHubSource
- func (g *GitHubSource) CanHandle(identifier string) bool
- func (g *GitHubSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
- func (g *GitHubSource) Inspect(ctx context.Context, identifier string) (*SkillMeta, error)
- func (g *GitHubSource) Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
- func (g *GitHubSource) SourceID() string
- type SkillBundle
- type SkillMeta
- type SkillSource
- type SkillsShSource
- func (s *SkillsShSource) CanHandle(identifier string) bool
- func (s *SkillsShSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
- func (s *SkillsShSource) Inspect(ctx context.Context, identifier string) (*SkillMeta, error)
- func (s *SkillsShSource) Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
- func (s *SkillsShSource) SourceID() string
- type SourceRouter
- type UrlSource
- func (u *UrlSource) CanHandle(identifier string) bool
- func (u *UrlSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
- func (u *UrlSource) Inspect(ctx context.Context, identifier string) (*SkillMeta, error)
- func (u *UrlSource) Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
- func (u *UrlSource) SourceID() string
Constants ¶
This section is empty.
Variables ¶
var TrustedRepos = map[string]bool{ "openai/skills": true, "anthropics/skills": true, "huggingface/skills": true, "NVIDIA/skills": true, }
TrustedRepos 受信任的 GitHub 仓库列表。
Functions ¶
func TrustLevelForRepo ¶
TrustLevelForRepo 根据仓库判断信任级别。
Types ¶
type GitHubSource ¶
type GitHubSource struct {
// contains filtered or unexported fields
}
GitHubSource 通过下载 GitHub 仓库 ZIP 获取 Skill。
func (*GitHubSource) CanHandle ¶
func (g *GitHubSource) CanHandle(identifier string) bool
CanHandle 含 "/" 的非 URL 标识符可由 GitHubSource 处理。
func (*GitHubSource) Fetch ¶
func (g *GitHubSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Fetch 下载 GitHub 仓库 ZIP 并提取 Skill。
type SkillBundle ¶
type SkillBundle struct {
Meta SkillMeta
Content []byte // SKILL.md 原始内容
Files map[string][]byte // 附属文件(相对路径 → 内容)
TempDir string // 临时解压目录(调用方负责清理)
}
SkillBundle Fetch 返回的完整 Skill 内容。
type SkillMeta ¶
type SkillMeta struct {
Name string `json:"name"`
Identifier string `json:"identifier"`
Source string `json:"source"`
TrustLevel string `json:"trust_level"`
Description string `json:"description"`
}
SkillMeta 搜索或检查返回的轻量 Skill 信息。
type SkillSource ¶
type SkillSource interface {
Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Inspect(ctx context.Context, identifier string) (*SkillMeta, error)
SourceID() string
CanHandle(identifier string) bool
}
SkillSource 远程 Skill 源接口。
type SkillsShSource ¶
type SkillsShSource struct {
// contains filtered or unexported fields
}
SkillsShSource 通过 skills.sh API 搜索 Skill。
func NewSkillsShSource ¶
func NewSkillsShSource() *SkillsShSource
NewSkillsShSource 创建 SkillsShSource。
func (*SkillsShSource) CanHandle ¶
func (s *SkillsShSource) CanHandle(identifier string) bool
CanHandle 含 "/" 的非 URL 标识符可由 SkillsShSource 处理。
func (*SkillsShSource) Fetch ¶
func (s *SkillsShSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Fetch 通过 skills.sh 搜索后委托 GitHubSource 下载。
type SourceRouter ¶
type SourceRouter struct {
// contains filtered or unexported fields
}
SourceRouter 管理一组远程 Skill 源,按优先级路由请求。
func NewSourceRouter ¶
func NewSourceRouter() *SourceRouter
NewSourceRouter 创建包含所有内置源的 SourceRouter。
func (*SourceRouter) Fetch ¶
func (r *SourceRouter) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Fetch 按优先级遍历源,返回第一个成功获取的 SkillBundle。
func (*SourceRouter) ResolveShortName ¶
func (r *SourceRouter) ResolveShortName(ctx context.Context, name string) (*SkillBundle, error)
ResolveShortName 对不含 "/" 的短名称,通过 skills.sh 搜索精确匹配后安装。
type UrlSource ¶
type UrlSource struct {
// contains filtered or unexported fields
}
UrlSource 通过 HTTP 直链下载 SKILL.md。