skills

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package skills loads the skills a workspace offers: a SKILL.md with frontmatter and instructions, optionally scripts, from the built-in set, ~/.blitz/skills and (when trusted) the project; and the policy that caps what their scripts may do (spec_skills_013).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StorageURL

func StorageURL(uri string) (string, error)

StorageURL is where a storage_uri is fetched: https as it is, gs:// through Cloud Storage's public endpoint.

Types

type AuthorDetails

type AuthorDetails struct {
	Name  string `yaml:"name"`
	Email string `yaml:"email,omitempty"`
	URL   string `yaml:"url,omitempty"`
}

AuthorDetails is a skill contributor.

type CompiledReference

type CompiledReference struct {
	SkillID    string   `yaml:"skill_id,omitempty"`
	SHA256Hash string   `yaml:"sha256_hash,omitempty"`
	HITLTier   HITLTier `yaml:"hitl_tier,omitempty"`
}

CompiledReference is Castor's pointer to a registered, hashed skill. Only its hash and tier are read.

type Evaluation

type Evaluation struct {
	Tier   HITLTier // approval tier its scripts run at
	Bypass bool     // Tier0BypassAll granted: the skill asked and the policy allows it
	// Network is granted: the skill asked (custom_hints.network) and is on
	// the policy's allowlist.
	Network bool
	// Env are the host environment variables the skill asked for that the
	// policy passes through; Withheld are the ones it doesn't.
	Env, Withheld []string
	Hash          string // ContentHash, "" if it couldn't be computed
	Scripts       []ScriptVerdict
	// Blocked are reasons none of the skill's scripts may run.
	Blocked []string
}

Evaluation is what a skill may do under a host policy: for each setting, the stricter of what the skill asks for and what the policy allows.

func Evaluate

func Evaluate(s *Skill, p config.SkillPolicy) Evaluation

Evaluate applies policy p to skill s.

func (Evaluation) Runnable

func (e Evaluation) Runnable() bool

Runnable reports whether any script may run.

type ExecutionHints

type ExecutionHints struct {
	PreferredModel        string            `yaml:"preferred_model,omitempty"`
	RequiresHumanApproval bool              `yaml:"requires_human_approval,omitempty"`
	EnvironmentVariables  []string          `yaml:"environment_variables,omitempty"`
	TimeoutSeconds        int               `yaml:"timeout_seconds,omitempty"`
	CustomHints           map[string]string `yaml:"custom_hints,omitempty"`
	HITLTier              HITLTier          `yaml:"hitl_tier,omitempty"`
	AllowHITLBypass       bool              `yaml:"allow_hitl_bypass,omitempty"`
	// WritesWorkspace means the skill's scripts change the workspace's files.
	// They run in a copy of it, and what they changed is kept only once
	// approved, diff shown, as tier 3 asks (BL-SK-02).
	WritesWorkspace bool `yaml:"writes_workspace,omitempty"`
}

ExecutionHints are operational hints for running a skill.

func (*ExecutionHints) NeedsNetwork

func (h *ExecutionHints) NeedsNetwork() bool

NeedsNetwork reports whether the skill's scripts declare that they need the network. The proto has no field for it yet, so it is the custom hint network: "true" (or "required").

type HITLTier

type HITLTier int

HITLTier is a human-in-the-loop risk tier: how much approval a skill's actions need. Values match the proto enum, so the zero value is TierUnspecified (never a bypass) and higher tiers compare greater.

const (
	TierUnspecified HITLTier = iota
	Tier0BypassAll
	Tier1AutoRead
	Tier2AuditedWrite
	Tier3MandatoryApproval
)

The tiers, lowest risk first: bypass (no checks, only where the policy allows it), automatic reads, audited and checkpointed writes, and approval for everything.

func ParseHITLTier

func ParseHITLTier(s string) (HITLTier, error)

ParseHITLTier reads a tier by name: the proto enum name (HITL_POLICY_TIER_2_AUDITED_WRITE), the short form Castor stores (TIER_2_AUDITED_WRITE), or tier_2. Bare numbers are refused: the proto numbers its enum one higher than the tier, so "2" would be ambiguous.

func (HITLTier) String

func (t HITLTier) String() string

String is the tier's proto enum name, such as TIER_2_AUDITED_WRITE.

func (*HITLTier) UnmarshalYAML

func (t *HITLTier) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML reads a tier name (see ParseHITLTier).

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider discovers, indexes, and activates skills across embedded and external paths.

func NewProvider

func NewProvider() (*Provider, error)

NewProvider initializes the skills provider with embedded built-in skills.

func (*Provider) DiscoverExternal

func (p *Provider) DiscoverExternal(dirs []string) error

