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) FetchVersion(ctx context.Context, identifier, version 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 ClawHubSource
- func (c *ClawHubSource) CanHandle(identifier string) bool
- func (c *ClawHubSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
- func (c *ClawHubSource) FetchVersion(ctx context.Context, slug, version string) (*SkillBundle, error)
- func (c *ClawHubSource) GetDetail(ctx context.Context, slug, version string) (*SkillDetail, *SkillBundle, error)
- func (c *ClawHubSource) Inspect(ctx context.Context, identifier string) (*SkillMeta, error)
- func (c *ClawHubSource) Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
- func (c *ClawHubSource) 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) FetchVersion(ctx context.Context, identifier, version 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 SkillDetail
- 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
- func (r *SourceRouter) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
- func (r *SourceRouter) FetchFromSource(ctx context.Context, identifier, sourceID, version string) (*SkillBundle, error)
- func (r *SourceRouter) FetchVersion(ctx context.Context, identifier, version string) (*SkillBundle, error)
- func (r *SourceRouter) ResolveShortName(ctx context.Context, name string) (*SkillBundle, error)
- func (r *SourceRouter) Search(ctx context.Context, query string, limit int) ([]SkillMeta, error)
- func (r *SourceRouter) SearchWithFilter(ctx context.Context, query string, limit int, filterSources []string) ([]SkillMeta, error)
- 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
- type VersionedSource
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。 ":" 用于标识外部源(如 clawhub:<slug>@<version>)。
func (*BuiltinSource) Fetch ¶ added in v0.1.1
func (s *BuiltinSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Fetch 调用服务端下载接口获取完整 Skill 包。
func (*BuiltinSource) FetchVersion ¶ added in v0.1.13
func (s *BuiltinSource) FetchVersion(ctx context.Context, identifier, version string) (*SkillBundle, error)
FetchVersion 实现 fetch.VersionedSource。 下载内置 Skill 的指定版本(通过查询参数传递),服务端目前可能忽略版本参数。
func (*BuiltinSource) SourceID ¶ added in v0.1.1
func (s *BuiltinSource) SourceID() string
SourceID 返回源标识。
type ClawHubSource ¶ added in v0.1.13
type ClawHubSource struct {
// contains filtered or unexported fields
}
ClawHubSource 通过 ClawHub API 发现和下载 Skill。
func NewClawHubSource ¶ added in v0.1.13
func NewClawHubSource() *ClawHubSource
NewClawHubSource 创建 ClawHubSource。
func (*ClawHubSource) CanHandle ¶ added in v0.1.13
func (c *ClawHubSource) CanHandle(identifier string) bool
CanHandle 处理纯 skill 名称(不含 / 和 https:// 前缀的标识符)。
func (*ClawHubSource) Fetch ¶ added in v0.1.13
func (c *ClawHubSource) Fetch(ctx context.Context, identifier string) (*SkillBundle, error)
Fetch 下载 ClawHub skill zip 包并提取内容。 identifier 为纯 skill 名称(不含 clawhub: 前缀)。
func (*ClawHubSource) FetchVersion ¶ added in v0.1.13
func (c *ClawHubSource) FetchVersion(ctx context.Context, slug, version string) (*SkillBundle, error)
FetchVersion 下载指定版本的 ClawHub skill zip 包并提取内容。 slug 为纯 skill 名称(不含 clawhub: 前缀)。 version 为空或 "latest" 时,download URL 不带 version 参数。
func (*ClawHubSource) GetDetail ¶ added in v0.1.13
func (c *ClawHubSource) GetDetail(ctx context.Context, slug, version string) (*SkillDetail, *SkillBundle, error)
GetDetail 通过 ClawHub API 获取 skill 元数据,并下载 zip 返回完整详情及 bundle。 从 /api/v1/skills/{slug} 获取 Author、Installs、Version、Tags、Icon 等字段, 再下载 zip 解析 SKILL.md 和文件列表。
func (*ClawHubSource) Search ¶ added in v0.1.13
Search 调用 ClawHub search 或 list API。 有关键词时使用 /api/v1/search?q=;无关键词时使用 /api/v1/skills?limit=。
func (*ClawHubSource) SourceID ¶ added in v0.1.13
func (c *ClawHubSource) 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。
func (*GitHubSource) FetchVersion ¶ added in v0.1.13
func (g *GitHubSource) FetchVersion(ctx context.Context, identifier, version string) (*SkillBundle, error)
FetchVersion 实现 fetch.VersionedSource。 使用 version 作为分支/tag 名下载 GitHub 仓库(如 v1.2.3 或 main)。
type SkillBundle ¶
type SkillBundle struct {
Meta SkillMeta
Content []byte // SKILL.md 原始内容
Files map[string][]byte // 附属文件(相对路径 → 内容)
TempDir string // 临时解压目录(调用方负责清理)
}
SkillBundle Fetch 返回的完整 Skill 内容。
type SkillDetail ¶ added in v0.1.13
type SkillDetail struct {
SkillID string `json:"skill_id"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Author string `json:"author"`
Category string `json:"category"`
Tags []string `json:"tags"`
Icon string `json:"icon,omitempty"`
SkillMD string `json:"skill_md"` // SKILL.md body(不含 frontmatter)
Files []string `json:"files"`
}
SkillDetail 表示从 ClawHub zip 中解析出的 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) FetchFromSource ¶ added in v0.1.13
func (r *SourceRouter) FetchFromSource(ctx context.Context, identifier, sourceID, version string) (*SkillBundle, error)
FetchFromSource 从指定 sourceID 的源中获取 Skill。 如果 identifier 能被该源直接处理,则直接获取;否则按名称搜索后再获取。 当源实现了 VersionedSource 且 version 非空时,会传入版本参数。
func (*SourceRouter) FetchVersion ¶ added in v0.1.13
func (r *SourceRouter) FetchVersion(ctx context.Context, identifier, version string) (*SkillBundle, error)
FetchVersion 按优先级遍历源,返回第一个成功获取的指定版本 SkillBundle。 对于实现了 VersionedSource 的源,会传入 version;否则退化为不带版本的 Fetch。
func (*SourceRouter) ResolveShortName ¶
func (r *SourceRouter) ResolveShortName(ctx context.Context, name string) (*SkillBundle, error)
ResolveShortName 对不含 "/" 的短名称,按 source 优先级依次搜索精确匹配后安装。
func (*SourceRouter) SearchWithFilter ¶ added in v0.1.13
func (r *SourceRouter) SearchWithFilter(ctx context.Context, query string, limit int, filterSources []string) ([]SkillMeta, error)
SearchWithFilter 并发向指定源列表发起搜索;filterSources 为空时搜索全部源。
type UrlSource ¶
type UrlSource struct {
// contains filtered or unexported fields
}
UrlSource 通过 HTTP 直链下载 SKILL.md。
type VersionedSource ¶ added in v0.1.13
type VersionedSource interface {
SkillSource
FetchVersion(ctx context.Context, identifier string, version string) (*SkillBundle, error)
}
VersionedSource 支持版本化获取的 Skill 源接口。 实现此接口的源可处理指定版本的安装请求。