Documentation
¶
Index ¶
- Constants
- func ExpandCommandsWithError(ctx context.Context, content string, run Runner) (string, error)
- func FormatMCPSkillRef(origin, uri string) string
- func IsHomeSkillPath(path string) bool
- func ParseMCPSkillRef(ref string) (origin, uri string, ok bool)
- type ExpansionAbort
- type MCPSkillProvider
- type MCPSkillSummary
- type Runner
- type Skill
Constants ¶
const KitDirEnv = "DOCKER_AGENT_KIT_DIR"
KitDirEnv names the environment variable that points at a docker-agent kit directory staged by the host before launching a sandbox. When set, local skill discovery is rooted exclusively at the kit's skills directory; the usual $HOME / git-walking lookups are skipped because they target paths that don't exist inside the sandbox.
const KitSkillsSubdir = "skills"
KitSkillsSubdir is the path inside a kit that holds the staged skills.
Variables ¶
This section is empty.
Functions ¶
func ExpandCommandsWithError ¶ added in v1.130.0
ExpandCommandsWithError replaces !`command` patterns in content. Runner errors are embedded in the result, except ExpansionAbort and context cancellation, which stop expansion and propagate to the caller.
func FormatMCPSkillRef ¶ added in v1.166.0
FormatMCPSkillRef returns the origin-scoped skill reference for an MCP skill.
func IsHomeSkillPath ¶ added in v1.66.0
IsHomeSkillPath reports whether path is under one of the global skill directories in the user's home directory.
func ParseMCPSkillRef ¶ added in v1.166.0
ParseMCPSkillRef parses an origin-scoped MCP skill reference of the form "mcp:<origin>/<uri>".
Types ¶
type ExpansionAbort ¶ added in v1.130.0
type ExpansionAbort interface {
error
AbortExpansion()
}
ExpansionAbort marks an error that must stop command expansion rather than being embedded in the skill content.
type MCPSkillProvider ¶ added in v1.166.0
type MCPSkillProvider interface {
// SkillOrigin returns the host-assigned label identifying this MCP server
// (never the server's self-reported serverInfo.name).
SkillOrigin() string
// SupportsMCPSkills reports whether this server is connected, opted in,
// and declared both resources and io.modelcontextprotocol/skills.
SupportsMCPSkills() bool
// ListMCPSkills returns the server's validated skill entries without
// fetching SKILL.md or supporting file bodies.
ListMCPSkills(ctx context.Context) ([]MCPSkillSummary, error)
// ReadMCPSkill loads and verifies SKILL.md by URI (via skills/get and
// resources/read), holds its manifest for the acting window, and returns
// origin-tagged content.
ReadMCPSkill(ctx context.Context, uri string) (string, error)
// ReadMCPSkillFile reads and verifies a supporting file (or lists a
// directory when path is empty, ".", or ends with "/") of a loaded skill.
ReadMCPSkillFile(ctx context.Context, skillURI, relPath string) (string, error)
}
MCPSkillProvider is implemented by MCP toolsets that can discover and serve verified Agent Skills over MCP.
type MCPSkillSummary ¶ added in v1.166.0
type MCPSkillSummary struct {
URI string
Name string
Description string
Files []string // Relative supporting file paths (excluding SKILL.md).
Dynamic bool
}
MCPSkillSummary describes an Agent Skill advertised by a connected MCP server implementing the io.modelcontextprotocol/skills extension (SEP-2640).
type Runner ¶ added in v1.130.0
Runner executes one command embedded in skill content and returns its stdout. A skill body is untrusted data, so implementations are expected to get the user's consent before running anything on their machine: returning an error keeps the command from running and inlines the reason in the expanded content.
func ShellRunner ¶ added in v1.130.0
ShellRunner returns a Runner that executes commands with the system shell in workDir. It performs no approval of its own — wrap it to gate execution.
type Skill ¶
type Skill struct {
Name string
Description string
FilePath string
BaseDir string
Files []string
Local bool // true for filesystem-loaded skills, false for remote
License string
Compatibility string
Metadata map[string]string
AllowedTools []string
// Toolsets lists names of reusable toolset definitions (from the top-level
// `toolsets` section) to expose to the skill while it runs as a fork
// sub-agent (context: fork), in addition to the parent agent's tools.
// Populated from inline config or the SKILL.md `toolsets` frontmatter.
// Ignored for non-fork skills.
Toolsets []string
Context string // "fork" to run the skill as an isolated sub-agent
// Model is an optional model override applied while the skill runs as
// a sub-agent (context: fork). It accepts either a named model from the
// agent config or an inline "provider/model" reference (e.g.
// "openai/gpt-4o-mini"). It is ignored for non-fork skills.
Model string
// InlineContent holds the skill body for skills defined directly in the
// agent config rather than loaded from a file or URL. When set, the
// skill has no FilePath/BaseDir and its content is served from memory.
InlineContent string
}
Skill represents a loaded skill with its metadata and content location.
func Load ¶
Load discovers and loads skills from the given sources. Each source is either "local" (for filesystem-based skills) or an HTTP/HTTPS URL (a public GitHub repository or a well-known skills discovery endpoint).
Local skills are loaded from (in order, later overrides earlier):
Global locations (under $HOME):
- ~/.codex/skills/ (recursive)
- ~/.claude/skills/ (flat)
- ~/.agents/skills/ (recursive)
Project locations (under cwd, closest wins):
- .claude/skills/ (flat, only at cwd)
- .github/skills/ (flat, scanned from each ancestor up to $HOME — or the enclosing git root outside $HOME — down to cwd)
- .agents/skills/ (flat, same ancestor scan; overrides .github/skills at the same level)
The returned slice is sorted by skill name for deterministic ordering.
func LoadWithWarnings ¶ added in v1.149.0
func LoadWithWarnings(ctx context.Context, sources []string, env environment.Provider) ([]Skill, []string)
LoadWithWarnings loads skills and reports GitHub source failures to the caller. The environment provider supplies the optional GITHUB_TOKEN credential.
func LoadWithWarningsFromDir ¶ added in v1.156.0
func LoadWithWarningsFromDir(ctx context.Context, sources []string, env environment.Provider, dir string) ([]Skill, []string)
LoadWithWarningsFromDir discovers project-local skills in dir rather than the process cwd.
func (Skill) ExpandsCommands ¶ added in v1.130.0
ExpandsCommands reports whether !`command` patterns in the skill body may be executed. Local files and the agent config are part of what the user chose to run, and the config already dictates instructions, toolsets and permissions, so a command embedded in it grants nothing it could not already do. A remote body is data fetched from a third-party server at runtime and never earns that authority.