Documentation
¶
Overview ¶
Package fetch 提供从远程源发现和下载 Skill 的能力。
Index ¶
- Variables
- func TrustLevelForRepo(owner, repo string) string
- type BuiltinSource
- func (s *BuiltinSource) CanHandle(identifier string) bool
- func (s *BuiltinSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
- func (s *BuiltinSource) Inspect(ctx context.Context, identifier string) (*SkillMeta, error)
- func (s *BuiltinSource) Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
- func (s *BuiltinSource) SourceID() 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 BuiltinSource ¶ added in v0.1.1
type BuiltinSource struct {
// contains filtered or unexported fields
}
BuiltinSource 通过 HTTP API 从 Leros 服务端获取内置 Skill。
func NewBuiltinSource ¶ added in v0.1.1
func NewBuiltinSource(serverAddr string) *BuiltinSource
NewBuiltinSource 创建 BuiltinSource。
func (*BuiltinSource) CanHandle ¶ added in v0.1.1
func (s *BuiltinSource) CanHandle(identifier string) bool
CanHandle 处理不含 "/" 和 "://" 的短名称/skill_id。
func (*BuiltinSource) Fetch ¶ added in v0.1.1
func (s *BuiltinSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Fetch 调用服务端下载接口获取完整 Skill 包。
func (*BuiltinSource) SourceID ¶ added in v0.1.1
func (s *BuiltinSource) SourceID() string
SourceID 返回源标识。
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 {
SkillID string `json:"skill_id"`
Name string `json:"name,omitempty"`
Identifier string `json:"identifier"`
Source string `json:"source"`
TrustLevel string `json:"trust_level"`
Description string `json:"description"`
Version string `json:"version,omitempty"`
Author string `json:"author,omitempty"`
Category string `json:"category,omitempty"`
Tags []string `json:"tags,omitempty"`
Icon string `json:"icon,omitempty"`
Installs int64 `json:"installs,omitempty"`
}
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 NewSourceRouterWithSources ¶ added in v0.1.1
func NewSourceRouterWithSources(sources ...SkillSource) *SourceRouter
NewSourceRouterWithSources 使用指定源列表创建 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 对不含 "/" 的短名称,按 source 优先级依次搜索精确匹配后安装。
type UrlSource ¶
type UrlSource struct {
// contains filtered or unexported fields
}
UrlSource 通过 HTTP 直链下载 SKILL.md。