DiscoverExternal scans search directories for SKILL.md files. External skills cannot replace built-in ones; conflicts are reported in the returned (joined) error while other skills still load.

func (*Provider) Get

func (p *Provider) Get(name string) (*Skill, bool)

Get returns a skill by name.

func (*Provider) List

func (p *Provider) List() []*Skill

List returns all discovered skills sorted by name.

func (*Provider) Search

func (p *Provider) Search(query string) []*Skill

Search filters skills matching query in name, description, or tags.

type ResourceInterpretation

type ResourceInterpretation struct {
	InterpretedText string   `yaml:"interpreted_text,omitempty"`
	Summary         string   `yaml:"summary,omitempty"`
	KeyEntities     []string `yaml:"key_entities,omitempty"`
}

ResourceInterpretation is text a resource was turned into.

type ResourceRequirement

type ResourceRequirement struct {
	ID             string                  `yaml:"id,omitempty"`
	Name           string                  `yaml:"name,omitempty"`
	Description    string                  `yaml:"description,omitempty"`
	Category       string                  `yaml:"category,omitempty"` // RESOURCE_CATEGORY_DOCUMENT_TEXT, or document_text
	MimeType       string                  `yaml:"mime_type,omitempty"`
	Storage        *ResourceStorage        `yaml:"storage,omitempty"`
	InlineContent  string                  `yaml:"inline_content,omitempty"`
	Interpretation *ResourceInterpretation `yaml:"interpretation,omitempty"`
	// AutoInjectContext means the interpretation goes with the instructions.
	AutoInjectContext bool `yaml:"auto_inject_context,omitempty"`
}

ResourceRequirement is Castor's context asset (castor.skills.v1).

func (ResourceRequirement) CategoryName

func (r ResourceRequirement) CategoryName() string

CategoryName is a resource category's short form ("document_text").

type ResourceStorage

type ResourceStorage struct {
	GCSURI             string `yaml:"gcs_uri,omitempty"`
	PublicURL          string `yaml:"public_url,omitempty"`
	GeminiFilesAPIName string `yaml:"gemini_files_api_name,omitempty"`
	GeminiFilesAPIURI  string `yaml:"gemini_files_api_uri,omitempty"`
	SizeBytes          int64  `yaml:"size_bytes,omitempty"`
	MimeType           string `yaml:"mime_type,omitempty"`
	SHA256Hash         string `yaml:"sha256_hash,omitempty"`
}

ResourceStorage is where a resource lives.

type ScriptDefinition

type ScriptDefinition struct {
	Name                 string            `yaml:"name"`
	Description          string            `yaml:"description,omitempty"`
	Language             ScriptLanguage    `yaml:"language,omitempty"`
	InlineCode           string            `yaml:"inline_code,omitempty"`
	StorageURI           string            `yaml:"storage_uri,omitempty"`
	RelativePath         string            `yaml:"relative_path,omitempty"`
	EntryPoint           string            `yaml:"entry_point,omitempty"`
	Dependencies         []string          `yaml:"dependencies,omitempty"`
	TimeoutSeconds       int               `yaml:"timeout_seconds,omitempty"`
	EnvironmentVariables map[string]string `yaml:"environment_variables,omitempty"`
	// StorageSHA256 pins a storage_uri script's content: the hex SHA-256
	// it must have (Blitz's field; Castor's proto has none).
	StorageSHA256 string `yaml:"storage_sha256,omitempty"`
	// RequiresPython is the Python a script needs (">=3.11"); without it,
	// the script's PEP 723 metadata may say (BL-SK-03).
	RequiresPython string `yaml:"requires_python,omitempty"`
}

ScriptDefinition is a helper script shipped with (or referenced by) a skill. Exactly one of InlineCode, StorageURI and RelativePath is its source.

type ScriptLanguage

type ScriptLanguage string

ScriptLanguage is a script's runtime.

const (
	LanguageUnspecified ScriptLanguage = ""
	LanguagePython      ScriptLanguage = "python"
	LanguageTypeScript  ScriptLanguage = "typescript"
)

The languages a skill's scripts can be written in; a script must name one (unspecified is a problem the skill's validation reports).

func (*ScriptLanguage) UnmarshalYAML

func (l *ScriptLanguage) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML reads python / typescript, or the proto enum names.

type ScriptVerdict

type ScriptVerdict struct {
	Name           string
	Allowed        bool
	Reasons        []string // why it may not run
	TimeoutSeconds int      // capped by the policy
	Dependencies   []string
}

ScriptVerdict is whether one script may run, and with what limits.

type Skill

type Skill struct {
	SkillMetadata
	Content   string   `json:"content"`
	Path      string   `json:"path"`
	Resources []string `json:"resources"`
	// Problems are definition errors (see SkillMetadata.Validate).
	Problems []string `json:"problems,omitempty"`
	// contains filtered or unexported fields
}

