Documentation
¶
Overview ¶
Package skill provides SDK-free skill manifests, loading, registry, and activation helpers.
Index ¶
- Constants
- Variables
- func EffectiveSafety(m Manifest, lookup func(toolName string) tool.Safety) tool.Safety
- func Validate(m *Manifest) error
- type ActivationDecision
- type Asset
- type Budgets
- type DenyVerifier
- type EffectiveTool
- type HumanApproval
- type Limits
- type Loader
- type LoaderOption
- type Manifest
- type MaxCost
- type MemoryRegistry
- type ModelHints
- type Pack
- type ProgressiveDisclosure
- type PromptReference
- type PromptTemplate
- type Provider
- type References
- type Registry
- type Requires
- type Safety
- type Script
- type Signature
- type VerificationOutcome
- type VerificationStatus
- type Verifier
- type WarnOnlyVerifier
Constants ¶
const ( // MaxBodyBytes bounds the SKILL.md body size. MaxBodyBytes = 4 << 20 // 4 MiB // MaxAssetBytes bounds a single inert asset size. MaxAssetBytes = 16 << 20 // 16 MiB // MaxAssetTotalBytes bounds the aggregate size of all inert assets. MaxAssetTotalBytes = 64 << 20 // 64 MiB )
Size limits for untrusted skill-pack files. Reads fail closed once exceeded.
const ManifestFileName = "kit.skill.yaml"
const MaxManifestBytes = 1 << 20 // 1 MiB
MaxManifestBytes bounds the manifest file size accepted at load time.
const SkillMarkdownFileName = "SKILL.md"
Variables ¶
var ( // ErrManifestInvalid marks a manifest that failed schema validation. ErrManifestInvalid = errors.New("skill: invalid manifest") // ErrParseManifest marks a manifest that could not be decoded. ErrParseManifest = errors.New("skill: manifest parse failed") // ErrFileTooLarge marks a pack file that exceeds its size limit. ErrFileTooLarge = errors.New("skill: file exceeds size limit") // ErrAssetsTooLarge marks a pack whose aggregate assets exceed the limit. ErrAssetsTooLarge = errors.New("skill: assets exceed total size limit") // ErrInvalidUTF8 marks a text pack file that is not valid UTF-8. ErrInvalidUTF8 = errors.New("skill: file is not valid UTF-8") // ErrInvalidPackFile marks a pack path that is not an accepted regular file // or directory (symlink, escaping path, wrong type). ErrInvalidPackFile = errors.New("skill: invalid pack file") // ErrVerificationDenied marks a manifest rejected by the verifier. ErrVerificationDenied = errors.New("skill: verification denied") // ErrAlreadyRegistered marks a duplicate registration. ErrAlreadyRegistered = errors.New("skill: already registered") )
Sentinel errors for classifiable skill manifest, loading, verification, and registry failures. Policy rejections (invalid manifest, parse/size/UTF-8/path violations, verification denial, duplicate registration) wrap one of these so callers can match with errors.Is; low-level IO failures (missing or unreadable files) are returned as-is.
Functions ¶
func EffectiveSafety ¶
Types ¶
type ActivationDecision ¶
type ActivationDecision struct {
SkillName string `json:"skill_name"`
Allowed bool `json:"allowed"`
Reason string `json:"reason,omitempty"`
EffectiveSafety tool.Safety `json:"effective_safety"`
Tools []EffectiveTool `json:"tools"`
}
func Activate ¶
func Activate(m Manifest, principalGrants, operatorCeiling []string, toolEnvelopes map[string]tool.Envelope) ActivationDecision
Activate composes the effective safety and per-tool envelopes for a skill into an ActivationDecision. The skill is Allowed only when every referenced tool resolves to a present envelope whose required scopes survive intersection with the principal grants and operator ceiling; otherwise the decision fails closed and Reason names the first blocking tool.
type Budgets ¶
type Budgets struct {
MaxTokens int `yaml:"max_tokens,omitempty" json:"max_tokens,omitempty"`
MaxCalls int `yaml:"max_calls,omitempty" json:"max_calls,omitempty"`
MaxCost MaxCost `yaml:"max_cost,omitempty" json:"max_cost,omitempty"`
WallClock string `yaml:"wall_clock,omitempty" json:"wall_clock,omitempty"`
}
type DenyVerifier ¶
type DenyVerifier struct{}
DenyVerifier is the canonical operator-deny verifier: it rejects every manifest unconditionally. Use it as a safe default until a real signature verifier (e.g., Sigstore/cosign) is wired in.
func (DenyVerifier) Verify ¶
func (DenyVerifier) Verify(*Manifest, string) (VerificationOutcome, error)
Verify always denies.
type EffectiveTool ¶
type EffectiveTool struct {
Name string `json:"name"`
Envelope tool.Envelope `json:"envelope"`
Allowed bool `json:"allowed"`
Reason string `json:"reason,omitempty"`
}
func EffectiveEnvelope ¶
type HumanApproval ¶
type Limits ¶
type Limits struct {
// Manifest bounds the manifest file size.
Manifest int64
// Body bounds the SKILL.md body size.
Body int64
// Asset bounds a single inert asset size.
Asset int64
// AssetTotal bounds the aggregate size of all inert assets.
AssetTotal int64
}
Limits bounds the sizes of untrusted skill-pack files read at load time. Reads fail closed once a bound is exceeded. The zero value is not usable; obtain defaults from DefaultLimits or inject via WithLimits, which fills any non-positive field with its default.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader loads and activates skill packs from the filesystem, enforcing size limits, rejecting symlinks and escaping paths, and running an injected verifier before a pack is returned.
func NewLoader ¶
func NewLoader(opts ...LoaderOption) *Loader
NewLoader builds a Loader. Without options it verifies with WarnOnlyVerifier and enforces DefaultLimits.
type LoaderOption ¶
type LoaderOption func(*Loader)
LoaderOption configures a Loader.
func WithLimits ¶
func WithLimits(limits Limits) LoaderOption
WithLimits injects the size limits enforced on untrusted pack files. Any non-positive field falls back to its DefaultLimits value.
func WithLogger ¶
func WithLogger(logger *slog.Logger) LoaderOption
WithLogger injects the logger used to surface non-fatal verification warnings.
func WithVerifier ¶
func WithVerifier(v Verifier) LoaderOption
WithVerifier injects the manifest verifier consulted at load time. When omitted the loader uses WarnOnlyVerifier.
type Manifest ¶
type Manifest struct {
SchemaVersion string `yaml:"schema_version" json:"schema_version"`
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
Description string `yaml:"description" json:"description"`
License string `yaml:"license,omitempty" json:"license,omitempty"`
Authors []string `yaml:"authors,omitempty" json:"authors,omitempty"`
References References `yaml:"references" json:"references"`
Requires Requires `yaml:"requires,omitempty" json:"requires,omitempty"`
HumanApproval []HumanApproval `yaml:"human_approval" json:"human_approval"`
Budgets Budgets `yaml:"budgets,omitempty" json:"budgets,omitempty"`
ModelHints ModelHints `yaml:"model_hints,omitempty" json:"model_hints,omitempty"`
ProgressiveDisclosure ProgressiveDisclosure `yaml:"progressive_disclosure,omitempty" json:"progressive_disclosure,omitempty"`
Scripts []Script `yaml:"scripts,omitempty" json:"scripts,omitempty"`
Signature *Signature `yaml:"signature,omitempty" json:"signature,omitempty"`
Safety Safety `yaml:"safety,omitempty" json:"safety,omitempty"`
}
func LoadManifest ¶
LoadManifest reads and parses a manifest file, enforcing MaxManifestBytes and rejecting symlinks before reading.
func ParseManifest ¶
ParseManifest decodes and validates a manifest from raw YAML bytes. Unknown fields are rejected and the result is validated, so it fails closed on malformed or untrusted input.
type MemoryRegistry ¶
type MemoryRegistry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *MemoryRegistry
func (*MemoryRegistry) List ¶
func (r *MemoryRegistry) List() []Manifest
func (*MemoryRegistry) Register ¶
func (r *MemoryRegistry) Register(provider Provider) error
type ModelHints ¶
type Pack ¶
type Pack struct {
Root string
Manifest Manifest
SkillBody string
References []Asset
Scripts []Asset
VerificationWarnings []string
// contains filtered or unexported fields
}
func (*Pack) ListScripts ¶
type ProgressiveDisclosure ¶
type PromptReference ¶
type PromptTemplate ¶
PromptTemplate aliases the canonical prompt template type for providers that bundle local prompt assets with a skill pack.
type Provider ¶
type Provider interface {
Manifest() Manifest
OpenAsset(name string) (io.ReadCloser, error)
}
type References ¶
type References struct {
Tools []string `yaml:"tools" json:"tools"`
Prompts []PromptReference `yaml:"prompts" json:"prompts"`
Resources []string `yaml:"resources" json:"resources"`
MCPServers []string `yaml:"mcp_servers" json:"mcp_servers"`
}
type Signature ¶
type VerificationOutcome ¶
type VerificationOutcome struct {
Status VerificationStatus
Warnings []string
Reason string
}
VerificationOutcome is the result of verifying a manifest at load time.
func Denied ¶
func Denied(reason string) VerificationOutcome
Denied reports a rejected verification with a human-readable reason.
func Verified ¶
func Verified() VerificationOutcome
Verified reports a passing verification with no warnings.
func Warning ¶
func Warning(messages ...string) VerificationOutcome
Warning reports a passing verification carrying non-fatal warnings.
type VerificationStatus ¶
type VerificationStatus int
VerificationStatus is the outcome kind of a manifest verification.
const ( // VerificationVerified indicates the manifest passed verification. VerificationVerified VerificationStatus = iota // VerificationWarning indicates verification succeeded with non-fatal warnings. VerificationWarning // VerificationDenied indicates verification rejected the manifest. VerificationDenied )
type Verifier ¶
type Verifier interface {
Verify(manifest *Manifest, root string) (VerificationOutcome, error)
}
Verifier verifies a skill manifest at load time. The loader consults it after parsing and validation: Denied fails the load, Warning is surfaced on the pack, and Verified proceeds silently.
Implementations MUST be safe for concurrent use.
type WarnOnlyVerifier ¶
type WarnOnlyVerifier struct{}
WarnOnlyVerifier permits unsigned manifests with a warning and treats any signed manifest as verified. Suitable for development and tests; operators SHOULD pair it with DenyVerifier or a real signature verifier in production.
func (WarnOnlyVerifier) Verify ¶
func (WarnOnlyVerifier) Verify(manifest *Manifest, _ string) (VerificationOutcome, error)
Verify returns Verified for signed manifests and a Warning otherwise.