Skill represents an Agent Skill specification.

func ParseSkillMD

func ParseSkillMD(content []byte, path string) (*Skill, error)

ParseSkillMD parses a SKILL.md document with YAML frontmatter.

func (*Skill) ContentHash

func (s *Skill) ContentHash() (string, error)

ContentHash is the SHA-256 of every regular file in the skill's directory (SKILL.md, scripts, resources), in path order, each as its relative path, its size and its content. It identifies exactly what was reviewed, so a config can pin a skill (skills.policy.trusted_hashes). Symbolic links are skipped. The format is "sha256:<hex>".

func (*Skill) CopyTo

func (s *Skill) CopyTo(dir string) error

CopyTo writes the skill's files into dir (for built-in skills, whose files are embedded). Symbolic links are skipped.

func (*Skill) HostDir

func (s *Skill) HostDir() string

HostDir is the skill's directory on disk, or "" for built-in skills.

func (*Skill) Matches

func (s *Skill) Matches(query string) bool

Matches returns true if the query matches the skill's name, description, or tags.

func (*Skill) ReadScript

func (s *Skill) ReadScript(rel string) ([]byte, error)

ReadScript returns a script's source shipped in the skill (relative_path): from its directory, or from the embedded files of a built-in skill.

func (*Skill) ScriptPath

func (s *Skill) ScriptPath(rel string) (string, error)

ScriptPath returns the host path of a script shipped in the skill's directory (relative_path), checked through os.Root so neither ".." nor a symbolic link can lead outside the directory. Built-in skills have no host directory; use CopyTo.

type SkillMetadata

type SkillMetadata struct {
	// Agent Skills spec.
	Name          string            `yaml:"name"`
	Description   string            `yaml:"description"`
	License       string            `yaml:"license,omitempty"`
	Compatibility string            `yaml:"compatibility,omitempty"`
	AllowedTools  string            `yaml:"allowed-tools,omitempty"`
	Metadata      map[string]string `yaml:"metadata,omitempty"`

	// Castor (castor.skills.v1.SkillDefinition).
	Tags               []string           `yaml:"tags"`
	Version            string             `yaml:"version,omitempty"`
	Author             string             `yaml:"author,omitempty"`
	Authors            []AuthorDetails    `yaml:"authors,omitempty"`
	AllowedToolsLegacy string             `yaml:"allowed_tools,omitempty"`
	ToolRequirements   []ToolRequirement  `yaml:"tool_requirements,omitempty"`
	Category           string             `yaml:"category,omitempty"`
	TriggerPhrases     []string           `yaml:"trigger_phrases,omitempty"`
	ExecutionHints     *ExecutionHints    `yaml:"execution_hints,omitempty"`
	CompiledReference  *CompiledReference `yaml:"compiled_reference,omitempty"`
	Scripts            []ScriptDefinition `yaml:"scripts,omitempty"`
	// ResourceRequirements are Castor's resources: context assets the
	// skill uses, listed by activate_skill.
	ResourceRequirements []ResourceRequirement `yaml:"resources,omitempty"`
	SkillID              string                `yaml:"skill_id,omitempty"`
	URI                  string                `yaml:"uri,omitempty"`
	SourceURI            string                `yaml:"source_uri,omitempty"`
}

SkillMetadata defines metadata stored in SKILL.md frontmatter: the Agent Skills spec fields, plus Castor's skill definition fields (see definition.go). Unknown keys are ignored, so skills written for other tools still load.

func (*SkillMetadata) AllowedToolsList

func (m *SkillMetadata) AllowedToolsList() []string

AllowedToolsList is the spec's allowed-tools (or Castor's legacy allowed_tools), split on spaces and commas.

func (*SkillMetadata) DeclaredTier

func (m *SkillMetadata) DeclaredTier() HITLTier

DeclaredTier is the tier the skill asks for: execution_hints.hitl_tier, else the compiled reference's, and at least tier 3 when it says it requires human approval.

func (*SkillMetadata) Validate

func (m *SkillMetadata) Validate() []string

Validate reports problems with the skill's definition. A skill with problems still loads (its instructions are useful), but the scripts involved are not run.

type ToolRequirement

type ToolRequirement struct {
	Name        string   `yaml:"name"`
	Scopes      []string `yaml:"scopes,omitempty"`
	Description string   `yaml:"description,omitempty"`
}

ToolRequirement is a tool a skill needs, with the scopes it needs it for (e.g. Bash with ["git:*"]).

Directories

Path Synopsis
Package builtin holds the skills Blitz ships with (a SKILL.md each), embedded in the binary.
Package builtin holds the skills Blitz ships with (a SKILL.md each), embedded in the binary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL